Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
36 virtual void saveXmlAttributes(ostream &s,uintb offset,int4 size)
const { s <<
" space=\"iop\""; }
37 virtual void printRaw(ostream &s,uintb offset)
const;
38 virtual void saveXml(ostream &s)
const;
113 mutable uint4 addlflags;
116 list<PcodeOp *>::iterator basiciter;
117 list<PcodeOp *>::iterator insertiter;
118 list<PcodeOp *>::iterator codeiter;
120 vector<Varnode *> inrefs;
123 void setOpcode(
TypeOp *t_op);
124 void setOutput(
Varnode *vn) { output = vn; }
125 void clearInput(int4 slot) { inrefs[slot] = (
Varnode *)0; }
127 void setFlag(uint4 fl) { flags |= fl; }
128 void clearFlag(uint4 fl) { flags &= ~fl; }
129 void setAdditionalFlag(uint4 fl) { addlflags |= fl; }
130 void clearAdditionalFlag(uint4 fl) { addlflags &= ~fl; }
131 void flipFlag(uint4 fl) { flags ^= fl; }
132 void setNumInputs(int4 num);
133 void removeInput(int4 slot);
134 void insertInput(int4 slot);
135 void setOrder(uintm ord) { start.
setOrder(ord); }
137 void setBasicIter(list<PcodeOp *>::iterator iter) { basiciter = iter; }
142 int4 numInput(
void)
const {
return inrefs.size(); }
143 Varnode *getOut(
void) {
return output; }
144 const Varnode *getOut(
void)
const {
return (
const Varnode *) output; }
145 Varnode *getIn(int4 slot) {
return inrefs[slot]; }
146 const Varnode *getIn(int4 slot)
const {
return (
const Varnode *) inrefs[slot]; }
148 BlockBasic *getParent(
void) {
return parent; }
150 uintm getTime(
void)
const {
return start.
getTime(); }
151 const SeqNum &getSeqNum(
void)
const {
return start; }
152 list<PcodeOp *>::iterator getInsertIter(
void)
const {
return insertiter; }
153 list<PcodeOp *>::iterator getBasicIter(
void)
const {
return basiciter; }
154 int4
getSlot(
const Varnode *vn)
const { int4 i,n; n=inrefs.size();
for(i=0;i<n;++i)
if (inrefs[i]==vn)
break;
return i; }
156 int4
getRepeatSlot(
const Varnode *vn,int4 firstSlot,list<PcodeOp *>::const_iterator iter)
const;
162 bool isDead(
void)
const {
return ((flags&
PcodeOp::dead)!=0); }
163 bool isAssignment(
void)
const {
return (output!=(
Varnode *)0); }
164 bool isCall(
void)
const {
return ((flags&
PcodeOp::call)!=0); }
187 bool isMark(
void)
const {
return ((flags&
PcodeOp::mark)!=0); }
210 TypeOp *getOpcode(
void)
const {
return opcode; }
211 OpCode code(
void)
const {
return opcode->getOpcode(); }
213 uintb
collapse(
bool &markedInput)
const;
220 void printRaw(ostream &s)
const { opcode->
printRaw(s,
this); }
221 const string &getOpName(
void)
const {
return opcode->getName(); }
223 void saveXml(ostream &s)
const;
230 bool inheritsSign(
void)
const {
return opcode->
inheritsSign(); }
255 list<PcodeOp *> deadlist;
256 list<PcodeOp *> alivelist;
257 list<PcodeOp *> storelist;
258 list<PcodeOp *> loadlist;
259 list<PcodeOp *> returnlist;
260 list<PcodeOp *> useroplist;
261 list<PcodeOp *> deadandgone;
263 void addToCodeList(
PcodeOp *op);
264 void removeFromCodeList(
PcodeOp *op);
265 void clearCodeLists(
void);
270 void setUniqId(uintm val) { uniqid = val; }
271 uintm getUniqId(
void)
const {
return uniqid; }
282 bool empty(
void)
const {
return optree.empty(); }
288 PcodeOpTree::const_iterator
beginAll(
void)
const {
return optree.begin(); }
291 PcodeOpTree::const_iterator
endAll(
void)
const {
return optree.end(); }
294 PcodeOpTree::const_iterator
begin(
const Address &addr)
const;
297 PcodeOpTree::const_iterator
end(
const Address &addr)
const;
300 list<PcodeOp *>::const_iterator
beginAlive(
void)
const {
return alivelist.begin(); }
303 list<PcodeOp *>::const_iterator
endAlive(
void)
const {
return alivelist.end(); }
306 list<PcodeOp *>::const_iterator
beginDead(
void)
const {
return deadlist.begin(); }
309 list<PcodeOp *>::const_iterator
endDead(
void)
const {
return deadlist.end(); }
312 list<PcodeOp *>::const_iterator
begin(
OpCode opc)
const;
315 list<PcodeOp *>::const_iterator
end(
OpCode opc)
const;
bool inheritsSign(void) const
Return true if the op-code inherits it signedness from its inputs.
Definition: typeop.hh:107
void markIncidentalCopy(PcodeOp *firstop, PcodeOp *lastop)
Mark any COPY ops in the given range as incidental.
Definition: op.cc:928
bool usesSpacebasePtr(void) const
Return true if this LOADs or STOREs from a dynamic spacebase pointer.
Definition: op.hh:206
uintm getTime(void) const
Get the time field of a sequence number.
Definition: address.hh:129
PcodeOp * fallthru(const PcodeOp *op) const
Find the PcodeOp considered a fallthru of the given PcodeOp.
Definition: op.cc:967
PcodeOpTree::const_iterator begin(const Address &addr) const
Start of all PcodeOps at one Address.
Definition: op.cc:1003
A region where processor data is stored.
Definition: space.hh:73
int4 compareOrder(const PcodeOp *bop) const
Compare the control-flow order of this and bop.
Definition: op.cc:721
@ indirect_store
CPUI_INDIRECT is caused by CPUI_STORE.
Definition: op.hh:100
Varnode * setInput(Varnode *vn)
Mark a Varnode as an input to the function.
Definition: varnode.cc:992
Space for storing internal PcodeOp pointers as addresses.
Definition: op.hh:32
@ commutative
Order of input parameters does not matter.
Definition: op.hh:83
A class for uniquely labelling and comparing PcodeOps.
Definition: address.hh:111
list< PcodeOp * >::const_iterator endDead(void) const
End of all PcodeOps marked as dead.
Definition: op.hh:309
bool isCpoolTransformed(void) const
Return true if we have already examined this cpool.
Definition: op.hh:203
@ special_prop
Does some special form of datatype propagation.
Definition: op.hh:103
PcodeOp * target(const Address &addr) const
Find the first executing PcodeOp for a target address.
Definition: op.cc:946
Container class for PcodeOps associated with a single function.
Definition: op.hh:253
@ dead
This operation is dead.
Definition: op.hh:72
void moveSequenceDead(PcodeOp *firstop, PcodeOp *lastop, PcodeOp *prev)
Move a sequence of PcodeOps to a point in the dead list.
Definition: op.cc:913
bool isCallWithoutSpec(void) const
Return true if this op acts as call but does not have a full specification.
Definition: op.hh:166
bool isBoolOutput(void) const
Return true if this op produces a boolean output.
Definition: op.hh:173
int4 functionalEqualityLevel(Varnode *vn1, Varnode *vn2, Varnode **res1, Varnode **res2)
Try to determine if vn1 and vn2 contain the same value.
Definition: op.cc:1101
PcodeOpTree::const_iterator endAll(void) const
End of all PcodeOps in sequence number order.
Definition: op.hh:291
@ ternary
Evaluate as ternary operator (or higher)
Definition: op.hh:87
uint4 getHaltType(void) const
Get type which indicates unusual halt in control-flow.
Definition: op.hh:160
@ returns
This instruction returns to caller.
Definition: op.hh:70
list< PcodeOp * >::const_iterator beginDead(void) const
Start of all PcodeOps marked as dead.
Definition: op.hh:306
@ special
Cannot be evaluated (without special processing)
Definition: op.hh:86
bool functionalDifference(Varnode *vn1, Varnode *vn2, int4 depth)
Return true if vn1 and vn2 are verifiably different values.
Definition: op.cc:1200
Data-type and behavior information associated with specific p-code op-codes.
void markDead(PcodeOp *op)
Mark the given PcodeOp as dead.
Definition: op.cc:885
PcodeOp(int4 s, const SeqNum &sq)
Construct an unattached PcodeOp.
Definition: op.cc:71
int4 getRepeatSlot(const Varnode *vn, int4 firstSlot, list< PcodeOp * >::const_iterator iter) const
Find the slot for a given Varnode, which may be take up multiple input slots.
Definition: op.cc:93
@ booloutput
Boolean operation.
Definition: op.hh:76
uintb getOffset(void) const
Get the address offset.
Definition: address.hh:300
virtual void saveXml(ostream &s) const
Write the details of this space as XML.
Definition: op.cc:55
@ has_callspec
Op has a call specification associated with it.
Definition: op.hh:98
@ binary
Evaluate as binary expression.
Definition: op.hh:85
uintm getCseHash(void) const
Return hash indicating possibility of common subexpression elimination.
Definition: op.cc:131
@ nonprinting
Op should not be directly printed as source.
Definition: op.hh:89
bool functionalEquality(Varnode *vn1, Varnode *vn2)
Determine if two Varnodes hold the same value.
Definition: op.cc:1185
An XML element. A node in the DOM tree.
Definition: xml.hh:150
A basic block for p-code operations.
Definition: block.hh:365
@ modified
This op has been modified by the current action.
Definition: op.hh:105
bool isCallOrBranch(void) const
Return true if this op is a call or branch.
Definition: op.hh:176
@ noreturn
placeholder for previous call that doesn't exit
Definition: op.hh:93
Lowest level operation of the p-code language.
Definition: op.hh:58
list< PcodeOp * >::const_iterator endAlive(void) const
End of all PcodeOps marked as alive.
Definition: op.hh:303
@ badinstruction
placeholder for bad instruction data
Definition: op.hh:91
bool isCalculatedBool(void) const
Return true if output is 1-bit boolean.
Definition: op.hh:201
void destroy(PcodeOp *op)
Destroy/retire the given PcodeOp.
Definition: op.cc:846
bool isFallthruTrue(void) const
Return true if the fall-thru branch is taken when the boolean input is true.
Definition: op.hh:182
@ call
This instruction calls a subroutine.
Definition: op.hh:69
PcodeOp * previousOp(void) const
Return the previous op within this op's basic block or null.
Definition: op.cc:344
uintb collapse(bool &markedInput) const
Calculate the constant output produced by this op.
Definition: op.cc:437
uint4 getEvalType(void) const
Get the evaluation type of this op.
Definition: op.hh:158
virtual Datatype * getInputLocal(const PcodeOp *op, int4 slot) const
Find the minimal (or suggested) data-type of an input to this op-code.
Definition: typeop.cc:188
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
PcodeOp * op
The p-code end-point of the edge.
Definition: op.hh:237
@ mark
Used by many algorithms that need to detect loops or avoid repeats.
Definition: op.hh:82
bool isCollapsible(void) const
Definition: op.cc:115
@ ptrflow
Op consumes or produces a ptr.
Definition: op.hh:99
@ unary
Evaluate as unary expression.
Definition: op.hh:84
const Address & getAddr(void) const
Get the address portion of a sequence number.
Definition: address.hh:126
void destroyDead(void)
Destroy/retire all PcodeOps in the dead list.
Definition: op.cc:828
PcodeOpTree::const_iterator end(const Address &addr) const
End of all PcodeOps at one Address.
Definition: op.cc:1009
virtual void restoreXml(const Element *el)
Recover the details of this space from XML.
Definition: op.cc:61
@ indirect_creation
Output varnode is created by indirect effect.
Definition: op.hh:96
virtual void printRaw(ostream &s, uintb offset) const
Write an address in this space to a stream.
Definition: op.cc:35
virtual void saveXmlAttributes(ostream &s, uintb offset) const
Save an address as XML.
Definition: op.hh:35
@ fallthru_true
Set if fallthru happens on true condition.
Definition: op.hh:78
int4 getSlot(const Varnode *vn) const
Get the slot number of the indicated input varnode.
Definition: op.hh:155
void insertAfterDead(PcodeOp *op, PcodeOp *prev)
Insert the given PcodeOp after a point in the dead list.
Definition: op.cc:896
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
void changeOpcode(PcodeOp *op, TypeOp *newopc)
Change the op-code for the given PcodeOp.
Definition: op.cc:862
Container for data structures associated with a single function.
Definition: funcdata.hh:45
The base datatype class for the decompiler.
Definition: type.hh:62
PcodeOp * findOp(const SeqNum &num) const
Find a PcodeOp by sequence number.
Definition: op.cc:956
PcodeOp * nextOp(void) const
Return the next op in the control-flow from this or null.
Definition: op.cc:323
@ missing
ops at this address were not generated
Definition: op.hh:94
@ incidental_copy
Treat this as incidental for parameter recovery algorithms.
Definition: op.hh:107
@ calculated_bool
Output has been determined to be a 1-bit boolean value.
Definition: op.hh:97
The interface to a translation engine for a processor.
Definition: translate.hh:294
static PcodeOp * getOpFromConst(const Address &addr)
Retrieve the PcodeOp encoded as the address addr.
Definition: op.hh:225
map< SeqNum, PcodeOp * > PcodeOpTree
A map from sequence number (SeqNum) to PcodeOp.
Definition: op.hh:244
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
bool isCseMatch(const PcodeOp *op) const
Return true if this and op represent common subexpressions.
Definition: op.cc:154
virtual Datatype * getOutputLocal(const PcodeOp *op) const
Find the minimal (or suggested) data-type of an output to this op-code.
Definition: typeop.cc:178
void markAlive(PcodeOp *op)
Mark the given PcodeOp as alive.
Definition: op.cc:874
@ startmark
This op is the first in its instruction.
Definition: op.hh:81
bool notPrinted(void) const
Return true if this op is not directly represented in C output.
Definition: op.hh:171
list< PcodeOp * >::const_iterator beginAlive(void) const
Start of all PcodeOps marked as alive.
Definition: op.hh:300
@ spacebase_ptr
Loads or stores from a dynamic pointer into a spacebase.
Definition: op.hh:95
bool isFlowBreak(void) const
Return true if this op breaks fall-thru flow.
Definition: op.hh:178
@ marker
Definition: op.hh:73
@ halt
instruction causes processor or process to halt
Definition: op.hh:90
@ unimplemented
placeholder for unimplemented instruction
Definition: op.hh:92
void saveXml(ostream &s) const
Definition: op.cc:389
@ is_cpool_transformed
Have we checked for cpool transforms.
Definition: op.hh:108
Associate data-type and behavior information with a specific p-code op-code.
Definition: typeop.hh:37
@ boolean_flip
Set if condition must be false to take branch.
Definition: op.hh:77
uintb getNZMaskLocal(bool cliploop) const
Calculate known zero bits for output to this op.
Definition: op.cc:508
bool isBooleanFlip(void) const
Return true if this op flips the true/false meaning of its control-flow branching.
Definition: op.hh:180
void collapseConstantSymbol(Varnode *newConst) const
Propagate constant symbol from inputs to given output.
Definition: op.cc:464
PcodeOp * create(int4 inputs, const Address &pc)
Create a PcodeOp with at a given Address.
Definition: op.cc:798
int4 slot
Slot indicating the input Varnode end-point of the edge.
Definition: op.hh:238
@ warning
Warning has been generated for this op.
Definition: op.hh:106
virtual void printRaw(ostream &s, const PcodeOp *op)=0
Print (for debugging purposes) this specific PcodeOp to the stream.
@ branch
This instruction is a branch.
Definition: op.hh:68
bool isMoveable(const PcodeOp *point) const
Can this be moved to after point, without disturbing data-flow.
Definition: op.cc:179
@ coderef
The first parameter to this op is a coderef.
Definition: op.hh:80
@ indirect_source
Op is source of (one or more) CPUI_INDIRECTs.
Definition: op.hh:79
An edge in a data-flow path or graph.
Definition: op.hh:236
void setOrder(uintm ord)
Set the order field of a sequence number.
Definition: address.hh:135
IopSpace(AddrSpaceManager *m, const Translate *t, const string &nm, int4 ind)
Definition: op.cc:27
virtual void saveXmlAttributes(ostream &s, uintb offset, int4 size) const
Save an address and size as XML.
Definition: op.hh:36
A manager for different address spaces.
Definition: translate.hh:218
PcodeOp * target(void) const
Return starting op for instruction associated with this op.
Definition: op.cc:360
PcodeOpTree::const_iterator beginAll(void) const
Start of all PcodeOps in sequence number order.
Definition: op.hh:288
void clear(void)
Clear all PcodeOps from this container.
Definition: op.cc:1051
@ startbasic
This instruction starts a basic block.
Definition: op.hh:67
@ splittingbranch
Dead edge cannot be removed as it splits.
Definition: op.hh:88
@ special_print
Op is marked for special printing.
Definition: op.hh:104
bool markExplicitUnsigned(PcodeOp *op, int4 slot) const
Check if a constant input should be explicitly labeled as unsigned.
Definition: typeop.cc:230
@ nocollapse
This op cannot be collapsed further.
Definition: op.hh:71
A container for Varnode objects from a specific function.
Definition: varnode.hh:327
void printDebug(ostream &s) const
Print debug description of this op to stream.
Definition: op.cc:376