GP-4782 Refactor RulePtrsubUndo

This commit is contained in:
caheckman 2024-07-12 15:21:07 +00:00
parent be305db930
commit 34adcff830
7 changed files with 355 additions and 80 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -71,6 +71,7 @@ class AddTreeState {
bool checkTerm(Varnode *vn,uint8 treeCoeff); ///< Accumulate details of given term and continue tree traversal
bool spanAddTree(PcodeOp *op,uint8 treeCoeff); ///< Walk the given sub-tree accumulating details
void calcSubtype(void); ///< Calculate final sub-type offset
void assignPropagatedType(PcodeOp *op); ///< Assign a data-type propagated through the given PcodeOp
Varnode *buildMultiples(void); ///< Build part of tree that is multiple of base size
Varnode *buildExtra(void); ///< Build part of tree not accounted for by multiples or \e offset
bool buildDegenerate(void); ///< Transform ADD into degenerate PTRADD
@ -1079,6 +1080,11 @@ public:
virtual int4 applyOp(PcodeOp *op,Funcdata &data);
};
class RulePtrsubUndo : public Rule {
static const int4 DEPTH_LIMIT; ///< The maximum depth of the additive expression to check
static int8 getConstOffsetBack(Varnode *vn,int8 &multiplier,int4 maxLevel);
static int8 getExtraOffset(PcodeOp *op,int8 &multiplier);
static int8 removeLocalAdds(Varnode *vn,Funcdata &data);
static int8 removeLocalAddRecurse(PcodeOp *op,int4 slot,int4 maxLevel,Funcdata &data);
public:
RulePtrsubUndo(const string &g) : Rule(g, 0, "ptrsubundo") {} ///< Constructor
virtual Rule *clone(const ActionGroupList &grouplist) const {