SystemCClang.h 2.78 KB
Newer Older
Anirudh Kaushik's avatar
Anirudh Kaushik committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
// ===-- src/SystemCClang.h - systec-clang class definition -------*- C++
// -*-===//
// 
// systemc-clang: SystemC Parser
// 
// This file is distributed under the University of Illinois License.
// See LICENSE.mkd for details.
// 
// ===----------------------------------------------------------------------===//
// /
// / \file
// / \brief This file contains the class declaration for main SystemC parser.
// /
// ===----------------------------------------------------------------------===//
#ifndef _SYSTEMC_CLANG_H_
#define _SYSTEMC_CLANG_H_

#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/AST.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/SourceManager.h"
#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
#include "FindModule.h"
#include "FindPorts.h"
#include "FindTLMInterfaces.h"
#include "FindEvents.h"
#include "FindGlobalEvents.h"
#include "FindEntryFunctions.h"
#include "FindSensitivity.h"
#include "FindSCMain.h"
#include "FindWait.h"
#include "FindNotify.h"
#include "FindConstructor.h"
#include "SCModules.h"
#include "FindSignals.h"
#include "FindSimTime.h"
#include "Model.h"
#include "FindNetlist.h"
#include "FindArgument.h"
#include "Utility.h"
#include "SuspensionAutomata.h"
Anirudh's avatar
Anirudh committed
51 52
#include "SCuitable/GlobalSuspensionAutomata.h"
#include "SCuitable/FindGPUMacro.h"
rmrf's avatar
rmrf committed
53

Anirudh Kaushik's avatar
Anirudh Kaushik committed
54 55
using namespace clang;

rmrf's avatar
rmrf committed
56
namespace scpar {
Anirudh Kaushik's avatar
Anirudh Kaushik committed
57

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

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

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

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

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

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

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

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

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

#endif