decompiler  1.0.0
Classes
ruleaction.hh File Reference

This is the basic set of transformation Rule objects. More...

#include "action.hh"

Classes

class  ghidra::AddTreeState
 Structure for sorting out pointer expression trees. More...
 
class  ghidra::RuleEarlyRemoval
 Get rid of unused PcodeOp objects where we can guarantee the output is unused. More...
 
class  ghidra::RuleCollectTerms
 Collect terms in a sum: V * c + V * d => V * (c + d) More...
 
class  ghidra::RuleSelectCse
 Look for common sub-expressions (built out of a restricted set of ops) More...
 
class  ghidra::RulePiece2Zext
 Concatenation with 0 becomes an extension: V = concat(#0,W) => V = zext(W) More...
 
class  ghidra::RulePiece2Sext
 Concatenation with sign bits becomes an extension: concat( V s>> #0x1f , V) => sext(V) More...
 
class  ghidra::RuleBxor2NotEqual
 Eliminate BOOL_XOR: V ^^ W => V != W More...
 
class  ghidra::RuleOrMask
 Simplify INT_OR with full mask: V = W | 0xffff => V = W More...
 
class  ghidra::RuleAndMask
 Collapse unnecessary INT_AND. More...
 
class  ghidra::RuleOrConsume
 Simply OR with unconsumed input: `V = A | B => V = B if nzm(A) & consume(V) == 0. More...
 
class  ghidra::RuleOrCollapse
 Collapse unnecessary INT_OR. More...
 
class  ghidra::RuleAndOrLump
 Collapse constants in logical expressions: (V & c) & d => V & (c & d) More...
 
class  ghidra::RuleNegateIdentity
 Apply INT_NEGATE identities: V & ~V => #0, V | ~V -> #-1 More...
 
class  ghidra::RuleShiftBitops
 Shifting away all non-zero bits of one-side of a logical/arithmetic op. More...
 
class  ghidra::RuleRightShiftAnd
 Simplify INT_RIGHT and INT_SRIGHT ops where an INT_AND mask becomes unnecessary. More...
 
class  ghidra::RuleIntLessEqual
 Convert LESSEQUAL to LESS: V <= c => V < (c+1) More...
 
class  ghidra::RuleEquality
 Collapse INT_EQUAL and INT_NOTEQUAL: f(V,W) == f(V,W) => true More...
 
class  ghidra::RuleTermOrder
 Order the inputs to commutative operations. More...
 
class  ghidra::RulePullsubMulti
 Pull SUBPIECE back through MULTIEQUAL. More...
 
class  ghidra::RulePullsubIndirect
 Pull-back SUBPIECE through INDIRECT. More...
 
class  ghidra::RulePushMulti
 Simplify MULTIEQUAL operations where the branches hold the same value. More...
 
class  ghidra::RuleNotDistribute
 Distribute BOOL_NEGATE: !(V && W) => !V || !W More...
 
class  ghidra::RuleHighOrderAnd
 Simplify INT_AND when applied to aligned INT_ADD: (V + c) & 0xfff0 => V + (c & 0xfff0) More...
 
class  ghidra::RuleAndDistribute
 Distribute INT_AND through INT_OR if result is simpler. More...
 
class  ghidra::RuleLessOne
 Transform INT_LESS of 0 or 1: V < 1 => V == 0, V <= 0 => V == 0 More...
 
class  ghidra::RuleRangeMeld
 Merge range conditions of the form: V s< c, c s< V, V == c, V != c More...
 
class  ghidra::RuleFloatRange
 Merge range conditions of the form: V f< c, c f< V, V f== c etc. More...
 
class  ghidra::RuleAndCommute
 Commute INT_AND with INT_LEFT and INT_RIGHT: (V << W) & d => (V & (W >> c)) << c More...
 
class  ghidra::RuleAndPiece
 Convert PIECE to INT_ZEXT where appropriate: V & concat(W,X) => zext(X) More...
 
class  ghidra::RuleAndZext
 Convert INT_AND to INT_ZEXT where appropriate: sext(X) & 0xffff => zext(X) More...
 
class  ghidra::RuleAndCompare
 Simplify INT_ZEXT and SUBPIECE in masked comparison: zext(V) & c == 0 => V & (c & mask) == 0 More...
 
class  ghidra::RuleDoubleSub
 Simplify chained SUBPIECE: sub( sub(V,c), d) => sub(V, c+d) More...
 
class  ghidra::RuleDoubleShift
 Simplify chained shifts INT_LEFT and INT_RIGHT. More...
 
class  ghidra::RuleDoubleArithShift
 Simplify two sequential INT_SRIGHT: (x s>> c) s>> d => x s>> saturate(c + d) More...
 
class  ghidra::RuleConcatShift
 Simplify INT_RIGHT canceling PIECE: concat(V,W) >> c => zext(V) More...
 
class  ghidra::RuleLeftRight
 Transform canceling INT_RIGHT or INT_SRIGHT of INT_LEFT. More...
 
class  ghidra::RuleShiftCompare
 Transform shifts in comparisons: V >> c == d => V == (d << c) More...
 
class  ghidra::RuleLessEqual
 Simplify 'less than or equal': V < W || V == W => V <= W More...
 
class  ghidra::RuleLessNotEqual
 Simplify INT_LESSEQUAL && INT_NOTEQUAL: V <= W && V != W => V < W More...
 
class  ghidra::RuleTrivialArith
 Simplify trivial arithmetic expressions. More...
 
class  ghidra::RuleTrivialBool
 Simplify boolean expressions when one side is constant. More...
 
class  ghidra::RuleZextEliminate
 Eliminate INT_ZEXT in comparisons: zext(V) == c => V == c More...
 
class  ghidra::RuleSlessToLess
 Convert INT_SLESS to INT_LESS when comparing positive values. More...
 
class  ghidra::RuleZextSless
 Transform INT_ZEXT and INT_SLESS: zext(V) s< c => V < c More...
 
class  ghidra::RuleBitUndistribute
 Undo distributed operations through INT_AND, INT_OR, and INT_XOR. More...
 
class  ghidra::RuleBooleanNegate
 Simplify comparisons with boolean values: V == false => !V, V == true => V More...
 
class  ghidra::RuleBoolZext
 Simplify boolean expressions of the form zext(V) * -1. More...
 
class  ghidra::RuleLogic2Bool
 Convert logical to boolean operations: V & W => V && W, V | W => V || W More...
 
class  ghidra::RuleIndirectCollapse
 Remove a CPUI_INDIRECT if its blocking PcodeOp is dead. More...
 
class  ghidra::RuleMultiCollapse
 Collapse MULTIEQUAL whose inputs all trace to the same value. More...
 
class  ghidra::RuleSborrow
 Simplify signed comparisons using INT_SBORROW. More...
 
class  ghidra::RuleTrivialShift
 Simplify trivial shifts: V << 0 => V, V << #64 => 0 More...
 
class  ghidra::RuleSignShift
 Normalize sign-bit extraction: V >> 0x1f => (V s>> 0x1f) * -1 More...
 
class  ghidra::RuleTestSign
 Convert sign-bit test to signed comparison: (V s>> 0x1f) != 0 => V s< 0 More...
 
class  ghidra::RuleIdentityEl
 Collapse operations using identity element: V + 0 => V More...
 
class  ghidra::RuleShift2Mult
 Convert INT_LEFT to INT_MULT: V << 2 => V * 4 More...
 
class  ghidra::RuleShiftPiece
 Convert "shift and add" to PIECE: (zext(V) << 16) + zext(W) => concat(V,W) More...
 
class  ghidra::RuleCollapseConstants
 Collapse constant expressions. More...
 
class  ghidra::RuleTransformCpool
 Transform CPOOLREF operations by looking up the value in the constant pool. More...
 
class  ghidra::RulePropagateCopy
 Propagate the input of a COPY to all the places that read the output. More...
 
class  ghidra::Rule2Comp2Mult
 Eliminate INT_2COMP: -V => V * -1 More...
 
class  ghidra::RuleCarryElim
 Transform INT_CARRY using a constant: carry(V,c) => -c <= V More...
 
class  ghidra::RuleSub2Add
 Eliminate INT_SUB: V - W => V + W * -1 More...
 
class  ghidra::RuleXorCollapse
 Eliminate INT_XOR in comparisons: (V ^ W) == 0 => V == W More...
 
class  ghidra::RuleAddMultCollapse
 Collapse constants in an additive or multiplicative expression. More...
 
class  ghidra::RuleLoadVarnode
 Convert LOAD operations using a constant offset to COPY. More...
 
class  ghidra::RuleStoreVarnode
 Convert STORE operations using a constant offset to COPY. More...
 
class  ghidra::RuleSubExtComm
 Commute SUBPIECE and INT_ZEXT: sub(zext(V),c) => zext(sub(V,c)) More...
 
class  ghidra::RuleSubCommute
 Commute SUBPIECE operations with earlier operations where possible. More...
 
class  ghidra::RuleConcatCommute
 Commute PIECE with INT_AND, INT_OR, and INT_XOR. More...
 
class  ghidra::RuleConcatZext
 Commute PIECE with INT_ZEXT: concat(zext(V),W) => zext(concat(V,W)) More...
 
class  ghidra::RuleZextCommute
 Commute INT_ZEXT with INT_RIGHT: zext(V) >> W => zext(V >> W) More...
 
class  ghidra::RuleZextShiftZext
 Simplify multiple INT_ZEXT operations: zext( zext(V) << c ) => zext(V) << c More...
 
class  ghidra::RuleShiftAnd
 Eliminate any INT_AND when the bits it zeroes out are discarded by a shift. More...
 
class  ghidra::RuleConcatZero
 Simplify concatenation with zero: concat(V,0) => zext(V) << c More...
 
class  ghidra::RuleConcatLeftShift
 Simplify concatenation of extended value: concat(V, zext(W) << c) => concat( concat(V,W), 0) More...
 
class  ghidra::RuleSubZext
 Simplify INT_ZEXT applied to SUBPIECE expressions. More...
 
class  ghidra::RuleSubCancel
 Simplify composition of SUBPIECE with INT_ZEXT, INT_SEXT, and INT_AND. More...
 
class  ghidra::RuleShiftSub
 Simplify SUBPIECE applied to INT_LEFT: sub( V << 8*k, c) => sub(V,c-k) More...
 
class  ghidra::RuleHumptyDumpty
 Simplify break and rejoin: concat( sub(V,c), sub(V,0) ) => V More...
 
class  ghidra::RuleDumptyHump
 Simplify join and break apart: sub( concat(V,W), c) => sub(W,c) More...
 
class  ghidra::RuleHumptyOr
 Simplify masked pieces INT_ORed together: (V & ff00) | (V & 00ff) => V More...
 
class  ghidra::RuleSwitchSingle
 Convert BRANCHIND with only one computed destination to a BRANCH. More...
 
class  ghidra::RuleCondNegate
 Flip conditions to match structuring cues. More...
 
class  ghidra::RuleBoolNegate
 Apply a set of identities involving BOOL_NEGATE. More...
 
class  ghidra::RuleLess2Zero
 Simplify INT_LESS applied to extremal constants. More...
 
class  ghidra::RuleLessEqual2Zero
 Simplify INT_LESSEQUAL applied to extremal constants. More...
 
class  ghidra::RuleSLess2Zero
 Simplify INT_SLESS applied to 0 or -1. More...
 
class  ghidra::RuleEqual2Zero
 Simplify INT_EQUAL applied to 0: 0 == V + W * -1 => V == W or 0 == V + c => V == -c More...
 
class  ghidra::RuleEqual2Constant
 Simplify INT_EQUAL applied to arithmetic expressions. More...
 
class  ghidra::RulePtrArith
 Transform pointer arithmetic. More...
 
class  ghidra::RuleStructOffset0
 Convert a LOAD or STORE to the first element of a structure to a PTRSUB. More...
 
class  ghidra::RulePushPtr
 Push a Varnode with known pointer data-type to the bottom of its additive expression. More...
 
class  ghidra::RulePtraddUndo
 Remove PTRADD operations with mismatched data-type information. More...
 
class  ghidra::RulePtrsubUndo
 Remove PTRSUB operations with mismatched data-type information. More...
 
class  ghidra::RuleMultNegOne
 Cleanup: Convert INT_2COMP from INT_MULT: V * -1 => -V More...
 
class  ghidra::RuleAddUnsigned
 Cleanup: Convert INT_ADD of constants to INT_SUB: V + 0xff... => V - 0x00... More...
 
class  ghidra::Rule2Comp2Sub
 Cleanup: Convert INT_ADD back to INT_SUB: V + -W ==> V - W More...
 
class  ghidra::RuleSubRight
 Cleanup: Convert truncation to cast: sub(V,c) => sub(V>>c*8,0) More...
 
class  ghidra::RulePtrsubCharConstant
 Cleanup: Set-up to print string constants. More...
 
class  ghidra::RuleExtensionPush
 Duplicate CPUI_INT_ZEXT and CPUI_INT_SEXT operations if the result is used in multiple pointer calculations. More...
 
class  ghidra::RulePieceStructure
 Concatenating structure pieces gets printed as explicit write statements. More...
 
class  ghidra::RuleSplitCopy
 Split COPY ops based on TypePartialStruct. More...
 
class  ghidra::RuleSplitLoad
 Split LOAD ops based on TypePartialStruct. More...
 
class  ghidra::RuleSplitStore
 Split STORE ops based on TypePartialStruct. More...
 
class  ghidra::RuleSubNormal
 Pull-back SUBPIECE through INT_RIGHT and INT_SRIGHT. More...
 
class  ghidra::RulePositiveDiv
 Signed division of positive values is unsigned division. More...
 
class  ghidra::RuleDivTermAdd
 Simplify expressions associated with optimized division expressions. More...
 
class  ghidra::RuleDivTermAdd2
 Simplify another expression associated with optimized division. More...
 
class  ghidra::RuleDivOpt
 Convert INT_MULT and shift forms into INT_DIV or INT_SDIV. More...
 
class  ghidra::RuleSignDiv2
 Convert INT_SRIGHT form into INT_SDIV: (V + -1*(V s>> 31)) s>> 1 => V s/ 2 More...
 
class  ghidra::RuleDivChain
 Collapse two consecutive divisions: (x / c1) / c2 => x / (c1*c2) More...
 
class  ghidra::RuleSignForm
 Normalize sign extraction: sub(sext(V),c) => V s>> 31 More...
 
class  ghidra::RuleSignForm2
 Normalize sign extraction: sub(sext(V) * small,c) s>> 31 => V s>> 31 More...
 
class  ghidra::RuleSignNearMult
 Simplify division form: (V + (V s>> 0x1f)>>(32-n)) & (-1<<n) => (V s/ 2^n) * 2^n More...
 
class  ghidra::RuleModOpt
 Simplify expressions that optimize INT_REM and INT_SREM. More...
 
class  ghidra::RuleSignMod2nOpt
 Convert INT_SREM forms: (V + (sign >> (64-n)) & (2^n-1)) - (sign >> (64-n) => V s% 2^n More...
 
class  ghidra::RuleSignMod2Opt
 Convert INT_SREM form: (V - sign)&1 + sign => V s% 2 More...
 
class  ghidra::RuleSignMod2nOpt2
 Convert INT_SREM form: V - (Vadj & ~(2^n-1)) => V s% 2^n More...
 
class  ghidra::RuleSegment
 Propagate constants through a SEGMENTOP. More...
 
class  ghidra::RuleSubvarAnd
 Perform SubVariableFlow analysis triggered by INT_AND. More...
 
class  ghidra::RuleSubvarSubpiece
 Perform SubVariableFlow analysis triggered by SUBPIECE. More...
 
class  ghidra::RuleSplitFlow
 Try to detect and split artificially joined Varnodes. More...
 
class  ghidra::RulePtrFlow
 Mark Varnode and PcodeOp objects that are carrying or operating on pointers. More...
 
class  ghidra::RuleSubvarCompZero
 Perform SubvariableFlow analysis triggered by testing of a single bit. More...
 
class  ghidra::RuleSubvarShift
 Perform SubvariableFlow analysis triggered by INT_RIGHT. More...
 
class  ghidra::RuleSubvarZext
 Perform SubvariableFlow analysis triggered by INT_ZEXT. More...
 
class  ghidra::RuleSubvarSext
 Perform SubvariableFlow analysis triggered by INT_SEXT. More...
 
class  ghidra::RuleSubfloatConvert
 Perform SubfloatFlow analysis triggered by FLOAT_FLOAT2FLOAT. More...
 
class  ghidra::RuleNegateNegate
 Simplify INT_NEGATE chains: ~~V => V More...
 
class  ghidra::RuleConditionalMove
 Simplify various conditional move situations. More...
 
class  ghidra::RuleConditionalMove::BoolExpress
 Class for categorizing and rebuilding a boolean expression. More...
 
class  ghidra::RuleFloatCast
 Replace (casttosmall)(casttobig)V with identity or with single cast. More...
 
class  ghidra::RuleIgnoreNan
 Treat FLOAT_NAN as always evaluating to false. More...
 
class  ghidra::RuleFuncPtrEncoding
 Eliminate ARM/THUMB style masking of the low order bits on function pointers. More...
 
class  ghidra::RuleThreeWayCompare
 Simplify expressions involving three-way comparisons. More...
 
class  ghidra::RulePopcountBoolXor
 Simplify boolean expressions that are combined through POPCOUNT. More...
 
class  ghidra::RuleOrMultiBool
 Simplify boolean expressions that are combined through INT_OR. More...
 
class  ghidra::RulePiecePathology
 Search for concatenations with unlikely things to inform return/parameter consumption calculation. More...
 
class  ghidra::RuleXorSwap
 Simplify limited chains of XOR operations. More...
 
class  ghidra::RuleLzcountShiftBool
 Simplify equality checks that use lzcount: lzcount(X) >> c => X == 0 if X is 2^c bits wide. More...
 

Detailed Description

This is the basic set of transformation Rule objects.

Each Rule triggers on a specific localized data-flow configuration. They are generally applied simultaneously from a pool (see ActionPool) and can interact with each other to produce an emergent transformation. The Rules are applied repeatedly until no Rule can make any additional transformations.