From a9ed06bec80a2a975102195b5b7b4fe7fece3d38 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Mon, 19 Sep 2016 15:50:07 -0600 Subject: change rosecg path & add install --- lib/rosecg/CMakeLists.txt | 6 ++ lib/rosecg/include/CG_roseBuilder.h | 108 -------------------------- lib/rosecg/include/CG_roseRepr.h | 46 ----------- lib/rosecg/include/code_gen/CG_roseBuilder.h | 108 ++++++++++++++++++++++++++ lib/rosecg/include/code_gen/CG_roseRepr.h | 46 +++++++++++ lib/rosecg/include/code_gen/rose_attributes.h | 91 ++++++++++++++++++++++ lib/rosecg/include/rose_attributes.h | 91 ---------------------- lib/rosecg/src/CG_roseBuilder.cc | 2 +- lib/rosecg/src/CG_roseRepr.cc | 4 +- lib/rosecg/src/rose_attributes.cc | 2 +- src/ir_rose.cc | 6 +- 11 files changed, 258 insertions(+), 252 deletions(-) delete mode 100644 lib/rosecg/include/CG_roseBuilder.h delete mode 100644 lib/rosecg/include/CG_roseRepr.h create mode 100644 lib/rosecg/include/code_gen/CG_roseBuilder.h create mode 100644 lib/rosecg/include/code_gen/CG_roseRepr.h create mode 100644 lib/rosecg/include/code_gen/rose_attributes.h delete mode 100644 lib/rosecg/include/rose_attributes.h diff --git a/lib/rosecg/CMakeLists.txt b/lib/rosecg/CMakeLists.txt index 610bc50..f6dde35 100644 --- a/lib/rosecg/CMakeLists.txt +++ b/lib/rosecg/CMakeLists.txt @@ -16,3 +16,9 @@ add_library(rosecg ${CODEGEN_ROSE_SRC}) install(TARGETS rosecg DESTINATION lib) + +install(TARGETS omega + ARCHIVE DESTINATION lib) + +install(DIRECTORY include/code_gen + DESTINATION include) diff --git a/lib/rosecg/include/CG_roseBuilder.h b/lib/rosecg/include/CG_roseBuilder.h deleted file mode 100644 index bb622c7..0000000 --- a/lib/rosecg/include/CG_roseBuilder.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef CG_roseBuilder_h -#define CG_roseBuilder_h - -#include -#include "rose_attributes.h" -#include -#include "CG_roseRepr.h" -#include - -namespace omega { - -class CG_roseBuilder : public CG_outputBuilder { -public: - CG_roseBuilder(int isFortran, SgGlobal* global, SgGlobal* global_scope, SgSymbolTable* symtab1, SgSymbolTable* symtab2, SgNode* root); - ~CG_roseBuilder(); - - //! substitute variables in stmt - CG_outputRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt, - const std::vector &vars, - std::vector &subs) const; - - - - //! assignment generation - CG_outputRepr* CreateAssignment(int indent, CG_outputRepr* lhs, - CG_outputRepr* rhs) const; - - //! function invocation generation - CG_outputRepr* CreateInvoke(const std::string &funcName, - std::vector &argList) const; - - //! comment generation - CG_outputRepr* CreateComment(int indent, const std::string &commentText) const; - //! Attribute generation - CG_outputRepr* CreateAttribute(CG_outputRepr *control, - const std::string &commentText) const; - //! Pragma Attribute - CG_outputRepr* CreatePragmaAttribute(CG_outputRepr *scopeStmt, int looplevel, - const std::string &pragmaText) const; - - //! Prefetch Attribute - CG_outputRepr* CreatePrefetchAttribute(CG_outputRepr *scopeStmt, int looplevel, - const std::string &arrName, int hint) const; - - //! if stmt gen operations - CG_outputRepr* CreateIf(int indent, CG_outputRepr* guardCondition, - CG_outputRepr* true_stmtList, CG_outputRepr* false_stmtList) const; - - //! inductive variable generation, to be used in CreateLoop as control - CG_outputRepr* CreateInductive(CG_outputRepr* index, - CG_outputRepr* lower, - CG_outputRepr* upper, - CG_outputRepr* step) const; - - //! loop stmt generation - CG_outputRepr* CreateLoop(int indent, CG_outputRepr* control, - CG_outputRepr* stmtList) const; - - CG_outputRepr* CreateInt(int num ) const; - bool isInteger(CG_outputRepr *op) const; - CG_outputRepr* CreateIdent(const std::string &varName) const; - - //! binary arithmetic operations - CG_outputRepr* CreatePlus(CG_outputRepr* lop, CG_outputRepr* rop) const; - CG_outputRepr* CreateMinus(CG_outputRepr* lop, CG_outputRepr* rop) const; - CG_outputRepr* CreateTimes(CG_outputRepr* lop, CG_outputRepr* rop) const; - CG_outputRepr* CreateIntegerFloor(CG_outputRepr* lop, CG_outputRepr* rop) const; - CG_outputRepr* CreateIntegerMod(CG_outputRepr* lop, CG_outputRepr* rop) const; - - //! binary logical operations - CG_outputRepr* CreateAnd(CG_outputRepr* lop, CG_outputRepr* rop) const; - - //--------------------------------------------------------------------------- - // binary relational operations - //--------------------------------------------------------------------------- - // CG_outputRepr* CreateGE(CG_outputRepr*, CG_outputRepr*) const; - CG_outputRepr* CreateLE(CG_outputRepr* lop, CG_outputRepr* rop) const; - CG_outputRepr* CreateEQ(CG_outputRepr* lop, CG_outputRepr* rop) const; - - //--------------------------------------------------------------------------- - // stmt list gen operations - //--------------------------------------------------------------------------- - CG_outputRepr* - StmtListAppend(CG_outputRepr* list1, CG_outputRepr* list2) const; - - CG_outputRepr* CreateDim3(const char* varName, CG_outputRepr* arg1, CG_outputRepr* arg2, CG_outputRepr* arg3 = NULL) const; - - // Manu:: added for fortran support - bool isInputFortran() const; - -private: - SgSymbolTable *symtab_; - SgSymbolTable *symtab2_; - SgNode* root_; - SgGlobal* global_; - SgGlobal* global_scope; - int isFortran; // Manu:: added for fortran support -}; - -extern char *k_ocg_comment; -std::vectorsubstitute(SgNode *tnl, const SgVariableSymbol *sym, SgExpression *expr,SgNode* root) ; - - - - -} // namespace - -#endif diff --git a/lib/rosecg/include/CG_roseRepr.h b/lib/rosecg/include/CG_roseRepr.h deleted file mode 100644 index 28553e7..0000000 --- a/lib/rosecg/include/CG_roseRepr.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef CG_roseRepr_h -#define CG_roseRepr_h - -#include -#include "rose.h" - -namespace omega { - -class CG_roseRepr : public CG_outputRepr { - friend class CG_roseBuilder; -public: - CG_roseRepr(); - CG_roseRepr(SgNode *tnl); - CG_roseRepr(SgExpression *exp); - CG_roseRepr(SgStatementPtrList* stmtlist); - - ~CG_roseRepr(); - CG_outputRepr *clone() const; - void clear(); - - SgNode* GetCode() const; - SgStatementPtrList* GetList() const; - SgExpression *GetExpression() const; - - - - - //--------------------------------------------------------------------------- - // Dump operations - //--------------------------------------------------------------------------- - void Dump() const; -private: - // only one of _tnl and _op would be active at any time, depending on - // whether it is building a statement list or an expression tree - SgNode *tnl_; - SgExpression *op_; - SgStatementPtrList *list_; - void DumpFileHelper(SgNode* node, FILE* fp) const; - //operand op_; -}; - - - -} // namespace - -#endif diff --git a/lib/rosecg/include/code_gen/CG_roseBuilder.h b/lib/rosecg/include/code_gen/CG_roseBuilder.h new file mode 100644 index 0000000..ca33f7e --- /dev/null +++ b/lib/rosecg/include/code_gen/CG_roseBuilder.h @@ -0,0 +1,108 @@ +#ifndef CG_roseBuilder_h +#define CG_roseBuilder_h + +#include +#include "code_gen/rose_attributes.h" +#include +#include "code_gen/CG_roseRepr.h" +#include + +namespace omega { + +class CG_roseBuilder : public CG_outputBuilder { +public: + CG_roseBuilder(int isFortran, SgGlobal* global, SgGlobal* global_scope, SgSymbolTable* symtab1, SgSymbolTable* symtab2, SgNode* root); + ~CG_roseBuilder(); + + //! substitute variables in stmt + CG_outputRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt, + const std::vector &vars, + std::vector &subs) const; + + + + //! assignment generation + CG_outputRepr* CreateAssignment(int indent, CG_outputRepr* lhs, + CG_outputRepr* rhs) const; + + //! function invocation generation + CG_outputRepr* CreateInvoke(const std::string &funcName, + std::vector &argList) const; + + //! comment generation + CG_outputRepr* CreateComment(int indent, const std::string &commentText) const; + //! Attribute generation + CG_outputRepr* CreateAttribute(CG_outputRepr *control, + const std::string &commentText) const; + //! Pragma Attribute + CG_outputRepr* CreatePragmaAttribute(CG_outputRepr *scopeStmt, int looplevel, + const std::string &pragmaText) const; + + //! Prefetch Attribute + CG_outputRepr* CreatePrefetchAttribute(CG_outputRepr *scopeStmt, int looplevel, + const std::string &arrName, int hint) const; + + //! if stmt gen operations + CG_outputRepr* CreateIf(int indent, CG_outputRepr* guardCondition, + CG_outputRepr* true_stmtList, CG_outputRepr* false_stmtList) const; + + //! inductive variable generation, to be used in CreateLoop as control + CG_outputRepr* CreateInductive(CG_outputRepr* index, + CG_outputRepr* lower, + CG_outputRepr* upper, + CG_outputRepr* step) const; + + //! loop stmt generation + CG_outputRepr* CreateLoop(int indent, CG_outputRepr* control, + CG_outputRepr* stmtList) const; + + CG_outputRepr* CreateInt(int num ) const; + bool isInteger(CG_outputRepr *op) const; + CG_outputRepr* CreateIdent(const std::string &varName) const; + + //! binary arithmetic operations + CG_outputRepr* CreatePlus(CG_outputRepr* lop, CG_outputRepr* rop) const; + CG_outputRepr* CreateMinus(CG_outputRepr* lop, CG_outputRepr* rop) const; + CG_outputRepr* CreateTimes(CG_outputRepr* lop, CG_outputRepr* rop) const; + CG_outputRepr* CreateIntegerFloor(CG_outputRepr* lop, CG_outputRepr* rop) const; + CG_outputRepr* CreateIntegerMod(CG_outputRepr* lop, CG_outputRepr* rop) const; + + //! binary logical operations + CG_outputRepr* CreateAnd(CG_outputRepr* lop, CG_outputRepr* rop) const; + + //--------------------------------------------------------------------------- + // binary relational operations + //--------------------------------------------------------------------------- + // CG_outputRepr* CreateGE(CG_outputRepr*, CG_outputRepr*) const; + CG_outputRepr* CreateLE(CG_outputRepr* lop, CG_outputRepr* rop) const; + CG_outputRepr* CreateEQ(CG_outputRepr* lop, CG_outputRepr* rop) const; + + //--------------------------------------------------------------------------- + // stmt list gen operations + //--------------------------------------------------------------------------- + CG_outputRepr* + StmtListAppend(CG_outputRepr* list1, CG_outputRepr* list2) const; + + CG_outputRepr* CreateDim3(const char* varName, CG_outputRepr* arg1, CG_outputRepr* arg2, CG_outputRepr* arg3 = NULL) const; + + // Manu:: added for fortran support + bool isInputFortran() const; + +private: + SgSymbolTable *symtab_; + SgSymbolTable *symtab2_; + SgNode* root_; + SgGlobal* global_; + SgGlobal* global_scope; + int isFortran; // Manu:: added for fortran support +}; + +extern char *k_ocg_comment; +std::vectorsubstitute(SgNode *tnl, const SgVariableSymbol *sym, SgExpression *expr,SgNode* root) ; + + + + +} // namespace + +#endif diff --git a/lib/rosecg/include/code_gen/CG_roseRepr.h b/lib/rosecg/include/code_gen/CG_roseRepr.h new file mode 100644 index 0000000..28553e7 --- /dev/null +++ b/lib/rosecg/include/code_gen/CG_roseRepr.h @@ -0,0 +1,46 @@ +#ifndef CG_roseRepr_h +#define CG_roseRepr_h + +#include +#include "rose.h" + +namespace omega { + +class CG_roseRepr : public CG_outputRepr { + friend class CG_roseBuilder; +public: + CG_roseRepr(); + CG_roseRepr(SgNode *tnl); + CG_roseRepr(SgExpression *exp); + CG_roseRepr(SgStatementPtrList* stmtlist); + + ~CG_roseRepr(); + CG_outputRepr *clone() const; + void clear(); + + SgNode* GetCode() const; + SgStatementPtrList* GetList() const; + SgExpression *GetExpression() const; + + + + + //--------------------------------------------------------------------------- + // Dump operations + //--------------------------------------------------------------------------- + void Dump() const; +private: + // only one of _tnl and _op would be active at any time, depending on + // whether it is building a statement list or an expression tree + SgNode *tnl_; + SgExpression *op_; + SgStatementPtrList *list_; + void DumpFileHelper(SgNode* node, FILE* fp) const; + //operand op_; +}; + + + +} // namespace + +#endif diff --git a/lib/rosecg/include/code_gen/rose_attributes.h b/lib/rosecg/include/code_gen/rose_attributes.h new file mode 100644 index 0000000..9766f52 --- /dev/null +++ b/lib/rosecg/include/code_gen/rose_attributes.h @@ -0,0 +1,91 @@ +#ifndef ROSE_ATTRIBUTES_HH +#define ROSE_ATTRIBUTES_HH + +#include "rose.h" +#include +#include +#include + +namespace omega { + +class CodeInsertion; + +typedef std::vector CodeInsertionPtrList; +typedef std::vector::iterator CodeInsertionPtrListItr; + +class CodeInsertion { +public: + int loop_level; + bool marked; + CodeInsertion(int looplevel) { this->loop_level = looplevel; marked = false; } + ~CodeInsertion() {} + virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL) = 0; +}; + +class PragmaInsertion : public CodeInsertion { +private: + std::string name; +public: + PragmaInsertion(int loop_level, const std::string &pragma) : CodeInsertion(loop_level) { this->name = std::string(pragma); } + ~PragmaInsertion() { } + virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL); +}; + +class MMPrefetchInsertion : public CodeInsertion { +private: + std::string arrName; + std::vector indecies; + std::vector offsets; + int indexCount; + int cacheHint; + void initialize(const std::string& arrName, int hint); + void addDim(int offset); + void addDim(int offset, const std::string& indexer); + SgExpression* buildArrArg(SgScopeStatement* scopeStmt); + SgExpression* makeIndexExp(int dim, SgScopeStatement* scopeStmt); +public: + MMPrefetchInsertion(int loop_level, const std::string &arr, int hint) : CodeInsertion(loop_level) + { this->initialize(arr, hint); } + ~MMPrefetchInsertion() { } + virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL); +}; + +class CodeInsertionAttribute : public AstAttribute { +private: + std::vector code_insertions; +public: + CodeInsertionAttribute() { code_insertions = std::vector(); } + ~CodeInsertionAttribute() {} + + void add(CodeInsertion* ci) { code_insertions.push_back(ci); } + CodeInsertionPtrListItr begin() { return code_insertions.begin(); } + CodeInsertionPtrListItr end() { return code_insertions.end(); } + void remove(CodeInsertion* ci) { std::remove(code_insertions.begin(), code_insertions.end(), ci); } + int countCodeInsertions() { return code_insertions.size(); } +}; + +struct CodeInsertionMark { +public: + SgStatement* stmt; + CodeInsertion* ci; +}; + +class CodeInsertionVisitor : public AstPrePostProcessing { +private: + int loop_level; + std::vector ci_marks; + void markStmt(SgStatement* stmt, CodeInsertion* ci); +public: + void initialize(); + virtual void preOrderVisit(SgNode* n); + virtual void postOrderVisit(SgNode* n); + void insertCode(); +}; + +void postProcessRoseCodeInsertion(SgProject* proj); +void copyAttributes(SgNode* s, SgNode* d); +CodeInsertionAttribute* getOrCreateCodeInsertionAttribute(SgNode* node); + +} + +#endif diff --git a/lib/rosecg/include/rose_attributes.h b/lib/rosecg/include/rose_attributes.h deleted file mode 100644 index 9766f52..0000000 --- a/lib/rosecg/include/rose_attributes.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef ROSE_ATTRIBUTES_HH -#define ROSE_ATTRIBUTES_HH - -#include "rose.h" -#include -#include -#include - -namespace omega { - -class CodeInsertion; - -typedef std::vector CodeInsertionPtrList; -typedef std::vector::iterator CodeInsertionPtrListItr; - -class CodeInsertion { -public: - int loop_level; - bool marked; - CodeInsertion(int looplevel) { this->loop_level = looplevel; marked = false; } - ~CodeInsertion() {} - virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL) = 0; -}; - -class PragmaInsertion : public CodeInsertion { -private: - std::string name; -public: - PragmaInsertion(int loop_level, const std::string &pragma) : CodeInsertion(loop_level) { this->name = std::string(pragma); } - ~PragmaInsertion() { } - virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL); -}; - -class MMPrefetchInsertion : public CodeInsertion { -private: - std::string arrName; - std::vector indecies; - std::vector offsets; - int indexCount; - int cacheHint; - void initialize(const std::string& arrName, int hint); - void addDim(int offset); - void addDim(int offset, const std::string& indexer); - SgExpression* buildArrArg(SgScopeStatement* scopeStmt); - SgExpression* makeIndexExp(int dim, SgScopeStatement* scopeStmt); -public: - MMPrefetchInsertion(int loop_level, const std::string &arr, int hint) : CodeInsertion(loop_level) - { this->initialize(arr, hint); } - ~MMPrefetchInsertion() { } - virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL); -}; - -class CodeInsertionAttribute : public AstAttribute { -private: - std::vector code_insertions; -public: - CodeInsertionAttribute() { code_insertions = std::vector(); } - ~CodeInsertionAttribute() {} - - void add(CodeInsertion* ci) { code_insertions.push_back(ci); } - CodeInsertionPtrListItr begin() { return code_insertions.begin(); } - CodeInsertionPtrListItr end() { return code_insertions.end(); } - void remove(CodeInsertion* ci) { std::remove(code_insertions.begin(), code_insertions.end(), ci); } - int countCodeInsertions() { return code_insertions.size(); } -}; - -struct CodeInsertionMark { -public: - SgStatement* stmt; - CodeInsertion* ci; -}; - -class CodeInsertionVisitor : public AstPrePostProcessing { -private: - int loop_level; - std::vector ci_marks; - void markStmt(SgStatement* stmt, CodeInsertion* ci); -public: - void initialize(); - virtual void preOrderVisit(SgNode* n); - virtual void postOrderVisit(SgNode* n); - void insertCode(); -}; - -void postProcessRoseCodeInsertion(SgProject* proj); -void copyAttributes(SgNode* s, SgNode* d); -CodeInsertionAttribute* getOrCreateCodeInsertionAttribute(SgNode* node); - -} - -#endif diff --git a/lib/rosecg/src/CG_roseBuilder.cc b/lib/rosecg/src/CG_roseBuilder.cc index 09370a4..8f7e3df 100644 --- a/lib/rosecg/src/CG_roseBuilder.cc +++ b/lib/rosecg/src/CG_roseBuilder.cc @@ -13,7 +13,7 @@ *****************************************************************************/ #include -#include "CG_roseBuilder.h" +#include "code_gen/CG_roseBuilder.h" #include struct ir_error: public std::runtime_error { diff --git a/lib/rosecg/src/CG_roseRepr.cc b/lib/rosecg/src/CG_roseRepr.cc index 0b0c073..5472239 100644 --- a/lib/rosecg/src/CG_roseRepr.cc +++ b/lib/rosecg/src/CG_roseRepr.cc @@ -11,8 +11,8 @@ 02/01/06 - Chun Chen - created *****************************************************************************/ -#include "CG_roseRepr.h" -#include "rose_attributes.h" +#include "code_gen/CG_roseRepr.h" +#include "code_gen/rose_attributes.h" #include #include #include diff --git a/lib/rosecg/src/rose_attributes.cc b/lib/rosecg/src/rose_attributes.cc index 3debb2d..c5ba30b 100644 --- a/lib/rosecg/src/rose_attributes.cc +++ b/lib/rosecg/src/rose_attributes.cc @@ -1,4 +1,4 @@ -#include "rose_attributes.h" +#include "code_gen/rose_attributes.h" namespace omega { diff --git a/src/ir_rose.cc b/src/ir_rose.cc index dc3eed8..223e7a4 100644 --- a/src/ir_rose.cc +++ b/src/ir_rose.cc @@ -14,9 +14,9 @@ #include #include "ir_rose.hh" #include "ir_rose_utils.hh" -#include "rose_attributes.h" -#include "CG_roseRepr.h" -#include "CG_roseBuilder.h" +#include "code_gen/rose_attributes.h" +#include "code_gen/CG_roseRepr.h" +#include "code_gen/CG_roseBuilder.h" using namespace SageBuilder; using namespace SageInterface; -- cgit v1.2.3-70-g09d2