summaryrefslogtreecommitdiff
path: root/lib/rosecg/include/code_gen/CG_roseBuilder.h
blob: ca33f7e3af57f30253effffb52ad3108c4ec3c6f (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef CG_roseBuilder_h
#define CG_roseBuilder_h

#include <basic/Tuple.h>
#include "code_gen/rose_attributes.h"
#include <code_gen/CG_outputBuilder.h>
#include "code_gen/CG_roseRepr.h"
#include <string>

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<std::string> &vars,
                                               std::vector<CG_outputRepr *> &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<CG_outputRepr *> &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::vector<SgVarRefExp *>substitute(SgNode *tnl, const SgVariableSymbol *sym, SgExpression *expr,SgNode* root) ;




} // namespace

#endif