-
Notifications
You must be signed in to change notification settings - Fork 0
/
concrete_pattern.hh
executable file
·185 lines (147 loc) · 4.43 KB
/
concrete_pattern.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*--------------------------------------------------------------------------- *
* srtl implementation in c++ *
* *
* This file contains class header definitions for the concrete pattern class *
* *
* *
* concrete_pattern.hh *
* Change History *
* -------------------------------------------------------------------------- *
* Name Date Change Description *
* Aniket 14-Aug-13 Initial Version *
* *
*--------------------------------------------------------------------------- */
#ifndef __CPATTERN_H_INCLUDED__
#define __CPATTERN_H_INCLUDED__
#include <vector>
#include "node.hh"
#include "pattern.hh"
/**
* Different types of concrete patterns are
* denoted by the member variable type.
* The value of the variable denotes the following.
* 1. Insn
* 2. Expand
* 3. peephole2
* 4. split
* 5. insn_and_split
***/
class ConcretePattern: public Pattern {
private:
std::string name;
/*
* The following two variables describe whether the in / out parts of
* the construct are instantiates or overrides.
* Do not use these variable directly. Use the methods
* isInstantiates / isOverrides or setInstantiates / setOverrides.
*/
SubType subTypeOut;
std::vector<Operand> operandsIn;
std::vector<ModeStmt> modeStmtsIn;
std::vector<Operand> operandsOut; /* This is only required for peep2, splits & insn_split */
std::vector<ModeStmt> modeStmtsOut;
Pattern* parentPattern;
Pattern* parentPatternOut;
int lineStart;
int lineEnd;
/*
* This is the structure that stores
* the tree structure. It is constructed based on
* the abstract patterns.
*/
Node* tree;
Node* treeOut;
bool error;
std::string cmdBody;
std::string cmdBodyOut;
public:
ConcretePattern (Type pt) {
error = false;
type = pt;
name = "";
}
Node* getTree(){
return tree;
}
ConcretePattern (std::string V, Type t) {
name = V;
type = t;
error = false;
}
~ConcretePattern ();
std::string getPatName () {
return name;
}
void setPatName (std::string V) {
name = V;
}
Type getPatType () {
return type;
}
void setPatType (Type t) {
type = t;
}
void setError(){
error = true;
}
bool inError(){
return error;
}
void setParentPattern (Pattern* p){
parentPattern = p;
}
void setParentPatternOut (Pattern* p) {
parentPatternOut = p;
}
Pattern* getParentPattern () {
return parentPattern;
}
Pattern* getParentPatternOut () {
return parentPatternOut;
}
std::vector<Operand> getOperands () {
return operandsIn;
}
std::vector<Operand> getOperandsOut () {
return operandsOut;
}
void setCmdBody (std::string str) {
cmdBody = str;
}
void setCmdBodyOut (std::string str) {
cmdBodyOut = str;
}
std::vector<ModeStmt> getModeStmts () {
return modeStmtsIn;
}
std::vector<ModeStmt> getModeStmtsOut () {
return modeStmtsOut;
}
void setSubTypeIn (SubType st) {
subType = st;
}
void setSubTypeOut (SubType st) {
subTypeOut = st;
}
SubType getSubTypeIn () {
return subType;
}
SubType getSubTypeOut () {
return subTypeOut;
}
std::string getName() {
return name;
}
void addOperand (const Operand o);
void addOperands (const std::vector<Operand> ol);
void addModeStmt (const ModeStmt ms);
void addModeStmts (const std::vector<ModeStmt> msv);
void addOperandOut (const Operand o);
void addModeStmtOut (const ModeStmt ms);
void addOperandsOut (const std::vector<Operand> ol);
void addModeStmtsOut (const std::vector<ModeStmt> msv);
void createPattern ();
void createPatternOut ();
void trav(Node* aRoot);
};
#endif