Package ghidra.program.model.pcode
Class PcodeOp
- java.lang.Object
-
- ghidra.program.model.pcode.PcodeOp
-
- Direct Known Subclasses:
PcodeOpAST
,PcodeOpRaw
public class PcodeOp extends java.lang.Object
Pcode Op describes a generic machine operation. You can think of it as the microcode for a specific processor's instruction set. There are a finite number of PcodeOp's that theoretically can define the operations for any given processor. Pcode have An operation code Some number of input parameter varnodes possible output varnode
-
-
Field Summary
Fields Modifier and Type Field Description static int
BOOL_AND
static int
BOOL_NEGATE
static int
BOOL_OR
static int
BOOL_XOR
static int
BRANCH
static int
BRANCHIND
static int
CALL
static int
CALLIND
static int
CALLOTHER
static int
CAST
static int
CBRANCH
static int
COPY
static int
CPOOLREF
static int
EXTRACT
static int
FLOAT_ABS
static int
FLOAT_ADD
static int
FLOAT_CEIL
static int
FLOAT_DIV
static int
FLOAT_EQUAL
static int
FLOAT_FLOAT2FLOAT
static int
FLOAT_FLOOR
static int
FLOAT_INT2FLOAT
static int
FLOAT_LESS
static int
FLOAT_LESSEQUAL
static int
FLOAT_MULT
static int
FLOAT_NAN
static int
FLOAT_NEG
static int
FLOAT_NOTEQUAL
static int
FLOAT_ROUND
static int
FLOAT_SQRT
static int
FLOAT_SUB
static int
FLOAT_TRUNC
static int
INDIRECT
static int
INSERT
static int
INT_2COMP
static int
INT_ADD
static int
INT_AND
static int
INT_CARRY
static int
INT_DIV
static int
INT_EQUAL
static int
INT_LEFT
static int
INT_LESS
static int
INT_LESSEQUAL
static int
INT_MULT
static int
INT_NEGATE
static int
INT_NOTEQUAL
static int
INT_OR
static int
INT_REM
static int
INT_RIGHT
static int
INT_SBORROW
static int
INT_SCARRY
static int
INT_SDIV
static int
INT_SEXT
static int
INT_SLESS
static int
INT_SLESSEQUAL
static int
INT_SREM
static int
INT_SRIGHT
static int
INT_SUB
static int
INT_XOR
static int
INT_ZEXT
static int
LOAD
static int
MULTIEQUAL
static int
NEW
static int
PCODE_MAX
static int
PIECE
static int
POPCOUNT
static int
PTRADD
static int
PTRSUB
static int
RETURN
static int
SEGMENTOP
static int
STORE
static int
SUBPIECE
static int
UNIMPLEMENTED
-
Constructor Summary
Constructors Constructor Description PcodeOp(Address a, int sequencenumber, int op)
Constructor - no inputs, outputPcodeOp(Address a, int sequencenumber, int op, Varnode[] in)
Constructor - no outputPcodeOp(Address a, int sequencenumber, int op, Varnode[] in, Varnode out)
Constructor - inputs and outputsPcodeOp(SequenceNumber sq, int op, int numinputs, Varnode out)
Constructor - pcode part of sequence of pcodes, some number of inputs, outputPcodeOp(SequenceNumber sq, int op, Varnode[] in, Varnode out)
Constructor - pcode part of sequence of pcodes, inputs, outputs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildXML(java.lang.StringBuilder resBuf, AddressFactory addrFactory)
java.util.Iterator<PcodeOp>
getBasicIter()
Varnode
getInput(int i)
Varnode[]
getInputs()
java.util.Iterator<java.lang.Object>
getInsertIter()
java.lang.String
getMnemonic()
static java.lang.String
getMnemonic(int op)
Get string representation for p-code operationint
getNumInputs()
int
getOpcode()
static int
getOpcode(java.lang.String s)
Get the p-code op code for the given mnemonic string.Varnode
getOutput()
PcodeBlockBasic
getParent()
SequenceNumber
getSeqnum()
int
getSlot(Varnode vn)
Assuming vn is an input to this op, return its input slot numberint
hashCode()
void
insertInput(Varnode vn, int slot)
Insert an input varnode at the given index of input varnodesboolean
isAssignment()
boolean
isDead()
Check if the pcode has been determined to be a dead operation.static PcodeOp
readXML(XmlPullParser parser, PcodeFactory pfact)
Read p-code from XML streamvoid
removeInput(int slot)
Remove a varnode at the given slot from the list of input varnodesvoid
setInput(Varnode vn, int slot)
Set/Replace an input varnode at the given slot.void
setOpcode(int o)
Set the pcode operation codevoid
setOrder(int ord)
Set relative position information of PcodeOps within a basic block, may change as basic block is edited.void
setOutput(Varnode vn)
Set the output varnode for the pcode operation.void
setTime(int t)
Set a unique number for pcode ops that are attached to the same addressjava.lang.String
toString()
-
-
-
Field Detail
-
UNIMPLEMENTED
public static final int UNIMPLEMENTED
- See Also:
- Constant Field Values
-
COPY
public static final int COPY
- See Also:
- Constant Field Values
-
LOAD
public static final int LOAD
- See Also:
- Constant Field Values
-
STORE
public static final int STORE
- See Also:
- Constant Field Values
-
BRANCH
public static final int BRANCH
- See Also:
- Constant Field Values
-
CBRANCH
public static final int CBRANCH
- See Also:
- Constant Field Values
-
BRANCHIND
public static final int BRANCHIND
- See Also:
- Constant Field Values
-
CALL
public static final int CALL
- See Also:
- Constant Field Values
-
CALLIND
public static final int CALLIND
- See Also:
- Constant Field Values
-
CALLOTHER
public static final int CALLOTHER
- See Also:
- Constant Field Values
-
RETURN
public static final int RETURN
- See Also:
- Constant Field Values
-
INT_EQUAL
public static final int INT_EQUAL
- See Also:
- Constant Field Values
-
INT_NOTEQUAL
public static final int INT_NOTEQUAL
- See Also:
- Constant Field Values
-
INT_SLESS
public static final int INT_SLESS
- See Also:
- Constant Field Values
-
INT_SLESSEQUAL
public static final int INT_SLESSEQUAL
- See Also:
- Constant Field Values
-
INT_LESS
public static final int INT_LESS
- See Also:
- Constant Field Values
-
INT_LESSEQUAL
public static final int INT_LESSEQUAL
- See Also:
- Constant Field Values
-
INT_ZEXT
public static final int INT_ZEXT
- See Also:
- Constant Field Values
-
INT_SEXT
public static final int INT_SEXT
- See Also:
- Constant Field Values
-
INT_ADD
public static final int INT_ADD
- See Also:
- Constant Field Values
-
INT_SUB
public static final int INT_SUB
- See Also:
- Constant Field Values
-
INT_CARRY
public static final int INT_CARRY
- See Also:
- Constant Field Values
-
INT_SCARRY
public static final int INT_SCARRY
- See Also:
- Constant Field Values
-
INT_SBORROW
public static final int INT_SBORROW
- See Also:
- Constant Field Values
-
INT_2COMP
public static final int INT_2COMP
- See Also:
- Constant Field Values
-
INT_NEGATE
public static final int INT_NEGATE
- See Also:
- Constant Field Values
-
INT_XOR
public static final int INT_XOR
- See Also:
- Constant Field Values
-
INT_AND
public static final int INT_AND
- See Also:
- Constant Field Values
-
INT_OR
public static final int INT_OR
- See Also:
- Constant Field Values
-
INT_LEFT
public static final int INT_LEFT
- See Also:
- Constant Field Values
-
INT_RIGHT
public static final int INT_RIGHT
- See Also:
- Constant Field Values
-
INT_SRIGHT
public static final int INT_SRIGHT
- See Also:
- Constant Field Values
-
INT_MULT
public static final int INT_MULT
- See Also:
- Constant Field Values
-
INT_DIV
public static final int INT_DIV
- See Also:
- Constant Field Values
-
INT_SDIV
public static final int INT_SDIV
- See Also:
- Constant Field Values
-
INT_REM
public static final int INT_REM
- See Also:
- Constant Field Values
-
INT_SREM
public static final int INT_SREM
- See Also:
- Constant Field Values
-
BOOL_NEGATE
public static final int BOOL_NEGATE
- See Also:
- Constant Field Values
-
BOOL_XOR
public static final int BOOL_XOR
- See Also:
- Constant Field Values
-
BOOL_AND
public static final int BOOL_AND
- See Also:
- Constant Field Values
-
BOOL_OR
public static final int BOOL_OR
- See Also:
- Constant Field Values
-
FLOAT_EQUAL
public static final int FLOAT_EQUAL
- See Also:
- Constant Field Values
-
FLOAT_NOTEQUAL
public static final int FLOAT_NOTEQUAL
- See Also:
- Constant Field Values
-
FLOAT_LESS
public static final int FLOAT_LESS
- See Also:
- Constant Field Values
-
FLOAT_LESSEQUAL
public static final int FLOAT_LESSEQUAL
- See Also:
- Constant Field Values
-
FLOAT_NAN
public static final int FLOAT_NAN
- See Also:
- Constant Field Values
-
FLOAT_ADD
public static final int FLOAT_ADD
- See Also:
- Constant Field Values
-
FLOAT_DIV
public static final int FLOAT_DIV
- See Also:
- Constant Field Values
-
FLOAT_MULT
public static final int FLOAT_MULT
- See Also:
- Constant Field Values
-
FLOAT_SUB
public static final int FLOAT_SUB
- See Also:
- Constant Field Values
-
FLOAT_NEG
public static final int FLOAT_NEG
- See Also:
- Constant Field Values
-
FLOAT_ABS
public static final int FLOAT_ABS
- See Also:
- Constant Field Values
-
FLOAT_SQRT
public static final int FLOAT_SQRT
- See Also:
- Constant Field Values
-
FLOAT_INT2FLOAT
public static final int FLOAT_INT2FLOAT
- See Also:
- Constant Field Values
-
FLOAT_FLOAT2FLOAT
public static final int FLOAT_FLOAT2FLOAT
- See Also:
- Constant Field Values
-
FLOAT_TRUNC
public static final int FLOAT_TRUNC
- See Also:
- Constant Field Values
-
FLOAT_CEIL
public static final int FLOAT_CEIL
- See Also:
- Constant Field Values
-
FLOAT_FLOOR
public static final int FLOAT_FLOOR
- See Also:
- Constant Field Values
-
FLOAT_ROUND
public static final int FLOAT_ROUND
- See Also:
- Constant Field Values
-
MULTIEQUAL
public static final int MULTIEQUAL
- See Also:
- Constant Field Values
-
INDIRECT
public static final int INDIRECT
- See Also:
- Constant Field Values
-
PIECE
public static final int PIECE
- See Also:
- Constant Field Values
-
SUBPIECE
public static final int SUBPIECE
- See Also:
- Constant Field Values
-
CAST
public static final int CAST
- See Also:
- Constant Field Values
-
PTRADD
public static final int PTRADD
- See Also:
- Constant Field Values
-
PTRSUB
public static final int PTRSUB
- See Also:
- Constant Field Values
-
SEGMENTOP
public static final int SEGMENTOP
- See Also:
- Constant Field Values
-
CPOOLREF
public static final int CPOOLREF
- See Also:
- Constant Field Values
-
NEW
public static final int NEW
- See Also:
- Constant Field Values
-
INSERT
public static final int INSERT
- See Also:
- Constant Field Values
-
EXTRACT
public static final int EXTRACT
- See Also:
- Constant Field Values
-
POPCOUNT
public static final int POPCOUNT
- See Also:
- Constant Field Values
-
PCODE_MAX
public static final int PCODE_MAX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PcodeOp
public PcodeOp(SequenceNumber sq, int op, int numinputs, Varnode out)
Constructor - pcode part of sequence of pcodes, some number of inputs, output- Parameters:
sq
- place in sequence of pcodeop
- pcode operationnuminputs
- number of inputs to operation, actual inputs not defined yet.out
- output from operation
-
PcodeOp
public PcodeOp(SequenceNumber sq, int op, Varnode[] in, Varnode out)
Constructor - pcode part of sequence of pcodes, inputs, outputs- Parameters:
sq
- place in sequence of pcodeop
- pcode operationin
- inputs to operationout
- output from operation
-
PcodeOp
public PcodeOp(Address a, int sequencenumber, int op, Varnode[] in, Varnode out)
Constructor - inputs and outputs- Parameters:
a
- address pcode is attached tosequencenumber
- unique sequence number for the specified address.op
- pcode operationin
- inputs to operationout
- output from operation
-
PcodeOp
public PcodeOp(Address a, int sequencenumber, int op, Varnode[] in)
Constructor - no output- Parameters:
a
- address pcode is attached tosequencenumber
- id within a single addressop
- operation pcode performsin
- inputs from pcode operation
-
PcodeOp
public PcodeOp(Address a, int sequencenumber, int op)
Constructor - no inputs, output- Parameters:
a
- address pcode is attached tosequencenumber
- id within a single addressop
- pcode operation
-
-
Method Detail
-
getOpcode
public final int getOpcode()
- Returns:
- pcode operation code
-
getNumInputs
public final int getNumInputs()
- Returns:
- number of input varnodes
-
getInputs
public final Varnode[] getInputs()
- Returns:
- get input varnodes
-
getInput
public final Varnode getInput(int i)
- Parameters:
i
- the i'th input varnode- Returns:
- the i'th input varnode
-
getOutput
public final Varnode getOutput()
- Returns:
- get output varnodes
-
getSlot
public final int getSlot(Varnode vn)
Assuming vn is an input to this op, return its input slot number- Parameters:
vn
- is the input varnode- Returns:
- the slot number
-
getMnemonic
public final java.lang.String getMnemonic()
- Returns:
- get the string representation for the pcode operation
-
isDead
public boolean isDead()
Check if the pcode has been determined to be a dead operation.- Returns:
- true if the pcode has been determined to have no effect in the context it is used
-
isAssignment
public final boolean isAssignment()
- Returns:
- true if the pcode assigns a value to an output varnode
-
getSeqnum
public final SequenceNumber getSeqnum()
- Returns:
- the sequence number this pcode is within some number of pcode
-
getBasicIter
public java.util.Iterator<PcodeOp> getBasicIter()
-
getInsertIter
public java.util.Iterator<java.lang.Object> getInsertIter()
-
getParent
public PcodeBlockBasic getParent()
- Returns:
- the pcode basic block this pcode belongs to
-
setOpcode
public final void setOpcode(int o)
Set the pcode operation code- Parameters:
o
- pcode operation code
-
setInput
public final void setInput(Varnode vn, int slot)
Set/Replace an input varnode at the given slot.- Parameters:
vn
- varnode to replaceslot
- index of input varnode to be replaced
-
removeInput
public final void removeInput(int slot)
Remove a varnode at the given slot from the list of input varnodes- Parameters:
slot
- index of input varnode to remove
-
insertInput
public final void insertInput(Varnode vn, int slot)
Insert an input varnode at the given index of input varnodes- Parameters:
vn
- varnode to insertslot
- insert index in input varnode list
-
setTime
public final void setTime(int t)
Set a unique number for pcode ops that are attached to the same address- Parameters:
t
- unique id
-
setOrder
public final void setOrder(int ord)
Set relative position information of PcodeOps within a basic block, may change as basic block is edited.- Parameters:
ord
- relative position of pcode op in basic block
-
setOutput
public final void setOutput(Varnode vn)
Set the output varnode for the pcode operation.- Parameters:
vn
- new output varnode
-
buildXML
public void buildXML(java.lang.StringBuilder resBuf, AddressFactory addrFactory)
-
readXML
public static PcodeOp readXML(XmlPullParser parser, PcodeFactory pfact) throws PcodeXMLException
Read p-code from XML stream- Parameters:
parser
- is the XML streampfact
- factory used to create p-code correctly- Returns:
- new PcodeOp
- Throws:
PcodeXMLException
- if XML layout is incorrect
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getMnemonic
public static final java.lang.String getMnemonic(int op)
Get string representation for p-code operation- Parameters:
op
- operation code- Returns:
- String representation of p-code operation
-
getOpcode
public static int getOpcode(java.lang.String s) throws UnknownInstructionException
Get the p-code op code for the given mnemonic string.- Parameters:
s
- is the mnemonic string- Returns:
- the op code
- Throws:
UnknownInstructionException
- if there is no matching mnemonic
-
-