Interface OpGen<T extends JitOp>
- Type Parameters:
T- the class of p-code op node in the use-def graph
- All Known Subinterfaces:
BinOpGen<T>,FloatCompareBinOpGen<T>,FloatConvertUnOpGen<T>,FloatOpBinOpGen<T>,FloatOpUnOpGen<T>,IntBitwiseBinOpGen<T>,IntCompareBinOpGen<T>,IntCountUnOpGen<T>,IntExtUnOpGen<T>,IntOpBinOpGen<T>,IntOpUnOpGen<T>,IntPredBinOpGen<T>,IntShiftBinOpGen<T>,UnOpGen<T>
- All Known Implementing Classes:
BoolAndOpGen,BoolNegateOpGen,BoolOrOpGen,BoolXorOpGen,BranchIndOpGen,BranchOpGen,CallOtherMissingOpGen,CallOtherOpGen,CatenateOpGen,CBranchOpGen,CopyOpGen,FloatAbsOpGen,FloatAddOpGen,FloatCeilOpGen,FloatDivOpGen,FloatEqualOpGen,FloatFloat2FloatOpGen,FloatFloorOpGen,FloatInt2FloatOpGen,FloatLessEqualOpGen,FloatLessOpGen,FloatMultOpGen,FloatNaNOpGen,FloatNegOpGen,FloatNotEqualOpGen,FloatRoundOpGen,FloatSqrtOpGen,FloatSubOpGen,FloatTruncOpGen,Int2CompOpGen,IntAddOpGen,IntAndOpGen,IntCarryOpGen,IntDivOpGen,IntEqualOpGen,IntLeftOpGen,IntLessEqualOpGen,IntLessOpGen,IntMultOpGen,IntNegateOpGen,IntNotEqualOpGen,IntOrOpGen,IntRemOpGen,IntRightOpGen,IntSBorrowOpGen,IntSCarryOpGen,IntSDivOpGen,IntSExtOpGen,IntSLessEqualOpGen,IntSLessOpGen,IntSRemOpGen,IntSRightOpGen,IntSubOpGen,IntXorOpGen,IntZExtOpGen,LoadOpGen,LzCountOpGen,NopOpGen,PhiOpGen,PopCountOpGen,StoreOpGen,SubPieceOpGen,SynthSubPieceOpGen,UnimplementedOpGen
The JitCodeGenerator selects the correct generator for each PcodeOp using
JitDataFlowModel.getJitOp(PcodeOp) and lookup(JitOp). The following table lists
each p-code op, its use-def class, its generator class, and a brief strategy for its bytecode
implementation.
There are other p-code ops. Some are only used in "high" p-code, and so we need not implement
them here. Others are used in abstract virtual machines, e.g., PcodeOp.NEW or are just
not yet implemented, e.g., PcodeOp.SEGMENTOP.
The mapping from PcodeOp opcode to JitOp is done in, e.g.,
JitOp.binOp(PcodeOp, JitOutVar, JitVal, JitVal), and the mapping from JitOp to
OpGen is done in lookup(JitOp).
The synthetic use-def nodes do not correspond to any p-code op. They are synthesized based on
access patterns to the JitDataFlowState. Their generators do not emit any bytecode. See
JitVarScopeModel regarding coalescing and allocating variables.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe result when bytecode after that emitted is not reachablestatic final recordThe result when bytecode after that emitted is reachablestatic interfaceThe result of emitting code for a p-code op -
Method Summary
Modifier and TypeMethodDescriptionstatic <N extends Emitter.Next>
Emitter<N> generateSyserrInts(Emitter<N> em, Opnd<JitType.MpIntJitType> opnd) For debugging: emit code to print the values of the given operand to stderr.<THIS extends JitCompiledPassage>
OpGen.OpResultgenRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, T op, JitControlFlowModel.JitBlock block, Scope scope) Emit bytecode into therunmethod.lookup(T op) Lookup the generator for a given p-code op use-def node
-
Method Details
-
lookup
Lookup the generator for a given p-code op use-def node- Type Parameters:
T- the class of the op- Parameters:
op- theJitOpwhose generator to look up- Returns:
- the generator
-
generateSyserrInts
static <N extends Emitter.Next> Emitter<N> generateSyserrInts(Emitter<N> em, Opnd<JitType.MpIntJitType> opnd) For debugging: emit code to print the values of the given operand to stderr.- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackopnd- the operand whose values to print- Returns:
- the emitter typed with the incoming stack
-
genRun
<THIS extends JitCompiledPassage> OpGen.OpResult genRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, T op, JitControlFlowModel.JitBlock block, Scope scope) Emit bytecode into therunmethod.This method must emit the code needed to load any input operands, convert them to the appropriate type, perform the actual operation, and then if applicable, store the output operand. The implementations should delegate to
JitCodeGenerator.genReadToStack(Emitter, Local, JitVal, ghidra.pcode.emu.jit.analysis.JitType.SimpleJitType, Ext),JitCodeGenerator.genWriteFromStack(Emitter, Local, JitVar, ghidra.pcode.emu.jit.analysis.JitType.SimpleJitType, Ext, Scope)or similar for mp-int types.- Type Parameters:
THIS- the type of the generated passage- Parameters:
em- the emitter typed with the empty stacklocalThis- a handle to the local holding thethisreferencelocalCtxmod- a handle to the local holdingctxmodretReq- an indication of what must be returned by thisJitCompiledPassage.run(int)method.gen- the code generatorop- the p-code op (use-def node) to translateblock- the basic block containing the p-code opscope- a scope for generating temporary local storage- Returns:
- the result of emitting the p-code op's bytecode
-