summaryrefslogtreecommitdiff
path: root/lib/codegen/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib/codegen/include')
-rw-r--r--lib/codegen/include/code_gen/CG.h23
-rw-r--r--lib/codegen/include/code_gen/CG_outputBuilder.h171
-rw-r--r--lib/codegen/include/code_gen/CG_outputRepr.h10
-rw-r--r--lib/codegen/include/code_gen/CG_stringBuilder.h37
-rw-r--r--lib/codegen/include/code_gen/CG_stringRepr.h12
-rwxr-xr-xlib/codegen/include/code_gen/CG_utils.h40
6 files changed, 204 insertions, 89 deletions
diff --git a/lib/codegen/include/code_gen/CG.h b/lib/codegen/include/code_gen/CG.h
index ce56768..4dd629c 100644
--- a/lib/codegen/include/code_gen/CG.h
+++ b/lib/codegen/include/code_gen/CG.h
@@ -22,9 +22,13 @@ struct CG_result {
virtual std::pair<CG_result *, Relation> liftOverhead(int depth, bool propagate_up) = 0;
virtual Relation hoistGuard() = 0;
virtual void removeGuard(const Relation &guard) = 0;
- virtual CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const = 0;
- CG_outputRepr *printRepr(CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts) const;
- std::string printString() const;
+ virtual CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString = false) const = 0;
+ CG_outputRepr *printRepr(CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, std::vector<std::map<std::string,std::vector<CG_outputRepr *> > >uninterpreted_symbols, bool printString = false) const;
+ std::string printString(std::vector<std::map<std::string, std::vector<CG_outputRepr *> > >uninterpreted_symbols = std::vector<std::map<std::string, std::vector<CG_outputRepr *> > >()) const;
+
+ //virtual CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const = 0;
+ //CG_outputRepr *printRepr(CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts) const;
+ //std::string printString() const;
int num_level() const;
virtual CG_result *clone() const = 0;
virtual void dump(int indent) const {}
@@ -52,7 +56,8 @@ struct CG_split: public CG_result {
std::pair<CG_result *, Relation> liftOverhead(int depth, bool propagate_up);
Relation hoistGuard();
void removeGuard(const Relation &guard);
- CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
+ CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString=false) const;
+ // CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
CG_result *clone() const;
void dump(int indent) const;
@@ -85,8 +90,11 @@ struct CG_loop: public CG_result {
std::pair<CG_result *, Relation> liftOverhead(int depth, bool propagate_up);
Relation hoistGuard();
void removeGuard(const Relation &guard);
- CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
- CG_outputRepr *printRepr(bool do_print_guard, int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
+ CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::vector<std::map<std::string, std::vector<CG_outputRepr *> > >unin, bool printString = false) const;
+ CG_outputRepr *printRepr(bool do_print_guard, int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString = false) const;
+
+ // CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
+ //CG_outputRepr *printRepr(bool do_print_guard, int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
CG_result *clone() const;
void dump(int indent) const;
};
@@ -108,7 +116,8 @@ struct CG_leaf: public CG_result {
std::pair<CG_result *, Relation> liftOverhead(int depth, bool propagate_up);
Relation hoistGuard();
void removeGuard(const Relation &guard);
- CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
+ CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString = false) const;
+ // CG_outputRepr *printRepr(int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly) const;
CG_result *clone() const;
void dump(int indent) const;
};
diff --git a/lib/codegen/include/code_gen/CG_outputBuilder.h b/lib/codegen/include/code_gen/CG_outputBuilder.h
index 19dc440..ce86c91 100644
--- a/lib/codegen/include/code_gen/CG_outputBuilder.h
+++ b/lib/codegen/include/code_gen/CG_outputBuilder.h
@@ -4,7 +4,7 @@
All Rights Reserved.
Purpose:
- abstract base class of comiler IR code builder
+ abstract base class of compiler IR code builder
Notes:
All "CG_outputRepr *" parameters are consumed inside the the function
@@ -29,57 +29,98 @@
namespace omega {
-//! abstract base class of comiler IR code builder
class CG_outputBuilder {
+private:
+
public:
+
CG_outputBuilder() {}
virtual ~CG_outputBuilder() {}
- //! 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
- virtual CG_outputRepr *CreateAssignment(int indent, CG_outputRepr *lhs,
+ virtual CG_outputRepr *CreateStruct(const std::string class_name,
+ std::vector<std::string> class_data_members, // why not just vector< CG_outputRepr> subparts;
+ std::vector<CG_outputRepr *> class_data_types )=0;
+ virtual CG_outputRepr *CreateClassInstance(std::string name , CG_outputRepr *class_def)=0;
+ virtual CG_outputRepr *lookup_member_data(CG_outputRepr* scope, std::string varName, CG_outputRepr *instance)=0;
+ virtual CG_outputRepr* CreatePointer(std::string &name) const = 0;
+ virtual CG_outputRepr* ObtainInspectorRange(const std::string &_s, const std::string &_name) const=0;
+
+
+
+ //---------------------------------------------------------------------------
+ // substitute variables in stmt
+ //---------------------------------------------------------------------------
+ virtual CG_outputRepr *CreateSubstitutedStmt(int indent,
+ CG_outputRepr *stmt,
+ const std::vector<std::string> &vars,
+ std::vector<CG_outputRepr *> &subs,
+ bool actuallyPrint =true) const = 0;
+
+ //---------------------------------------------------------------------------
+ // assignment stmt generation
+ //---------------------------------------------------------------------------
+ virtual CG_outputRepr *CreateAssignment(int indent,
+ CG_outputRepr *lhs,
CG_outputRepr *rhs) const = 0;
- //! function invocation generation
+ virtual CG_outputRepr *CreatePlusAssignment(int indent,
+ CG_outputRepr *lhs,
+ CG_outputRepr *rhs) const = 0;
+
+ //---------------------------------------------------------------------------
+ // function invocation generation
+ //---------------------------------------------------------------------------
virtual CG_outputRepr *CreateInvoke(const std::string &funcName,
- std::vector<CG_outputRepr *> &argList) const = 0;
+ std::vector<CG_outputRepr *> &argList,
+ bool is_array=false) 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;
@@ -87,73 +128,87 @@ 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;
+ virtual CG_outputRepr *CreateFloat(float num) const = 0;
+ virtual CG_outputRepr *CreateDouble(double num) const = 0;
+ virtual bool isInteger(CG_outputRepr *op) const = 0;
+ virtual bool QueryInspectorType(const std::string &varName) const = 0;
- //! basic identity/variable creation
+ //---------------------------------------------------------------------------
+ // basic identity/variable creation
+ //---------------------------------------------------------------------------
virtual CG_outputRepr *CreateIdent(const std::string &varName) const = 0;
-
- //! Addition operations, NULL parameter means 0,
+ virtual CG_outputRepr* CreateDotExpression(CG_outputRepr *lop,
+ CG_outputRepr *rop) const =0;
+ virtual CG_outputRepr* CreateArrayRefExpression(const std::string &_s,
+ CG_outputRepr *rop) const =0;
+ virtual CG_outputRepr* CreateArrayRefExpression(CG_outputRepr *lop,
+ CG_outputRepr *rop) const=0;
+ virtual CG_outputRepr* ObtainInspectorData(const std::string &_s, const std::string &member_name) const=0;
+ virtual CG_outputRepr* CreateNullStatement() 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
+ //---------------------------------------------------------------------------
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 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
- */
+ //---------------------------------------------------------------------------
+ // 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
+ //---------------------------------------------------------------------------
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 conditional Greater than or equal to
+ //---------------------------------------------------------------------------
+ // binary condition operations
+ //---------------------------------------------------------------------------
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;
+ virtual CG_outputRepr *CreateNEQ(CG_outputRepr *lop, CG_outputRepr *rop) const = 0;
+ virtual CG_outputRepr *CreateAddressOf(CG_outputRepr *op) const = 0;
+ virtual CG_outputRepr *CreateBreakStatement(void) 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;
+ virtual CG_outputRepr *CreateStatementFromExpression(CG_outputRepr *exp) const = 0;
+
+ virtual const char *ClassName() { return "UNKNOWN"; }
};
}
diff --git a/lib/codegen/include/code_gen/CG_outputRepr.h b/lib/codegen/include/code_gen/CG_outputRepr.h
index 0897007..d72ae6f 100644
--- a/lib/codegen/include/code_gen/CG_outputRepr.h
+++ b/lib/codegen/include/code_gen/CG_outputRepr.h
@@ -15,17 +15,19 @@
#ifndef _CG_OUTPUTREPR_H
#define _CG_OUTPUTREPR_H
+#include <string.h>
+
namespace omega {
class CG_outputRepr {
public:
+
CG_outputRepr() {}
- //! shallow delete
- virtual ~CG_outputRepr() { }
+ virtual ~CG_outputRepr() { /* shallow delete */ }
virtual CG_outputRepr *clone() const = 0;
- //! delete actual IR code wrapped inside
- virtual void clear() { }
+ virtual void clear() { /* delete actual IR code wrapped inside */ }
virtual void dump() const {}
+ virtual char *type() const = 0;
};
}
diff --git a/lib/codegen/include/code_gen/CG_stringBuilder.h b/lib/codegen/include/code_gen/CG_stringBuilder.h
index 09d3503..390039a 100644
--- a/lib/codegen/include/code_gen/CG_stringBuilder.h
+++ b/lib/codegen/include/code_gen/CG_stringBuilder.h
@@ -8,22 +8,39 @@ namespace omega {
class CG_stringBuilder: public CG_outputBuilder {
public:
+
CG_stringBuilder() {}
~CG_stringBuilder() {}
bool isInteger(CG_outputRepr *op) const;
- CG_stringRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt, const std::vector<std::string> &vars, std::vector<CG_outputRepr *> &subs) const;
+ bool QueryInspectorType(const std::string &varName) const;
+
+ CG_stringRepr *CreateInt(int num) const;
+ CG_stringRepr *CreateFloat(float num) const;
+ CG_stringRepr *CreateDouble(double num) const;
+
+ CG_stringRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt, const std::vector<std::string> &vars, std::vector<CG_outputRepr *> &subs, bool actuallyPrint) const;
CG_stringRepr *CreateAssignment(int indent, CG_outputRepr *lhs, CG_outputRepr *rhs) const;
- CG_stringRepr *CreateInvoke(const std::string &funcName, std::vector<CG_outputRepr *> &argList) const;
+ CG_stringRepr *CreatePlusAssignment(int indent, CG_outputRepr *lhs, CG_outputRepr *rhs) const;
+ CG_stringRepr *CreateInvoke(const std::string &funcName, std::vector<CG_outputRepr *> &argList,bool is_array=false) const;
CG_stringRepr *CreateComment(int indent, const std::string &commentText) const;
CG_stringRepr* CreateAttribute(CG_outputRepr *control,
const std::string &commentText) const;
CG_outputRepr *CreatePragmaAttribute(CG_outputRepr *scopeStmt, int looplevel, const std::string &pragmaText) const;
CG_outputRepr *CreatePrefetchAttribute(CG_outputRepr *scopeStmt, int looplevel, const std::string &arrName, int hint) const;
+ CG_stringRepr* CreateNullStatement() const;
CG_stringRepr *CreateIf(int indent, CG_outputRepr *guardCondition, CG_outputRepr *true_stmtList, CG_outputRepr *false_stmtList) const;
CG_stringRepr *CreateInductive(CG_outputRepr *index, CG_outputRepr *lower, CG_outputRepr *upper, CG_outputRepr *step) const;
CG_stringRepr *CreateLoop(int indent, CG_outputRepr *control, CG_outputRepr *stmtList) const;
- CG_stringRepr *CreateInt(int num) const;
+
+ CG_stringRepr *CreateAddressOf(CG_outputRepr *op) const ;
CG_stringRepr *CreateIdent(const std::string &varName) const;
+ CG_stringRepr *CreateDotExpression(CG_outputRepr *lop,
+ CG_outputRepr *rop) const;
+ CG_stringRepr *CreateArrayRefExpression(const std::string &_s,
+ CG_outputRepr *rop) const;
+ CG_stringRepr* CreateArrayRefExpression(CG_outputRepr *lop,
+ CG_outputRepr *rop) const;
+ CG_stringRepr *ObtainInspectorData(const std::string &_s, const std::string &member_name) const;
CG_stringRepr *CreatePlus(CG_outputRepr *lop, CG_outputRepr *rop) const;
CG_stringRepr *CreateMinus(CG_outputRepr *lop, CG_outputRepr *rop) const;
CG_stringRepr *CreateTimes(CG_outputRepr *lop, CG_outputRepr *rop) const;
@@ -35,7 +52,21 @@ public:
CG_stringRepr *CreateGE(CG_outputRepr *lop, CG_outputRepr *rop) const;
CG_stringRepr *CreateLE(CG_outputRepr *lop, CG_outputRepr *rop) const;
CG_stringRepr *CreateEQ(CG_outputRepr *lop, CG_outputRepr *rop) const;
+ CG_stringRepr *CreateNEQ(CG_outputRepr *lop, CG_outputRepr *rop) const;
+ CG_stringRepr *CreateBreakStatement(void) const;
CG_stringRepr *StmtListAppend(CG_outputRepr *list1, CG_outputRepr *list2) const;
+ CG_stringRepr *CreateStatementFromExpression(CG_outputRepr *exp) const;
+
+ CG_outputRepr *CreateStruct(const std::string struct_name,
+ std::vector<std::string> data_members,
+ std::vector<CG_outputRepr *> data_types);
+
+ CG_outputRepr *CreateClassInstance(std::string name , CG_outputRepr *class_def);
+ CG_outputRepr *lookup_member_data(CG_outputRepr* scope, std::string varName, CG_outputRepr *instance);
+ const char *ClassName() { return "stringBuilder"; };
+ CG_outputRepr* CreatePointer(std::string &name) const;
+ CG_outputRepr* ObtainInspectorRange(const std::string &_s, const std::string &_name) const;
+
};
diff --git a/lib/codegen/include/code_gen/CG_stringRepr.h b/lib/codegen/include/code_gen/CG_stringRepr.h
index a6df85d..b483bdb 100644
--- a/lib/codegen/include/code_gen/CG_stringRepr.h
+++ b/lib/codegen/include/code_gen/CG_stringRepr.h
@@ -18,6 +18,7 @@
#include <code_gen/CG_outputRepr.h>
#include <string>
#include <iostream>
+#include <stdio.h>
namespace omega {
@@ -26,11 +27,16 @@ private:
std::string s_;
public:
- CG_stringRepr() {}
- CG_stringRepr(const std::string &s) { s_ = s; }
- ~CG_stringRepr() {}
+ char *type() const { return strdup("string"); };
+
+
+ CG_stringRepr() {};
+ CG_stringRepr(const std::string &s){ s_ = s; }
+ ~CG_stringRepr() {}
CG_outputRepr *clone() const { return new CG_stringRepr(s_); }
void dump() const { std::cout << s_ << std::endl; }
+ void Dump() const;
+ void DumpToFile(FILE *fp = stderr) const;
//---------------------------------------------------------------------------
// basic operation
diff --git a/lib/codegen/include/code_gen/CG_utils.h b/lib/codegen/include/code_gen/CG_utils.h
index a6128bc..c0995d1 100755
--- a/lib/codegen/include/code_gen/CG_utils.h
+++ b/lib/codegen/include/code_gen/CG_utils.h
@@ -12,20 +12,29 @@ namespace omega {
class CG_loop;
-CG_outputRepr *output_inequality_repr(CG_outputBuilder *ocg, const GEQ_Handle &inequality, Variable_ID v, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::set<Variable_ID> excluded_floor_vars = std::set<Variable_ID>());
-CG_outputRepr *output_substitution_repr(CG_outputBuilder *ocg, const EQ_Handle &equality, Variable_ID v, bool apply_v_coef, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-CG_outputRepr *output_upper_bound_repr(CG_outputBuilder *ocg, const GEQ_Handle &inequality, Variable_ID v, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-CG_outputRepr *output_lower_bound_repr(CG_outputBuilder *ocg, const GEQ_Handle &inequality, Variable_ID v, const EQ_Handle &stride_eq, Variable_ID wc, const Relation &R, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
+CG_outputRepr *output_inequality_repr(CG_outputBuilder *ocg, const GEQ_Handle &inequality, Variable_ID v, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::map<std::string, std::vector<CG_outputRepr *> > unin,std::set<Variable_ID> excluded_floor_vars = std::set<Variable_ID>());
+CG_outputRepr *output_substitution_repr(CG_outputBuilder *ocg, const EQ_Handle &equality, Variable_ID v, bool apply_v_coef, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
-CG_outputRepr *output_ident(CG_outputBuilder *ocg, const Relation &R, Variable_ID v, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-std::pair<CG_outputRepr *, std::pair<CG_outputRepr *, int> > output_assignment(CG_outputBuilder *ocg, const Relation &R, int level, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-CG_outputRepr *output_loop(CG_outputBuilder *ocg, const Relation &R, int level, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-CG_outputRepr *output_guard(CG_outputBuilder *ocg, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-std::vector<CG_outputRepr *> output_substitutions(CG_outputBuilder *ocg, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
+CG_outputRepr *output_upper_bound_repr(CG_outputBuilder *ocg,
+ const GEQ_Handle &inequality,
+ Variable_ID v,
+ const Relation &R,
+ const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
+ std::map<std::string, std::vector<CG_outputRepr *> > unin);
+
+CG_outputRepr *output_lower_bound_repr(CG_outputBuilder *ocg, const GEQ_Handle &inequality, Variable_ID v, const EQ_Handle &stride_eq, Variable_ID wc, const Relation &R, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
+
+CG_outputRepr *output_ident(CG_outputBuilder *ocg, const Relation &R, Variable_ID v, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
+std::pair<CG_outputRepr *, std::pair<CG_outputRepr *, int> > output_assignment(CG_outputBuilder *ocg, const Relation &R, int level, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
+CG_outputRepr *output_loop(CG_outputBuilder *ocg, const Relation &R, int level, const Relation &known, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
+CG_outputRepr *output_guard(CG_outputBuilder *ocg, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
+std::vector<CG_outputRepr *> output_substitutions(CG_outputBuilder *ocg, const Relation &R, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,std::map<std::string, std::vector<CG_outputRepr *> > unin);
bool bound_must_hit_stride(const GEQ_Handle &inequality, Variable_ID v, const EQ_Handle &stride_eq, Variable_ID wc, const Relation &bounds, const Relation &known);
-std::pair<EQ_Handle, int> find_simplest_assignment(const Relation &R, Variable_ID v, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly = std::vector<std::pair<CG_outputRepr *, int> >());
+std::pair<EQ_Handle, int> find_simplest_assignment(const Relation &R, Variable_ID v, const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly = std::vector<std::pair<CG_outputRepr *, int> >(), bool *has_global_inspector= NULL);
std::pair<bool, GEQ_Handle> find_floor_definition(const Relation &R, Variable_ID v, std::set<Variable_ID> excluded_floor_vars = std::set<Variable_ID>());
+//Anand: 07/31/2013 -- Added the followinng temporary function needs cleanup
+std::vector<std::pair<bool, GEQ_Handle> > find_floor_definition_temp(const Relation &R, Variable_ID v, std::set<Variable_ID> excluded_floor_vars = std::set<Variable_ID>());
std::pair<EQ_Handle, Variable_ID> find_simplest_stride(const Relation &R, Variable_ID v);
Variable_ID replicate_floor_definition(const Relation &R, const Variable_ID floor_var, Relation &r, F_Exists *f_exists, F_And *f_root, std::map<Variable_ID, Variable_ID> &exists_mapping);
@@ -34,12 +43,15 @@ CG_outputRepr *leaf_print_repr(BoolSet<> active, const std::map<int, Relation> &
CG_outputRepr *guard_repr, const Relation &known,
int indent, CG_outputBuilder *ocg, const std::vector<int> &remap,
const std::vector<Relation> &xforms, const std::vector<CG_outputRepr *> &stmts,
- const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
-CG_outputRepr *loop_print_repr(const std::vector<CG_loop *> &loops, int start, int end,
+ const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin);
+CG_outputRepr *loop_print_repr(BoolSet<> active,const std::vector<CG_loop *> &loops, int start, int end,
const Relation &guard, CG_outputRepr *guard_repr,
- int indent, CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts,
- const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly);
+ int indent, const std::vector<int> &remap, const std::vector<Relation> &xforms,CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts,
+ const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly, std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin);
+Relation checkAndRestoreIfProjectedByGlobal(const Relation &R1, const Relation &R2, Variable_ID v);
+//Relation addInequalitiesToRelation( const Relation &R, std::vector<GEQ_Handle> &inequalities);
+std::string print_to_iegen_string(Relation &R);
}
#endif