16 #ifndef __SLGHPATEXPRESS__
17 #define __SLGHPATEXPRESS__
19 #include "slghpattern.hh"
23 vector<Token *> toklist;
26 static PatternBlock *buildSingle(int4 startbit,int4 endbit,uintm byteval);
27 static PatternBlock *buildBigBlock(int4 size,int4 bitstart,int4 bitend,intb value);
28 static PatternBlock *buildLittleBlock(int4 size,int4 bitstart,int4 bitend,intb value);
40 void setLeftEllipsis(
bool val) { leftellipsis = val; }
41 void setRightEllipsis(
bool val) { rightellipsis = val; }
42 bool getLeftEllipsis(
void)
const {
return leftellipsis; }
43 bool getRightEllipsis(
void)
const {
return rightellipsis; }
48 Pattern *getPattern(
void)
const {
return pattern; }
49 int4 getMinimumLength(
void)
const;
50 bool alwaysTrue(
void)
const {
return pattern->alwaysTrue(); }
51 bool alwaysFalse(
void)
const {
return pattern->alwaysFalse(); }
52 bool alwaysInstructionTrue(
void)
const {
return pattern->alwaysInstructionTrue(); }
64 virtual TokenPattern genMinPattern(
const vector<TokenPattern> &ops)
const=0;
65 virtual void listValues(vector<const PatternValue *> &list)
const=0;
66 virtual void getMinMax(vector<intb> &minlist,vector<intb> &maxlist)
const=0;
67 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const=0;
68 virtual void saveXml(ostream &s)
const=0;
70 intb getSubValue(
const vector<intb> &replace) {
72 return getSubValue(replace,listpos); }
73 void layClaim(
void) { refcount += 1; }
81 virtual void listValues(vector<const PatternValue *> &list)
const { list.push_back(
this); }
82 virtual void getMinMax(vector<intb> &minlist,vector<intb> &maxlist)
const {
83 minlist.push_back(minValue()); maxlist.push_back(maxValue()); }
84 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const {
return replace[listpos++]; }
85 virtual intb minValue(
void)
const=0;
86 virtual intb maxValue(
void)
const=0;
94 int4 bytestart,byteend;
102 virtual intb minValue(
void)
const {
return 0; }
103 virtual intb maxValue(
void)
const { intb res=0; res=~res;
zero_extend(res,bitend-bitstart);
return res; }
104 virtual void saveXml(ostream &s)
const;
109 int4 startbit,endbit;
110 int4 startbyte,endbyte;
116 int4 getStartBit(
void)
const {
return startbit; }
117 int4 getEndBit(
void)
const {
return endbit; }
118 bool getSignBit(
void)
const {
return signbit; }
122 virtual intb minValue(
void)
const {
return 0; }
123 virtual intb maxValue(
void)
const { intb res=0; res=~res;
zero_extend(res,(endbit-startbit));
return res; }
124 virtual void saveXml(ostream &s)
const;
133 virtual intb getValue(
ParserWalker &walker)
const {
return val; }
136 virtual intb minValue(
void)
const {
return val; }
137 virtual intb maxValue(
void)
const {
return val; }
138 virtual void saveXml(ostream &s)
const;
149 virtual intb minValue(
void)
const {
return (intb)0; }
150 virtual intb maxValue(
void)
const {
return (intb)0; }
151 virtual void saveXml(ostream &s)
const { s <<
"<start_exp/>"; }
162 virtual intb minValue(
void)
const {
return (intb)0; }
163 virtual intb maxValue(
void)
const {
return (intb)0; }
164 virtual void saveXml(ostream &s)
const { s <<
"<end_exp/>"; }
176 void changeIndex(int4 newind) { index = newind; }
177 bool isConstructorRelative(
void)
const;
178 const string &getName(
void)
const;
180 virtual TokenPattern genMinPattern(
const vector<TokenPattern> &ops)
const {
return ops[index]; }
182 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
183 virtual intb minValue(
void)
const;
184 virtual intb maxValue(
void)
const;
185 virtual void saveXml(ostream &s)
const;
199 virtual void listValues(vector<const PatternValue *> &list)
const {
200 left->listValues(list); right->listValues(list); }
201 virtual void getMinMax(vector<intb> &minlist,vector<intb> &maxlist)
const {
202 left->getMinMax(minlist,maxlist); right->getMinMax(minlist,maxlist); }
203 virtual void saveXml(ostream &s)
const;
216 virtual void listValues(vector<const PatternValue *> &list)
const {
217 unary->listValues(list); }
218 virtual void getMinMax(vector<intb> &minlist,vector<intb> &maxlist)
const {
219 unary->getMinMax(minlist,maxlist);
221 virtual void saveXml(ostream &s)
const;
230 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
231 virtual void saveXml(ostream &s)
const;
239 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
240 virtual void saveXml(ostream &s)
const;
248 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
249 virtual void saveXml(ostream &s)
const;
257 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
258 virtual void saveXml(ostream &s)
const;
266 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
267 virtual void saveXml(ostream &s)
const;
275 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
276 virtual void saveXml(ostream &s)
const;
284 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
285 virtual void saveXml(ostream &s)
const;
293 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
294 virtual void saveXml(ostream &s)
const;
302 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
303 virtual void saveXml(ostream &s)
const;
311 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
312 virtual void saveXml(ostream &s)
const;
320 virtual intb getSubValue(
const vector<intb> &replace,int4 &listpos)
const;
321 virtual void saveXml(ostream &s)
const;
325 vector<OperandSymbol *> &operands;
327 base=-1; offset=0; cur_rightmost = -1; size = 0; }
343 const TokenPattern &getTokenPattern(
void)
const {
return resultpattern; }
344 virtual void genPattern(
const vector<TokenPattern> &ops)
const=0;
346 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const {}
347 void layClaim(
void) { refcount += 1; }
355 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
357 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;
366 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
383 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
389 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
395 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
401 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
407 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
413 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
423 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
425 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;
435 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
437 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;
447 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
449 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;
458 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
460 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;
469 virtual void genPattern(
const vector<TokenPattern> &ops)
const;
471 virtual void operandOrder(
Constructor *ct,vector<OperandSymbol *> &order)
const;