SystemCClang.h 2.71 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"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
54 55 56 57 58
using namespace clang;

namespace scpar
{

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

	  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
79
    ASTContext & _context;
Anirudh Kaushik's avatar
Anirudh Kaushik committed
80 81 82

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

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

  template < typename A > class LightsCameraAction:
	public clang::ASTFrontendAction
	{
	  protected:

94 95 96 97
   	  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
98 99 100 101 102 103 104
		};

	};							// End class LightsCameraAction

}								// End namespace scpar

#endif