SystemCClang.h 2.7 KB
Newer Older
Anirudh Kaushik's avatar
Anirudh Kaushik committed
1 2
// ===-- src/SystemCClang.h - systec-clang class definition -------*- C++
// -*-===//
rmrf's avatar
rmrf committed
3
//
Anirudh Kaushik's avatar
Anirudh Kaushik committed
4
// systemc-clang: SystemC Parser
rmrf's avatar
rmrf committed
5
//
Anirudh Kaushik's avatar
Anirudh Kaushik committed
6 7
// This file is distributed under the University of Illinois License.
// See LICENSE.mkd for details.
rmrf's avatar
rmrf committed
8
//
Anirudh Kaushik's avatar
Anirudh Kaushik committed
9 10 11 12 13 14 15 16 17 18
// ===----------------------------------------------------------------------===//
// /
// / \file
// / \brief This file contains the class declaration for main SystemC parser.
// /
// ===----------------------------------------------------------------------===//
#ifndef _SYSTEMC_CLANG_H_
#define _SYSTEMC_CLANG_H_

#include "clang/AST/AST.h"
rmrf's avatar
rmrf committed
19
#include "clang/AST/ASTConsumer.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
20 21
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
rmrf's avatar
rmrf committed
22 23
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
24 25 26 27 28 29 30 31
#include "clang/Parse/Parser.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"

using namespace clang::driver;
using namespace clang::tooling;

// / This is the include files we add to parse SystemC
rmrf's avatar
rmrf committed
32 33 34
#include "FindArgument.h"
#include "FindConstructor.h"
#include "FindEntryFunctions.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
35 36
#include "FindEvents.h"
#include "FindGlobalEvents.h"
rmrf's avatar
rmrf committed
37 38
#include "FindModule.h"
#include "FindNetlist.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
39
#include "FindNotify.h"
rmrf's avatar
rmrf committed
40 41 42
#include "FindPorts.h"
#include "FindSCMain.h"
#include "FindSensitivity.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
43 44
#include "FindSignals.h"
#include "FindSimTime.h"
rmrf's avatar
rmrf committed
45 46
#include "FindTLMInterfaces.h"
#include "FindWait.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
47
#include "Model.h"
rmrf's avatar
rmrf committed
48
#include "FindSCModules.h"
Anirudh's avatar
Anirudh committed
49
#include "SCuitable/FindGPUMacro.h"
rmrf's avatar
rmrf committed
50 51 52
#include "SCuitable/GlobalSuspensionAutomata.h"
#include "SuspensionAutomata.h"
#include "Utility.h"
53 54
#include "FindTemplateParameters.h"             \

rmrf's avatar
rmrf committed
55

Anirudh Kaushik's avatar
Anirudh Kaushik committed
56 57
using namespace clang;

rmrf's avatar
rmrf committed
58
namespace scpar {
Anirudh Kaushik's avatar
Anirudh Kaushik committed
59

rmrf's avatar
rmrf committed
60 61 62 63 64
class SystemCConsumer : public ASTConsumer,
                        public RecursiveASTVisitor<SystemCConsumer> {
public:
  llvm::raw_ostream &_os;
  SourceManager &_sm;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
65

rmrf's avatar
rmrf committed
66 67
  SystemCConsumer(CompilerInstance &);
  ~SystemCConsumer();
Anirudh Kaushik's avatar
Anirudh Kaushik committed
68

rmrf's avatar
rmrf committed
69 70 71 72
  // Virtual methods that plugins may override.
  virtual bool preFire();
  virtual bool postFire();
  virtual bool fire();
Anirudh Kaushik's avatar
Anirudh Kaushik committed
73

rmrf's avatar
rmrf committed
74
  Model *getSystemCModel();
Anirudh Kaushik's avatar
Anirudh Kaushik committed
75

rmrf's avatar
rmrf committed
76 77
  virtual void HandleTranslationUnit(ASTContext &context);
  ASTContext &_context;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
78

rmrf's avatar
rmrf committed
79 80 81 82
private:
  CompilerInstance &_ci;
  // ASTContext& _context;
  Model *_systemcModel;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
83

rmrf's avatar
rmrf committed
84 85
  // Rewriter _rewrite;
}; // End class SystemCConsumer
Anirudh Kaushik's avatar
Anirudh Kaushik committed
86

rmrf's avatar
rmrf committed
87 88 89 90
class SystemCClang : public SystemCConsumer {
public:
  SystemCClang(CompilerInstance &ci) : SystemCConsumer(ci) {}
};
rmrf's avatar
rmrf committed
91

rmrf's avatar
rmrf committed
92 93 94 95 96 97 98 99 100
template <typename A>
class LightsCameraAction : public clang::ASTFrontendAction {
protected:
  virtual std::unique_ptr<clang::ASTConsumer>
  CreateASTConsumer(CompilerInstance &ci, llvm::StringRef inFile) {
    return std::unique_ptr<clang::ASTConsumer>(new A(ci));
  };
}; // End class LightsCameraAction
} // End namespace scpar
Anirudh Kaushik's avatar
Anirudh Kaushik committed
101 102

#endif