17 #include "pcodecompile.hh" 18 #include "filemanage.hh" 34 vector<RtlPair> named;
37 ConstructTpl *getMainSection(
void)
const {
return main.section; }
38 ConstructTpl *getNamedSection(int4 index)
const {
return named[index].section; }
39 RtlPair getMainPair(
void)
const {
return main; }
40 RtlPair getNamedPair(int4 i)
const {
return named[i]; }
41 void setNextIndex(int4 i) { nextindex = i; }
42 int4 getMaxId(
void)
const {
return named.size(); }
71 vector<ContextChange *> contvec;
77 static vector<ContextChange *> *collectAndPrependContext(
const list<WithBlock> &stack, vector<ContextChange *> *contvec);
78 static SubtableSymbol *getCurrentSubtable(
const list<WithBlock> &stack);
84 struct OptimizeRecord {
93 OptimizeRecord(
void) {
94 writeop = -1; readop = -1; inslot=-1; writecount=0; readcount=0; writesection=-2; readsection=-2; opttype=-1; }
97 int4 unnecessarypcode;
100 bool printextwarning;
101 bool printdeadwarning;
103 vector<SubtableSymbol *> postorder;
104 map<SubtableSymbol *,int4> sizemap;
106 void printOpName(ostream &s,
OpTpl *op);
107 void printOpError(
OpTpl *op,
Constructor *ct,int4 err1,int4 err2,
const string &message);
120 static void examineVn(map<uintb,OptimizeRecord> &recs,
const VarnodeTpl *vn,uint4 i,int4 inslot,int4 secnum);
122 bool readWriteInterference(
const VarnodeTpl *vn,
const OpTpl *op,
bool checkread)
const;
123 void optimizeGather1(
Constructor *ct,map<uintb,OptimizeRecord> &recs,int4 secnum)
const;
124 void optimizeGather2(
Constructor *ct,map<uintb,OptimizeRecord> &recs,int4 secnum)
const;
125 OptimizeRecord *findValidRule(
Constructor *ct,map<uintb,OptimizeRecord> &recs)
const;
126 void applyOptimization(
Constructor *ct,
const OptimizeRecord &rec);
127 void checkUnusedTemps(
Constructor *ct,
const map<uintb,OptimizeRecord> &recs);
132 bool testTruncations(
bool isbigendian);
133 void optimizeAll(
void);
134 int4 getNumUnnecessaryPcode(
void)
const {
return unnecessarypcode; }
135 int4 getNumReadNoWrite(
void)
const {
return readnowrite; }
136 int4 getNumWriteNoRead(
void)
const {
return writenoread; }
149 vector<OpTpl *> &outvec;
150 vector<HandleTpl *> params;
151 bool transferOp(
OpTpl *op,vector<HandleTpl *> ¶ms);
152 virtual void dump(
OpTpl *op );
154 void reportError(
const Location* loc,
const string &val);
157 slgh = sl; haserror =
false; }
158 void setMacroOp(
OpTpl *macroop);
159 bool hasError(
void)
const {
return haserror; }
161 virtual void appendBuild(
OpTpl *bld,int4 secnum) { dump(bld); }
162 virtual void delaySlot(
OpTpl *op) { dump(op); }
163 virtual void setLabel(
OpTpl *op);
164 virtual void appendCrossBuild(
OpTpl *bld,int4 secnum) { dump(bld); }
169 virtual uintb allocateTemp(
void);
171 virtual void reportError(
const Location* loc,
const string &msg);
172 virtual void reportWarning(
const Location* loc,
const string &msg);
184 map<string,string> preproc_defines;
185 vector<FieldContext> contexttable;
186 vector<ConstructTpl *> macrotable;
187 vector<Token *> tokentable;
188 vector<SubtableSymbol *> tables;
189 vector<SectionSymbol *> sections;
190 list<WithBlock> withstack;
194 vector<string> relpath;
195 vector<string> filename;
197 map<Constructor *, Location> ctorLocationMap;
198 map<SleighSymbol *, Location> symbolLocationMap;
200 bool warnunnecessarypcode;
202 bool lenientconflicterrors;
203 bool warnalllocalcollisions;
205 vector<string> noplist;
209 const Location* getCurrentLocation(
void)
const;
210 void predefinedSymbols(
void);
211 int4 calcContextVarLayout(int4 start,int4 sz,int4 numbits);
212 void buildDecisionTrees(
void);
213 void buildPatterns(
void);
214 void checkConsistency(
void);
215 static int4 findCollision(map<uintb,int4> &local2Operand,
const vector<uintb> &locals,
int operand);
217 void checkLocalCollisions(
void);
218 void checkNops(
void);
221 SleighSymbol *dedupSymbolList(vector<SleighSymbol *> *symlist);
222 bool expandMacros(
ConstructTpl *ctpl,
const vector<ConstructTpl *> ¯otable);
224 static void shiftUniqueVn(
VarnodeTpl *vn,int4 sa);
225 static void shiftUniqueOp(
OpTpl *op,int4 sa);
226 static void shiftUniqueHandle(
HandleTpl *hand,int4 sa);
227 static void shiftUniqueConstruct(
ConstructTpl *tpl,int4 sa);
228 void checkUniqueAllocation(
void);
233 string formatStatusMessage(
const Location* loc,
const string &msg);
234 void reportError(
const string &msg);
235 void reportError(
const Location *loc,
const string &msg);
236 void reportWarning(
const string &msg);
237 void reportWarning(
const Location *loc,
const string &msg);
238 int4 numErrors(
void)
const {
return errors; }
239 void reportInfo(
const string &msg);
240 void reportInfo(
const Location *loc,
const string &msg);
243 uintb getUniqueAddr(
void);
244 void setUnnecessaryPcodeWarning(
bool val) { warnunnecessarypcode = val; }
245 void setDeadTempWarning(
bool val) { warndeadtemps = val; }
246 void setEnforceLocalKeyWord(
bool val) { pcode.setEnforceLocalKey(val); }
247 void setLenientConflict(
bool val) { lenientconflicterrors = val; }
248 void setLocalCollisionWarning(
bool val) { warnalllocalcollisions = val; }
249 void setAllNopWarning(
bool val) { warnallnops = val; }
253 void calcContextLayout(
void);
254 string grabCurrentFilePath(
void)
const;
255 void parseFromNewFile(
const string &fname);
256 void parsePreprocMacro(
void);
257 void parseFileFinished(
void);
258 void nextLine(
void) { lineno.back() += 1; }
259 bool getPreprocValue(
const string &nm,
string &res)
const;
260 void setPreprocValue(
const string &nm,
const string &value);
261 bool undefinePreprocValue(
const string &nm);
269 void setEndian(int4 end);
270 void setAlignment(int4 val) { alignment = val; }
271 void defineVarnodes(
SpaceSymbol *spacesym,uintb *off,uintb *size,vector<string> *names);
272 void defineBitrange(
string *name,
VarnodeSymbol *sym,uint4 bitoffset,uint4 numb);
273 void addUserOp(vector<string> *names);
274 void attachValues(vector<SleighSymbol *> *symlist,vector<intb> *numlist);
275 void attachNames(vector<SleighSymbol *> *symlist,vector<string> *names);
276 void attachVarnodes(vector<SleighSymbol *> *symlist,vector<SleighSymbol *> *varlist);
288 MacroSymbol *createMacro(
string *name,vector<string> *param);
289 void compareMacroParams(
MacroSymbol *sym,
const vector<ExprTree *> ¶m);
290 vector<OpTpl *> *createMacroUse(
MacroSymbol *sym,vector<ExprTree *> *param);
297 bool isInRoot(
Constructor *ct)
const {
return (root == ct->getParent()); }
298 void resetConstructors(
void);
303 void recordNop(
void);
A container for parsed XML documents.
Definition: xml.hh:249
Definition: slghsymbol.hh:146
Definition: semantics.hh:192
virtual int4 oneInstruction(PcodeEmit &emit, const Address &baseaddr) const
Transform a single machine instruction into pcode.
Definition: slgh_compile.hh:308
Definition: semantics.hh:137
Abstract class for emitting pcode to an application.
Definition: translate.hh:76
Definition: slghpatexpress.hh:56
Definition: slgh_compile.hh:31
Definition: slgh_compile.hh:146
Common core of classes that read or write SLEIGH specification files natively.
Definition: sleighbase.hh:29
Definition: slgh_compile.hh:139
Definition: pcodecompile.hh:32
Definition: slghsymbol.hh:245
Definition: slgh_compile.hh:59
Definition: slghsymbol.hh:54
Definition: slghsymbol.hh:116
virtual int4 printAssembly(AssemblyEmit &emit, const Address &baseaddr) const
Disassemble a single machine instruction.
Definition: slgh_compile.hh:309
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Definition: slghsymbol.hh:279
Definition: slghsymbol.hh:23
Definition: slgh_compile.hh:24
Base class for applications that process SLEIGH format specifications.
Definition: slgh_compile.hh:83
Definition: semantics.hh:107
Definition: slgh_compile.hh:167
Definition: semantics.hh:161
Definition: slghsymbol.hh:107
Definition: slgh_compile.hh:46
Definition: semantics.hh:31
Definition: pcodecompile.hh:55
virtual int4 instructionLength(const Address &baseaddr) const
Get the length of a machine instruction.
Definition: slgh_compile.hh:307
Definition: slghsymbol.hh:313
Definition: slgh_compile.hh:68
virtual void initialize(DocumentStorage &store)
Initialize the translator given XML configuration documents.
Definition: slgh_compile.hh:306
Definition: slgh_compile.hh:179
Definition: slghsymbol.hh:99
Abstract class for emitting disassembly to an application.
Definition: translate.hh:118
Definition: pcodecompile.hh:21
Definition: slghsymbol.hh:592
Definition: slghsymbol.hh:561
Definition: slghsymbol.hh:466
Definition: semantics.hh:77
Definition: slghpatexpress.hh:336