summaryrefslogtreecommitdiff
path: root/omegalib/codegen/include/code_gen/codegen.h
blob: 469653d489250b87b8f61b82df0923bd8f6ca5d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _CODEGEN_H
#define _CODEGEN_H

#include <omega/Relation.h>
#include <code_gen/CG.h>
#include <code_gen/CG_outputBuilder.h>
#include <vector>
#include <string>

namespace omega {

class CodeGen {
public:
  static const std::string loop_var_name_prefix;
  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#

public:
  CodeGen(const std::vector<Relation> &xforms, const std::vector<Relation> &IS, const Relation &known = Relation::Null(),
		                 std::vector< std::vector<int > > smtNonSplitLevels_ =   std::vector< std::vector<int > >(),
		                 std::vector< std::vector<std::string> > loopIdxNames_ =  std::vector< std::vector<std::string> >(),
		                 std::vector< std::pair<int, std::string> >  syncs_ =    std::vector< std::pair<int, std::string> >()
		         );
  ~CodeGen() {}
  
  CG_result *buildAST(int effort = 1);
  int num_level() const { return projected_IS_.size(); }
  
private:
  CG_result *buildAST(int level, const BoolSet<> &active, bool split_on_const, const Relation &restriction);

  friend class CG_result;
  friend class CG_split;
  friend class CG_loop;
  friend class CG_leaf;
};

}
#endif