Interface ValGen<V extends JitVal>

Type Parameters:
V - the class op p-code value node in the use-def graph
All Known Subinterfaces:
DirectMemoryVarGen, InputVarGen, LocalOutVarGen, LocalVarGen<V>, MemoryOutVarGen, MemoryVarGen<V>, SubLocalVarGen<V>, SubMemoryVarGen<V>, VarGen<V>
All Known Implementing Classes:
ConstValGen, FailValGen, MissingVarGen, SubDirectMemoryVarGen, SubInputVarGen, SubLocalOutVarGen, SubMemoryOutVarGen, WholeDirectMemoryVarGen, WholeInputVarGen, WholeLocalOutVarGen, WholeMemoryOutVarGen

public interface ValGen<V extends JitVal>
The bytecode generator for a specific value (operand) access.

The JitCodeGenerator selects the correct generator for each input operand using lookup(JitVal) and each output operand VarGen.lookup(JitVar). The op generator has already retrieved the JitOp whose operands are of the JitVal class.

Varnode Type Use-Def Type Generator Type Read Bytecodes / Methods Write Bytecodes / Methods
constant JitConstVal ConstValGen ldc
unique,
register
JitInputVar,
JitLocalOutVar,
JitMissingVar
InputVarGen,
LocalOutVarGen
iload, lload, fload, dload istore, lstore, fstore, dstore
memory JitDirectMemoryVar,
JitMemoryOutVar
DirectMemoryVarGen,
MemoryOutVarGen
readInt*, readLong*, etc. writeInt*, writeLong*, etc.
*indirect JitIndirectMemoryVar None
See Also:
Implementation Notes:
Memory-mapped registers are treated as memory varnodes, not register, because they are shared by all threads. TODO: A JitConfiguration flag that says "the machine is single threaded!" so we can optimize memory accesses in the same manner we do registers and uniques., The memory variables are all generally handled as if ints, and then type conversions are applied if necessary to access them as floating point., JitMissingVar is a special case of unique and register variable where the definition could not be found. It is used as an intermediate result in the JitDataFlowModel, but should be converted to a JitOutVar defined by a JitPhiOp before it enters the use-def graph., JitIndirectMemoryVar is a singleton dummy used in the JitDataFlowModel. It is immediately thrown away, as indirect memory access is instead modeled by JitLoadOp and JitStoreOp.
  • Method Details

    • lookup

      static <V extends JitVal> ValGen<V> lookup(V v)
      Lookup the generator for a given p-code value use-def node
      Type Parameters:
      V - the class of the value
      Parameters:
      v - the JitVal whose generator to look up
      Returns:
      the generator
    • castBack

      static <FT extends Types.BPrim<?>, TT extends Types.BPrim<?>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, FT>> Emitter<Emitter.Ent<N1,TT>> castBack(Emitter<N0> em, JitType.SimpleJitType<TT,?> to, JitType.SimpleJitType<FT,?> from)
    • genValInit

      <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<N> genValInit(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v)
      Emit code to prepare any class-level items required to use this variable

      For example, if this represents a direct memory variable, then this can prepare a reference to the portion of the state involved, allowing it to access it readily.

      This should be used to emit code into the constructor.

      Type Parameters:
      THIS - the type of the generated class
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      Returns:
      the emitter with ...
    • genReadToStack

      <THIS extends JitCompiledPassage, T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next> Emitter<Emitter.Ent<N,T>> genReadToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JT type, Opnd.Ext ext)
      Emit code to read the value onto the stack
      Type Parameters:
      THIS - the type of the generated class
      T - the desired JVM type
      JT - the desired p-code type
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      type - the desired p-code type
      ext - the kind of extension to apply
      Returns:
      the emitter with ..., result
    • genReadToOpnd

      <THIS extends JitCompiledPassage, N extends Emitter.Next> Opnd.OpndEm<JitType.MpIntJitType,N> genReadToOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope)
      Emit code to read the value into local variables

      NOTE: In some cases, this may not emit any code at all. It may simple compose the operand from locals already allocated for a variable being "read."

      Type Parameters:
      THIS - the type of the generated class
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      type - the desired p-code type
      ext - the kind of extension to apply
      scope - a scope for generated temporary variables
      Returns:
      the operand and emitter with ...
    • genReadLegToStack

      <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genReadLegToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JitType.MpIntJitType type, int leg, Opnd.Ext ext)
      Emit code to read a leg of the value onto the stack
      Type Parameters:
      THIS - the type of the generated class
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      type - the desired p-code type
      leg - the leg index, 0 being the least significant
      ext - the kind of extension to apply
      Returns:
      the emitter with ..., result
    • genReadToArray

      <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TRef<int[]>>> genReadToArray(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope, int slack)
      Emit code to read the value into an array
      Type Parameters:
      THIS - the type of the generated class
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      type - the desired p-code type
      ext - the kind of extension to apply
      scope - a scope for generated temporary variables
      slack - the number of extra (more significant) elements to allocate in the array
      Returns:
      the operand and emitter with ..., arrayref
    • genReadToBool

      <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genReadToBool(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v)
      Emit code to read the value onto the stack as a boolean
      Type Parameters:
      THIS - the type of the generated class
      N - the tail of the stack (...)
      Parameters:
      em - the emitter
      localThis - a handle to this
      gen - the code generator
      v - the value
      Returns:
      the emitter with ..., result
    • subpiece

      ValGen<V> subpiece(int byteOffset, int maxByteSize)
      Create a generator for a PcodeOp.SUBPIECE of a value.
      Parameters:
      byteOffset - the number of least-significant bytes to remove
      maxByteSize - the maximum size of the resulting variable. In general, a subpiece should never exceed the size of the parent varnode, but if it does, this will truncate that excess.
      Returns:
      the resulting subpiece generator