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.ObjectPcode 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 intBOOL_ANDstatic intBOOL_NEGATEstatic intBOOL_ORstatic intBOOL_XORstatic intBRANCHstatic intBRANCHINDstatic intCALLstatic intCALLINDstatic intCALLOTHERstatic intCASTstatic intCBRANCHstatic intCOPYstatic intCPOOLREFstatic intEXTRACTstatic intFLOAT_ABSstatic intFLOAT_ADDstatic intFLOAT_CEILstatic intFLOAT_DIVstatic intFLOAT_EQUALstatic intFLOAT_FLOAT2FLOATstatic intFLOAT_FLOORstatic intFLOAT_INT2FLOATstatic intFLOAT_LESSstatic intFLOAT_LESSEQUALstatic intFLOAT_MULTstatic intFLOAT_NANstatic intFLOAT_NEGstatic intFLOAT_NOTEQUALstatic intFLOAT_ROUNDstatic intFLOAT_SQRTstatic intFLOAT_SUBstatic intFLOAT_TRUNCstatic intINDIRECTstatic intINSERTstatic intINT_2COMPstatic intINT_ADDstatic intINT_ANDstatic intINT_CARRYstatic intINT_DIVstatic intINT_EQUALstatic intINT_LEFTstatic intINT_LESSstatic intINT_LESSEQUALstatic intINT_MULTstatic intINT_NEGATEstatic intINT_NOTEQUALstatic intINT_ORstatic intINT_REMstatic intINT_RIGHTstatic intINT_SBORROWstatic intINT_SCARRYstatic intINT_SDIVstatic intINT_SEXTstatic intINT_SLESSstatic intINT_SLESSEQUALstatic intINT_SREMstatic intINT_SRIGHTstatic intINT_SUBstatic intINT_XORstatic intINT_ZEXTstatic intLOADstatic intMULTIEQUALstatic intNEWstatic intPCODE_MAXstatic intPIECEstatic intPOPCOUNTstatic intPTRADDstatic intPTRSUBstatic intRETURNstatic intSEGMENTOPstatic intSTOREstatic intSUBPIECEstatic intUNIMPLEMENTED
-
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 voidbuildXML(java.lang.StringBuilder resBuf, AddressFactory addrFactory)java.util.Iterator<PcodeOp>getBasicIter()VarnodegetInput(int i)Varnode[]getInputs()java.util.Iterator<java.lang.Object>getInsertIter()java.lang.StringgetMnemonic()static java.lang.StringgetMnemonic(int op)Get string representation for p-code operationintgetNumInputs()intgetOpcode()static intgetOpcode(java.lang.String s)Get the p-code op code for the given mnemonic string.VarnodegetOutput()PcodeBlockBasicgetParent()SequenceNumbergetSeqnum()intgetSlot(Varnode vn)Assuming vn is an input to this op, return its input slot numberinthashCode()voidinsertInput(Varnode vn, int slot)Insert an input varnode at the given index of input varnodesbooleanisAssignment()booleanisDead()Check if the pcode has been determined to be a dead operation.static PcodeOpreadXML(XmlPullParser parser, PcodeFactory pfact)Read p-code from XML streamvoidremoveInput(int slot)Remove a varnode at the given slot from the list of input varnodesvoidsetInput(Varnode vn, int slot)Set/Replace an input varnode at the given slot.voidsetOpcode(int o)Set the pcode operation codevoidsetOrder(int ord)Set relative position information of PcodeOps within a basic block, may change as basic block is edited.voidsetOutput(Varnode vn)Set the output varnode for the pcode operation.voidsetTime(int t)Set a unique number for pcode ops that are attached to the same addressjava.lang.StringtoString()
-
-
-
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:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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 UnknownInstructionExceptionGet 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
-
-