SystemCClang.h 2.79 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 51
// ===-- 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
52 53
#include "SCuitable/GlobalSuspensionAutomata.h"
#include "SCuitable/FindGPUMacro.h"
rmrf's avatar
rmrf committed
54 55 56

#include "matchers/sc_module.h"

Anirudh Kaushik's avatar
Anirudh Kaushik committed
57 58 59 60 61
using namespace clang;

namespace scpar
{

62
  class SystemCConsumer:public ASTConsumer, public RecursiveASTVisitor < SystemCConsumer >
Anirudh Kaushik's avatar
Anirudh Kaushik committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
	{

	  private:
     
	  public:
		llvm::raw_ostream & _os;
		SourceManager & _sm;

		SystemCConsumer(CompilerInstance &);
		~SystemCConsumer();

		// Virtual methods that plugins may override. 
		virtual bool preFire();
		virtual bool postFire();
		virtual bool fire();

		Model *getSystemCModel();

		virtual void HandleTranslationUnit(ASTContext & context);  
rmrf's avatar
rmrf committed
82
    ASTContext & _context;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
83 84 85

	  private:
		CompilerInstance & _ci;
rmrf's avatar
rmrf committed
86
		//ASTContext& _context;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
87 88 89 90 91
		Model *_systemcModel;

		// Rewriter _rewrite; 
	};							// End class SystemCConsumer

rmrf's avatar
rmrf committed
92 93 94 95 96
  class SystemCClang : public SystemCConsumer {

  };


Anirudh Kaushik's avatar
Anirudh Kaushik committed
97 98 99 100 101
  template < typename A > class LightsCameraAction:
	public clang::ASTFrontendAction
	{
	  protected:

102 103 104 105
   	  virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(CompilerInstance & ci,	llvm::StringRef inFile) {
	//	virtual ASTConsumer * CreateASTConsumer(CompilerInstance & ci, StringRef) {
          		  return std::unique_ptr<clang::ASTConsumer>(new SystemCConsumer(ci));
			//return new A(ci);
Anirudh Kaushik's avatar
Anirudh Kaushik committed
106 107 108 109 110 111 112
		};

	};							// End class LightsCameraAction

}								// End namespace scpar

#endif