summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-09-18 15:16:52 -0600
committerTuowen Zhao <ztuowen@gmail.com>2016-09-18 15:16:52 -0600
commit18644419b50b2b14a24456e0fcdb210f231ee317 (patch)
tree3d2a57050ae93ee0ceb71df319b1533480a4001d
parent2fce43d484e4148ae858f410d51dcd9951d34374 (diff)
downloadchill-18644419b50b2b14a24456e0fcdb210f231ee317.tar.gz
chill-18644419b50b2b14a24456e0fcdb210f231ee317.tar.bz2
chill-18644419b50b2b14a24456e0fcdb210f231ee317.zip
doc updated for code_gen
-rw-r--r--README.md14
-rw-r--r--doxygen/Doxyfile.in2
-rw-r--r--omegalib/codegen/include/code_gen/CG_outputBuilder.h116
-rw-r--r--omegalib/codegen/include/code_gen/CG_outputRepr.h6
-rw-r--r--omegalib/codegen/include/code_gen/CG_roseBuilder.h80
-rw-r--r--omegalib/codegen/include/code_gen/CG_roseRepr.h1
-rw-r--r--omegalib/codegen/include/code_gen/CG_suifBuilder.h88
-rw-r--r--omegalib/codegen/include/code_gen/CG_suifRepr.h36
-rwxr-xr-xomegalib/codegen/include/code_gen/codegen.h12
-rw-r--r--omegalib/codegen/src/CG_roseBuilder.cc456
-rw-r--r--omegalib/omega/include/basic/Bag.h29
-rwxr-xr-xomegalib/omega/include/basic/BoolSet.h18
-rw-r--r--omegalib/omega/include/basic/Collection.h12
-rw-r--r--omegalib/omega/include/basic/ConstString.h1
-rw-r--r--omegalib/omega/include/basic/DynamicArray.c (renamed from omegalib/omega/include/basic/Dynamic_Array.c)58
-rw-r--r--omegalib/omega/include/basic/DynamicArray.h103
-rw-r--r--omegalib/omega/include/basic/Dynamic_Array.h103
-rw-r--r--omegalib/omega/include/basic/Iterator.h48
-rw-r--r--omegalib/omega/include/basic/Link.h17
-rw-r--r--omegalib/omega/include/basic/List.h5
-rw-r--r--omegalib/omega/include/omega/reach.h8
-rw-r--r--omegalib/omega/src/reach.cc6
-rw-r--r--omegalib/omegacalc/include/omega_calc/PT-omega.c8
-rw-r--r--omegalib/omegacalc/src/parser.l2
-rwxr-xr-xomegalib/omegacalc/src/parser.ll2
-rw-r--r--omegalib/omegacalc/src/parser.y16
-rwxr-xr-xomegalib/omegacalc/src/parser.yy14
27 files changed, 317 insertions, 944 deletions
diff --git a/README.md b/README.md
index 91b7b0f..3cdca60 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,10 @@
-# Build
+# CHiLL
+
+***The Composable High Level Loop Source-to-Source Translator***
+
+## How to use
+
+### Build
1. build boost, rose
2. checkout repo, cd
@@ -6,13 +12,13 @@
4. `cmake --build build -- -j10`
5. If no errors during build, executables are in `build`
-# Install
+### Install
1. Optionally set `CMAKE_INSTALL_PREFIX`
2. Optionally `cmake --build build -- install`
-# Doc
+## Additional Doc
* CHiLL.pdf
-* `cmake --build build -- doc`
+* Doxygen: `cmake --build build -- doc`
diff --git a/doxygen/Doxyfile.in b/doxygen/Doxyfile.in
index 67b9abb..9d2f5a3 100644
--- a/doxygen/Doxyfile.in
+++ b/doxygen/Doxyfile.in
@@ -920,7 +920,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
-USE_MDFILE_AS_MAINPAGE =
+USE_MDFILE_AS_MAINPAGE = README.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
diff --git a/omegalib/codegen/include/code_gen/CG_outputBuilder.h b/omegalib/codegen/include/code_gen/CG_outputBuilder.h
index 2203235..19dc440 100644
--- a/omegalib/codegen/include/code_gen/CG_outputBuilder.h
+++ b/omegalib/codegen/include/code_gen/CG_outputBuilder.h
@@ -29,76 +29,57 @@
namespace omega {
+//! abstract base class of comiler IR code builder
class CG_outputBuilder {
public:
CG_outputBuilder() {}
virtual ~CG_outputBuilder() {}
- //---------------------------------------------------------------------------
- // substitute variables in stmt
- //---------------------------------------------------------------------------
+ //! substitute variables in stmt
virtual CG_outputRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt,
const std::vector<std::string> &vars,
std::vector<CG_outputRepr *> &subs) const = 0;
- //---------------------------------------------------------------------------
- // assignment stmt generation
- //---------------------------------------------------------------------------
+ //! assignment stmt generation
virtual CG_outputRepr *CreateAssignment(int indent, CG_outputRepr *lhs,
CG_outputRepr *rhs) const = 0;
- //---------------------------------------------------------------------------
- // function invocation generation
- //---------------------------------------------------------------------------
+ //! function invocation generation
virtual CG_outputRepr *CreateInvoke(const std::string &funcName,
std::vector<CG_outputRepr *> &argList) const = 0;
- //---------------------------------------------------------------------------
- // comment generation
- //---------------------------------------------------------------------------
+ //! comment generation
virtual CG_outputRepr *CreateComment(int indent,
const std::string &commentText) const = 0;
- //---------------------------------------------------------------------------
- // Attribute generation
- //---------------------------------------------------------------------------
+ //! Attribute generation
virtual CG_outputRepr* CreateAttribute(CG_outputRepr *control,
const std::string &commentText) const = 0;
- //---------------------------------------------------------------------------
- // Pragma Attribute
- // --------------------------------------------------------------------------
+ //! Pragma Attribute
virtual CG_outputRepr* CreatePragmaAttribute(CG_outputRepr *scopeStmt, int looplevel, const std::string &pragmaText) const = 0;
- //---------------------------------------------------------------------------
- // Prefetch Attribute
- //---------------------------------------------------------------------------
+ //! Prefetch Attribute
virtual CG_outputRepr* CreatePrefetchAttribute(CG_outputRepr *scopeStmt, int looplevel, const std::string &arrName, int hint) const = 0;
- //---------------------------------------------------------------------------
- // generate if stmt, true/false stmt can be NULL but not the condition
- //---------------------------------------------------------------------------
+ //! generate if stmt, true/false stmt can be NULL but not the condition
virtual CG_outputRepr *CreateIf(int indent, CG_outputRepr *guardCondition,
CG_outputRepr *true_stmtList,
CG_outputRepr *false_stmtList) const = 0;
- //---------------------------------------------------------------------------
- // generate loop inductive variable (loop control structure)
- //---------------------------------------------------------------------------
+ //! generate loop inductive variable (loop control structure)
virtual CG_outputRepr *CreateInductive(CG_outputRepr *index,
CG_outputRepr *lower,
CG_outputRepr *upper,
CG_outputRepr *step) const = 0;
- //---------------------------------------------------------------------------
- // generate loop stmt from loop control and loop body, NULL parameter allowed
- //---------------------------------------------------------------------------
+ //! generate loop stmt from loop control and loop body, NULL parameter allowed
virtual CG_outputRepr *CreateLoop(int indent, CG_outputRepr *control,
CG_outputRepr *stmtList) const = 0;
- //---------------------------------------------------------------------------
- // copy operation, NULL parameter allowed. this function makes pointer
- // handling uniform regardless NULL status
- //---------------------------------------------------------------------------
+ //! copy operation, NULL parameter allowed.
+ /*!
+ * this function makes pointer handling uniform regardless NULL status
+ */
virtual CG_outputRepr *CreateCopy(CG_outputRepr *original) const {
if (original == NULL)
return NULL;
@@ -106,69 +87,72 @@ public:
return original->clone();
}
- //---------------------------------------------------------------------------
- // basic integer number creation
- //---------------------------------------------------------------------------
+ //! basic integer number creation
virtual CG_outputRepr *CreateInt(int num) const = 0;
virtual bool isInteger(CG_outputRepr *op) const = 0;
- //---------------------------------------------------------------------------
- // basic identity/variable creation
- //---------------------------------------------------------------------------
+ //! basic identity/variable creation
virtual CG_outputRepr *CreateIdent(const std::string &varName) const = 0;
- //---------------------------------------------------------------------------
- // binary arithmetic operations, NULL parameter means 0,
- // Note:
- // integer division truncation method undefined, only use when lop is known
- // to be multiple of rop, otherwise use integer floor instead
- //---------------------------------------------------------------------------
+ //! Addition operations, NULL parameter means 0,
virtual CG_outputRepr *CreatePlus(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ //! Subtraction operations, NULL parameter means 0,
virtual CG_outputRepr *CreateMinus(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ //! Multiplication operations, NULL parameter means 0,
virtual CG_outputRepr *CreateTimes(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ //! Division operations, NULL parameter means 0,
+ /*!
+ * integer division truncation method undefined, only use when lop is known
+ * to be multiple of rop, otherwise use integer floor instead
+ */
virtual CG_outputRepr *CreateDivide(CG_outputRepr *lop, CG_outputRepr *rop) const {
return CreateIntegerFloor(lop, rop);
}
- //---------------------------------------------------------------------------
- // integer arithmetic functions, NULL parameter means 0, second parameter
- // must be postive (i.e. b > 0 below), otherwise function undefined
- // Note:
- // ceil(a, b) = -floor(-a, b) or floor(a+b-1, b) or floor(a-1, b)+1
- // mod(a, b) = a-b*floor(a, b)
- // where result must lie in range [0,b)
- // floor(a, b) = a/b if a >= 0
- // (a-b+1)/b if a < 0
- // where native '/' operator behaves as 5/2 = 2, (-5)/2 = -2
- //---------------------------------------------------------------------------
+ //! integer floor functions, NULL parameter means 0
+ /*!
+ * second parameter must be postive (i.e. b > 0 below), otherwise function undefined
+ *
+ * floor(a, b)
+ * * = a/b if a >= 0
+ * * = (a-b+1)/b if a < 0
+ */
virtual CG_outputRepr *CreateIntegerFloor(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ //! integer mod functions, NULL parameter means 0
+ /*!
+ * second parameter must be postive (i.e. b > 0 below), otherwise function undefined
+ *
+ * mod(a, b) = a-b*floor(a, b) where result must lie in range [0,b)
+ */
virtual CG_outputRepr *CreateIntegerMod(CG_outputRepr *lop, CG_outputRepr *rop) const {
CG_outputRepr *lop2 = CreateCopy(lop);
CG_outputRepr *rop2 = CreateCopy(rop);
return CreateMinus(lop2, CreateTimes(rop2, CreateIntegerFloor(lop, rop)));
}
+ //! integer ceil functions, NULL parameter means 0
+ /*!
+ * second parameter must be postive (i.e. b > 0 below), otherwise function undefined
+ *
+ * ceil(a, b) = -floor(-a, b) or floor(a+b-1, b) or floor(a-1, b)+1
+ */
virtual CG_outputRepr *CreateIntegerCeil(CG_outputRepr *lop, CG_outputRepr *rop) const {
return CreateMinus(NULL, CreateIntegerFloor(CreateMinus(NULL, lop), rop));
}
- //---------------------------------------------------------------------------
- // binary logical operation, NULL parameter means TRUE
- //---------------------------------------------------------------------------
+ //! binary logical operation, NULL parameter means TRUE
virtual CG_outputRepr *CreateAnd(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
- //---------------------------------------------------------------------------
- // binary condition operations
- //---------------------------------------------------------------------------
+ //! binary conditional Greater than or equal to
virtual CG_outputRepr *CreateGE(CG_outputRepr *lop, CG_outputRepr *rop) const {
return CreateLE(rop, lop);
}
+ //! binary conditional Less than or equal to
virtual CG_outputRepr *CreateLE(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ //! binary conditional equal to
virtual CG_outputRepr *CreateEQ(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
- //---------------------------------------------------------------------------
- // join stmts together, NULL parameter allowed
- //---------------------------------------------------------------------------
+ //! join stmts together, NULL parameter allowed
virtual CG_outputRepr *StmtListAppend(CG_outputRepr *list1, CG_outputRepr *list2) const = 0;
};
diff --git a/omegalib/codegen/include/code_gen/CG_outputRepr.h b/omegalib/codegen/include/code_gen/CG_outputRepr.h
index 92f3d9f..0897007 100644
--- a/omegalib/codegen/include/code_gen/CG_outputRepr.h
+++ b/omegalib/codegen/include/code_gen/CG_outputRepr.h
@@ -20,9 +20,11 @@ namespace omega {
class CG_outputRepr {
public:
CG_outputRepr() {}
- virtual ~CG_outputRepr() { /* shallow delete */ }
+ //! shallow delete
+ virtual ~CG_outputRepr() { }
virtual CG_outputRepr *clone() const = 0;
- virtual void clear() { /* delete actual IR code wrapped inside */ }
+ //! delete actual IR code wrapped inside
+ virtual void clear() { }
virtual void dump() const {}
};
diff --git a/omegalib/codegen/include/code_gen/CG_roseBuilder.h b/omegalib/codegen/include/code_gen/CG_roseBuilder.h
index 93b708e..5dad663 100644
--- a/omegalib/codegen/include/code_gen/CG_roseBuilder.h
+++ b/omegalib/codegen/include/code_gen/CG_roseBuilder.h
@@ -14,98 +14,60 @@ public:
CG_roseBuilder(int isFortran, SgGlobal* global, SgGlobal* global_scope, SgSymbolTable* symtab1, SgSymbolTable* symtab2, SgNode* root);
~CG_roseBuilder();
- //---------------------------------------------------------------------------
- // place holder generation
- //---------------------------------------------------------------------------
- // CG_outputRepr* CreatePlaceHolder(int indent, CG_outputRepr *stmt,
- // Tuple<CG_outputRepr*> &funcList,
- // Tuple<std::string> &loop_vars) const;
-
-
- //---------------------------------------------------------------------------
- // substitute variables in stmt
- //---------------------------------------------------------------------------
-
-
-
+ //! 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
- //---------------------------------------------------------------------------
+ //! assignment generation
CG_outputRepr* CreateAssignment(int indent, CG_outputRepr* lhs,
CG_outputRepr* rhs) const;
- //---------------------------------------------------------------------------
- // function invocation generation
- //---------------------------------------------------------------------------
+ //! function invocation generation
CG_outputRepr* CreateInvoke(const std::string &funcName,
std::vector<CG_outputRepr *> &argList) const;
- //---------------------------------------------------------------------------
- // comment generation
- //---------------------------------------------------------------------------
+ //! comment generation
CG_outputRepr* CreateComment(int indent, const std::string &commentText) const;
- //---------------------------------------------------------------------------
- // Attribute generation
- //---------------------------------------------------------------------------
+ //! Attribute generation
CG_outputRepr* CreateAttribute(CG_outputRepr *control,
const std::string &commentText) const;
- //---------------------------------------------------------------------------
- // Pragma Attribute
- //---------------------------------------------------------------------------
+ //! Pragma Attribute
CG_outputRepr* CreatePragmaAttribute(CG_outputRepr *scopeStmt, int looplevel,
const std::string &pragmaText) const;
- //---------------------------------------------------------------------------
- // Prefetch Attribute
- //---------------------------------------------------------------------------
+ //! Prefetch Attribute
CG_outputRepr* CreatePrefetchAttribute(CG_outputRepr *scopeStmt, int looplevel,
const std::string &arrName, int hint) const;
- //---------------------------------------------------------------------------
- // if stmt gen operations
- //---------------------------------------------------------------------------
+ //! 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
- //---------------------------------------------------------------------------
+ //! 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
- //---------------------------------------------------------------------------
+ //! loop stmt generation
CG_outputRepr* CreateLoop(int indent, CG_outputRepr* control,
CG_outputRepr* stmtList) const;
- //---------------------------------------------------------------------------
- // basic operations
- //---------------------------------------------------------------------------
CG_outputRepr* CreateInt(int num ) const;
bool isInteger(CG_outputRepr *op) const;
CG_outputRepr* CreateIdent(const std::string &varName) const;
- //---------------------------------------------------------------------------
- // binary arithmetic operations
- //---------------------------------------------------------------------------
+ //! 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
- //---------------------------------------------------------------------------
+ //! binary logical operations
CG_outputRepr* CreateAnd(CG_outputRepr* lop, CG_outputRepr* rop) const;
//---------------------------------------------------------------------------
@@ -118,30 +80,14 @@ public:
//---------------------------------------------------------------------------
// stmt list gen operations
//---------------------------------------------------------------------------
- // CG_outputRepr*
- // CreateStmtList(CG_outputRepr *singleton = NULL) const;
- // CG_outputRepr*
- // StmtListInsertLast(CG_outputRepr* list, CG_outputRepr* node) const;
CG_outputRepr*
StmtListAppend(CG_outputRepr* list1, CG_outputRepr* list2) const;
- //CG_outputRepr* CreateDim3(const char* varName, int arg1, int arg2) 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;
- //---------------------------------------------------------------------------
- // kernel generation
- //---------------------------------------------------------------------------
- // CG_outputRepr* CreateKernel(immed_list* iml) const;
-
- //---------------------------------------------------------------------------
- // Add a modifier to a type (for things like __global__)
- //---------------------------------------------------------------------------
- //type_node* ModifyType(type_node* base, const char* modifier) const;
-
-
private:
SgSymbolTable *symtab_;
SgSymbolTable *symtab2_;
@@ -152,8 +98,6 @@ private:
};
extern char *k_ocg_comment;
- //bool substitute(SgExpression *in, SgVariableSymbol *sym, SgExpression *expr, SgNode* root, SgExpression* parent);
- //bool substitute(SgStatement *tn, SgVariableSymbol *sym, SgExpression* expr, SgNode* root, SgSymbolTable* symtab);
std::vector<SgVarRefExp *>substitute(SgNode *tnl, const SgVariableSymbol *sym, SgExpression *expr,SgNode* root) ;
diff --git a/omegalib/codegen/include/code_gen/CG_roseRepr.h b/omegalib/codegen/include/code_gen/CG_roseRepr.h
index 4861db7..28553e7 100644
--- a/omegalib/codegen/include/code_gen/CG_roseRepr.h
+++ b/omegalib/codegen/include/code_gen/CG_roseRepr.h
@@ -29,7 +29,6 @@ public:
// Dump operations
//---------------------------------------------------------------------------
void Dump() const;
- //void DumpToFile(FILE *fp = stderr) 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
diff --git a/omegalib/codegen/include/code_gen/CG_suifBuilder.h b/omegalib/codegen/include/code_gen/CG_suifBuilder.h
deleted file mode 100644
index 9f57e3d..0000000
--- a/omegalib/codegen/include/code_gen/CG_suifBuilder.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef CG_suifBuilder_h
-#define CG_suifBuilder_h
-
-#include <basic/Tuple.h>
-#include <code_gen/CG_outputBuilder.h>
-#include <code_gen/CG_suifRepr.h>
-#include <string>
-
-namespace omega {
-
-
-class CG_suifBuilder: public CG_outputBuilder {
-public:
- //CG_suifBuilder(proc_symtab *symtab) {symtab_ = symtab;}
- CG_suifBuilder(proc_symtab *symtab);
- //protonu--initializing code_gen stuff for cuda
- //this looks like a flaw in my design
- //end--protonu
- ~CG_suifBuilder() {}
-
- CG_outputRepr* CreatePlaceHolder(int indent, CG_outputRepr *stmt,
- Tuple<CG_outputRepr*> &funcList,
- Tuple<std::string> &loop_vars) const;
- CG_outputRepr* CreateAssignment(int indent, CG_outputRepr* lhs,
- CG_outputRepr* rhs) const;
- CG_outputRepr* CreateInvoke(const std::string &fname,
- Tuple<CG_outputRepr*> &argList) const;
- CG_outputRepr* CreateComment(int indent, const std::string &commentText) const;
- CG_outputRepr* CreateAttribute(CG_outputRepr *control,
- const std::string &commentText) const;
-
- CG_outputRepr* CreateIf(int indent, CG_outputRepr* guardCondition,
- CG_outputRepr* true_stmtList, CG_outputRepr* false_stmtList) const;
- CG_outputRepr* CreateInductive(CG_outputRepr* index,
- CG_outputRepr* lower,
- CG_outputRepr* upper,
- CG_outputRepr* step) const;
- CG_outputRepr* CreateLoop(int indent, CG_outputRepr* control,
- CG_outputRepr* stmtList) const;
- CG_outputRepr* CreateInt(int) const;
- CG_outputRepr* CreateIdent(const std::string &idStr) const;
- CG_outputRepr* CreatePlus(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateMinus(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateTimes(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateIntegerDivide(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateIntegerMod(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateAnd(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateGE(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateLE(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* CreateEQ(CG_outputRepr*, CG_outputRepr*) const;
- CG_outputRepr* StmtListAppend(CG_outputRepr* list1, CG_outputRepr* list2) const;
- //---------------------------------------------------------------------------
- // pragma generation
- //---------------------------------------------------------------------------
- virtual CG_outputRepr* CreatePragma(int indent, const std::string &pragmaText) const;
-
- //---------------------------------------------------------------------------
- // dim3 generation
- //---------------------------------------------------------------------------
- virtual CG_outputRepr* CreateDim3(immed varName, immed arg1, immed arg2) const;
- virtual CG_outputRepr* CreateDim3(immed varName, immed arg1, immed arg2, immed arg3) const;
-
-
- //---------------------------------------------------------------------------
- // kernel generation
- //---------------------------------------------------------------------------
- virtual CG_outputRepr* CreateKernel(immed_list* iml) const;
-
- //---------------------------------------------------------------------------
- // Add a modifier to a type (for things like __global__)
- //---------------------------------------------------------------------------
- type_node* ModifyType(type_node* base, const char* modifier) const;
-private:
- proc_symtab *symtab_;
-};
-
-extern char *k_ocg_comment;
-
-bool substitute(instruction *in, var_sym *sym, operand expr,
- base_symtab *st=NULL);
-bool substitute(tree_node *tn, var_sym *sym, operand expr,
- base_symtab *st=NULL);
-bool substitute(tree_node_list *tnl, var_sym *sym, operand expr,
- base_symtab *st = NULL);
-
-}
-
-#endif
diff --git a/omegalib/codegen/include/code_gen/CG_suifRepr.h b/omegalib/codegen/include/code_gen/CG_suifRepr.h
deleted file mode 100644
index ce7c6cd..0000000
--- a/omegalib/codegen/include/code_gen/CG_suifRepr.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef CG_suifRepr_h
-#define CG_suifRepr_h
-
-#include <code_gen/CG_outputRepr.h>
-#include <suif1.h>
-
-namespace omega {
-
-class CG_suifRepr : public CG_outputRepr {
- friend class CG_suifBuilder;
-public:
- CG_suifRepr();
- CG_suifRepr(tree_node_list *tnl);
- CG_suifRepr(operand op);
- virtual ~CG_suifRepr();
- virtual CG_outputRepr *clone();
- virtual void clear();
-
- tree_node_list* GetCode() const;
- operand GetExpression() const;
-
- //---------------------------------------------------------------------------
- // Dump operations
- //---------------------------------------------------------------------------
- virtual void Dump() const;
- virtual void DumpToFile(FILE *fp = stderr) 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
- tree_node_list *tnl_;
- operand op_;
-};
-
-} // namespace
-
-#endif
diff --git a/omegalib/codegen/include/code_gen/codegen.h b/omegalib/codegen/include/code_gen/codegen.h
index 469653d..cb63bfd 100755
--- a/omegalib/codegen/include/code_gen/codegen.h
+++ b/omegalib/codegen/include/code_gen/codegen.h
@@ -15,10 +15,14 @@ public:
static const int var_substitution_threshold;
protected:
- std::vector<std::vector<Relation> > projected_IS_; // projected_IS_[level-1][new stmt#]
- std::vector<Relation> xforms_; // transformations[original stmt#]
- Relation known_; // no need to generate code for constraints satisfied in known
- std::vector<int> remap_; // map new stmt# to original stmt#
+ //! projected_IS_[level-1][new stmt#]
+ std::vector<std::vector<Relation> > projected_IS_;
+ //! transformations[original stmt#]
+ std::vector<Relation> xforms_;
+ //! no need to generate code for constraints satisfied in known
+ Relation known_;
+ //! map new stmt# to original stmt#
+ std::vector<int> remap_;
public:
CodeGen(const std::vector<Relation> &xforms, const std::vector<Relation> &IS, const Relation &known = Relation::Null(),
diff --git a/omegalib/codegen/src/CG_roseBuilder.cc b/omegalib/codegen/src/CG_roseBuilder.cc
index eb16830..7e12634 100644
--- a/omegalib/codegen/src/CG_roseBuilder.cc
+++ b/omegalib/codegen/src/CG_roseBuilder.cc
@@ -33,22 +33,6 @@ namespace omega {
//-----------------------------------------------------------------------------
char *k_ocg_comment;
-// void __attribute__ ((constructor)) my_init(void) {
-// ANNOTE(k_ocg_comment, "omega_comment", TRUE);
-// }
-
-/*
- const char *libcode_gen_ver_string = "";
- const char *libcode_gen_who_string = "";
- const char *libcode_gen_suif_string = "";
-
- void init_code_gen(int&, char* []) {
- ANNOTE(k_ocg_comment, "omega_comment", TRUE);
- }
-
- void exit_code_gen(void) {
- }
- */
CG_roseBuilder::CG_roseBuilder(int is_fortran, SgGlobal* global, SgGlobal* firstScope,
SgSymbolTable* symtab, SgSymbolTable* symtab2, SgNode* root) :
isFortran(is_fortran), global_(global), global_scope(firstScope), symtab_(symtab), symtab2_(
@@ -77,8 +61,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
SgNode *tnl;
SgStatement* statement;
if (list != NULL) {
- //statement = *((*list).begin());
- //tnl = isSgNode(statement);
delete stmt;
for (int i = 0; i < subs.size(); i++) {
if (subs[i] == NULL)
@@ -92,8 +74,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
statement = (*it);
tnl = isSgNode(statement);
- // std::string master = tnl->unparseToString();
-
int j;
int not_in_symtab_;
@@ -109,15 +89,12 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
vs = symtab2_->find_variable(SgName(vars[i].c_str()));
}
if (vs != NULL) {
- //std::string x = vars[i].c_str() ;
- //std::string y = isSgNode(op)->unparseToString();
std::vector<SgVarRefExp *> array = substitute(tnl,
(const SgVariableSymbol*) vs, op, root_);
for (std::vector<SgVarRefExp *>::iterator it =
array.begin(); it != array.end(); it++) {
- // std::string z = isSgNode(array[j])->unparseToString();
if (isSgVarRefExp(op)) {
if (strcmp(
isSgVarRefExp(op)->get_symbol()->get_name().getString().c_str(),
@@ -125,9 +102,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
(*it)->set_symbol(
isSgVarRefExp(op)->get_symbol());
- // std::string z = isSgNode(array[j])->unparseToString();
-
- // isSgBinaryOp(array[j]->get_parent())->replace_expression(array[j], op);
}
} else if (isSgExpression(op)) {
@@ -146,10 +120,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
}
}
- /* std::vector<SgVarRefExp *> array2 = substitute (tnl,(const SgVariableSymbol*) vs, op, root_);
- if(array2.size() != 0)
- throw ir_error("variable replacement unsuccessful");
- */
}
}
@@ -166,7 +136,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
} else {
tnl = static_cast<CG_roseRepr *>(stmt)->tnl_;
- //std::string master = tnl->unparseToString();
if (tnl == NULL)
throw ir_error("both list and tnl are null!!");
@@ -195,8 +164,6 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
vs = symtab2_->find_variable(SgName(vars[i].c_str()));
}
if (vs != NULL) {
- //std::string x = vars[i].c_str() ;
- //std::string y = isSgNode(op)->unparseToString();
std::vector<SgVarRefExp *> array = substitute(tnl, vs, op,
root_);
@@ -204,27 +171,17 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
if (strcmp(
isSgVarRefExp(op)->get_symbol()->get_name().getString().c_str(),
vs->get_name().getString().c_str())) {
- // symtab2_->remove(vs);
}
}
- /* else if(not_in_symtab_ && isSgVarRefExp(isSgAddOp(op)->get_lhs_operand())){
- if(strcmp(isSgVarRefExp(isSgAddOp(op)->get_lhs_operand())->get_symbol()->get_name().getString().c_str(),\
- vs->get_name().getString().c_str())){
- symtab2_->remove(vs);
- }
- }*/
- //symtab2_->remove(vs);
+
for (std::vector<SgVarRefExp *>::iterator j = array.begin();
j != array.end(); j++) {
- // std::string z = isSgNode(array[j])->unparseToString();
if (isSgVarRefExp(op)) {
if (strcmp(
isSgVarRefExp(op)->get_symbol()->get_name().getString().c_str(),
vs->get_name().getString().c_str())) {
(*j)->set_symbol(isSgVarRefExp(op)->get_symbol());
- //isSgBinaryOp(array[j]->get_parent())->replace_expression(array[j], op);
- // std::string z = isSgNode(array[j])->unparseToString();
}
} else if (isSgExpression(op)) {
@@ -240,78 +197,11 @@ CG_outputRepr* CG_roseBuilder::CreateSubstitutedStmt(int, CG_outputRepr *stmt,
}
else
throw ir_error("unrecognized expression type");
- /* if(strcmp(isSgVarRefExp(isSgAddOp(op)->get_lhs_operand())->get_symbol()->get_name().getString().c_str(),\
- vs->get_name().getString().c_str() )){
- array[j]->set_symbol(isSgVarRefExp(isSgAddOp(op)->get_lhs_operand())->get_symbol());
-
- */
}
}
- /* std::vector<SgVarRefExp *> array2 = substitute (tnl,(const SgVariableSymbol*) vs, op, root_);
- if(array2.size() != 0)
- throw ir_error("variable replacement unsuccessful");
- */
}
- /* SgExpression* exp = NULL;
-
- if(stmt1 = isSgStatement(tnl)){
- if (SgExprStatement* expr_stmt = isSgExprStatement(stmt1))
- exp = expr_stmt->get_expression();
- else if( block = isSgBasicBlock(tnl)){
- SgStatementPtrList& stmts = block->get_statements();
- SgExpression* exp2;
- for(int i =0; i < stmts.size(); i++){
- if(isSgExprStatement(stmts[i])){
- exp2 = isSgExprStatement(stmts[i])->get_expression();
- if(exp2 != NULL){
-
- if(isSgBinaryOp(exp2)) {
- substitute(isSgBinaryOp(exp2)->get_lhs_operand(), vs, op, root_, exp2);
- substitute(isSgBinaryOp(exp2)->get_rhs_operand(), vs, op, root_, exp2);
- }
- else if (isSgUnaryOp(exp2))
- substitute(isSgUnaryOp(exp2)->get_operand(), vs, op, root_, exp2);
-
-
- }//end if
-
- }//end if
- }//end for
-
- }//end else
- else if(SgForStatement* for_stmt = isSgForStatement(tnl)){
- SgForStatement* temp = for_stmt;
- while(isSgForStatement(temp)){
-
-
-
- }
-
-
-
-
- }
-
-
- }//end if
- else
- exp = isSgExpression(tnl);
-
- if(exp != NULL){
- if(isSgBinaryOp(exp)) {
- substitute(isSgBinaryOp(exp)->get_lhs_operand(), vs, op, root_, exp);
- substitute(isSgBinaryOp(exp)->get_rhs_operand(), vs, op, root_, exp);
- }
- else if (isSgUnaryOp(exp))
- substitute(isSgUnaryOp(exp)->get_operand(), vs, op, root_, exp);
-
- }
- // if (op.is_instr())
- // delete op.instr();
- }
- */
}
return new CG_roseRepr(tnl);
}
@@ -352,9 +242,6 @@ CG_outputRepr* CG_roseBuilder::CreateAssignment(int, CG_outputRepr *lhs,
CG_outputRepr* CG_roseBuilder::CreateInvoke(const std::string &fname,
std::vector<CG_outputRepr *> &list) const {
- // Manu:: debug
-// std::cout << "--------- CreateInvoke --------- \n";
-
if (fname == std::string("max") || fname == std::string("min")) {
if (list.size() == 0) {
return NULL;
@@ -389,7 +276,6 @@ CG_outputRepr* CG_roseBuilder::CreateInvoke(const std::string &fname,
SgExpression *cond = static_cast<CG_roseRepr *>(CreateLE(new CG_roseRepr(op2), new CG_roseRepr(op1)))->op_;
appendExpression(arg_list, cond);
ins = isSgExpression(buildFunctionCallExp(fName, retType, arg_list, global_));
-// std::cout << "--------- CreateInvoke:: " << isSgNode(ins)->unparseToString().c_str() << "\n";
}
} else {
@@ -404,7 +290,6 @@ CG_outputRepr* CG_roseBuilder::CreateInvoke(const std::string &fname,
SgExpression *cond = static_cast<CG_roseRepr *>(CreateLE(new CG_roseRepr(op1), new CG_roseRepr(op2)))->op_;
appendExpression(arg_list, cond);
ins = isSgExpression(buildFunctionCallExp(fName, retType, arg_list, global_));
-// std::cout << "--------- CreateInvoke:: " << isSgNode(ins)->unparseToString().c_str() << "\n";
}
}
@@ -442,10 +327,6 @@ CG_outputRepr* CG_roseBuilder::CreateComment(int,
CG_outputRepr* CG_roseBuilder::CreateIf(int, CG_outputRepr *guardList,
CG_outputRepr *true_stmtList, CG_outputRepr *false_stmtList) const {
- // static int if_counter = 1;
- // std::string s = std::string("omegaif_")+to_string(if_counter++);
- // SgLabelStatement* label =buildLabelStatement(SgName(const_cast<char *>(s.c_str())));
-
if (true_stmtList == NULL && false_stmtList == NULL) {
delete guardList;
return NULL;
@@ -517,11 +398,6 @@ CG_outputRepr* CG_roseBuilder::CreateIf(int, CG_outputRepr *guardList,
SgIfStmt* ti = buildIfStmt(header, isSgStatement(then_part),
isSgStatement(else_part));
-// label->set_scope(ti);//may have to be shifted to after symbol table insertion
-// SgLabelSymbol* if_label = isSgLabelSymbol(label->get_symbol_from_symbol_table());
-
-// symtab_->insert( SgName(const_cast<char *>(s.c_str())) , isSgSymbol(if_label));
-
delete guardList;
delete true_stmtList;
delete false_stmtList;
@@ -551,10 +427,6 @@ CG_outputRepr* CG_roseBuilder::CreateInductive(CG_outputRepr *index,
SgExpression* upper_bound = static_cast<CG_roseRepr*>(upper)->op_;
SgExpression* step_size = static_cast<CG_roseRepr*>(step)->op_;
- /* label_sym *contLabel = new label_sym("");
- label_sym *brkLabel = new label_sym(""); may not be required on rose?!
- */
-
SgStatement* for_init_stmt = buildAssignStatement(index_sym, lower_bound);
SgLessOrEqualOp* cond = buildLessOrEqualOp(index_sym, upper_bound);
SgExprStatement* test = buildExprStatement(cond);
@@ -570,7 +442,6 @@ CG_outputRepr* CG_roseBuilder::CreateInductive(CG_outputRepr *index,
// Manu
if (isInputFortran()) {
- // std::cout << "CG_roseBuilder:: need to construct a fortran do statement\n";
SgFortranDo * forStmt=new SgFortranDo(Sg_File_Info::generateDefaultFileInfoForTransformationNode());
forStmt->set_has_end_statement(true);
forStmt->set_bound(upper_bound);
@@ -578,7 +449,6 @@ CG_outputRepr* CG_roseBuilder::CreateInductive(CG_outputRepr *index,
forStmt->set_initialization(isSgExprStatement(for_init_stmt)->get_expression());
return new CG_roseRepr(isSgNode(forStmt));
} else {
-// std::cout << "CG_roseBuilder:: for statement is fine\n";
return new CG_roseRepr(isSgNode(for_stmt));
@@ -647,20 +517,11 @@ CG_outputRepr* CG_roseBuilder::CreateLoop(int, CG_outputRepr *control,
if (isInputFortran()) {
tfd = isSgFortranDo(tnl);
}
- // Manu:: debug
-/* if (!tf) {
- std::cout << "CreateLoop:: Not a for loop\n";
- if (isSgFortranDo(tnl))
- std::cout << "CreateLoop:: It is a fortran do loop\n";
- }
-*/
-
SgStatementPtrList * body = static_cast<CG_roseRepr*>(stmtList)->list_;
if (body != NULL) {
if (!((*body).empty())) {
if ((*body).size() == 1) {
- // if(isSgBasicBlock(*((*body).begin()))){
if (!isInputFortran()) { // Manu:: added if-else for fortran support
tf->set_loop_body(*((*body).begin()));
(*((*body).begin()))->set_parent(tf);
@@ -670,14 +531,6 @@ CG_outputRepr* CG_roseBuilder::CreateLoop(int, CG_outputRepr *control,
bb1->append_statement(*((*body).begin()));
tfd->set_body(bb1);
}
- // }
- /* else{
- SgBasicBlock* bb1 = buildBasicBlock();
- bb1->set_parent(tf);
- bb1->append_statement(*((*body).begin()));
- tf->set_loop_body(bb1);
-
- }*/
} else {
// Manu:: support for fortran label (do - continue)
SgName *sname = NULL;
@@ -904,9 +757,6 @@ CG_outputRepr* CG_roseBuilder::CreateIntegerMod(CG_outputRepr *lop,
//-----------------------------------------------------------------------------
CG_outputRepr* CG_roseBuilder::CreateAnd(CG_outputRepr *lop,
CG_outputRepr *rop) const {
- /*if (rop == NULL || lop == NULL) {
- return NULL;
- }*/
if (rop == NULL)
return lop;
@@ -928,11 +778,6 @@ CG_outputRepr* CG_roseBuilder::CreateAnd(CG_outputRepr *lop,
//-----------------------------------------------------------------------------
// binary relational operations
//-----------------------------------------------------------------------------
-/*CG_outputRepr* CG_roseBuilder::CreateGE(CG_outputRepr *lop,
- CG_outputRepr *rop) const {
- return CreateLE(rop, lop);
-}*/
-
CG_outputRepr* CG_roseBuilder::CreateLE(CG_outputRepr *lop,
CG_outputRepr *rop) const {
if (rop == NULL || lop == NULL) {
@@ -972,44 +817,6 @@ CG_outputRepr* CG_roseBuilder::CreateEQ(CG_outputRepr *lop,
//-----------------------------------------------------------------------------
// stmt list gen operations
//-----------------------------------------------------------------------------
-/*CG_outputRepr* CG_roseBuilder::CreateStmtList(CG_outputRepr *singleton) const {
-
- if (singleton == NULL) {
- return new CG_roseRepr(new SgStatementPtrList);
- }
-
- SgStatementPtrList *tnl = static_cast<CG_roseRepr *>(singleton)->list_;
- SgNode* sgn = static_cast<CG_roseRepr *>(singleton)->tnl_;
-
- if (tnl == NULL)
- tnl = new SgStatementPtrList;
-
- if (sgn == NULL) {
- SgExpression* op = static_cast<CG_roseRepr *>(singleton)->op_;
-
- if (op != NULL)
- (*tnl).push_back(
- buildExprStatement(
- static_cast<CG_roseRepr *>(singleton)->op_));
-
- } else
- (*tnl).push_back(isSgStatement(sgn));
-
- delete singleton;
- return new CG_roseRepr(tnl);
-
-// tnl = isSgNode(buildBasicBlock(buildExprStatement(static_cast<CG_roseRepr *>(singleton)->op_)));
-
-// delete singleton;
-// return new CG_roseRepr(tnl);
-
-}
-
-CG_outputRepr* CG_roseBuilder::StmtListInsertLast(CG_outputRepr *list,
- CG_outputRepr *node) const {
- return StmtListAppend(list, node);
-}
-*/
CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
CG_outputRepr *list2) const {
@@ -1019,10 +826,6 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
return list2;
}
- // SgStatement* parent;
- // SgStatement* stmt1;
- // SgStatement* stmt2;
-
SgStatementPtrList* new_list;
SgStatementPtrList* tnl1 = static_cast<CG_roseRepr *>(list1)->list_;
@@ -1041,20 +844,6 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
if (tnl2 && two)
throw ir_error("error in stmtlistappend!!");
-// SgNode* sg1 = static_cast<CG_roseRepr *>(list1)->tnl_;
-
-//if((*tnl1).empty()){
-
-// if(SgStatement* stmt = isSgStatement(sg1))
-// (*tnl1).push_back(stmt);
-//else if(isSgScopeStatement(sg1)){
-// SgStatementPtrList scopeStmtPtrLst = isSgScopeStatement(sg1)->generateStatementList();
-
-// for(SgStatementPtrList::iterator it1 = scopeStmtPtrLst.begin();it1 != scopeStmtPtrLst.end(); it1++)
-// (*tnl1).push_back(*it1);
-//}
-//}
-
if ((tnl1 == NULL) && (tnl2 == NULL)) {
if ((one != NULL) && (two != NULL)) {
@@ -1079,12 +868,6 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
} else {
if ((tnl2 != NULL) && (tnl1 == NULL)) {
- /* for(SgStatementPtrList::iterator it = (*tnl2).begin(); it != (*tnl2).end(); it++)
- {
- (*tnl1).push_back(*it);
-
- }
- */
if (one == NULL)
return list2;
else {
@@ -1096,7 +879,6 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
(*new_list).push_back(*it);
}
- //delete list2;
return static_cast<CG_outputRepr *>(new CG_roseRepr(new_list));
}
} else if ((tnl1 != NULL) && (tnl2 == NULL)) {
@@ -1105,7 +887,6 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
else {
(*tnl1).push_back(isSgStatement(two));
- // delete list1;
return static_cast<CG_outputRepr *>(new CG_roseRepr(tnl1));
}
@@ -1118,53 +899,10 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
}
- // delete list2;
- // delete list1;
return static_cast<CG_outputRepr *>(new CG_roseRepr(tnl1));
}
-//else{
-// SgNode* tnll2 = static_cast<CG_roseRepr *>(list2)->tnl_;
-// if(tnll2 != NULL){
-// if(isSgStatement(tnll2))
-// (*tnl1).push_back(isSgStatement(tnll2));
-// else if(isSgScopeStatement(tnll2)){
-// SgStatementPtrList scopeStmtPtrLst1 = isSgScopeStatement(tnll2)->generateStatementList();
-
-// for(SgStatementPtrList::iterator it2 = scopeStmtPtrLst1.begin();it2 != scopeStmtPtrLst1.end(); it2++)
-// (*tnl1).push_back(*it2);
-
-// }
-//}
-// else{
-// SgStatement* stmt2 = isSgStatement(buildExprStatement(static_cast<CG_roseRepr *>(list2)->op_));
-// (*tnl1).push_back(stmt2);
-
-// }
-
-//}
- // stmt2 = isSgStatement(tnl2);
-
-// std::string c = tnl1->unparseToString();
-
-// std::string d = isSgNode(stmt2)->unparseToString();
-
-// if(isSgForStatement(tnl1) || isSgBasicBlock(tnl1))
-// isSgScopeStatement(tnl1)->append_statement(stmt2);
-// else
-// {
- // stmt1 = isSgStatement(tnl1);
- // parent = isSgStatement(tnl1->get_parent());
- // if(isSgForStatement(tnl1->get_parent()) || isSgBasicBlock(tnl1->get_parent()))
- // isSgScopeStatement(tnl1->get_parent())->append_statement(stmt2);
- // else if (isSgStatement(tnl1->get_parent()))
- // isSgStatement(tnl1->get_parent())->insert_statement(stmt1, stmt2, false);
-
-// }
}
-// delete list2;
-
-// return list1;
}
@@ -1172,14 +910,7 @@ CG_outputRepr* CG_roseBuilder::StmtListAppend(CG_outputRepr *list1,
CG_outputRepr* CG_roseBuilder::CreateDim3(const char* varName, CG_outputRepr* arg1,
CG_outputRepr* arg2, CG_outputRepr* arg3) const {
- //SgName type_name("dim3");
- //SgClassSymbol * type_symbol = global_scope->lookup_class_symbol(type_name);
- // SgClassDeclaration * type_decl = isSgClassDeclaration(
- // type_symbol->get_declaration());
-
- //SgVariableDeclaration * var_decl = buildVariableDeclaration(varName, type_symbol->get_type());
-
- SgFunctionSymbol * ctor_symbol = global_scope->lookup_function_symbol(
+ SgFunctionSymbol * ctor_symbol = global_scope->lookup_function_symbol(
SgName("dim3"));
SgExprListExp * ctor_args;
@@ -1203,103 +934,11 @@ CG_outputRepr* CG_roseBuilder::CreateDim3(const char* varName, CG_outputRepr* ar
SgStatementPtrList *tnl2 = new SgStatementPtrList;
- // (*tnl2).push_back(var_decl);
(*tnl2).push_back(decl);
return new CG_roseRepr(tnl2);
}
-/*CG_outputRepr* CG_roseBuilder::CreateDim3(const char* varName, int arg1,
- int arg2) const {
-
- SgName type_name("dim3");
- SgClassSymbol * type_symbol = global_scope->lookup_class_symbol(type_name);
- SgClassDeclaration * type_decl = isSgClassDeclaration(
- type_symbol->get_declaration());
-
- //SgVariableDeclaration * var_decl = buildVariableDeclaration(varName, type_symbol->get_type());
-
- SgFunctionSymbol * ctor_symbol = global_scope->lookup_function_symbol(
- SgName("dim3"));
-
- SgExprListExp * ctor_args = buildExprListExp(buildIntVal(arg1),
- buildIntVal(arg2));
-
- SgFunctionCallExp * dim3_func_call = buildFunctionCallExp(
- buildFunctionRefExp(ctor_symbol->get_declaration()), ctor_args);
-
- char joined_str[20];
-
- strcpy(joined_str, "dim3 ");
- strcat(joined_str, varName);
-
- SgExprStatement* decl = buildAssignStatement(
- buildOpaqueVarRefExp(joined_str, isSgScopeStatement(root_)),
- dim3_func_call);
-
- SgStatementPtrList *tnl2 = new SgStatementPtrList;
-
- // (*tnl2).push_back(var_decl);
- (*tnl2).push_back(decl);
- return new CG_roseRepr(tnl2);
-}
-
-CG_outputRepr* CG_roseBuilder::CreateDim3(const char* varName, int arg1,
- int arg2, int arg3) const {
-
- SgName type_name("dim3");
- SgClassSymbol * type_symbol = global_scope->lookup_class_symbol(type_name);
- SgClassDeclaration * type_decl = isSgClassDeclaration(
- type_symbol->get_declaration());
-
- //SgVariableDeclaration * var_decl = buildVariableDeclaration(varName, type_symbol->get_type());
-
- SgFunctionSymbol * ctor_symbol = global_scope->lookup_function_symbol(
- SgName("dim3"));
-
- SgExprListExp * ctor_args = buildExprListExp(buildIntVal(arg1),
- buildIntVal(arg2), buildIntVal(arg3));
-
- SgFunctionCallExp * dim3_func_call = buildFunctionCallExp(
- buildFunctionRefExp(ctor_symbol->get_declaration()), ctor_args);
-
- char joined_str[20];
-
- strcpy(joined_str, "dim3 ");
- strcat(joined_str, varName);
-
- SgExprStatement* decl = buildAssignStatement(
- buildOpaqueVarRefExp(joined_str, isSgScopeStatement(root_)),
- dim3_func_call);
-
- SgStatementPtrList *tnl2 = new SgStatementPtrList;
-
- // (*tnl2).push_back(var_decl);
- (*tnl2).push_back(decl);
- return new CG_roseRepr(tnl2);
-
-
-
-}
-*/
-
-/*CG_outputRepr* CG_suifBuilder::CreateKernel(immed_list* iml) const {
- instruction *ins = new in_rrr(io_mrk);
- ins->append_annote(k_cuda_kernel, iml);
- tree_node_list *tnl = new tree_node_list;
- tnl->append(new tree_instr(ins));
- return new CG_suifRepr(tnl);
- }
-
- type_node* CG_suifBuilder::ModifyType(type_node* base, const char* modifier) const {
- modifier_type* result = new modifier_type(TYPE_NULL, base);
- immed_list *iml = new immed_list;
- iml->append(immed((char*)modifier));
- result->append_annote(k_cuda_modifier, iml);
- return result;
- }
- */
-
std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
SgExpression* expr, SgNode* root) {
@@ -1367,13 +1006,6 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
std::copy(a.begin(), a.end(), back_inserter(arrays));
}
}
- /*else if(isSgFortranDo(stmt)){
- SgFortranDo *tfortran = isSgFortranDo(stmt);
- omega::CG_roseRepr *r = new omega::CG_roseRepr(isSgStatement(tfortran->get_body()));
- std::vector<IR_ArrayRef *> a = FindArrayRef(r);
- delete r;
- std::copy(a.begin(), a.end(), back_inserter(arrays));
- }*/
else if (isSgVariableDeclaration(stmt)) {
if (SgExpression *init =
isSgVariableDeclaration(stmt)->get_variables().front()->get_initializer()) {
@@ -1386,9 +1018,6 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
}
} else if (isSgIfStmt(stmt)) {
SgIfStmt* tni = isSgIfStmt(stmt);
- //tni->get_conditional()->set_parent(tni);
- //tni->get_true_body()->set_parent(tni);
- //tni->get_false_body()->set_parent(tni);
std::vector<SgVarRefExp *> a = substitute(
isSgNode(tni->get_conditional()), sym, expr, root);
std::copy(a.begin(), a.end(), back_inserter(arrays));
@@ -1405,13 +1034,11 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
isSgNode(isSgExprStatement(stmt)->get_expression()),
sym, expr, root);
std::copy(a.begin(), a.end(), back_inserter(arrays));
- } //end else if
- } //end if
+ }
+ }
else {
op = isSgExpression(in);
- // std::string x = isSgNode(op)->unparseToString();
std::string y = sym->get_name().getString();
-// std::cout << "------substitute else:: " << in->unparseToString().c_str() << ", " << y.c_str() << "\n";
if (isSgBinaryOp(op)) {
@@ -1425,9 +1052,6 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
isSgBinaryOp(op)->get_rhs_operand(), sym, expr, root);
std::copy(a1.begin(), a1.end(), back_inserter(arrays));
} else if (isSgUnaryOp(op)) {
- //isSgUnaryOp(op)->get_operand()->set_parent(op);
- //std::string x = isSgNode(op)->unparseToString();
- //std::cout<<x<<std::endl;
std::vector<SgVarRefExp *> a = substitute(
isSgUnaryOp(op)->get_operand(), sym, expr, root);
std::copy(a.begin(), a.end(), back_inserter(arrays));
@@ -1435,12 +1059,9 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
std::string z =
isSgVarRefExp(op)->get_symbol()->get_name().getString();
if (!strcmp(z.c_str(), y.c_str())) {
- //isSgVarRefExp(op)->set_symbol(isSgVarRefExp(expr)->get_symbol());
arrays.push_back(isSgVarRefExp(op));
- //replaceVariableReferences(root, isSgVarRefExp(in)->get_symbol(), temp);
- //r = true;
- } //end if
- } //end else if
+ }
+ }
else if (isSgCallExpression(op)) {
SgExprListExp* exprs = isSgCallExpression(op)->get_args();
SgExpressionPtrList &expr_list = exprs->get_expressions();
@@ -1463,71 +1084,10 @@ std::vector<SgVarRefExp *> substitute(SgNode *in, const SgVariableSymbol *sym,
}
- //end else if
- //else if(!isSgValueExp(op))
- // throw ir_error("unrecognized expression type");
- } //end else
- } //end if
-
- /* bool r = false;
- if (isSgVarRefExp(in) && (isSgVarRefExp(in)->get_symbol() == sym)) {
- omega::CG_roseRepr *result = new omega::CG_roseRepr(expr);
- SgExpression* expr1 = result->GetExpression();
- delete result;
- SgVariableSymbol* temp = isSgVarRefExp(expr1)->get_symbol();
- parent->replace_expression(in, expr1);
- replaceVariableReferences(root, isSgVarRefExp(in)->get_symbol(), temp);
- r = true;
- }
- else if(isSgBinaryOp(in)){
- substitute(isSgBinaryOp(in)->get_lhs_operand(), sym, expr, root, in);
- substitute(isSgBinaryOp(in)->get_rhs_operand(), sym, expr, root, in);
- }
- else if(isSgUnaryOp(in))
- substitute(isSgUnaryOp(in)->get_operand(), sym, expr, root, in);
-
- */
+ }
+ }
return arrays;
}
-/*bool substitute(SgStatement *tn, SgVariableSymbol *sym, SgExpression* expr, SgNode* root, SgSymbolTable* symtab) {
- if (tn == NULL)
- return false;
-
- bool r = false;
- if( tn != NULL){
- if(isSgExpression(tn)){
- r = substitute(isSgExpression(tn), sym, expr, root, isSgExpression(tn)) || r;
-
- }
- else {
- omega::CG_roseRepr *result = new omega::CG_roseRepr(expr);
- SgExpression* expr1 = result->GetExpression();
- tn->replace_expression(buildVarRefExp(sym), expr1);
- for (unsigned i = 0; i < tn->get_numberOfTraversalSuccessors(); i++)
- r = substitute(isSgStatement(tn->get_traversalSuccessorByIndex(i)), sym, expr, root, symtab) || r;
-
- }
- }
- return r;
- }
-
- bool substitute(SgNode *tnl, SgVariableSymbol *sym, SgExpression* expr, SgNode* root, SgSymbolTable* symtab) {
- if (tnl == NULL)
- return false;
-
- bool r = false;
-
- for(int i=0; i < tnl->get_numberOfTraversalSuccessors(); i++){
-
- SgNode* tn = tnl->get_traversalSuccessorByIndex(i);
- r = substitute(isSgStatement(tn), sym, expr, root, symtab) || r;
- }
-
-
- return r;
- }
- */
-
} // namespace
diff --git a/omegalib/omega/include/basic/Bag.h b/omegalib/omega/include/basic/Bag.h
index 42285d0..3bd7143 100644
--- a/omegalib/omega/include/basic/Bag.h
+++ b/omegalib/omega/include/basic/Bag.h
@@ -14,13 +14,14 @@ virtual ~Bag();
Bag();
Bag(const Bag<T>&);
Bag & operator=(const Bag<T>&);
-virtual void operator |= (const Bag<T> & b); // add elements in b
+ //! add elements in b
+ virtual void operator |= (const Bag<T> & b);
Iterator<T> *new_iterator();
bool empty() const;
void remove(T);
-virtual void insert(T);
+ virtual void insert(T);
void clear();
-virtual bool contains(T) const;
+ virtual bool contains(T) const;
int size() const;
T extract();
// protected: breaks g++ 261
@@ -31,10 +32,11 @@ virtual bool contains(T) const;
template<class T> class Ordered_Bag : public Bag<T> {
public:
Ordered_Bag();
-// virtual ~Ordered_Bag();
Ordered_Bag(const Ordered_Bag<T>& B) : Bag<T>(B) {}
void insert(T);
-virtual void operator |= (const Ordered_Bag<T> & b); // add elements in b
+ //! add elements in b
+ virtual void operator |= (const Ordered_Bag<T> & b);
+ //! add elements in b
void operator |= (const Bag<T> & b);
bool contains(T) const;
bool operator == (const Ordered_Bag<T>&) const;
@@ -45,21 +47,26 @@ virtual void operator |= (const Ordered_Bag<T> & b); // add elements in b
template <class T> class Set : public Ordered_Bag <T> {
public:
Set();
-// virtual ~Set();
Set(T);
Set(const Set<T>& S) : Ordered_Bag<T>(S) {}
bool contains (const Set<T>& b) const;
bool contains (T t) const { return Ordered_Bag<T>::contains(t); }
// the above makes "standard" C++ happy
-
-virtual void operator |= (const Set<T> & b); // add elements in b
+
+ //! add elements in b
+ virtual void operator |= (const Set<T> & b);
+ //! add elements in b
void operator |= (const Ordered_Bag<T> & b);
+ //! add elements in b
void operator |= (const Bag<T> & b);
- void operator -= (const Set<T> & b); // delete items also in b
- void operator &= (const Set<T> & b); // delete items not in b
- bool operator & (const Set<T> &) const; // check for elements in common
+ //! delete items also in b
+ void operator -= (const Set<T> & b);
+ //! delete items not in b
+ void operator &= (const Set<T> & b);
+ //! check for elements in common
+ bool operator & (const Set<T> &) const;
};
} // namespace
diff --git a/omegalib/omega/include/basic/BoolSet.h b/omegalib/omega/include/basic/BoolSet.h
index dc9ef83..a78af2e 100755
--- a/omegalib/omega/include/basic/BoolSet.h
+++ b/omegalib/omega/include/basic/BoolSet.h
@@ -25,7 +25,8 @@
#include <iterator>
namespace omega {
-
+
+ //! BoolSet class, used as a set of integers from 0 to n-1 where n is a very small integer.
template<typename T = unsigned int>
class BoolSet {
protected:
@@ -50,17 +51,20 @@ public:
BoolSet<T> &operator|=(const BoolSet<T> &);
BoolSet<T> &operator&=(const BoolSet<T> &);
BoolSet<T> &operator-=(const BoolSet<T> &);
-
- template<typename TT> friend BoolSet<TT> operator|(const BoolSet<TT> &, const BoolSet<TT> &); // union
- template<typename TT> friend BoolSet<TT> operator&(const BoolSet<TT> &, const BoolSet<TT> &); // intersection
- template<typename TT> friend BoolSet<TT> operator-(const BoolSet<TT> &, const BoolSet<TT> &); // difference
- template<typename TT> friend BoolSet<TT> operator~(const BoolSet<TT> &); // complement
+
+ //! union
+ template<typename TT> friend BoolSet<TT> operator|(const BoolSet<TT> &, const BoolSet<TT> &);
+ //! intersection
+ template<typename TT> friend BoolSet<TT> operator&(const BoolSet<TT> &, const BoolSet<TT> &);
+ //! difference
+ template<typename TT> friend BoolSet<TT> operator-(const BoolSet<TT> &, const BoolSet<TT> &);
+ //! complement
+ template<typename TT> friend BoolSet<TT> operator~(const BoolSet<TT> &);
template<typename TT> friend bool operator==(const BoolSet<TT> &, const BoolSet<TT> &);
template<typename TT> friend bool operator!=(const BoolSet<TT> &, const BoolSet<TT> &);
template<typename TT> friend std::ostream& operator<<(std::ostream &, const BoolSet<TT> &);
template<typename TT> friend bool operator<(const BoolSet<TT> &, const BoolSet<TT> &);
-// iterator related
public:
class iterator;
class const_iterator;
diff --git a/omegalib/omega/include/basic/Collection.h b/omegalib/omega/include/basic/Collection.h
index c7e4eef..80ddf48 100644
--- a/omegalib/omega/include/basic/Collection.h
+++ b/omegalib/omega/include/basic/Collection.h
@@ -7,10 +7,7 @@ template<class T> class Iterator;
template<class T> class Any_Iterator;
-/*
- * protocol for any kind of collection
- */
-
+//! protocol for any kind of collection
template<class T> class Collection {
public:
virtual Iterator<T> *new_iterator() = 0;
@@ -20,21 +17,20 @@ public:
};
-/*
+/*!
* protocol for collections whose elements are ordered
* by the way they are entered into the collection, and
* whose elements can be accessed by "index"
*
* note that the implementation need not be a linked list
*/
-
template<class T> class Sequence : public Collection<T> {
public:
virtual const T &operator[](int) const = 0;
virtual T &operator[](int) = 0;
- virtual int index(const T &) const = 0; // Y in X --> X[X.index(Y)] == Y
-};
+ /*! Y in X --> X[X.index(Y)] == Y */
+ virtual int index(const T &) const = 0; };
} // namespace
diff --git a/omegalib/omega/include/basic/ConstString.h b/omegalib/omega/include/basic/ConstString.h
index 5149e55..f149c9d 100644
--- a/omegalib/omega/include/basic/ConstString.h
+++ b/omegalib/omega/include/basic/ConstString.h
@@ -10,7 +10,6 @@ namespace omega {
// global, but if it and its size are static to Const_String,
// the compiler still doesn't seem to like the definition,
// or the declaration either for that matter.
-
class ConstStringRep {
public:
const char *name;
diff --git a/omegalib/omega/include/basic/Dynamic_Array.c b/omegalib/omega/include/basic/DynamicArray.c
index 0300fd8..8ede2f7 100644
--- a/omegalib/omega/include/basic/Dynamic_Array.c
+++ b/omegalib/omega/include/basic/DynamicArray.c
@@ -1,9 +1,9 @@
#include <assert.h>
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
namespace omega {
-template<class T, int d> void Dynamic_Array<T,d>::do_constr()
+template<class T, int d> void DynamicArray<T,d>::do_constr()
{
// #if ! defined SHUT_UP_ABOUT_STATEMENT_WITH_NO_EFFECT_IN_DYNAMIC_ARRAY_CREATION
// assert(d > 0);
@@ -14,7 +14,7 @@ template<class T, int d> void Dynamic_Array<T,d>::do_constr()
}
-template<class T> void Dynamic_Array1<T>::do_construct(int d0)
+template<class T> void DynamicArray1<T>::do_construct(int d0)
{
this->bounds = new int[1];
this->bounds[0] = d0;
@@ -22,7 +22,7 @@ template<class T> void Dynamic_Array1<T>::do_construct(int d0)
this->partial = false;
}
-template<class T> void Dynamic_Array2<T>::do_construct(int d0, int d1)
+template<class T> void DynamicArray2<T>::do_construct(int d0, int d1)
{
this->bounds = new int[2];
this->bounds[0] = d0;
@@ -31,7 +31,7 @@ template<class T> void Dynamic_Array2<T>::do_construct(int d0, int d1)
this->partial = false;
}
-template<class T> void Dynamic_Array3<T>::do_construct(int d0,int d1,int d2)
+template<class T> void DynamicArray3<T>::do_construct(int d0,int d1,int d2)
{
this->bounds = new int[3];
this->bounds[0] = d0;
@@ -41,7 +41,7 @@ template<class T> void Dynamic_Array3<T>::do_construct(int d0,int d1,int d2)
this->partial = false;
}
-template<class T> void Dynamic_Array4<T>::do_construct(int d0,int d1,int d2,int d3)
+template<class T> void DynamicArray4<T>::do_construct(int d0,int d1,int d2,int d3)
{
this->bounds = new int[4];
this->bounds[0] = d0;
@@ -52,53 +52,53 @@ template<class T> void Dynamic_Array4<T>::do_construct(int d0,int d1,int d2,int
this->partial = false;
}
-template<class T, int d> Dynamic_Array<T,d>::Dynamic_Array()
+template<class T, int d> DynamicArray<T,d>::DynamicArray()
{
do_constr();
}
-template<class T> Dynamic_Array1<T>::Dynamic_Array1(const char *)
+template<class T> DynamicArray1<T>::DynamicArray1(const char *)
{
this->do_constr();
}
-template<class T> Dynamic_Array2<T>::Dynamic_Array2(const char *,const char *)
+template<class T> DynamicArray2<T>::DynamicArray2(const char *,const char *)
{
this->do_constr();
}
-template<class T> Dynamic_Array3<T>::Dynamic_Array3(const char *,const char *,const char *)
+template<class T> DynamicArray3<T>::DynamicArray3(const char *,const char *,const char *)
{
this->do_constr();
}
-template<class T> Dynamic_Array4<T>::Dynamic_Array4(const char *,const char *,const char *,const char *)
+template<class T> DynamicArray4<T>::DynamicArray4(const char *,const char *,const char *,const char *)
{
this->do_constr();
}
-template<class T> Dynamic_Array1<T>::Dynamic_Array1(int d0)
+template<class T> DynamicArray1<T>::DynamicArray1(int d0)
{
do_construct(d0);
}
-template<class T> Dynamic_Array2<T>::Dynamic_Array2(int d0, int d1)
+template<class T> DynamicArray2<T>::DynamicArray2(int d0, int d1)
{
do_construct(d0, d1);
}
-template<class T> Dynamic_Array3<T>::Dynamic_Array3(int d0,int d1,int d2)
+template<class T> DynamicArray3<T>::DynamicArray3(int d0,int d1,int d2)
{
do_construct(d0, d1, d2);
}
-template<class T> Dynamic_Array4<T>::Dynamic_Array4(int d0,int d1,int d2,int d3)
+template<class T> DynamicArray4<T>::DynamicArray4(int d0,int d1,int d2,int d3)
{
do_construct(d0, d1, d2, d3);
}
-template<class T, int d> void Dynamic_Array<T,d>::do_destruct()
+template<class T, int d> void DynamicArray<T,d>::do_destruct()
{
if (! partial)
{
@@ -108,13 +108,13 @@ template<class T, int d> void Dynamic_Array<T,d>::do_destruct()
}
-template<class T, int d> Dynamic_Array<T,d>::~Dynamic_Array()
+template<class T, int d> DynamicArray<T,d>::~DynamicArray()
{
do_destruct();
}
-template<class T> void Dynamic_Array1<T>::resize(int d0)
+template<class T> void DynamicArray1<T>::resize(int d0)
{
assert(!this->partial);
this->do_destruct();
@@ -124,7 +124,7 @@ template<class T> void Dynamic_Array1<T>::resize(int d0)
do_construct(d0);
}
-template<class T> void Dynamic_Array2<T>::resize(int d0, int d1)
+template<class T> void DynamicArray2<T>::resize(int d0, int d1)
{
assert(!this->partial);
this->do_destruct();
@@ -134,7 +134,7 @@ template<class T> void Dynamic_Array2<T>::resize(int d0, int d1)
do_construct(d0, d1);
}
-template<class T> void Dynamic_Array3<T>::resize(int d0, int d1, int d2)
+template<class T> void DynamicArray3<T>::resize(int d0, int d1, int d2)
{
assert(!this->partial);
this->do_destruct();
@@ -144,7 +144,7 @@ template<class T> void Dynamic_Array3<T>::resize(int d0, int d1, int d2)
do_construct(d0, d1, d2);
}
-template<class T> void Dynamic_Array4<T>::resize(int d0, int d1, int d2, int d3)
+template<class T> void DynamicArray4<T>::resize(int d0, int d1, int d2, int d3)
{
assert(!this->partial);
this->do_destruct();
@@ -155,7 +155,7 @@ template<class T> void Dynamic_Array4<T>::resize(int d0, int d1, int d2, int d3)
}
-template<class T> T& Dynamic_Array1<T>::operator[](int d0)
+template<class T> T& DynamicArray1<T>::operator[](int d0)
{
#if !defined (NDEBUG)
assert(this->elements != 0 && "Trying to dereference undefined array");
@@ -165,41 +165,41 @@ template<class T> T& Dynamic_Array1<T>::operator[](int d0)
return this->elements[d0];
}
-template<class T> Dynamic_Array1<T> Dynamic_Array2<T>::operator[](int d0)
+template<class T> DynamicArray1<T> DynamicArray2<T>::operator[](int d0)
{
#if !defined (NDEBUG)
assert(this->elements != 0 && "Trying to dereference undefined array");
assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds");
#endif
- Dynamic_Array1<T> result;
+ DynamicArray1<T> result;
result.bounds = this->bounds+1;
result.elements = this->elements + this->bounds[1] * d0;
result.partial = true;
return result;
}
-template<class T> Dynamic_Array2<T> Dynamic_Array3<T>::operator[](int d0)
+template<class T> DynamicArray2<T> DynamicArray3<T>::operator[](int d0)
{
#if !defined (NDEBUG)
assert(this->elements != 0 && "Trying to dereference undefined array");
assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds");
#endif
- Dynamic_Array2<T> result;
+ DynamicArray2<T> result;
result.bounds = this->bounds+1;
result.elements = this->elements + this->bounds[1] * this->bounds[2] * d0;
result.partial = true;
return result;
}
-template<class T> Dynamic_Array3<T> Dynamic_Array4<T>::operator[](int d0)
+template<class T> DynamicArray3<T> DynamicArray4<T>::operator[](int d0)
{
#if !defined (NDEBUG)
assert(this->elements != 0 && "Trying to dereference undefined array");
assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds");
#endif
- Dynamic_Array3<T> result;
+ DynamicArray3<T> result;
result.bounds = this->bounds+1;
result.elements = this->elements + this->bounds[1] * this->bounds[2] * this->bounds[3] * d0;
result.partial = true;
@@ -208,7 +208,7 @@ template<class T> Dynamic_Array3<T> Dynamic_Array4<T>::operator[](int d0)
template<class T, int d>
- Dynamic_Array<T,d>::Dynamic_Array(Dynamic_Array<T,d> &D)
+ DynamicArray<T,d>::DynamicArray(DynamicArray<T,d> &D)
{
assert(D.elements != 0 && "Trying to copy an undefined array");
partial = true;
diff --git a/omegalib/omega/include/basic/DynamicArray.h b/omegalib/omega/include/basic/DynamicArray.h
new file mode 100644
index 0000000..ac9bae4
--- /dev/null
+++ b/omegalib/omega/include/basic/DynamicArray.h
@@ -0,0 +1,103 @@
+#ifndef Already_Included_DynamicArray
+#define Already_Included_DynamicArray
+
+namespace omega {
+
+template <class T> class DynamicArray2;
+template <class T> class DynamicArray3;
+template <class T> class DynamicArray4;
+
+template <class T, int d> class DynamicArray
+ {
+ public:
+ DynamicArray(DynamicArray<T,d> &D);
+ ~DynamicArray();
+
+ protected:
+ DynamicArray();
+ bool partial;
+ int *bounds;
+ T *elements;
+
+ void do_constr();
+ void do_destruct();
+ };
+
+
+template <class T> class DynamicArray1 : public DynamicArray<T,1>
+ {
+ public:
+ DynamicArray1(const char *s0 = 0);
+ DynamicArray1(int d0);
+ void resize(int d0);
+ T& operator[](int d);
+
+ friend class DynamicArray2<T>;
+
+ private:
+ void do_construct(int d0);
+ };
+
+
+template <class T> class DynamicArray2 : public DynamicArray<T,2>
+ {
+ public:
+ DynamicArray2(const char *s0 = 0, const char *s1 = 0);
+ DynamicArray2(int d0, int d1);
+ void resize(int d0, int d1);
+ DynamicArray1<T> operator[](int d);
+
+ friend class DynamicArray3<T>;
+
+ private:
+ void do_construct(int d0, int d1);
+ };
+
+
+template <class T> class DynamicArray3 : public DynamicArray<T,3>
+ {
+ public:
+ DynamicArray3(const char *s0 = 0, const char *s1 = 0, const char *s2 = 0);
+ DynamicArray3(int d0, int d1, int d2);
+ void resize(int d0, int d1, int d2);
+ DynamicArray2<T> operator[](int d);
+
+ friend class DynamicArray4<T>;
+
+ private:
+ void do_construct(int d0, int d1, int d2);
+ };
+
+template <class T> class DynamicArray4 : public DynamicArray<T,4>
+ {
+ public:
+ DynamicArray4(const char *s0 = 0, const char *s1 = 0, const char *s2 = 0, const char *s3 = 0);
+ DynamicArray4(int d0, int d1, int d2, int d3);
+ void resize(int d0, int d1, int d2, int d3);
+ DynamicArray3<T> operator[](int d);
+
+ private:
+ void do_construct(int d0, int d1, int d2, int d3);
+ };
+
+} // namespace
+
+#if ! defined DONT_INCLUDE_TEMPLATE_CODE
+#include <basic/DynamicArray.c>
+#endif
+
+#define instantiate_DynamicArray1(T) template class DynamicArray1<T>; \
+ template class DynamicArray<T,1>;
+
+#define instantiate_DynamicArray2(T) template class DynamicArray2<T>; \
+ template class DynamicArray<T,2>; \
+ instantiate_DynamicArray1(T);
+
+#define instantiate_DynamicArray3(T) template class DynamicArray3<T>; \
+ template class DynamicArray<T,3>; \
+ instantiate_DynamicArray2(T);
+
+#define instantiate_DynamicArray4(T) template class DynamicArray4<T>; \
+ template class DynamicArray<T,4>; \
+ instantiate_DynamicArray3(T);
+#endif
diff --git a/omegalib/omega/include/basic/Dynamic_Array.h b/omegalib/omega/include/basic/Dynamic_Array.h
deleted file mode 100644
index c0bdf12..0000000
--- a/omegalib/omega/include/basic/Dynamic_Array.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef Already_Included_Dynamic_Array
-#define Already_Included_Dynamic_Array
-
-namespace omega {
-
-template <class T> class Dynamic_Array2;
-template <class T> class Dynamic_Array3;
-template <class T> class Dynamic_Array4;
-
-template <class T, int d> class Dynamic_Array
- {
- public:
- Dynamic_Array(Dynamic_Array<T,d> &D);
- ~Dynamic_Array();
-
- protected:
- Dynamic_Array();
- bool partial;
- int *bounds;
- T *elements;
-
- void do_constr();
- void do_destruct();
- };
-
-
-template <class T> class Dynamic_Array1 : public Dynamic_Array<T,1>
- {
- public:
- Dynamic_Array1(const char *s0 = 0);
- Dynamic_Array1(int d0);
- void resize(int d0);
- T& operator[](int d);
-
- friend class Dynamic_Array2<T>;
-
- private:
- void do_construct(int d0);
- };
-
-
-template <class T> class Dynamic_Array2 : public Dynamic_Array<T,2>
- {
- public:
- Dynamic_Array2(const char *s0 = 0, const char *s1 = 0);
- Dynamic_Array2(int d0, int d1);
- void resize(int d0, int d1);
- Dynamic_Array1<T> operator[](int d);
-
- friend class Dynamic_Array3<T>;
-
- private:
- void do_construct(int d0, int d1);
- };
-
-
-template <class T> class Dynamic_Array3 : public Dynamic_Array<T,3>
- {
- public:
- Dynamic_Array3(const char *s0 = 0, const char *s1 = 0, const char *s2 = 0);
- Dynamic_Array3(int d0, int d1, int d2);
- void resize(int d0, int d1, int d2);
- Dynamic_Array2<T> operator[](int d);
-
- friend class Dynamic_Array4<T>;
-
- private:
- void do_construct(int d0, int d1, int d2);
- };
-
-template <class T> class Dynamic_Array4 : public Dynamic_Array<T,4>
- {
- public:
- Dynamic_Array4(const char *s0 = 0, const char *s1 = 0, const char *s2 = 0, const char *s3 = 0);
- Dynamic_Array4(int d0, int d1, int d2, int d3);
- void resize(int d0, int d1, int d2, int d3);
- Dynamic_Array3<T> operator[](int d);
-
- private:
- void do_construct(int d0, int d1, int d2, int d3);
- };
-
-} // namespace
-
-#if ! defined DONT_INCLUDE_TEMPLATE_CODE
-#include <basic/Dynamic_Array.c>
-#endif
-
-#define instantiate_Dynamic_Array1(T) template class Dynamic_Array1<T>; \
- template class Dynamic_Array<T,1>;
-
-#define instantiate_Dynamic_Array2(T) template class Dynamic_Array2<T>; \
- template class Dynamic_Array<T,2>; \
- instantiate_Dynamic_Array1(T);
-
-#define instantiate_Dynamic_Array3(T) template class Dynamic_Array3<T>; \
- template class Dynamic_Array<T,3>; \
- instantiate_Dynamic_Array2(T);
-
-#define instantiate_Dynamic_Array4(T) template class Dynamic_Array4<T>; \
- template class Dynamic_Array<T,4>; \
- instantiate_Dynamic_Array3(T);
-#endif
diff --git a/omegalib/omega/include/basic/Iterator.h b/omegalib/omega/include/basic/Iterator.h
index 8975d9e..f62874c 100644
--- a/omegalib/omega/include/basic/Iterator.h
+++ b/omegalib/omega/include/basic/Iterator.h
@@ -16,24 +16,24 @@ namespace omega {
#define foreachSeparated(x,T,S,A,B) do {for (omega::Any_Iterator<T> __P_##x = (S).any_iterator();__P_##x;) {T & x = *__P_##x; A; __P_##x++; if (__P_##x) B;}} while (0)
-/*
- * Abstract base class Iterator<type>
+/*!
+ * \brief Abstract base class Iterator<type>
+ *
* Supports two styles of iteration:
- *
+ * ~~~
* for ( ... initialize i (typically i = collection) ... ; i ; i++ )
* operate_on(*i)
- *
+ * ~~~
* or
- *
+ * ~~~
* for ( ... initialize i ... ; i.live() ; i.next() )
* operate_on(i.curr())
- *
- * >>> IF THE COLLECTION IS CHANGED, THE ITERATOR IS NO LONGER VALID <<<
+ * ~~~
+ * **IF THE COLLECTION IS CHANGED, THE ITERATOR IS NO LONGER VALID**
*
* For collections that are not "Sequence"s, the order in
* which the elements are returned may not be consistent.
*/
-
template<class T> class Iterator {
public:
virtual const T & operator*() const = 0;
@@ -54,9 +54,8 @@ public:
};
-// A generator is like an iterator but it gives out values,
-// which may or may not exist in some writable collection
-
+//! A generator is like an iterator but it gives out values
+/*! Values may or may not exist in some writable collection */
template<class T> class Generator {
public:
virtual T operator*() const = 0;
@@ -74,14 +73,13 @@ public:
-// Delegate to any kind of iterator (on the heap)
-// If created via a reference, become a copy of the iterator
-// If created via a pointer, manipulate that pointer and free *p when this dies
-//
-// Mostly useful for Collection::iterator
-// Iterator::Iterator(Collection)
-
-
+//! Delegate to any kind of iterator (on the heap)
+/*!
+ * * If created via a reference, become a copy of the iterator
+ * * If created via a pointer, manipulate that pointer and free *p when this dies
+ *
+ * Mostly useful for Collection::iterator `Iterator::Iterator(Collection)`
+ */
template<class T> class Any_Iterator : public Iterator<T> {
public:
Any_Iterator(Collection<T> &c);
@@ -101,13 +99,13 @@ public:
Iterator<T> *new_copy() const { return new Any_Iterator<T>((*me).new_copy()); }
private:
- Any_Iterator(Iterator<T> *p) // take over *p, *p MUST BE ON THE HEAP
- { me = p; }
+ //! take over *p, *p MUST BE ON THE HEAP
+ Any_Iterator(Iterator<T> *p) { me = p; }
friend class Collection<T>;
-#if 0
- // Couldn't make this work with g++258
- friend Any_Iterator<T> Collection<T>::any_iterator();
-#endif
+/*
+ * // Couldn't make this work with g++258
+ * friend Any_Iterator<T> Collection<T>::any_iterator();
+ */
Iterator<T> *me;
};
diff --git a/omegalib/omega/include/basic/Link.h b/omegalib/omega/include/basic/Link.h
index ede7a2b..bdf169c 100644
--- a/omegalib/omega/include/basic/Link.h
+++ b/omegalib/omega/include/basic/Link.h
@@ -16,20 +16,19 @@ namespace omega {
#endif
#endif
-/*
- List_Element: one item in a list and the pointer to the next.
- Each such object should be pointed to by either exactly one
- other List_Element or by some other pointer(s), exactly one
- of which will delete the List_Element.
- ListElements should ONLY be allocated on the heap.
- */
-
#if ListElementFreeList
// g++ 2.5.8 does not allow static data in template classes, so...
extern void *kludgy_List_Element_new(size_t size);
extern void kludgy_List_Element_delete(void *ptr, size_t size);
#endif
-
+/*!
+ * \brief List_Element: one item in a list and the pointer to the next.
+ *
+ * Each such object should be pointed to by either exactly one
+ * other List_Element or by some other pointer(s), exactly one
+ * of which will delete the List_Element.
+ * ListElements should ONLY be allocated on the heap.
+ */
template <class T> class List_Element {
public:
#if ListElementFreeList
diff --git a/omegalib/omega/include/basic/List.h b/omegalib/omega/include/basic/List.h
index c6fc062..ee394d9 100644
--- a/omegalib/omega/include/basic/List.h
+++ b/omegalib/omega/include/basic/List.h
@@ -4,11 +4,6 @@
/*
* Linked lists with an interface like a bit of libg++'s SLList class
*/
-
-
-#if 0
-#include <basic/assert.h> /* List requires assert which needs Exit which */
-#endif /* needs List! just include assert in List.c */
#include <stdio.h> // for NULL
#include <basic/Iterator.h>
#include <basic/Collection.h>
diff --git a/omegalib/omega/include/omega/reach.h b/omegalib/omega/include/omega/reach.h
index ff4bf79..76d7dee 100644
--- a/omegalib/omega/include/omega/reach.h
+++ b/omegalib/omega/include/omega/reach.h
@@ -7,15 +7,15 @@ class reachable_information {
public:
Tuple<std::string> node_names;
Tuple<int> node_arity;
- Dynamic_Array1<Relation> start_nodes;
- Dynamic_Array2<Relation> transitions;
+ DynamicArray1<Relation> start_nodes;
+ DynamicArray2<Relation> transitions;
};
-Dynamic_Array1<Relation> *
+DynamicArray1<Relation> *
Reachable_Nodes(reachable_information * reachable_info);
-Dynamic_Array1<Relation> *
+DynamicArray1<Relation> *
I_Reachable_Nodes(reachable_information * reachable_info);
} // namespace
diff --git a/omegalib/omega/src/reach.cc b/omegalib/omega/src/reach.cc
index bde785c..6569edb 100644
--- a/omegalib/omega/src/reach.cc
+++ b/omegalib/omega/src/reach.cc
@@ -1,12 +1,12 @@
#include <omega.h>
#include <omega/Relations.h>
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
#include <omega/reach.h>
namespace omega {
-typedef Dynamic_Array1<Relation> Rel_Array1;
-typedef Dynamic_Array2<Relation> Rel_Array2;
+typedef DynamicArray1<Relation> Rel_Array1;
+typedef DynamicArray2<Relation> Rel_Array2;
// This is from parallelism.c, modified
diff --git a/omegalib/omegacalc/include/omega_calc/PT-omega.c b/omegalib/omegacalc/include/omega_calc/PT-omega.c
index ad6b979..b0f5227 100644
--- a/omegalib/omegacalc/include/omega_calc/PT-omega.c
+++ b/omegalib/omegacalc/include/omega_calc/PT-omega.c
@@ -9,7 +9,7 @@
#include <basic/Tuple.h>
#include <basic/Section.h>
#include <basic/Exit.h>
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
#include <omega.h>
#include <omega/AST.h>
@@ -64,9 +64,9 @@ instantiate_Map(EQ_Handle,Variable_ID);
instantiate_Map(Variable_ID,Set<Variable_ID>);
instantiate_Map(Const_String, Relation *);
-instantiate_Dynamic_Array1(Coef_Var_Decl *);
-instantiate_Dynamic_Array1(Relation);
-instantiate_Dynamic_Array2(Relation);
+instantiate_DynamicArray1(Coef_Var_Decl *);
+instantiate_DynamicArray1(Relation);
+instantiate_DynamicArray2(Relation);
/* Stuff required by calculator: */
diff --git a/omegalib/omegacalc/src/parser.l b/omegalib/omegacalc/src/parser.l
index ac2b448..04933f4 100644
--- a/omegalib/omegacalc/src/parser.l
+++ b/omegalib/omegacalc/src/parser.l
@@ -4,7 +4,7 @@
#include <sstream>
#include <iostream>
#include <omega_calc/AST.h>
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
using namespace omega;
#include "y.tab.h"
diff --git a/omegalib/omegacalc/src/parser.ll b/omegalib/omegacalc/src/parser.ll
index 86de3a4..e095f24 100755
--- a/omegalib/omegacalc/src/parser.ll
+++ b/omegalib/omegacalc/src/parser.ll
@@ -20,7 +20,7 @@
#include <iostream>
#include <fstream>
#include <omega_calc/AST.h>
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
#include "parser.tab.hh"
#include <omega_calc/myflex.h>
diff --git a/omegalib/omegacalc/src/parser.y b/omegalib/omegacalc/src/parser.y
index 7369b94..d365797 100644
--- a/omegalib/omegacalc/src/parser.y
+++ b/omegalib/omegacalc/src/parser.y
@@ -14,7 +14,7 @@
%{
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
#include <basic/Iterator.h>
#include <code_gen/code_gen.h>
#include <omega_calc/AST.h>
@@ -102,8 +102,8 @@ void flushScanBuffer();
Relation * RELATION;
tupleDescriptor * TUPLE_DESCRIPTOR;
RelTuplePair * REL_TUPLE_PAIR;
- Dynamic_Array2<Relation> * RELATION_ARRAY_2D;
- Dynamic_Array1<Relation> * RELATION_ARRAY_1D;
+ DynamicArray2<Relation> * RELATION_ARRAY_2D;
+ DynamicArray1<Relation> * RELATION_ARRAY_1D;
Tuple<std::string> *STRING_TUPLE;
std::string *STRING_VALUE;
}
@@ -407,7 +407,7 @@ inputItem : ';' /*empty*/
}
| reachable ';' {
flushScanBuffer();
- Dynamic_Array1<Relation> &final = *$1;
+ DynamicArray1<Relation> &final = *$1;
bool any_sat = false;
int i,n_nodes = reachable_info->node_names.size();
for(i = 1; i <= n_nodes; i++)
@@ -1582,13 +1582,13 @@ exp : COEF {$$ = new Exp($1);}
reachable : REACHABLE_FROM nodeNameList nodeSpecificationList {
- Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info);
+ DynamicArray1<Relation> *final = Reachable_Nodes(reachable_info);
$$ = final;
}
;
reachable_of : REACHABLE_OF VAR IN nodeNameList nodeSpecificationList {
- Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info);
+ DynamicArray1<Relation> *final = Reachable_Nodes(reachable_info);
int index = reachable_info->node_names.index(std::string($2));
if (index == 0) {
yyerror(std::string("no such node ") + to_string($2));
@@ -1629,7 +1629,7 @@ nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE {
int i,j;
int n_nodes = reachable_info->node_names.size();
Tuple<int> &arity = reachable_info->node_arity;
- Dynamic_Array2<Relation> &transitions = reachable_info->transitions;
+ DynamicArray2<Relation> &transitions = reachable_info->transitions;
/* fixup unspecified transitions to be false */
/* find arity */
@@ -1656,7 +1656,7 @@ nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE {
transitions[i][j] = Relation::False(arity[i],arity[j]);
/* fixup unused start node positions */
- Dynamic_Array1<Relation> &nodes = reachable_info->start_nodes;
+ DynamicArray1<Relation> &nodes = reachable_info->start_nodes;
for(i = 1; i <= n_nodes; i++)
if(nodes[i].is_null())
nodes[i] = Relation::False(arity[i]);
diff --git a/omegalib/omegacalc/src/parser.yy b/omegalib/omegacalc/src/parser.yy
index 896f926..c2821cc 100755
--- a/omegalib/omegacalc/src/parser.yy
+++ b/omegalib/omegacalc/src/parser.yy
@@ -14,7 +14,7 @@
%{
//#define YYDEBUG 1
-#include <basic/Dynamic_Array.h>
+#include <basic/DynamicArray.h>
#include <basic/Iterator.h>
#include <omega_calc/AST.h>
#include <omega/hull.h>
@@ -121,7 +121,7 @@ void flushScanBuffer();
omega::Relation *RELATION;
tupleDescriptor *TUPLE_DESCRIPTOR;
std::pair<std::vector<omega::Relation>, std::vector<omega::Relation> > *REL_TUPLE_PAIR;
- omega::Dynamic_Array1<omega::Relation> * RELATION_ARRAY_1D;
+ omega::DynamicArray1<omega::Relation> * RELATION_ARRAY_1D;
std::string *STRING_VALUE;
}
@@ -473,7 +473,7 @@ inputItem : ';' /*empty*/
}
| reachable ';' {
flushScanBuffer();
- Dynamic_Array1<Relation> &final = *$1;
+ DynamicArray1<Relation> &final = *$1;
bool any_sat = false;
int i,n_nodes = reachable_info->node_names.size();
for(i = 1; i <= n_nodes; i++)
@@ -1661,13 +1661,13 @@ exp : COEF {$$ = new Exp($1);}
reachable : REACHABLE_FROM nodeNameList nodeSpecificationList {
- Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info);
+ DynamicArray1<Relation> *final = Reachable_Nodes(reachable_info);
$$ = final;
}
;
reachable_of : REACHABLE_OF VAR IN nodeNameList nodeSpecificationList {
- Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info);
+ DynamicArray1<Relation> *final = Reachable_Nodes(reachable_info);
int index = reachable_info->node_names.index(std::string($2));
if (index == 0) {
yyerror(std::string("no such node ") + to_string($2));
@@ -1708,7 +1708,7 @@ nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE {
int i,j;
int n_nodes = reachable_info->node_names.size();
Tuple<int> &arity = reachable_info->node_arity;
- Dynamic_Array2<Relation> &transitions = reachable_info->transitions;
+ DynamicArray2<Relation> &transitions = reachable_info->transitions;
/* fixup unspecified transitions to be false */
/* find arity */
@@ -1735,7 +1735,7 @@ nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE {
transitions[i][j] = Relation::False(arity[i],arity[j]);
/* fixup unused start node positions */
- Dynamic_Array1<Relation> &nodes = reachable_info->start_nodes;
+ DynamicArray1<Relation> &nodes = reachable_info->start_nodes;
for(i = 1; i <= n_nodes; i++)
if(nodes[i].is_null())
nodes[i] = Relation::False(arity[i]);