My Project
ruleaction.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
24 
25 #ifndef __RULE_ACTION__
26 #define __RULE_ACTION__
27 
28 #include "action.hh"
29 
31 class AddTreeState {
32 public:
34  int4 size;
35  vector<Varnode *> multiple;
36  vector<uintb> coeff;
37  vector<Varnode *> nonmult;
38  uintb multsum;
39  uintb nonmultsum;
40  bool valid;
41 };
42 
43 class RuleEarlyRemoval : public Rule {
44 public:
45  RuleEarlyRemoval(const string &g) : Rule(g, 0, "earlyremoval") {}
46  virtual Rule *clone(const ActionGroupList &grouplist) const {
47  if (!grouplist.contains(getGroup())) return (Rule *)0;
48  return new RuleEarlyRemoval(getGroup());
49  }
50  // This rule applies to all ops
51  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
52 };
53 // class RuleAddrForceRelease : public Rule {
54 // public:
55 // RuleAddrForceRelease(const string &g) : Rule(g, 0, "addrforcerelease") {} ///< Constructor
56 // virtual void getOpList(vector<uint4> &oplist) const;
57 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
58 // };
59 class RuleCollectTerms : public Rule {
60  static Varnode *getMultCoeff(Varnode *vn,uintb &coef);
61  static int4 doDistribute(Funcdata &data,PcodeOp *op);
62 public:
63  RuleCollectTerms(const string &g) : Rule(g, 0, "collect_terms") {}
64  virtual Rule *clone(const ActionGroupList &grouplist) const {
65  if (!grouplist.contains(getGroup())) return (Rule *)0;
66  return new RuleCollectTerms(getGroup());
67  }
68  virtual void getOpList(vector<uint4> &oplist) const;
69  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
70 };
71 class RuleSelectCse : public Rule {
72 public:
73  RuleSelectCse(const string &g) : Rule(g,0,"selectcse") {}
74  virtual Rule *clone(const ActionGroupList &grouplist) const {
75  if (!grouplist.contains(getGroup())) return (Rule *)0;
76  return new RuleSelectCse(getGroup());
77  }
78  virtual void getOpList(vector<uint4> &oplist) const;
79  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
80 };
81 class RulePiece2Zext : public Rule {
82 public:
83  RulePiece2Zext(const string &g) : Rule(g, 0, "piece2zext") {}
84  virtual Rule *clone(const ActionGroupList &grouplist) const {
85  if (!grouplist.contains(getGroup())) return (Rule *)0;
86  return new RulePiece2Zext(getGroup());
87  }
88  virtual void getOpList(vector<uint4> &oplist) const;
89  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
90 };
91 class RulePiece2Sext : public Rule {
92 public:
93  RulePiece2Sext(const string &g) : Rule(g, 0, "piece2sext") {}
94  virtual Rule *clone(const ActionGroupList &grouplist) const {
95  if (!grouplist.contains(getGroup())) return (Rule *)0;
96  return new RulePiece2Sext(getGroup());
97  }
98  virtual void getOpList(vector<uint4> &oplist) const;
99  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
100 };
101 class RuleBxor2NotEqual : public Rule {
102 public:
103  RuleBxor2NotEqual(const string &g) : Rule(g, 0, "bxor2notequal") {}
104  virtual Rule *clone(const ActionGroupList &grouplist) const {
105  if (!grouplist.contains(getGroup())) return (Rule *)0;
106  return new RuleBxor2NotEqual(getGroup());
107  }
108  virtual void getOpList(vector<uint4> &oplist) const;
109  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
110 };
111 class RuleOrMask : public Rule {
112 public:
113  RuleOrMask(const string &g) : Rule(g, 0, "ormask") {}
114  virtual Rule *clone(const ActionGroupList &grouplist) const {
115  if (!grouplist.contains(getGroup())) return (Rule *)0;
116  return new RuleOrMask(getGroup());
117  }
118  virtual void getOpList(vector<uint4> &oplist) const;
119  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
120 };
121 class RuleAndMask : public Rule {
122 public:
123  RuleAndMask(const string &g) : Rule(g, 0, "andmask") {}
124  virtual Rule *clone(const ActionGroupList &grouplist) const {
125  if (!grouplist.contains(getGroup())) return (Rule *)0;
126  return new RuleAndMask(getGroup());
127  }
128  virtual void getOpList(vector<uint4> &oplist) const;
129  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
130 };
131 class RuleOrConsume : public Rule {
132 public:
133  RuleOrConsume(const string &g) : Rule(g, 0, "orconsume") {}
134  virtual Rule *clone(const ActionGroupList &grouplist) const {
135  if (!grouplist.contains(getGroup())) return (Rule *)0;
136  return new RuleOrConsume(getGroup());
137  }
138  virtual void getOpList(vector<uint4> &oplist) const;
139  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
140 };
141 class RuleOrCollapse : public Rule {
142 public:
143  RuleOrCollapse(const string &g) : Rule(g, 0, "orcollapse") {}
144  virtual Rule *clone(const ActionGroupList &grouplist) const {
145  if (!grouplist.contains(getGroup())) return (Rule *)0;
146  return new RuleOrCollapse(getGroup());
147  }
148  virtual void getOpList(vector<uint4> &oplist) const;
149  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
150 };
151 class RuleAndOrLump : public Rule {
152 public:
153  RuleAndOrLump(const string &g) : Rule(g, 0, "andorlump") {}
154  virtual Rule *clone(const ActionGroupList &grouplist) const {
155  if (!grouplist.contains(getGroup())) return (Rule *)0;
156  return new RuleAndOrLump(getGroup());
157  }
158  virtual void getOpList(vector<uint4> &oplist) const;
159  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
160 };
161 class RuleNegateIdentity : public Rule {
162 public:
163  RuleNegateIdentity(const string &g) : Rule(g, 0, "negateidentity") {}
164  virtual Rule *clone(const ActionGroupList &grouplist) const {
165  if (!grouplist.contains(getGroup())) return (Rule *)0;
166  return new RuleNegateIdentity(getGroup());
167  }
168  virtual void getOpList(vector<uint4> &oplist) const;
169  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
170 };
171 class RuleShiftBitops : public Rule {
172 public:
173  RuleShiftBitops(const string &g) : Rule(g, 0, "shiftbitops") {}
174  virtual Rule *clone(const ActionGroupList &grouplist) const {
175  if (!grouplist.contains(getGroup())) return (Rule *)0;
176  return new RuleShiftBitops(getGroup());
177  }
178  virtual void getOpList(vector<uint4> &oplist) const;
179  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
180 };
181 class RuleRightShiftAnd : public Rule {
182 public:
183  RuleRightShiftAnd(const string &g) : Rule(g, 0, "rightshiftand") {}
184  virtual Rule *clone(const ActionGroupList &grouplist) const {
185  if (!grouplist.contains(getGroup())) return (Rule *)0;
186  return new RuleRightShiftAnd(getGroup());
187  }
188  virtual void getOpList(vector<uint4> &oplist) const;
189  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
190 };
191 class RuleIntLessEqual : public Rule {
192 public:
193  RuleIntLessEqual(const string &g) : Rule(g, 0, "intlessequal") {}
194  virtual Rule *clone(const ActionGroupList &grouplist) const {
195  if (!grouplist.contains(getGroup())) return (Rule *)0;
196  return new RuleIntLessEqual(getGroup());
197  }
198  virtual void getOpList(vector<uint4> &oplist) const;
199  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
200 };
201 class RuleEquality : public Rule {
202 public:
203  RuleEquality(const string &g) : Rule(g, 0, "equality") {}
204  virtual Rule *clone(const ActionGroupList &grouplist) const {
205  if (!grouplist.contains(getGroup())) return (Rule *)0;
206  return new RuleEquality(getGroup());
207  }
208  virtual void getOpList(vector<uint4> &oplist) const;
209  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
210 };
211 // Reversible rules
212 class RuleTermOrder : public Rule {
213 public:
214  RuleTermOrder(const string &g) : Rule(g, 0, "termorder") {}
215  virtual Rule *clone(const ActionGroupList &grouplist) const {
216  if (!grouplist.contains(getGroup())) return (Rule *)0;
217  return new RuleTermOrder(getGroup());
218  }
219  virtual void getOpList(vector<uint4> &oplist) const;
220  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
221 };
222 class RulePullsubMulti : public Rule {
223 public:
224  RulePullsubMulti(const string &g) : Rule(g, 0, "pullsub_multi") {}
225  virtual Rule *clone(const ActionGroupList &grouplist) const {
226  if (!grouplist.contains(getGroup())) return (Rule *)0;
227  return new RulePullsubMulti(getGroup());
228  }
229  virtual void getOpList(vector<uint4> &oplist) const;
230  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
231  static void minMaxUse(Varnode *vn,int4 &maxByte,int4 &minByte);
232  static void replaceDescendants(Varnode *origVn,Varnode *newVn,int4 maxByte,int4 minByte,Funcdata &data);
233  static bool acceptableSize(int4 size);
234  static Varnode *buildSubpiece(Varnode *basevn,uint4 outsize,uint4 shift,Funcdata &data);
235  static Varnode *findSubpiece(Varnode *basevn,uint4 outsize,uint4 shift);
236 };
237 class RulePullsubIndirect : public Rule {
238 public:
239  RulePullsubIndirect(const string &g) : Rule(g, 0, "pullsub_indirect") {}
240  virtual Rule *clone(const ActionGroupList &grouplist) const {
241  if (!grouplist.contains(getGroup())) return (Rule *)0;
242  return new RulePullsubIndirect(getGroup());
243  }
244  virtual void getOpList(vector<uint4> &oplist) const;
245  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
246 };
247 class RulePushMulti : public Rule {
248  static PcodeOp *findSubstitute(Varnode *in1,Varnode *in2,BlockBasic *bb,PcodeOp *earliest);
249 public:
250  RulePushMulti(const string &g) : Rule(g, 0, "push_multi") {}
251  virtual Rule *clone(const ActionGroupList &grouplist) const {
252  if (!grouplist.contains(getGroup())) return (Rule *)0;
253  return new RulePushMulti(getGroup());
254  }
255  virtual void getOpList(vector<uint4> &oplist) const;
256  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
257 };
258 class RuleNotDistribute : public Rule {
259 public:
260  RuleNotDistribute(const string &g) : Rule(g, 0, "notdistribute") {}
261  virtual Rule *clone(const ActionGroupList &grouplist) const {
262  if (!grouplist.contains(getGroup())) return (Rule *)0;
263  return new RuleNotDistribute(getGroup());
264  }
265  virtual void getOpList(vector<uint4> &oplist) const;
266  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
267 };
268 class RuleHighOrderAnd : public Rule {
269 public:
270  RuleHighOrderAnd(const string &g) : Rule(g, 0, "highorderand") {}
271  virtual Rule *clone(const ActionGroupList &grouplist) const {
272  if (!grouplist.contains(getGroup())) return (Rule *)0;
273  return new RuleHighOrderAnd(getGroup());
274  }
275  virtual void getOpList(vector<uint4> &oplist) const;
276  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
277 };
278 class RuleAndDistribute : public Rule {
279 public:
280  RuleAndDistribute(const string &g) : Rule(g, 0, "anddistribute") {}
281  virtual Rule *clone(const ActionGroupList &grouplist) const {
282  if (!grouplist.contains(getGroup())) return (Rule *)0;
283  return new RuleAndDistribute(getGroup());
284  }
285  virtual void getOpList(vector<uint4> &oplist) const;
286  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
287 };
288 class RuleLessOne : public Rule {
289 public:
290  RuleLessOne(const string &g) : Rule(g, 0, "lessone") {}
291  virtual Rule *clone(const ActionGroupList &grouplist) const {
292  if (!grouplist.contains(getGroup())) return (Rule *)0;
293  return new RuleLessOne(getGroup());
294  }
295  virtual void getOpList(vector<uint4> &oplist) const;
296  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
297 };
298 class RuleRangeMeld : public Rule {
299 public:
300  RuleRangeMeld(const string &g) : Rule(g, 0, "rangemeld") {}
301  virtual Rule *clone(const ActionGroupList &grouplist) const {
302  if (!grouplist.contains(getGroup())) return (Rule *)0;
303  return new RuleRangeMeld(getGroup());
304  }
305  virtual void getOpList(vector<uint4> &oplist) const;
306  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
307 };
308 class RuleFloatRange : public Rule {
309 public:
310  RuleFloatRange(const string &g) : Rule(g, 0, "floatrange") {}
311  virtual Rule *clone(const ActionGroupList &grouplist) const {
312  if (!grouplist.contains(getGroup())) return (Rule *)0;
313  return new RuleFloatRange(getGroup());
314  }
315  virtual void getOpList(vector<uint4> &oplist) const;
316  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
317 };
318 class RuleAndCommute : public Rule {
319 public:
320  RuleAndCommute(const string &g) : Rule(g, 0, "andcommute") {}
321  virtual Rule *clone(const ActionGroupList &grouplist) const {
322  if (!grouplist.contains(getGroup())) return (Rule *)0;
323  return new RuleAndCommute(getGroup());
324  }
325  virtual void getOpList(vector<uint4> &oplist) const;
326  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
327 };
328 class RuleAndPiece : public Rule {
329 public:
330  RuleAndPiece(const string &g) : Rule(g, 0, "andpiece") {}
331  virtual Rule *clone(const ActionGroupList &grouplist) const {
332  if (!grouplist.contains(getGroup())) return (Rule *)0;
333  return new RuleAndPiece(getGroup());
334  }
335  virtual void getOpList(vector<uint4> &oplist) const;
336  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
337 };
338 class RuleAndCompare : public Rule {
339 public:
340  RuleAndCompare(const string &g) : Rule(g, 0, "andcompare") {}
341  virtual Rule *clone(const ActionGroupList &grouplist) const {
342  if (!grouplist.contains(getGroup())) return (Rule *)0;
343  return new RuleAndCompare(getGroup());
344  }
345  virtual void getOpList(vector<uint4> &oplist) const;
346  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
347 };
348 class RuleDoubleSub : public Rule {
349 public:
350  RuleDoubleSub(const string &g) : Rule(g, 0, "doublesub") {}
351  virtual Rule *clone(const ActionGroupList &grouplist) const {
352  if (!grouplist.contains(getGroup())) return (Rule *)0;
353  return new RuleDoubleSub(getGroup());
354  }
355  virtual void getOpList(vector<uint4> &oplist) const;
356  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
357 };
358 class RuleDoubleShift : public Rule {
359 public:
360  RuleDoubleShift(const string &g) : Rule(g, 0, "doubleshift") {}
361  virtual Rule *clone(const ActionGroupList &grouplist) const {
362  if (!grouplist.contains(getGroup())) return (Rule *)0;
363  return new RuleDoubleShift(getGroup());
364  }
365  virtual void getOpList(vector<uint4> &oplist) const;
366  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
367 };
368 class RuleDoubleArithShift : public Rule {
369 public:
370  RuleDoubleArithShift(const string &g) : Rule(g, 0, "doublearithshift") {}
371  virtual Rule *clone(const ActionGroupList &grouplist) const {
372  if (!grouplist.contains(getGroup())) return (Rule *)0;
373  return new RuleDoubleArithShift(getGroup());
374  }
375  virtual void getOpList(vector<uint4> &oplist) const;
376  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
377 };
378 class RuleConcatShift : public Rule {
379 public:
380  RuleConcatShift(const string &g) : Rule(g, 0, "concatshift") {}
381  virtual Rule *clone(const ActionGroupList &grouplist) const {
382  if (!grouplist.contains(getGroup())) return (Rule *)0;
383  return new RuleConcatShift(getGroup());
384  }
385  virtual void getOpList(vector<uint4> &oplist) const;
386  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
387 };
388 class RuleLeftRight : public Rule {
389 public:
390  RuleLeftRight(const string &g) : Rule(g, 0, "leftright") {}
391  virtual Rule *clone(const ActionGroupList &grouplist) const {
392  if (!grouplist.contains(getGroup())) return (Rule *)0;
393  return new RuleLeftRight(getGroup());
394  }
395  virtual void getOpList(vector<uint4> &oplist) const;
396  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
397 };
398 class RuleShiftCompare : public Rule {
399 public:
400  RuleShiftCompare(const string &g) : Rule(g, 0, "shiftcompare") {}
401  virtual Rule *clone(const ActionGroupList &grouplist) const {
402  if (!grouplist.contains(getGroup())) return (Rule *)0;
403  return new RuleShiftCompare(getGroup());
404  }
405  virtual void getOpList(vector<uint4> &oplist) const;
406  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
407 };
408 // class RuleShiftLess : public Rule {
409 // public:
410 // RuleShiftLess(const string &g) : Rule(g, 0, "shiftless") {} ///< Constructor
411 // virtual Rule *clone(const ActionGroupList &grouplist) const {
412 // if (!grouplist.contains(getGroup())) return (Rule *)0;
413 // return new RuleShiftLess(getGroup());
414 // }
415 // virtual void getOpList(vector<uint4> &oplist) const;
416 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
417 // };
418 class RuleLessEqual : public Rule {
419 public:
420  RuleLessEqual(const string &g) : Rule(g, 0, "lessequal") {}
421  virtual Rule *clone(const ActionGroupList &grouplist) const {
422  if (!grouplist.contains(getGroup())) return (Rule *)0;
423  return new RuleLessEqual(getGroup());
424  }
425  virtual void getOpList(vector<uint4> &oplist) const;
426  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
427 };
428 class RuleLessNotEqual : public Rule {
429 public:
430  RuleLessNotEqual(const string &g) : Rule(g, 0, "lessnotequal") {}
431  virtual Rule *clone(const ActionGroupList &grouplist) const {
432  if (!grouplist.contains(getGroup())) return (Rule *)0;
433  return new RuleLessNotEqual(getGroup());
434  }
435  virtual void getOpList(vector<uint4> &oplist) const;
436  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
437 };
438 class RuleTrivialArith : public Rule {
439 public:
440  RuleTrivialArith(const string &g) : Rule(g, 0, "trivialarith") {}
441  virtual Rule *clone(const ActionGroupList &grouplist) const {
442  if (!grouplist.contains(getGroup())) return (Rule *)0;
443  return new RuleTrivialArith(getGroup());
444  }
445  virtual void getOpList(vector<uint4> &oplist) const;
446  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
447 };
448 class RuleTrivialBool : public Rule {
449 public:
450  RuleTrivialBool(const string &g) : Rule(g, 0, "trivialbool") {}
451  virtual Rule *clone(const ActionGroupList &grouplist) const {
452  if (!grouplist.contains(getGroup())) return (Rule *)0;
453  return new RuleTrivialBool(getGroup());
454  }
455  virtual void getOpList(vector<uint4> &oplist) const;
456  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
457 };
458 class RuleZextEliminate : public Rule {
459 public:
460  RuleZextEliminate(const string &g) : Rule(g, 0, "zexteliminate") {}
461  virtual Rule *clone(const ActionGroupList &grouplist) const {
462  if (!grouplist.contains(getGroup())) return (Rule *)0;
463  return new RuleZextEliminate(getGroup());
464  }
465  virtual void getOpList(vector<uint4> &oplist) const;
466  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
467 };
468 class RuleSlessToLess : public Rule {
469 public:
470  RuleSlessToLess(const string &g) : Rule(g, 0, "slesstoless") {}
471  virtual Rule *clone(const ActionGroupList &grouplist) const {
472  if (!grouplist.contains(getGroup())) return (Rule *)0;
473  return new RuleSlessToLess(getGroup());
474  }
475  virtual void getOpList(vector<uint4> &oplist) const;
476  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
477 };
478 class RuleZextSless : public Rule {
479 public:
480  RuleZextSless(const string &g) : Rule(g, 0, "zextsless") {}
481  virtual Rule *clone(const ActionGroupList &grouplist) const {
482  if (!grouplist.contains(getGroup())) return (Rule *)0;
483  return new RuleZextSless(getGroup());
484  }
485  virtual void getOpList(vector<uint4> &oplist) const;
486  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
487 };
488 class RuleBitUndistribute : public Rule {
489 public:
490  RuleBitUndistribute(const string &g) : Rule(g, 0, "bitundistribute") {}
491  virtual Rule *clone(const ActionGroupList &grouplist) const {
492  if (!grouplist.contains(getGroup())) return (Rule *)0;
493  return new RuleBitUndistribute(getGroup());
494  }
495  virtual void getOpList(vector<uint4> &oplist) const;
496  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
497 };
498 class RuleBooleanNegate : public Rule {
499 public:
500  RuleBooleanNegate(const string &g) : Rule(g, 0, "booleannegate") {}
501  virtual Rule *clone(const ActionGroupList &grouplist) const {
502  if (!grouplist.contains(getGroup())) return (Rule *)0;
503  return new RuleBooleanNegate(getGroup());
504  }
505  virtual void getOpList(vector<uint4> &oplist) const;
506  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
507 };
508 class RuleBoolZext : public Rule {
509 public:
510  RuleBoolZext(const string &g) : Rule(g, 0, "boolzext") {}
511  virtual Rule *clone(const ActionGroupList &grouplist) const {
512  if (!grouplist.contains(getGroup())) return (Rule *)0;
513  return new RuleBoolZext(getGroup());
514  }
515  virtual void getOpList(vector<uint4> &oplist) const;
516  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
517 };
518 class RuleLogic2Bool : public Rule {
519 public:
520  RuleLogic2Bool(const string &g) : Rule(g, 0, "logic2bool") {}
521  virtual Rule *clone(const ActionGroupList &grouplist) const {
522  if (!grouplist.contains(getGroup())) return (Rule *)0;
523  return new RuleLogic2Bool(getGroup());
524  }
525  virtual void getOpList(vector<uint4> &oplist) const;
526  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
527 };
528 class RuleIndirectCollapse : public Rule {
529 public:
530  RuleIndirectCollapse(const string &g) : Rule(g, 0, "indirectcollapse") {}
531  virtual Rule *clone(const ActionGroupList &grouplist) const {
532  if (!grouplist.contains(getGroup())) return (Rule *)0;
533  return new RuleIndirectCollapse(getGroup());
534  }
535  virtual void getOpList(vector<uint4> &oplist) const;
536  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
537 };
538 class RuleMultiCollapse : public Rule {
539 public:
540  RuleMultiCollapse(const string &g) : Rule(g, 0, "multicollapse") {}
541  virtual Rule *clone(const ActionGroupList &grouplist) const {
542  if (!grouplist.contains(getGroup())) return (Rule *)0;
543  return new RuleMultiCollapse(getGroup());
544  }
545  virtual void getOpList(vector<uint4> &oplist) const;
546  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
547 };
548 class RuleSborrow : public Rule {
549 public:
550  RuleSborrow(const string &g) : Rule(g, 0, "sborrow") {}
551  virtual Rule *clone(const ActionGroupList &grouplist) const {
552  if (!grouplist.contains(getGroup())) return (Rule *)0;
553  return new RuleSborrow(getGroup());
554  }
555  virtual void getOpList(vector<uint4> &oplist) const;
556  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
557 };
558 class RuleTrivialShift : public Rule {
559 public:
560  RuleTrivialShift(const string &g) : Rule(g, 0, "trivialshift") {}
561  virtual Rule *clone(const ActionGroupList &grouplist) const {
562  if (!grouplist.contains(getGroup())) return (Rule *)0;
563  return new RuleTrivialShift(getGroup());
564  }
565  virtual void getOpList(vector<uint4> &oplist) const;
566  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
567 };
568 class RuleSignShift : public Rule {
569 public:
570  RuleSignShift(const string &g) : Rule(g, 0, "signshift") {}
571  virtual Rule *clone(const ActionGroupList &grouplist) const {
572  if (!grouplist.contains(getGroup())) return (Rule *)0;
573  return new RuleSignShift(getGroup());
574  }
575  virtual void getOpList(vector<uint4> &oplist) const;
576  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
577 };
578 class RuleTestSign : public Rule {
579  void findComparisons(Varnode *vn,vector<PcodeOp *> &res);
580 public:
581  RuleTestSign(const string &g) : Rule(g, 0, "testsign") {}
582  virtual Rule *clone(const ActionGroupList &grouplist) const {
583  if (!grouplist.contains(getGroup())) return (Rule *)0;
584  return new RuleTestSign(getGroup());
585  }
586  virtual void getOpList(vector<uint4> &oplist) const;
587  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
588 };
589 class RuleIdentityEl : public Rule {
590 public:
591  RuleIdentityEl(const string &g) : Rule(g, 0, "identityel") {}
592  virtual Rule *clone(const ActionGroupList &grouplist) const {
593  if (!grouplist.contains(getGroup())) return (Rule *)0;
594  return new RuleIdentityEl(getGroup());
595  }
596  virtual void getOpList(vector<uint4> &oplist) const;
597  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
598 };
599 class RuleShift2Mult : public Rule {
600 public:
601  RuleShift2Mult(const string &g) : Rule(g, 0, "shift2mult") {}
602  virtual Rule *clone(const ActionGroupList &grouplist) const {
603  if (!grouplist.contains(getGroup())) return (Rule *)0;
604  return new RuleShift2Mult(getGroup());
605  }
606  virtual void getOpList(vector<uint4> &oplist) const;
607  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
608 };
609 class RuleShiftPiece : public Rule {
610 public:
611  RuleShiftPiece(const string &g) : Rule(g, 0, "shiftpiece") {}
612  virtual Rule *clone(const ActionGroupList &grouplist) const {
613  if (!grouplist.contains(getGroup())) return (Rule *)0;
614  return new RuleShiftPiece(getGroup());
615  }
616  virtual void getOpList(vector<uint4> &oplist) const;
617  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
618 };
619 class RuleCollapseConstants : public Rule {
620 public:
621  RuleCollapseConstants(const string &g) : Rule(g, 0, "collapseconstants") {}
622  virtual Rule *clone(const ActionGroupList &grouplist) const {
623  if (!grouplist.contains(getGroup())) return (Rule *)0;
624  return new RuleCollapseConstants(getGroup());
625  }
626  // applies to all opcodes
627  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
628 };
629 class RuleTransformCpool : public Rule {
630 public:
631  RuleTransformCpool(const string &g) : Rule(g, 0, "transformcpool") {}
632  virtual Rule *clone(const ActionGroupList &grouplist) const {
633  if (!grouplist.contains(getGroup())) return (Rule *)0;
634  return new RuleTransformCpool(getGroup());
635  }
636  virtual void getOpList(vector<uint4> &oplist) const;
637  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
638 };
639 class RulePropagateCopy : public Rule {
640 public:
641  RulePropagateCopy(const string &g) : Rule(g, 0, "propagatecopy") {}
642  virtual Rule *clone(const ActionGroupList &grouplist) const {
643  if (!grouplist.contains(getGroup())) return (Rule *)0;
644  return new RulePropagateCopy(getGroup());
645  }
646  // applies to all opcodes
647  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
648 };
649 class Rule2Comp2Mult : public Rule {
650 public:
651  Rule2Comp2Mult(const string &g) : Rule(g,0,"2comp2mult") {}
652  virtual Rule *clone(const ActionGroupList &grouplist) const {
653  if (!grouplist.contains(getGroup())) return (Rule *)0;
654  return new Rule2Comp2Mult(getGroup());
655  }
656  virtual void getOpList(vector<uint4> &oplist) const;
657  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
658 };
659 class RuleCarryElim : public Rule {
660 public:
661  RuleCarryElim(const string &g) : Rule(g, 0, "carryelim") {}
662  virtual Rule *clone(const ActionGroupList &grouplist) const {
663  if (!grouplist.contains(getGroup())) return (Rule *)0;
664  return new RuleCarryElim(getGroup());
665  }
666  virtual void getOpList(vector<uint4> &oplist) const;
667  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
668 };
669 class RuleSub2Add : public Rule {
670 public:
671  RuleSub2Add(const string &g) : Rule(g, 0, "sub2add") {}
672  virtual Rule *clone(const ActionGroupList &grouplist) const {
673  if (!grouplist.contains(getGroup())) return (Rule *)0;
674  return new RuleSub2Add(getGroup());
675  }
676  virtual void getOpList(vector<uint4> &oplist) const;
677  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
678 };
679 class RuleXorCollapse : public Rule {
680 public:
681  RuleXorCollapse(const string &g) : Rule(g, 0, "xorcollapse") {}
682  virtual Rule *clone(const ActionGroupList &grouplist) const {
683  if (!grouplist.contains(getGroup())) return (Rule *)0;
684  return new RuleXorCollapse(getGroup());
685  }
686  virtual void getOpList(vector<uint4> &oplist) const;
687  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
688 };
689 class RuleAddMultCollapse : public Rule {
690 public:
691  RuleAddMultCollapse(const string &g) : Rule(g, 0, "addmultcollapse") {}
692  virtual Rule *clone(const ActionGroupList &grouplist) const {
693  if (!grouplist.contains(getGroup())) return (Rule *)0;
694  return new RuleAddMultCollapse(getGroup());
695  }
696  virtual void getOpList(vector<uint4> &oplist) const;
697  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
698 };
699 // class RuleUndistribute : public Rule {
700 // public:
701 // RuleUndistribute(const string &g) : Rule(g, 0, "undistribute") {} ///< Constructor
702 // virtual Rule *clone(const ActionGroupList &grouplist) const {
703 // if (!grouplist.contains(getGroup())) return (Rule *)0;
704 // return new RuleUndistribute(Group());
705 // }
706 // virtual void getOpList(vector<uint4> &oplist) const;
707 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
708 // };
709 class RuleLoadVarnode : public Rule {
710  friend class RuleStoreVarnode;
711  static AddrSpace *correctSpacebase(Architecture *glb,Varnode *vn,AddrSpace *spc);
712  static AddrSpace *vnSpacebase(Architecture *glb,Varnode *vn,uintb &val,AddrSpace *spc);
713  static AddrSpace *checkSpacebase(Architecture *glb,PcodeOp *op,uintb &offoff);
714 public:
715  RuleLoadVarnode(const string &g) : Rule(g, 0, "loadvarnode") {}
716  virtual Rule *clone(const ActionGroupList &grouplist) const {
717  if (!grouplist.contains(getGroup())) return (Rule *)0;
718  return new RuleLoadVarnode(getGroup());
719  }
720  virtual void getOpList(vector<uint4> &oplist) const;
721  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
722 };
723 class RuleStoreVarnode : public Rule {
724 public:
725  RuleStoreVarnode(const string &g) : Rule(g, 0, "storevarnode") {}
726  virtual Rule *clone(const ActionGroupList &grouplist) const {
727  if (!grouplist.contains(getGroup())) return (Rule *)0;
728  return new RuleStoreVarnode(getGroup());
729  }
730  virtual void getOpList(vector<uint4> &oplist) const;
731  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
732 };
733 // class RuleShadowVar : public Rule {
734 // public:
735 // RuleShadowVar(const string &g) : Rule(g, 0, "shadowvar") {} ///< Constructor
736 // virtual Rule *clone(const ActionGroupList &grouplist) const {
737 // if (!grouplist.contains(getGroup())) return (Rule *)0;
738 // return new RuleShadowVar(getGroup());
739 // }
740 // virtual void getOpList(vector<uint4> &oplist) const;
741 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
742 // };
743 class RuleSubExtComm : public Rule {
744 public:
745  RuleSubExtComm(const string &g) : Rule(g,0,"subextcomm") {}
746  virtual Rule *clone(const ActionGroupList &grouplist) const {
747  if (!grouplist.contains(getGroup())) return (Rule *)0;
748  return new RuleSubExtComm(getGroup());
749  }
750  virtual void getOpList(vector<uint4> &oplist) const;
751  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
752 };
753 class RuleSubCommute : public Rule {
754 public:
755  RuleSubCommute(const string &g) : Rule(g, 0, "subcommute") {}
756  virtual Rule *clone(const ActionGroupList &grouplist) const {
757  if (!grouplist.contains(getGroup())) return (Rule *)0;
758  return new RuleSubCommute(getGroup());
759  }
760  virtual void getOpList(vector<uint4> &oplist) const;
761  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
762  static bool cancelExtensions(PcodeOp *longform,PcodeOp *subOp,Varnode *ext0In,Varnode *ext1In,Funcdata &data);
763 };
764 class RuleConcatCommute : public Rule {
765 public:
766  RuleConcatCommute(const string &g) : Rule(g, 0, "concatcommute") {}
767  virtual Rule *clone(const ActionGroupList &grouplist) const {
768  if (!grouplist.contains(getGroup())) return (Rule *)0;
769  return new RuleConcatCommute(getGroup());
770  }
771  virtual void getOpList(vector<uint4> &oplist) const;
772  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
773 };
774 // class RuleIndirectConcat : public Rule {
775 // public:
776 // RuleIndirectConcat(const string &g) : Rule(g, 0, "indirectconcat") {} ///< Constructor
777 // virtual Rule *clone(const ActionGroupList &grouplist) const {
778 // if (!grouplist.contains(getGroup())) return (Rule *)0;
779 // return new RuleIndirectConcat(getGroup());
780 // }
781 // virtual void getOpList(vector<uint4> &oplist) const;
782 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
783 // };
784 class RuleConcatZext : public Rule {
785 public:
786  RuleConcatZext(const string &g) : Rule(g, 0, "concatzext") {}
787  virtual Rule *clone(const ActionGroupList &grouplist) const {
788  if (!grouplist.contains(getGroup())) return (Rule *)0;
789  return new RuleConcatZext(getGroup());
790  }
791  virtual void getOpList(vector<uint4> &oplist) const;
792  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
793 };
794 class RuleZextCommute : public Rule {
795 public:
796  RuleZextCommute(const string &g) : Rule(g, 0, "zextcommute") {}
797  virtual Rule *clone(const ActionGroupList &grouplist) const {
798  if (!grouplist.contains(getGroup())) return (Rule *)0;
799  return new RuleZextCommute(getGroup());
800  }
801  virtual void getOpList(vector<uint4> &oplist) const;
802  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
803 };
804 class RuleZextShiftZext : public Rule {
805 public:
806  RuleZextShiftZext(const string &g) : Rule(g, 0, "zextshiftzext") {}
807  virtual Rule *clone(const ActionGroupList &grouplist) const {
808  if (!grouplist.contains(getGroup())) return (Rule *)0;
809  return new RuleZextShiftZext(getGroup());
810  }
811  virtual void getOpList(vector<uint4> &oplist) const;
812  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
813 };
814 class RuleShiftAnd : public Rule {
815 public:
816  RuleShiftAnd(const string &g) : Rule(g, 0, "shiftand") {}
817  virtual Rule *clone(const ActionGroupList &grouplist) const {
818  if (!grouplist.contains(getGroup())) return (Rule *)0;
819  return new RuleShiftAnd(getGroup());
820  }
821  virtual void getOpList(vector<uint4> &oplist) const;
822  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
823 };
824 class RuleConcatZero : public Rule {
825 public:
826  RuleConcatZero(const string &g) : Rule(g, 0, "concatzero") {}
827  virtual Rule *clone(const ActionGroupList &grouplist) const {
828  if (!grouplist.contains(getGroup())) return (Rule *)0;
829  return new RuleConcatZero(getGroup());
830  }
831  virtual void getOpList(vector<uint4> &oplist) const;
832  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
833 };
834 class RuleConcatLeftShift : public Rule {
835 public:
836  RuleConcatLeftShift(const string &g) : Rule(g, 0, "concatleftshift") {}
837  virtual Rule *clone(const ActionGroupList &grouplist) const {
838  if (!grouplist.contains(getGroup())) return (Rule *)0;
839  return new RuleConcatLeftShift(getGroup());
840  }
841  virtual void getOpList(vector<uint4> &oplist) const;
842  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
843 };
844 class RuleSubZext : public Rule {
845 public:
846  RuleSubZext(const string &g) : Rule(g, 0, "subzext") {}
847  virtual Rule *clone(const ActionGroupList &grouplist) const {
848  if (!grouplist.contains(getGroup())) return (Rule *)0;
849  return new RuleSubZext(getGroup());
850  }
851  virtual void getOpList(vector<uint4> &oplist) const;
852  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
853 };
854 class RuleSubCancel : public Rule {
855 public:
856  RuleSubCancel(const string &g) : Rule(g, 0, "subcancel") {}
857  virtual Rule *clone(const ActionGroupList &grouplist) const {
858  if (!grouplist.contains(getGroup())) return (Rule *)0;
859  return new RuleSubCancel(getGroup());
860  }
861  virtual void getOpList(vector<uint4> &oplist) const;
862  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
863 };
864 class RuleShiftSub : public Rule {
865 public:
866  RuleShiftSub(const string &g) : Rule(g, 0, "shiftsub") {}
867  virtual Rule *clone(const ActionGroupList &grouplist) const {
868  if (!grouplist.contains(getGroup())) return (Rule *)0;
869  return new RuleShiftSub(getGroup());
870  }
871  virtual void getOpList(vector<uint4> &oplist) const;
872  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
873 };
874 class RuleHumptyDumpty : public Rule {
875 public:
876  RuleHumptyDumpty(const string &g) : Rule(g, 0, "humptydumpty") {}
877  virtual Rule *clone(const ActionGroupList &grouplist) const {
878  if (!grouplist.contains(getGroup())) return (Rule *)0;
879  return new RuleHumptyDumpty(getGroup());
880  }
881  virtual void getOpList(vector<uint4> &oplist) const;
882  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
883 };
884 class RuleDumptyHump : public Rule {
885 public:
886  RuleDumptyHump(const string &g) : Rule(g, 0, "dumptyhump") {}
887  virtual Rule *clone(const ActionGroupList &grouplist) const {
888  if (!grouplist.contains(getGroup())) return (Rule *)0;
889  return new RuleDumptyHump(getGroup());
890  }
891  virtual void getOpList(vector<uint4> &oplist) const;
892  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
893 };
894 class RuleHumptyOr : public Rule {
895 public:
896  RuleHumptyOr(const string &g) : Rule(g, 0, "humptyor") {}
897  virtual Rule *clone(const ActionGroupList &grouplist) const {
898  if (!grouplist.contains(getGroup())) return (Rule *)0;
899  return new RuleHumptyOr(getGroup());
900  }
901  virtual void getOpList(vector<uint4> &oplist) const;
902  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
903 };
904 class RuleEmbed : public Rule {
905 public:
906  RuleEmbed(const string &g) : Rule(g, 0, "embed") {}
907  virtual Rule *clone(const ActionGroupList &grouplist) const {
908  if (!grouplist.contains(getGroup())) return (Rule *)0;
909  return new RuleEmbed(getGroup());
910  }
911  virtual void getOpList(vector<uint4> &oplist) const;
912  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
913 };
914 class RuleSwitchSingle : public Rule {
915 public:
916  RuleSwitchSingle(const string &g) : Rule(g,0,"switchsingle") {}
917  virtual Rule *clone(const ActionGroupList &grouplist) const {
918  if (!grouplist.contains(getGroup())) return (Rule *)0;
919  return new RuleSwitchSingle(getGroup());
920  }
921  virtual void getOpList(vector<uint4> &oplist) const;
922  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
923 };
924 class RuleCondNegate : public Rule {
925 public:
926  RuleCondNegate(const string &g) : Rule(g, 0, "condnegate") {}
927  virtual Rule *clone(const ActionGroupList &grouplist) const {
928  if (!grouplist.contains(getGroup())) return (Rule *)0;
929  return new RuleCondNegate(getGroup());
930  }
931  virtual void getOpList(vector<uint4> &oplist) const;
932  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
933 };
934 class RuleBoolNegate : public Rule {
935 public:
936  RuleBoolNegate(const string &g) : Rule(g, 0, "boolnegate") {}
937  virtual Rule *clone(const ActionGroupList &grouplist) const {
938  if (!grouplist.contains(getGroup())) return (Rule *)0;
939  return new RuleBoolNegate(getGroup());
940  }
941  virtual void getOpList(vector<uint4> &oplist) const;
942  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
943 };
944 class RuleLess2Zero : public Rule {
945 public:
946  RuleLess2Zero(const string &g) : Rule(g, 0, "less2zero") {}
947  virtual Rule *clone(const ActionGroupList &grouplist) const {
948  if (!grouplist.contains(getGroup())) return (Rule *)0;
949  return new RuleLess2Zero(getGroup());
950  }
951  virtual void getOpList(vector<uint4> &oplist) const;
952  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
953 };
954 class RuleLessEqual2Zero : public Rule {
955 public:
956  RuleLessEqual2Zero(const string &g) : Rule(g, 0, "lessequal2zero") {}
957  virtual Rule *clone(const ActionGroupList &grouplist) const {
958  if (!grouplist.contains(getGroup())) return (Rule *)0;
959  return new RuleLessEqual2Zero(getGroup());
960  }
961  virtual void getOpList(vector<uint4> &oplist) const;
962  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
963 };
964 class RuleSLess2Zero : public Rule {
965  static Varnode *getHiBit(PcodeOp *op);
966 public:
967  RuleSLess2Zero(const string &g) : Rule(g, 0, "sless2zero") {}
968  virtual Rule *clone(const ActionGroupList &grouplist) const {
969  if (!grouplist.contains(getGroup())) return (Rule *)0;
970  return new RuleSLess2Zero(getGroup());
971  }
972  virtual void getOpList(vector<uint4> &oplist) const;
973  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
974 };
975 class RuleEqual2Zero : public Rule {
976 public:
977  RuleEqual2Zero(const string &g) : Rule(g, 0, "equal2zero") {}
978  virtual Rule *clone(const ActionGroupList &grouplist) const {
979  if (!grouplist.contains(getGroup())) return (Rule *)0;
980  return new RuleEqual2Zero(getGroup());
981  }
982  virtual void getOpList(vector<uint4> &oplist) const;
983  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
984 };
985 class RuleEqual2Constant : public Rule {
986 public:
987  RuleEqual2Constant(const string &g) : Rule(g, 0, "equal2constant") {}
988  virtual Rule *clone(const ActionGroupList &grouplist) const {
989  if (!grouplist.contains(getGroup())) return (Rule *)0;
990  return new RuleEqual2Constant(getGroup());
991  }
992  virtual void getOpList(vector<uint4> &oplist) const;
993  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
994 };
995 class RulePtrArith : public Rule {
996  static bool checkTerm(Varnode *vn,AddTreeState *state);
997  static bool spanAddTree(PcodeOp *op,AddTreeState *state);
998  static int4 transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Funcdata &data);
999 public:
1000  RulePtrArith(const string &g) : Rule(g, 0, "ptrarith") {}
1001  virtual Rule *clone(const ActionGroupList &grouplist) const {
1002  if (!grouplist.contains(getGroup())) return (Rule *)0;
1003  return new RulePtrArith(getGroup());
1004  }
1005  virtual void getOpList(vector<uint4> &oplist) const;
1006  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1007 };
1008 class RuleStructOffset0 : public Rule {
1009 public:
1010  RuleStructOffset0(const string &g) : Rule(g, 0, "structoffset0") {}
1011  virtual Rule *clone(const ActionGroupList &grouplist) const {
1012  if (!grouplist.contains(getGroup())) return (Rule *)0;
1013  return new RuleStructOffset0(getGroup());
1014  }
1015  virtual void getOpList(vector<uint4> &oplist) const;
1016  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1017 };
1018 class RulePushPtr : public Rule {
1019 public:
1020  RulePushPtr(const string &g) : Rule(g, 0, "pushptr") {}
1021  virtual Rule *clone(const ActionGroupList &grouplist) const {
1022  if (!grouplist.contains(getGroup())) return (Rule *)0;
1023  return new RulePushPtr(getGroup());
1024  }
1025  virtual void getOpList(vector<uint4> &oplist) const;
1026  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1027 };
1028 class RulePtraddUndo : public Rule {
1029 public:
1030  RulePtraddUndo(const string &g) : Rule(g, 0, "ptraddundo") {}
1031  virtual Rule *clone(const ActionGroupList &grouplist) const {
1032  if (!grouplist.contains(getGroup())) return (Rule *)0;
1033  return new RulePtraddUndo(getGroup());
1034  }
1035  virtual void getOpList(vector<uint4> &oplist) const;
1036  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1037 };
1038 class RulePtrsubUndo : public Rule {
1039 public:
1040  RulePtrsubUndo(const string &g) : Rule(g, 0, "ptrsubundo") {}
1041  virtual Rule *clone(const ActionGroupList &grouplist) const {
1042  if (!grouplist.contains(getGroup())) return (Rule *)0;
1043  return new RulePtrsubUndo(getGroup());
1044  }
1045  virtual void getOpList(vector<uint4> &oplist) const;
1046  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1047 };
1048 
1049 // Cleanup rules
1050 class RuleMultNegOne : public Rule {
1051 public:
1052  RuleMultNegOne(const string &g) : Rule( g, 0, "multnegone") {}
1053  virtual Rule *clone(const ActionGroupList &grouplist) const {
1054  if (!grouplist.contains(getGroup())) return (Rule *)0;
1055  return new RuleMultNegOne(getGroup());
1056  }
1057  virtual void getOpList(vector<uint4> &oplist) const;
1058  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1059 };
1060 
1061 class RuleAddUnsigned : public Rule {
1062 public:
1063  RuleAddUnsigned(const string &g) : Rule( g, 0, "addunsigned") {}
1064  virtual Rule *clone(const ActionGroupList &grouplist) const {
1065  if (!grouplist.contains(getGroup())) return (Rule *)0;
1066  return new RuleAddUnsigned(getGroup());
1067  }
1068  virtual void getOpList(vector<uint4> &oplist) const;
1069  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1070 };
1071 
1072 class Rule2Comp2Sub : public Rule {
1073 public:
1074  Rule2Comp2Sub(const string &g) : Rule( g, 0, "2comp2sub") {}
1075  virtual Rule *clone(const ActionGroupList &grouplist) const {
1076  if (!grouplist.contains(getGroup())) return (Rule *)0;
1077  return new Rule2Comp2Sub(getGroup());
1078  }
1079  virtual void getOpList(vector<uint4> &oplist) const;
1080  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1081 };
1082 
1083 class RuleSubRight : public Rule {
1084 public:
1085  RuleSubRight(const string &g) : Rule( g, 0, "subright") {}
1086  virtual Rule *clone(const ActionGroupList &grouplist) const {
1087  if (!grouplist.contains(getGroup())) return (Rule *)0;
1088  return new RuleSubRight(getGroup());
1089  }
1090  virtual void getOpList(vector<uint4> &oplist) const;
1091  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1092 };
1093 
1095  bool pushConstFurther(Funcdata &data,TypePointer *outtype,PcodeOp *op,int4 slot,uintb val);
1096 public:
1097  RulePtrsubCharConstant(const string &g) : Rule( g, 0, "ptrsubcharconstant") {}
1098  virtual Rule *clone(const ActionGroupList &grouplist) const {
1099  if (!grouplist.contains(getGroup())) return (Rule *)0;
1100  return new RulePtrsubCharConstant(getGroup());
1101  }
1102  virtual void getOpList(vector<uint4> &oplist) const;
1103  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1104 };
1105 
1106 class RuleSubNormal : public Rule {
1107 public:
1108  RuleSubNormal(const string &g) : Rule( g, 0, "subnormal") {}
1109  virtual Rule *clone(const ActionGroupList &grouplist) const {
1110  if (!grouplist.contains(getGroup())) return (Rule *)0;
1111  return new RuleSubNormal(getGroup());
1112  }
1113  virtual void getOpList(vector<uint4> &oplist) const;
1114  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1115 };
1116 
1117 // class RuleRightShiftSub : public Rule {
1118 // public:
1119 // RuleRightShiftSub(const string &g) : Rule( g, 0, "rightshiftsub") {} ///< Constructor
1120 // virtual Rule *clone(const ActionGroupList &grouplist) const {
1121 // if (!grouplist.contains(getGroup())) return (Rule *)0;
1122 // return new RuleRightShiftSub(Group());
1123 // }
1124 // virtual void getOpList(vector<uint4> &oplist) const;
1125 // virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1126 // };
1127 
1128 class RulePositiveDiv : public Rule {
1129 public:
1130  RulePositiveDiv(const string &g) : Rule( g, 0, "positivediv") {}
1131  virtual Rule *clone(const ActionGroupList &grouplist) const {
1132  if (!grouplist.contains(getGroup())) return (Rule *)0;
1133  return new RulePositiveDiv(getGroup());
1134  }
1135  virtual void getOpList(vector<uint4> &oplist) const;
1136  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1137 };
1138 
1139 class RuleDivTermAdd : public Rule {
1140 public:
1141  RuleDivTermAdd(const string &g) : Rule( g, 0, "divtermadd") {}
1142  virtual Rule *clone(const ActionGroupList &grouplist) const {
1143  if (!grouplist.contains(getGroup())) return (Rule *)0;
1144  return new RuleDivTermAdd(getGroup());
1145  }
1146  virtual void getOpList(vector<uint4> &oplist) const;
1147  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1148  static PcodeOp *findSubshift(PcodeOp *op,int4 &n,OpCode &shiftopc);
1149 };
1150 
1151 class RuleDivTermAdd2 : public Rule {
1152 public:
1153  RuleDivTermAdd2(const string &g) : Rule( g, 0, "divtermadd2") {}
1154  virtual Rule *clone(const ActionGroupList &grouplist) const {
1155  if (!grouplist.contains(getGroup())) return (Rule *)0;
1156  return new RuleDivTermAdd2(getGroup());
1157  }
1158  virtual void getOpList(vector<uint4> &oplist) const;
1159  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1160 };
1161 
1162 class RuleDivOpt : public Rule {
1163  static uintb calcDivisor(uintb n,uint8 y,int4 xsize);
1164  static void moveSignBitExtraction(Varnode *firstVn,Varnode *replaceVn,Funcdata &data);
1165 public:
1166  RuleDivOpt(const string &g) : Rule( g, 0, "divopt") {}
1167  virtual Rule *clone(const ActionGroupList &grouplist) const {
1168  if (!grouplist.contains(getGroup())) return (Rule *)0;
1169  return new RuleDivOpt(getGroup());
1170  }
1171  virtual void getOpList(vector<uint4> &oplist) const;
1172  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1173  static Varnode *findForm(PcodeOp *op,int4 &n,uintb &y,int4 &xsize,OpCode &extopc);
1174 };
1175 
1176 class RuleSignDiv2 : public Rule {
1177 public:
1178  RuleSignDiv2(const string &g) : Rule( g, 0, "signdiv2") {}
1179  virtual Rule *clone(const ActionGroupList &grouplist) const {
1180  if (!grouplist.contains(getGroup())) return (Rule *)0;
1181  return new RuleSignDiv2(getGroup());
1182  }
1183  virtual void getOpList(vector<uint4> &oplist) const;
1184  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1185 };
1186 
1187 class RuleSignForm : public Rule {
1188 public:
1189  RuleSignForm(const string &g) : Rule( g, 0, "signform") {}
1190  virtual Rule *clone(const ActionGroupList &grouplist) const {
1191  if (!grouplist.contains(getGroup())) return (Rule *)0;
1192  return new RuleSignForm(getGroup());
1193  }
1194  virtual void getOpList(vector<uint4> &oplist) const;
1195  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1196 };
1197 
1198 class RuleSignNearMult : public Rule {
1199 public:
1200  RuleSignNearMult(const string &g) : Rule( g, 0, "signnearmult") {}
1201  virtual Rule *clone(const ActionGroupList &grouplist) const {
1202  if (!grouplist.contains(getGroup())) return (Rule *)0;
1203  return new RuleSignNearMult(getGroup());
1204  }
1205  virtual void getOpList(vector<uint4> &oplist) const;
1206  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1207 };
1208 
1209 class RuleModOpt: public Rule {
1210 public:
1211  RuleModOpt(const string &g) : Rule( g, 0, "modopt") {}
1212  virtual Rule *clone(const ActionGroupList &grouplist) const {
1213  if (!grouplist.contains(getGroup())) return (Rule *)0;
1214  return new RuleModOpt(getGroup());
1215  }
1216  virtual void getOpList(vector<uint4> &oplist) const;
1217  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1218 };
1219 
1220 class RuleSegment : public Rule {
1221 public:
1222  RuleSegment(const string &g) : Rule( g, 0, "segment") {}
1223  virtual Rule *clone(const ActionGroupList &grouplist) const {
1224  if (!grouplist.contains(getGroup())) return (Rule *)0;
1225  return new RuleSegment(getGroup());
1226  }
1227  virtual void getOpList(vector<uint4> &oplist) const;
1228  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1229 };
1230 
1231 class RuleSubvarAnd : public Rule {
1232 public:
1233  RuleSubvarAnd(const string &g) : Rule( g, 0, "subvar_and") {}
1234  virtual Rule *clone(const ActionGroupList &grouplist) const {
1235  if (!grouplist.contains(getGroup())) return (Rule *)0;
1236  return new RuleSubvarAnd(getGroup());
1237  }
1238  virtual void getOpList(vector<uint4> &oplist) const;
1239  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1240 };
1241 
1242 class RuleSubvarSubpiece : public Rule {
1243 public:
1244  RuleSubvarSubpiece(const string &g) : Rule( g, 0, "subvar_subpiece") {}
1245  virtual Rule *clone(const ActionGroupList &grouplist) const {
1246  if (!grouplist.contains(getGroup())) return (Rule *)0;
1247  return new RuleSubvarSubpiece(getGroup());
1248  }
1249  virtual void getOpList(vector<uint4> &oplist) const;
1250  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1251 };
1252 
1253 class RuleSplitFlow : public Rule {
1254 public:
1255  RuleSplitFlow(const string &g) : Rule( g, 0, "splitflow") {}
1256  virtual Rule *clone(const ActionGroupList &grouplist) const {
1257  if (!grouplist.contains(getGroup())) return (Rule *)0;
1258  return new RuleSplitFlow(getGroup());
1259  }
1260  virtual void getOpList(vector<uint4> &oplist) const;
1261  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1262 };
1263 
1264 class RulePtrFlow : public Rule {
1265  Architecture *glb;
1266  bool hasTruncations;
1267  bool trialSetPtrFlow(PcodeOp *op);
1268  bool propagateFlowToDef(Varnode *vn);
1269  bool propagateFlowToReads(Varnode *vn);
1270  Varnode *truncatePointer(AddrSpace *spc,PcodeOp *op,Varnode *vn,int4 slot,Funcdata &data);
1271 public:
1272  RulePtrFlow(const string &g,Architecture *conf);
1273  virtual Rule *clone(const ActionGroupList &grouplist) const {
1274  if (!grouplist.contains(getGroup())) return (Rule *)0;
1275  return new RulePtrFlow(getGroup(),glb);
1276  }
1277  virtual void getOpList(vector<uint4> &oplist) const;
1278  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1279 };
1280 
1281 class RuleSubvarCompZero : public Rule {
1282 public:
1283  RuleSubvarCompZero(const string &g) : Rule( g, 0, "subvar_compzero") {}
1284  virtual Rule *clone(const ActionGroupList &grouplist) const {
1285  if (!grouplist.contains(getGroup())) return (Rule *)0;
1286  return new RuleSubvarCompZero(getGroup());
1287  }
1288  virtual void getOpList(vector<uint4> &oplist) const;
1289  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1290 };
1291 
1292 class RuleSubvarShift : public Rule {
1293 public:
1294  RuleSubvarShift(const string &g) : Rule( g, 0, "subvar_shift") {}
1295  virtual Rule *clone(const ActionGroupList &grouplist) const {
1296  if (!grouplist.contains(getGroup())) return (Rule *)0;
1297  return new RuleSubvarShift(getGroup());
1298  }
1299  virtual void getOpList(vector<uint4> &oplist) const;
1300  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1301 };
1302 
1303 class RuleSubvarZext : public Rule {
1304 public:
1305  RuleSubvarZext(const string &g) : Rule( g, 0, "subvar_zext") {}
1306  virtual Rule *clone(const ActionGroupList &grouplist) const {
1307  if (!grouplist.contains(getGroup())) return (Rule *)0;
1308  return new RuleSubvarZext(getGroup());
1309  }
1310  virtual void getOpList(vector<uint4> &oplist) const;
1311  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1312 };
1313 
1314 class RuleSubvarSext : public Rule {
1315  int4 isaggressive;
1316 public:
1317  RuleSubvarSext(const string &g) : Rule( g, 0, "subvar_sext") { isaggressive = false; }
1318  virtual Rule *clone(const ActionGroupList &grouplist) const {
1319  if (!grouplist.contains(getGroup())) return (Rule *)0;
1320  return new RuleSubvarSext(getGroup());
1321  }
1322  virtual void getOpList(vector<uint4> &oplist) const;
1323  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1324  virtual void reset(Funcdata &data);
1325 };
1326 
1327 class RuleSubfloatConvert : public Rule {
1328 public:
1329  RuleSubfloatConvert(const string &g) : Rule( g, 0, "subfloat_convert") {}
1330  virtual Rule *clone(const ActionGroupList &grouplist) const {
1331  if (!grouplist.contains(getGroup())) return (Rule *)0;
1332  return new RuleSubfloatConvert(getGroup());
1333  }
1334  virtual void getOpList(vector<uint4> &oplist) const;
1335  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1336 };
1337 
1338 class RuleNegateNegate : public Rule {
1339 public:
1340  RuleNegateNegate(const string &g) : Rule( g, 0, "negatenegate") {}
1341  virtual Rule *clone(const ActionGroupList &grouplist) const {
1342  if (!grouplist.contains(getGroup())) return (Rule *)0;
1343  return new RuleNegateNegate(getGroup());
1344  }
1345  virtual void getOpList(vector<uint4> &oplist) const;
1346  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1347 };
1348 
1349 class RuleConditionalMove : public Rule {
1351  class BoolExpress {
1352  int4 optype;
1353  OpCode opc;
1354  PcodeOp *op;
1355  uintb val;
1356  Varnode *in0;
1357  Varnode *in1;
1358  bool mustreconstruct;
1359  public:
1360  bool isConstant(void) const { return (optype==0); }
1361  uintb getVal(void) const { return val; }
1362  bool initialize(Varnode *vn);
1363  bool evaluatePropagation(FlowBlock *root,FlowBlock *branch);
1364  Varnode *constructBool(PcodeOp *insertop,Funcdata &data);
1365  };
1366  static Varnode *constructNegate(Varnode *vn,PcodeOp *op,Funcdata &data);
1367 public:
1368  RuleConditionalMove(const string &g) : Rule( g, 0, "conditionalmove") {}
1369  virtual Rule *clone(const ActionGroupList &grouplist) const {
1370  if (!grouplist.contains(getGroup())) return (Rule *)0;
1371  return new RuleConditionalMove(getGroup());
1372  }
1373  virtual void getOpList(vector<uint4> &oplist) const;
1374  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1375 };
1376 
1377 class RuleFloatCast : public Rule {
1378 public:
1379  RuleFloatCast(const string &g) : Rule( g, 0, "floatcast") {}
1380  virtual Rule *clone(const ActionGroupList &grouplist) const {
1381  if (!grouplist.contains(getGroup())) return (Rule *)0;
1382  return new RuleFloatCast(getGroup());
1383  }
1384  virtual void getOpList(vector<uint4> &oplist) const;
1385  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1386 };
1387 
1388 class RuleIgnoreNan : public Rule {
1389 public:
1390  RuleIgnoreNan(const string &g) : Rule( g, 0, "ignorenan") {}
1391  virtual Rule *clone(const ActionGroupList &grouplist) const {
1392  if (!grouplist.contains(getGroup())) return (Rule *)0;
1393  return new RuleIgnoreNan(getGroup());
1394  }
1395  virtual void getOpList(vector<uint4> &oplist) const;
1396  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1397 };
1398 
1399 class RuleFuncPtrEncoding : public Rule {
1400 public:
1401  RuleFuncPtrEncoding(const string &g) : Rule( g, 0, "funcptrencoding") {}
1402  virtual Rule *clone(const ActionGroupList &grouplist) const {
1403  if (!grouplist.contains(getGroup())) return (Rule *)0;
1404  return new RuleFuncPtrEncoding(getGroup());
1405  }
1406  virtual void getOpList(vector<uint4> &oplist) const;
1407  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1408 };
1409 
1410 class RuleThreeWayCompare : public Rule {
1411 public:
1412  RuleThreeWayCompare(const string &g) : Rule( g, 0, "threewaycomp") {}
1413  virtual Rule *clone(const ActionGroupList &grouplist) const {
1414  if (!grouplist.contains(getGroup())) return (Rule *)0;
1415  return new RuleThreeWayCompare(getGroup());
1416  }
1417  virtual void getOpList(vector<uint4> &oplist) const;
1418  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1419  static PcodeOp *detectThreeWay(PcodeOp *op,bool &isPartial);
1420  static int4 testCompareEquivalence(PcodeOp *lessop,PcodeOp *lessequalop);
1421 };
1422 
1423 class RulePopcountBoolXor : public Rule {
1424 public:
1425  RulePopcountBoolXor(const string &g) : Rule( g, 0, "popcountboolxor") {}
1426  virtual Rule *clone(const ActionGroupList &grouplist) const {
1427  if (!grouplist.contains(getGroup())) return (Rule *)0;
1428  return new RulePopcountBoolXor(getGroup());
1429  }
1430  virtual void getOpList(vector<uint4> &oplist) const;
1431  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1432  static Varnode *getBooleanResult(Varnode *vn,int4 bitPos,int4 &constRes);
1433 };
1434 
1435 class RulePiecePathology : public Rule {
1436  static bool isPathology(Varnode *vn,Funcdata &data);
1437  static int4 tracePathologyForward(PcodeOp *op,Funcdata &data);
1438 public:
1439  RulePiecePathology(const string &g) : Rule( g, 0, "piecepathology") {}
1440  virtual Rule *clone(const ActionGroupList &grouplist) const {
1441  if (!grouplist.contains(getGroup())) return (Rule *)0;
1442  return new RulePiecePathology(getGroup());
1443  }
1444  virtual void getOpList(vector<uint4> &oplist) const;
1445  virtual int4 applyOp(PcodeOp *op,Funcdata &data);
1446 };
1447 #endif
Propagate constants through a SEGMENTOP.
Definition: ruleaction.hh:1220
RuleTestSign(const string &g)
Constructor.
Definition: ruleaction.hh:581
RuleShift2Mult(const string &g)
Constructor.
Definition: ruleaction.hh:601
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1031
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:937
A region where processor data is stored.
Definition: space.hh:73
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:261
vector< uintb > coeff
Associated constant multiple.
Definition: ruleaction.hh:36
Perform SubfloatFlow analysis triggered by FLOAT_FLOAT2FLOAT.
Definition: ruleaction.hh:1327
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1330
RuleXorCollapse(const string &g)
Constructor.
Definition: ruleaction.hh:681
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:164
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
Collapse MULTIEQUAL whose inputs all trace to the same value.
Definition: ruleaction.hh:538
Concatenation with sign bits becomes an extension: concat( V s>> #0x1f , V) => sext(V) ...
Definition: ruleaction.hh:91
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:947
Simplify various conditional move situations.
Definition: ruleaction.hh:1349
RuleConditionalMove(const string &g)
Constructor.
Definition: ruleaction.hh:1368
Cleanup: Convert INT_ADD back to INT_SUB: V + -W ==> V - W
Definition: ruleaction.hh:1072
RuleSubvarCompZero(const string &g)
Constructor.
Definition: ruleaction.hh:1283
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:341
RulePopcountBoolXor(const string &g)
Constructor.
Definition: ruleaction.hh:1425
RuleBoolZext(const string &g)
Constructor.
Definition: ruleaction.hh:510
RuleDivOpt(const string &g)
Constructor.
Definition: ruleaction.hh:1166
uintb multsum
Sum of multiple constants.
Definition: ruleaction.hh:38
Look for common sub-expressions (built out of a restricted set of ops)
Definition: ruleaction.hh:71
Cleanup: Convert INT_ADD of constants to INT_SUB: V + 0xff... => V - 0x00...
Definition: ruleaction.hh:1061
RuleLessEqual2Zero(const string &g)
Constructor.
Definition: ruleaction.hh:956
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:225
Simplify join and break apart: sub( concat(V,W), c) => sub(W,c)
Definition: ruleaction.hh:884
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
RuleDoubleSub(const string &g)
Constructor.
Definition: ruleaction.hh:350
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:551
RuleSubExtComm(const string &g)
Constructor.
Definition: ruleaction.hh:745
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1064
Rule2Comp2Sub(const string &g)
Constructor.
Definition: ruleaction.hh:1074
RuleEqual2Zero(const string &g)
Constructor.
Definition: ruleaction.hh:977
int4 size
Size of ptr type in question.
Definition: ruleaction.hh:34
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:837
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:154
Collapse constants in an additive or multiplicative expression.
Definition: ruleaction.hh:689
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1234
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:501
Simplify INT_RIGHT canceling PIECE: concat(V,W) >> c => zext(V)
Definition: ruleaction.hh:378
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1053
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1190
The list of groups defining a root Action.
Definition: action.hh:29
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:94
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:592
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1075
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1179
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1426
Apply a set of identities involving BOOL_NEGATE.
Definition: ruleaction.hh:934
RulePushMulti(const string &g)
Constructor.
Definition: ruleaction.hh:250
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:371
Commute PIECE with INT_AND, INT_OR, and INT_XOR.
Definition: ruleaction.hh:764
RuleShiftCompare(const string &g)
Constructor.
Definition: ruleaction.hh:400
Simplify break and rejoin: concat( sub(V,c), sub(V,0) ) => V
Definition: ruleaction.hh:874
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1318
RuleSegment(const string &g)
Constructor.
Definition: ruleaction.hh:1222
RuleConcatShift(const string &g)
Constructor.
Definition: ruleaction.hh:380
Try to detect and split artificially joined Varnodes.
Definition: ruleaction.hh:1253
Container for data structures associated with a single function.
Definition: funcdata.hh:45
RuleNotDistribute(const string &g)
Constructor.
Definition: ruleaction.hh:260
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:652
Treat FLOAT_NAN as always evaluating to false.
Definition: ruleaction.hh:1388
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:46
RuleCollectTerms(const string &g)
Constructor.
Definition: ruleaction.hh:63
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:978
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:582
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1212
Simplify another expression associated with optimized division.
Definition: ruleaction.hh:1151
RuleSubfloatConvert(const string &g)
Constructor.
Definition: ruleaction.hh:1329
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:291
Simplify INT_LESSEQUAL applied to extremal constants.
Definition: ruleaction.hh:954
Datatype object representing a pointer.
Definition: type.hh:219
Simplify INT_LESSEQUAL && INT_NOTEQUAL: V <= W && V != W => V < W
Definition: ruleaction.hh:428
RuleHighOrderAnd(const string &g)
Constructor.
Definition: ruleaction.hh:270
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:511
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:847
Commute INT_AND with INT_LEFT and INT_RIGHT: (V << W) & d => (V & (W >> c)) << c
Definition: ruleaction.hh:318
Cleanup: Convert truncation to cast: sub(V,c) => sub(V>>c*8,0)
Definition: ruleaction.hh:1083
RuleOrCollapse(const string &g)
Constructor.
Definition: ruleaction.hh:143
Order the inputs to commutative operations.
Definition: ruleaction.hh:212
Eliminate any INT_AND when the bits it zeroes out are discarded by a shift.
Definition: ruleaction.hh:814
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:251
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:907
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:301
RuleBitUndistribute(const string &g)
Constructor.
Definition: ruleaction.hh:490
RuleLogic2Bool(const string &g)
Constructor.
Definition: ruleaction.hh:520
Remove a CPUI_INDIRECT if its blocking PcodeOp is dead.
Definition: ruleaction.hh:528
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1167
RuleSubvarShift(const string &g)
Constructor.
Definition: ruleaction.hh:1294
Commute INT_ZEXT with INT_RIGHT: zext(V) >> W => zext(V >> W)
Definition: ruleaction.hh:794
Simplify INT_SLESS applied to 0 or -1.
Definition: ruleaction.hh:964
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:662
Transform shifts in comparisons: V >> c == d => V == (d << c)
Definition: ruleaction.hh:398
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1440
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:491
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
RuleConcatLeftShift(const string &g)
Constructor.
Definition: ruleaction.hh:836
RuleDoubleShift(const string &g)
Constructor.
Definition: ruleaction.hh:360
Collapse operations using identity element: V + 0 => V
Definition: ruleaction.hh:589
RuleThreeWayCompare(const string &g)
Constructor.
Definition: ruleaction.hh:1412
RuleOrConsume(const string &g)
Constructor.
Definition: ruleaction.hh:133
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:672
Cleanup: Convert INT_2COMP from INT_MULT: V * -1 => -V
Definition: ruleaction.hh:1050
Convert INT_MULT and shift forms into INT_DIV or INT_SDIV.
Definition: ruleaction.hh:1162
RuleAndOrLump(const string &g)
Constructor.
Definition: ruleaction.hh:153
RuleAndCommute(const string &g)
Constructor.
Definition: ruleaction.hh:320
RuleAndPiece(const string &g)
Constructor.
Definition: ruleaction.hh:330
RulePiecePathology(const string &g)
Constructor.
Definition: ruleaction.hh:1439
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:642
Merge range conditions of the form: V s< c, c s< V, V == c, V != c
Definition: ruleaction.hh:298
Apply INT_NEGATE identities: V & ~V => #0, V | ~V -> #-1
Definition: ruleaction.hh:161
RuleAndCompare(const string &g)
Constructor.
Definition: ruleaction.hh:340
RuleRightShiftAnd(const string &g)
Constructor.
Definition: ruleaction.hh:183
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:622
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:561
Perform SubvariableFlow analysis triggered by INT_ZEXT.
Definition: ruleaction.hh:1303
RuleShiftBitops(const string &g)
Constructor.
Definition: ruleaction.hh:173
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:381
RuleSwitchSingle(const string &g)
Constructor.
Definition: ruleaction.hh:916
Transform pointer arithmetic.
Definition: ruleaction.hh:995
virtual void getOpList(vector< uint4 > &oplist) const
List of op codes this rule operates on.
Definition: ruleaction.cc:3974
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1154
Simplify boolean expressions of the form zext(V) * -1.
Definition: ruleaction.hh:508
RuleOrMask(const string &g)
Constructor.
Definition: ruleaction.hh:113
RuleFloatCast(const string &g)
Constructor.
Definition: ruleaction.hh:1379
Simplify INT_LESS applied to extremal constants.
Definition: ruleaction.hh:944
RuleLessEqual(const string &g)
Constructor.
Definition: ruleaction.hh:420
Simplify PIECE intended as embedding: concat(V, sub(W,0)) => W & 0xff | (zext(W) << 8) ...
Definition: ruleaction.hh:904
RuleAndDistribute(const string &g)
Constructor.
Definition: ruleaction.hh:280
RuleTrivialArith(const string &g)
Constructor.
Definition: ruleaction.hh:440
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1131
RulePushPtr(const string &g)
Constructor.
Definition: ruleaction.hh:1020
RuleHumptyDumpty(const string &g)
Constructor.
Definition: ruleaction.hh:876
RuleZextSless(const string &g)
Constructor.
Definition: ruleaction.hh:480
Simplify &#39;less than or equal&#39;: V < W || V == W => V <= W
Definition: ruleaction.hh:418
RulePositiveDiv(const string &g)
Constructor.
Definition: ruleaction.hh:1130
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:114
RuleSubCancel(const string &g)
Constructor.
Definition: ruleaction.hh:856
Collapse constant expressions.
Definition: ruleaction.hh:619
RuleLeftRight(const string &g)
Constructor.
Definition: ruleaction.hh:390
Collapse INT_EQUAL and INT_NOTEQUAL: f(V,W) == f(V,W) => true
Definition: ruleaction.hh:201
RuleSubvarSext(const string &g)
Constructor.
Definition: ruleaction.hh:1317
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:481
Simplify expressions that optimize INT_REM and INT_SREM.
Definition: ruleaction.hh:1209
RuleSborrow(const string &g)
Constructor.
Definition: ruleaction.hh:550
Concatenation with 0 becomes an extension: V = concat(#0,W) => V = zext(W)
Definition: ruleaction.hh:81
RuleSubZext(const string &g)
Constructor.
Definition: ruleaction.hh:846
RuleIntLessEqual(const string &g)
Constructor.
Definition: ruleaction.hh:193
RuleCondNegate(const string &g)
Constructor.
Definition: ruleaction.hh:926
Search for concatenations with unlikely things to inform return/parameter consumption calculation...
Definition: ruleaction.hh:1435
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1369
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:877
RuleSubvarZext(const string &g)
Constructor.
Definition: ruleaction.hh:1305
RuleDivTermAdd2(const string &g)
Constructor.
Definition: ruleaction.hh:1153
Convert LESSEQUAL to LESS: V <= c => V < (c+1)
Definition: ruleaction.hh:191
RuleDoubleArithShift(const string &g)
Constructor.
Definition: ruleaction.hh:370
Collapse constants in logical expressions: (V & c) & d => V & (c & d)
Definition: ruleaction.hh:151
Convert BRANCHIND with only one computed destination to a BRANCH.
Definition: ruleaction.hh:914
Simply OR with unconsumed input: `V = A | B => V = B if nzm(A) & consume(V) == 0. ...
Definition: ruleaction.hh:131
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:521
Convert INT_SLESS to INT_LESS when comparing positive values.
Definition: ruleaction.hh:468
Convert STORE operations using a constant offset to COPY.
Definition: ruleaction.hh:723
RuleSub2Add(const string &g)
Constructor.
Definition: ruleaction.hh:671
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1391
Lowest level operation of the p-code language.
Definition: op.hh:58
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:767
RuleSignDiv2(const string &g)
Constructor.
Definition: ruleaction.hh:1178
RuleIndirectCollapse(const string &g)
Constructor.
Definition: ruleaction.hh:530
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:271
RuleShiftPiece(const string &g)
Constructor.
Definition: ruleaction.hh:611
Simplify signed comparisons using INT_SBORROW.
Definition: ruleaction.hh:548
Remove PTRSUB operations with mismatched data-type information.
Definition: ruleaction.hh:1038
RuleBxor2NotEqual(const string &g)
Constructor.
Definition: ruleaction.hh:103
Action, Rule, and other associates classes supporting transformations on function data-flow...
RuleSignNearMult(const string &g)
Constructor.
Definition: ruleaction.hh:1200
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:331
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:716
Remove PTRADD operations with mismatched data-type information.
Definition: ruleaction.hh:1028
Transform INT_CARRY using a constant: carry(V,c) => -c <= V
Definition: ruleaction.hh:659
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:726
RuleSubvarSubpiece(const string &g)
Constructor.
Definition: ruleaction.hh:1244
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:917
RuleBoolNegate(const string &g)
Constructor.
Definition: ruleaction.hh:936
RuleLessNotEqual(const string &g)
Constructor.
Definition: ruleaction.hh:430
Simplify INT_RIGHT and INT_SRIGHT ops where an INT_AND mask becomes unnecessary.
Definition: ruleaction.hh:181
RulePtrsubUndo(const string &g)
Constructor.
Definition: ruleaction.hh:1040
Collect terms in a sum: V * c + V * d => V * (c + d)
Definition: ruleaction.hh:59
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:797
RuleZextShiftZext(const string &g)
Constructor.
Definition: ruleaction.hh:806
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1223
Simplify boolean expressions that are combined through POPCOUNT.
Definition: ruleaction.hh:1423
Eliminate ARM/THUMB style masking of the low order bits on function pointers.
Definition: ruleaction.hh:1399
vector< Varnode * > nonmult
Varnodes which are not multiples.
Definition: ruleaction.hh:37
Commute SUBPIECE operations with earlier operations where possible.
Definition: ruleaction.hh:753
RulePtrsubCharConstant(const string &g)
Constructor.
Definition: ruleaction.hh:1097
RuleTrivialBool(const string &g)
Constructor.
Definition: ruleaction.hh:450
RuleAddMultCollapse(const string &g)
Constructor.
Definition: ruleaction.hh:691
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:184
RuleStoreVarnode(const string &g)
Constructor.
Definition: ruleaction.hh:725
RuleFloatRange(const string &g)
Constructor.
Definition: ruleaction.hh:310
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:746
Commute PIECE with INT_ZEXT: concat(zext(V),W) => zext(concat(V,W))
Definition: ruleaction.hh:784
RuleNegateIdentity(const string &g)
Constructor.
Definition: ruleaction.hh:163
RulePiece2Zext(const string &g)
Constructor.
Definition: ruleaction.hh:83
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:174
Simplify expressions associated with optimized division expressions.
Definition: ruleaction.hh:1139
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
RuleNegateNegate(const string &g)
Constructor.
Definition: ruleaction.hh:1340
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:84
RuleAndMask(const string &g)
Constructor.
Definition: ruleaction.hh:123
Simplify INT_ZEXT and SUBPIECE in masked comparison: zext(V) & c == 0 => V & (c & mask) == 0 ...
Definition: ruleaction.hh:338
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:857
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:927
RuleSignShift(const string &g)
Constructor.
Definition: ruleaction.hh:570
Transform CPOOLREF operations by looking up the value in the constant pool.
Definition: ruleaction.hh:629
RuleConcatZext(const string &g)
Constructor.
Definition: ruleaction.hh:786
Simplify chained shifts INT_LEFT and INT_RIGHT.
Definition: ruleaction.hh:358
RulePullsubIndirect(const string &g)
Constructor.
Definition: ruleaction.hh:239
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:541
bool valid
Full tree search was performed.
Definition: ruleaction.hh:40
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:471
RuleLess2Zero(const string &g)
Constructor.
Definition: ruleaction.hh:946
Perform SubvariableFlow analysis triggered by INT_SEXT.
Definition: ruleaction.hh:1314
RuleSlessToLess(const string &g)
Constructor.
Definition: ruleaction.hh:470
RuleBooleanNegate(const string &g)
Constructor.
Definition: ruleaction.hh:500
Simplify trivial shifts: V << 0 => V, V << #64 => 0
Definition: ruleaction.hh:558
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:194
Undo distributed operations through INT_AND, INT_OR, and INT_XOR.
Definition: ruleaction.hh:488
Cleanup: Set-up to print string constants.
Definition: ruleaction.hh:1094
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1041
RuleFuncPtrEncoding(const string &g)
Constructor.
Definition: ruleaction.hh:1401
RuleShiftSub(const string &g)
Constructor.
Definition: ruleaction.hh:866
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:421
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:827
RuleTrivialShift(const string &g)
Constructor.
Definition: ruleaction.hh:560
RuleSplitFlow(const string &g)
Constructor.
Definition: ruleaction.hh:1255
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1098
Simplify two sequential INT_SRIGHT: (x s>> #c) s>> #d => x s>> saturate(#c + #d)
Definition: ruleaction.hh:368
A basic block for p-code operations.
Definition: block.hh:363
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:612
RuleTermOrder(const string &g)
Constructor.
Definition: ruleaction.hh:214
Eliminate INT_2COMP: -V => V * -1
Definition: ruleaction.hh:649
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:957
RulePullsubMulti(const string &g)
Constructor.
Definition: ruleaction.hh:224
RuleShiftAnd(const string &g)
Constructor.
Definition: ruleaction.hh:816
RuleSubRight(const string &g)
Constructor.
Definition: ruleaction.hh:1085
RuleEqual2Constant(const string &g)
Constructor.
Definition: ruleaction.hh:987
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:887
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1284
Class for performing a single transformation on a PcodeOp or Varnode.
Definition: action.hh:192
RuleSignForm(const string &g)
Constructor.
Definition: ruleaction.hh:1189
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:281
RuleHumptyOr(const string &g)
Constructor.
Definition: ruleaction.hh:896
RuleModOpt(const string &g)
Constructor.
Definition: ruleaction.hh:1211
Transform INT_LESS of 0 or 1: V < 1 => V == 0, V <= 0 => V == 0
Definition: ruleaction.hh:288
Simplify masked pieces INT_ORed together: (V & ff00) | (V & 00ff) => V
Definition: ruleaction.hh:894
RuleEmbed(const string &g)
Constructor.
Definition: ruleaction.hh:906
Eliminate INT_ZEXT in comparisons: zext(V) == c => V == c
Definition: ruleaction.hh:458
Convert LOAD operations using a constant offset to COPY.
Definition: ruleaction.hh:709
Convert PIECE to INT_ZEXT where appropriate: V & concat(W,X) => zext(X)
Definition: ruleaction.hh:328
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1256
RuleZextEliminate(const string &g)
Constructor.
Definition: ruleaction.hh:460
RuleZextCommute(const string &g)
Constructor.
Definition: ruleaction.hh:796
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:401
Mark Varnode and PcodeOp objects that are carrying or operating on pointers.
Definition: ruleaction.hh:1264
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1086
RuleCarryElim(const string &g)
Constructor.
Definition: ruleaction.hh:661
Distribute BOOL_NEGATE: !(V && W) => !V || !W
Definition: ruleaction.hh:258
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1021
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1402
RuleLessOne(const string &g)
Constructor.
Definition: ruleaction.hh:290
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:897
Pull SUBPIECE back through MULTIEQUAL.
Definition: ruleaction.hh:222
Perform SubVariableFlow analysis triggered by INT_AND.
Definition: ruleaction.hh:1231
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:311
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:104
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1380
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1306
Convert INT_LEFT to INT_MULT: V << 2 => V * 4
Definition: ruleaction.hh:599
Convert sign-bit test to signed comparison: (V s>> 0x1f) != 0 => V s< 0
Definition: ruleaction.hh:578
Simplify expressions involving three-way comparisons.
Definition: ruleaction.hh:1410
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1295
RulePiece2Sext(const string &g)
Constructor.
Definition: ruleaction.hh:93
RuleRangeMeld(const string &g)
Constructor.
Definition: ruleaction.hh:300
Simplify concatenation with zero: concat(V,0) => zext(V) << c
Definition: ruleaction.hh:824
RuleSelectCse(const string &g)
Constructor.
Definition: ruleaction.hh:73
RulePtraddUndo(const string &g)
Constructor.
Definition: ruleaction.hh:1030
RuleTransformCpool(const string &g)
Constructor.
Definition: ruleaction.hh:631
Pull-back SUBPIECE through INDIRECT.
Definition: ruleaction.hh:237
virtual int4 applyOp(PcodeOp *op, Funcdata &data)
Attempt to apply this Rule.
Definition: ruleaction.cc:3980
Perform SubVariableFlow analysis triggered by SUBPIECE.
Definition: ruleaction.hh:1242
const string & getGroup(void) const
Return the group this Rule belongs to.
Definition: action.hh:214
RuleDivTermAdd(const string &g)
Constructor.
Definition: ruleaction.hh:1141
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1201
RulePropagateCopy(const string &g)
Constructor.
Definition: ruleaction.hh:641
Simplify INT_NEGATE chains: ~~V => V
Definition: ruleaction.hh:1338
Convert INT_SRIGHT form into INT_SDIV: (V + -1*(V s>> 31)) s>> 1 => V s/ 2
Definition: ruleaction.hh:1176
Propagate the input of a COPY to all the places that read the output.
Definition: ruleaction.hh:639
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:817
Transform canceling INT_RIGHT or INT_SRIGHT of INT_LEFT.
Definition: ruleaction.hh:388
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1001
Simplify boolean expressions when one side is constant.
Definition: ruleaction.hh:448
uintb nonmultsum
Sum of non-multiple constants.
Definition: ruleaction.hh:39
Eliminate INT_XOR in comparisons: (V ^ W) == 0 => V == W
Definition: ruleaction.hh:679
Simplify comparisons with boolean values: V == false => !V, V == true => V
Definition: ruleaction.hh:498
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:807
Simplify MULTIEQUAL operations where the branches hold the same value.
Definition: ruleaction.hh:247
RuleStructOffset0(const string &g)
Constructor.
Definition: ruleaction.hh:1010
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:215
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:867
Convert a LOAD or STORE to the first element of a structure to a PTRSUB.
Definition: ruleaction.hh:1008
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:204
Eliminate BOOL_XOR: V ^^ W => V != W
Definition: ruleaction.hh:101
Transform INT_ZEXT and INT_SLESS: zext(V) s< c => V < c
Definition: ruleaction.hh:478
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:144
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:632
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:391
Commute SUBPIECE and INT_ZEXT: sub(zext(V),c) => zext(sub(V,c))
Definition: ruleaction.hh:743
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:64
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:988
Varnode * ptr
The pointer varnode.
Definition: ruleaction.hh:33
RuleEquality(const string &g)
Constructor.
Definition: ruleaction.hh:203
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1011
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:461
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1142
Simplify INT_EQUAL applied to 0: 0 == V + W * -1 => V == W or 0 == V + c => V == -c ...
Definition: ruleaction.hh:975
Distribute INT_AND through INT_OR if result is simpler.
Definition: ruleaction.hh:278
Simplify SUBPIECE applied to INT_LEFT: sub( V << 8*c, c) => sub(V,0)
Definition: ruleaction.hh:864
Simplify INT_EQUAL applied to arithmetic expressions.
Definition: ruleaction.hh:985
Flip conditions to match structuring cues.
Definition: ruleaction.hh:924
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:571
Rule2Comp2Mult(const string &g)
Constructor.
Definition: ruleaction.hh:651
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1273
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:441
Collapse unnecessary INT_AND.
Definition: ruleaction.hh:121
RuleEarlyRemoval(const string &g)
Constructor.
Definition: ruleaction.hh:45
Signed division of positive values is unsigned division.
Definition: ruleaction.hh:1128
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:602
RuleConcatCommute(const string &g)
Constructor.
Definition: ruleaction.hh:766
Collapse unnecessary INT_OR.
Definition: ruleaction.hh:141
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:451
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1413
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:968
RuleDumptyHump(const string &g)
Constructor.
Definition: ruleaction.hh:886
Get rid of unused PcodeOp objects where we can guarantee the output is unused.
Definition: ruleaction.hh:43
Replace (casttosmall)(casttobig)V with identity or with single cast.
Definition: ruleaction.hh:1377
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:240
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1341
Perform SubvariableFlow analysis triggered by INT_RIGHT.
Definition: ruleaction.hh:1292
Simplify composition of SUBPIECE with INT_ZEXT or INT_SEXT.
Definition: ruleaction.hh:854
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:431
RulePtrArith(const string &g)
Constructor.
Definition: ruleaction.hh:1000
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:134
Simplify trivial arithmetic expressions.
Definition: ruleaction.hh:438
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:692
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:124
RuleAddUnsigned(const string &g)
Constructor.
Definition: ruleaction.hh:1063
Simplify concatenation of extended value: concat(V, zext(W) << c) => concat( concat(V,W), 0)
Definition: ruleaction.hh:834
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:682
RuleIgnoreNan(const string &g)
Constructor.
Definition: ruleaction.hh:1390
RuleSubCommute(const string &g)
Constructor.
Definition: ruleaction.hh:755
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:321
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:531
vector< Varnode * > multiple
Varnodes which are multiples of size.
Definition: ruleaction.hh:35
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:787
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:351
Structure for sorting out pointer expression trees.
Definition: ruleaction.hh:31
Convert "shift and add" to PIECE: (zext(V) << 16) + zext(W) => concat(V,W)
Definition: ruleaction.hh:609
Normalize sign extraction: sub(sext(V),c) => V s>> 31
Definition: ruleaction.hh:1187
RuleCollapseConstants(const string &g)
Constructor.
Definition: ruleaction.hh:621
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1109
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:74
RuleSubNormal(const string &g)
Constructor.
Definition: ruleaction.hh:1108
RuleIdentityEl(const string &g)
Constructor.
Definition: ruleaction.hh:591
Perform SubvariableFlow analysis triggered by testing of a single bit.
Definition: ruleaction.hh:1281
Simplify chained SUBPIECE: sub( sub(V,c), d) => sub(V, c+d)
Definition: ruleaction.hh:348
Push a Varnode with known pointer data-type to the bottom of its additive expression.
Definition: ruleaction.hh:1018
RuleMultiCollapse(const string &g)
Constructor.
Definition: ruleaction.hh:540
Simplify INT_AND when applied to aligned INT_ADD: (V + c) & 0xfff0 => V + (c & 0xfff0) ...
Definition: ruleaction.hh:268
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:361
Eliminate INT_SUB: V - W => V + W * -1
Definition: ruleaction.hh:669
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:756
virtual Rule * clone(const ActionGroupList &grouplist) const
Clone the Rule.
Definition: ruleaction.hh:1245
RuleSubvarAnd(const string &g)
Constructor.
Definition: ruleaction.hh:1233
Normalize sign-bit extraction: V >> 0x1f => (V s>> 0x1f) * -1
Definition: ruleaction.hh:568
Simplify INT_OR with full mask: V = W | 0xffff => V = W
Definition: ruleaction.hh:111
Simplify INT_ZEXT applied to SUBPIECE expressions.
Definition: ruleaction.hh:844
Convert logical to boolean operations: V & W => V && W, V | W => V || W
Definition: ruleaction.hh:518
RuleMultNegOne(const string &g)
Constructor.
Definition: ruleaction.hh:1052
Shifting away all non-zero bits of one-side of a logical/arithmetic op.
Definition: ruleaction.hh:171
Pull-back SUBPIECE through INT_RIGHT and INT_SRIGHT.
Definition: ruleaction.hh:1106
RuleConcatZero(const string &g)
Constructor.
Definition: ruleaction.hh:826
Simplify multiple INT_ZEXT operations: zext( zext(V) << c ) => zext(V) << c
Definition: ruleaction.hh:804
Merge range conditions of the form: V f< c, c f< V, V f== c etc.
Definition: ruleaction.hh:308
RuleLoadVarnode(const string &g)
Constructor.
Definition: ruleaction.hh:715
RuleSLess2Zero(const string &g)
Constructor.
Definition: ruleaction.hh:967
Simplify division form: (V + (V s>> 0x1f)>>(32-n)) & (-1<<n) => (V s/ 2^n) * 2^n
Definition: ruleaction.hh:1198