16 #ifndef __SLGHPATTERN__
17 #define __SLGHPATTERN__
25 vector<uintm> maskvec;
38 void shift(int4 sa) { offset += sa; normalize(); }
39 int4 getLength(
void)
const {
return offset+nonzerosize; }
40 uintm getMask(int4 startbit,int4 size)
const;
41 uintm getValue(int4 startbit,int4 size)
const;
42 bool alwaysTrue(
void)
const {
return (nonzerosize==0); }
43 bool alwaysFalse(
void)
const {
return (nonzerosize==-1); }
46 void saveXml(ostream &s)
const;
47 void restoreXml(
const Element *el);
54 virtual Pattern *simplifyClone(
void)
const=0;
55 virtual void shiftInstruction(int4 sa)=0;
58 virtual Pattern *commonSubPattern(
const Pattern *b,int4 sa)
const=0;
60 virtual int4 numDisjoint(
void)
const=0;
62 virtual bool alwaysTrue(
void)
const=0;
63 virtual bool alwaysFalse(
void)
const=0;
64 virtual bool alwaysInstructionTrue(
void)
const=0;
65 virtual void saveXml(ostream &s)
const=0;
66 virtual void restoreXml(
const Element *el)=0;
72 virtual int4 numDisjoint(
void)
const {
return 0; }
74 uintm getMask(int4 startbit,int4 size,
bool context)
const;
75 uintm getValue(int4 startbit,int4 size,
bool context)
const;
76 int4 getLength(
bool context)
const;
93 virtual void shiftInstruction(int4 sa) { maskvalue->shift(sa); }
97 virtual bool isMatch(
ParserWalker &walker)
const {
return maskvalue->isInstructionMatch(walker); }
98 virtual bool alwaysTrue(
void)
const {
return maskvalue->alwaysTrue(); }
99 virtual bool alwaysFalse(
void)
const {
return maskvalue->alwaysFalse(); }
100 virtual bool alwaysInstructionTrue(
void)
const {
return maskvalue->alwaysTrue(); }
101 virtual void saveXml(ostream &s)
const;
102 virtual void restoreXml(
const Element *el);
114 virtual void shiftInstruction(int4 sa) { }
117 virtual Pattern *commonSubPattern(
const Pattern *b,int4 sa)
const;
118 virtual bool isMatch(
ParserWalker &walker)
const {
return maskvalue->isContextMatch(walker); }
119 virtual bool alwaysTrue(
void)
const {
return maskvalue->alwaysTrue(); }
120 virtual bool alwaysFalse(
void)
const {
return maskvalue->alwaysFalse(); }
121 virtual bool alwaysInstructionTrue(
void)
const {
return true; }
122 virtual void saveXml(ostream &s)
const;
123 virtual void restoreXml(
const Element *el);
130 virtual PatternBlock *getBlock(
bool cont)
const {
return cont ? context->getBlock() : instr->getBlock(); }
134 context = con; instr = in; }
136 virtual Pattern *simplifyClone(
void)
const;
137 virtual void shiftInstruction(int4 sa) { instr->shiftInstruction(sa); }
139 virtual bool alwaysTrue(
void)
const;
140 virtual bool alwaysFalse(
void)
const;
141 virtual bool alwaysInstructionTrue(
void)
const {
return instr->alwaysInstructionTrue(); }
144 virtual Pattern *commonSubPattern(
const Pattern *b,int4 sa)
const;
145 virtual void saveXml(ostream &s)
const;
146 virtual void restoreXml(
const Element *el);
150 vector<DisjointPattern *> orlist;
154 OrPattern(
const vector<DisjointPattern *> &list);
156 virtual Pattern *simplifyClone(
void)
const;
157 virtual void shiftInstruction(int4 sa);
159 virtual int4 numDisjoint(
void)
const {
return orlist.size(); }
160 virtual DisjointPattern *getDisjoint(int4 i)
const {
return orlist[i]; }
161 virtual bool alwaysTrue(
void)
const;
162 virtual bool alwaysFalse(
void)
const;
163 virtual bool alwaysInstructionTrue(
void)
const;
166 virtual Pattern *commonSubPattern(
const Pattern *b,int4 sa)
const;
167 virtual void saveXml(ostream &s)
const;
168 virtual void restoreXml(
const Element *el);