Class 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 TODO: write an emulator for each PcodeOp. It should execute on a Pcode machine state.
    • 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 pcode
        op - pcode operation
        numinputs - 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 pcode
        op - pcode operation
        in - inputs to operation
        out - 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 to
        sequencenumber - unique sequence number for the specified address.
        op - pcode operation
        in - inputs to operation
        out - output from operation
      • PcodeOp

        public PcodeOp​(Address a,
                       int sequencenumber,
                       int op,
                       Varnode[] in)
        Constructor - no output
        Parameters:
        a - address pcode is attached to
        op - operation pcode performs
        in - inputs from pcode operation
      • PcodeOp

        public PcodeOp​(Address a,
                       int sequencenumber,
                       int op)
        Constructor - no inputs, output
        Parameters:
        a - address pcode is attached to
        op - 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 replace
        slot - 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 insert
        slot - 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)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getMnemonic

        public static final java.lang.String getMnemonic​(int op)
        Get string representation for pcode operation
        Parameters:
        op - operation code
        Returns:
        String rep of pcode operation
        Throws:
        UnknownInstructionException