Package ghidra.program.model.pcode
Class PcodeOp
java.lang.Object
ghidra.program.model.pcode.PcodeOp
- Direct Known Subclasses:
PcodeOpAST
,PcodeOpRaw
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
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorDescriptionConstructor - no inputs, outputConstructor - no outputConstructor - 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
Modifier and TypeMethodDescriptionstatic PcodeOp
decode
(Decoder decoder, PcodeFactory pfact) Decode p-code from a streamvoid
encodeRaw
(Encoder encoder, AddressFactory addrFactory) Encode just the opcode and input/output Varnode data for this PcodeOp to a stream as an<op>
elementfinal Varnode
getInput
(int i) final Varnode[]
final String
static final String
getMnemonic
(int op) Get string representation for p-code operationfinal int
final int
static int
Get the p-code op code for the given mnemonic string.final Varnode
final SequenceNumber
final int
Assuming vn is an input to this op, return its input slot numberint
hashCode()
final void
insertInput
(Varnode vn, int slot) Insert an input varnode at the given index of input varnodesfinal boolean
final boolean
Return true if the PcodeOp is commutative.static boolean
isCommutative
(int opcode) Return true if the given opcode represents a commutative operation.boolean
isDead()
Check if the pcode has been determined to be a dead operation.final void
removeInput
(int slot) Remove a varnode at the given slot from the list of input varnodesfinal void
Set/Replace an input varnode at the given slot.final void
setOpcode
(int o) Set the pcode operation codefinal void
setOrder
(int ord) Set relative position information of PcodeOps within a basic block, may change as basic block is edited.final void
Set the output varnode for the pcode operation.final void
setTime
(int t) Set a unique number for pcode ops that are attached to the same addresstoString()
-
Field Details
-
UNIMPLEMENTED
public static final int UNIMPLEMENTED- See Also:
-
COPY
public static final int COPY- See Also:
-
LOAD
public static final int LOAD- See Also:
-
STORE
public static final int STORE- See Also:
-
BRANCH
public static final int BRANCH- See Also:
-
CBRANCH
public static final int CBRANCH- See Also:
-
BRANCHIND
public static final int BRANCHIND- See Also:
-
CALL
public static final int CALL- See Also:
-
CALLIND
public static final int CALLIND- See Also:
-
CALLOTHER
public static final int CALLOTHER- See Also:
-
RETURN
public static final int RETURN- See Also:
-
INT_EQUAL
public static final int INT_EQUAL- See Also:
-
INT_NOTEQUAL
public static final int INT_NOTEQUAL- See Also:
-
INT_SLESS
public static final int INT_SLESS- See Also:
-
INT_SLESSEQUAL
public static final int INT_SLESSEQUAL- See Also:
-
INT_LESS
public static final int INT_LESS- See Also:
-
INT_LESSEQUAL
public static final int INT_LESSEQUAL- See Also:
-
INT_ZEXT
public static final int INT_ZEXT- See Also:
-
INT_SEXT
public static final int INT_SEXT- See Also:
-
INT_ADD
public static final int INT_ADD- See Also:
-
INT_SUB
public static final int INT_SUB- See Also:
-
INT_CARRY
public static final int INT_CARRY- See Also:
-
INT_SCARRY
public static final int INT_SCARRY- See Also:
-
INT_SBORROW
public static final int INT_SBORROW- See Also:
-
INT_2COMP
public static final int INT_2COMP- See Also:
-
INT_NEGATE
public static final int INT_NEGATE- See Also:
-
INT_XOR
public static final int INT_XOR- See Also:
-
INT_AND
public static final int INT_AND- See Also:
-
INT_OR
public static final int INT_OR- See Also:
-
INT_LEFT
public static final int INT_LEFT- See Also:
-
INT_RIGHT
public static final int INT_RIGHT- See Also:
-
INT_SRIGHT
public static final int INT_SRIGHT- See Also:
-
INT_MULT
public static final int INT_MULT- See Also:
-
INT_DIV
public static final int INT_DIV- See Also:
-
INT_SDIV
public static final int INT_SDIV- See Also:
-
INT_REM
public static final int INT_REM- See Also:
-
INT_SREM
public static final int INT_SREM- See Also:
-
BOOL_NEGATE
public static final int BOOL_NEGATE- See Also:
-
BOOL_XOR
public static final int BOOL_XOR- See Also:
-
BOOL_AND
public static final int BOOL_AND- See Also:
-
BOOL_OR
public static final int BOOL_OR- See Also:
-
FLOAT_EQUAL
public static final int FLOAT_EQUAL- See Also:
-
FLOAT_NOTEQUAL
public static final int FLOAT_NOTEQUAL- See Also:
-
FLOAT_LESS
public static final int FLOAT_LESS- See Also:
-
FLOAT_LESSEQUAL
public static final int FLOAT_LESSEQUAL- See Also:
-
FLOAT_NAN
public static final int FLOAT_NAN- See Also:
-
FLOAT_ADD
public static final int FLOAT_ADD- See Also:
-
FLOAT_DIV
public static final int FLOAT_DIV- See Also:
-
FLOAT_MULT
public static final int FLOAT_MULT- See Also:
-
FLOAT_SUB
public static final int FLOAT_SUB- See Also:
-
FLOAT_NEG
public static final int FLOAT_NEG- See Also:
-
FLOAT_ABS
public static final int FLOAT_ABS- See Also:
-
FLOAT_SQRT
public static final int FLOAT_SQRT- See Also:
-
FLOAT_INT2FLOAT
public static final int FLOAT_INT2FLOAT- See Also:
-
FLOAT_FLOAT2FLOAT
public static final int FLOAT_FLOAT2FLOAT- See Also:
-
FLOAT_TRUNC
public static final int FLOAT_TRUNC- See Also:
-
FLOAT_CEIL
public static final int FLOAT_CEIL- See Also:
-
FLOAT_FLOOR
public static final int FLOAT_FLOOR- See Also:
-
FLOAT_ROUND
public static final int FLOAT_ROUND- See Also:
-
MULTIEQUAL
public static final int MULTIEQUAL- See Also:
-
INDIRECT
public static final int INDIRECT- See Also:
-
PIECE
public static final int PIECE- See Also:
-
SUBPIECE
public static final int SUBPIECE- See Also:
-
CAST
public static final int CAST- See Also:
-
PTRADD
public static final int PTRADD- See Also:
-
PTRSUB
public static final int PTRSUB- See Also:
-
SEGMENTOP
public static final int SEGMENTOP- See Also:
-
CPOOLREF
public static final int CPOOLREF- See Also:
-
NEW
public static final int NEW- See Also:
-
INSERT
public static final int INSERT- See Also:
-
EXTRACT
public static final int EXTRACT- See Also:
-
POPCOUNT
public static final int POPCOUNT- See Also:
-
LZCOUNT
public static final int LZCOUNT- See Also:
-
PCODE_MAX
public static final int PCODE_MAX- See Also:
-
-
Constructor Details
-
PcodeOp
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
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
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
Constructor - no output- Parameters:
a
- address pcode is attached tosequencenumber
- id within a single addressop
- operation pcode performsin
- inputs from pcode operation
-
PcodeOp
Constructor - no inputs, output- Parameters:
a
- address pcode is attached tosequencenumber
- id within a single addressop
- pcode operation
-
-
Method Details
-
getOpcode
public final int getOpcode()- Returns:
- pcode operation code
-
getNumInputs
public final int getNumInputs()- Returns:
- number of input varnodes
-
getInputs
- Returns:
- get input varnodes
-
getInput
- Parameters:
i
- the i'th input varnode- Returns:
- the i'th input varnode
-
getOutput
- Returns:
- get output varnodes
-
getSlot
Assuming vn is an input to this op, return its input slot number- Parameters:
vn
- is the input varnode- Returns:
- the slot number
-
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
-
isCommutative
public final boolean isCommutative()Return true if the PcodeOp is commutative. If true, the operation has exactly two inputs that can be switched without affecting the output.- Returns:
- true if the operation is commutative
-
getSeqnum
- Returns:
- the sequence number this pcode is within some number of pcode
-
getBasicIter
-
getInsertIter
-
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
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
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
Set the output varnode for the pcode operation.- Parameters:
vn
- new output varnode
-
encodeRaw
Encode just the opcode and input/output Varnode data for this PcodeOp to a stream as an<op>
element- Parameters:
encoder
- is the stream encoderaddrFactory
- is a factory for looking up encoded address spaces- Throws:
IOException
- for errors in the underlying stream
-
decode
Decode p-code from a stream- Parameters:
decoder
- is the stream decoderpfact
- factory used to create p-code correctly- Returns:
- new PcodeOp
- Throws:
DecoderException
- if encodings are invalid
-
toString
-
hashCode
public int hashCode() -
getMnemonic
Get string representation for p-code operation- Parameters:
op
- operation code- Returns:
- String representation of p-code operation
-
getOpcode
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
-
isCommutative
public static boolean isCommutative(int opcode) Return true if the given opcode represents a commutative operation. If true, the operation has exactly two inputs that can be switched without affecting the output.- Parameters:
opcode
- is the opcode- Returns:
- true if the operation is commutative
-