Package ghidra.pcode.emu.jit.gen.var
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
memoryvarnodes, notregister, because they are shared by all threads. TODO: AJitConfigurationflag 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 thentype conversionsare applied if necessary to access them as floating point.,JitMissingVaris a special case ofuniqueandregistervariable where the definition could not be found. It is used as an intermediate result in theJitDataFlowModel, but should be converted to aJitOutVardefined by aJitPhiOpbefore it enters the use-def graph.,JitIndirectMemoryVaris a singleton dummy used in theJitDataFlowModel. It is immediately thrown away, as indirect memory access is instead modeled byJitLoadOpandJitStoreOp.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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) <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<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<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<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<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<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 variablelookup(V v) Lookup the generator for a given p-code value use-def nodesubpiece(int byteOffset, int maxByteSize) Create a generator for aPcodeOp.SUBPIECEof a value.
-
Method Details
-
lookup
Lookup the generator for a given p-code value use-def node- Type Parameters:
V- the class of the value- Parameters:
v- theJitValwhose generator to look up- Returns:
- the generator
-
castBack
static <FT extends Types.BPrim<?>,TT extends Types.BPrim<?>, Emitter<Emitter.Ent<N1,N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, FT>> 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 variableFor 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 classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the value- Returns:
- the emitter with ...
-
genReadToStack
<THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<Emitter.Ent<N,JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next> 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 classT- the desired JVM typeJT- the desired p-code typeN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the valuetype- the desired p-code typeext- 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 variablesNOTE: 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 classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the valuetype- the desired p-code typeext- the kind of extension to applyscope- 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 classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the valuetype- the desired p-code typeleg- the leg index, 0 being the least significantext- 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 classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the valuetype- the desired p-code typeext- the kind of extension to applyscope- a scope for generated temporary variablesslack- 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 classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the value- Returns:
- the emitter with ..., result
-
subpiece
Create a generator for aPcodeOp.SUBPIECEof a value.- Parameters:
byteOffset- the number of least-significant bytes to removemaxByteSize- 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
-