Enum Class CBranchOpGen
- All Implemented Interfaces:
OpGen<JitCBranchOp>,Serializable,Comparable<CBranchOpGen>,Constable
cbranch.
First, emits code to load the condition onto the JVM stack.
With an JitPassage.IntBranch record, this looks up the label for the target block and checks if a
transition is necessary. If one is necessary, it emits an ifeq with the
transition and goto it guards. The ifeq skips to the
fall-through case. If a transition is not necessary, it simply emits an ifne to the target label.
With an JitPassage.ExtBranch record, this does the same as BranchOpGen but guarded by an
ifeq that skips to the fall-through case.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface ghidra.pcode.emu.jit.gen.op.OpGen
OpGen.DeadOpResult, OpGen.LiveOpResult, OpGen.OpResult -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescription<THIS extends JitCompiledPassage>
OpGen.LiveOpResultgenRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, JitCBranchOp op, JitControlFlowModel.JitBlock block, Scope scope) Emit bytecode into therunmethod.static CBranchOpGenReturns the enum constant of this class with the specified name.static CBranchOpGen[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GEN
The generator singleton
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
genRun
public <THIS extends JitCompiledPassage> OpGen.LiveOpResult genRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, JitCBranchOp 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.- Specified by:
genRunin interfaceOpGen<JitCBranchOp>- 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
- Implementation Notes:
- In addition to implementing the proper logic for a conditional branch, this
contains a special case for synthetic branches created using
JitPassage.ExitPcodeOp.cond(AddrCtx). Such synthetic ops are employed to check for context modification at instruction fall through. It's rare, but if there are multiple paths in an instruction's p-code or an injection, where one causes context modification and the other does not, then we must check for context modification at run time.Conventionally, all
PcodeOp.CBRANCHops should have the condition as its second operand. Our special "conditional exit" does not. TheJitDataFlowModelrecognizes this and usesJitFailValforJitCBranchOp.cond(). The "fail" value asserts that it never gets generated, which will ensure we apply special handling here.
-