blob: 9766f52be439f52276e286bb2d2919f5e314d034 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#ifndef ROSE_ATTRIBUTES_HH
#define ROSE_ATTRIBUTES_HH
#include "rose.h"
#include <algorithm>
#include <string>
#include <vector>
namespace omega {
class CodeInsertion;
typedef std::vector<CodeInsertion*> CodeInsertionPtrList;
typedef std::vector<CodeInsertion*>::iterator CodeInsertionPtrListItr;
class CodeInsertion {
public:
int loop_level;
bool marked;
CodeInsertion(int looplevel) { this->loop_level = looplevel; marked = false; }
~CodeInsertion() {}
virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL) = 0;
};
class PragmaInsertion : public CodeInsertion {
private:
std::string name;
public:
PragmaInsertion(int loop_level, const std::string &pragma) : CodeInsertion(loop_level) { this->name = std::string(pragma); }
~PragmaInsertion() { }
virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL);
};
class MMPrefetchInsertion : public CodeInsertion {
private:
std::string arrName;
std::vector<std::string*> indecies;
std::vector<int> offsets;
int indexCount;
int cacheHint;
void initialize(const std::string& arrName, int hint);
void addDim(int offset);
void addDim(int offset, const std::string& indexer);
SgExpression* buildArrArg(SgScopeStatement* scopeStmt);
SgExpression* makeIndexExp(int dim, SgScopeStatement* scopeStmt);
public:
MMPrefetchInsertion(int loop_level, const std::string &arr, int hint) : CodeInsertion(loop_level)
{ this->initialize(arr, hint); }
~MMPrefetchInsertion() { }
virtual SgStatement* getStatement(SgScopeStatement* scopeStmt = NULL);
};
class CodeInsertionAttribute : public AstAttribute {
private:
std::vector<CodeInsertion*> code_insertions;
public:
CodeInsertionAttribute() { code_insertions = std::vector<CodeInsertion*>(); }
~CodeInsertionAttribute() {}
void add(CodeInsertion* ci) { code_insertions.push_back(ci); }
CodeInsertionPtrListItr begin() { return code_insertions.begin(); }
CodeInsertionPtrListItr end() { return code_insertions.end(); }
void remove(CodeInsertion* ci) { std::remove(code_insertions.begin(), code_insertions.end(), ci); }
int countCodeInsertions() { return code_insertions.size(); }
};
struct CodeInsertionMark {
public:
SgStatement* stmt;
CodeInsertion* ci;
};
class CodeInsertionVisitor : public AstPrePostProcessing {
private:
int loop_level;
std::vector<CodeInsertionMark*> ci_marks;
void markStmt(SgStatement* stmt, CodeInsertion* ci);
public:
void initialize();
virtual void preOrderVisit(SgNode* n);
virtual void postOrderVisit(SgNode* n);
void insertCode();
};
void postProcessRoseCodeInsertion(SgProject* proj);
void copyAttributes(SgNode* s, SgNode* d);
CodeInsertionAttribute* getOrCreateCodeInsertionAttribute(SgNode* node);
}
#endif
|