Return address handling. Not happy with the design, but it (sorta) works.
This commit is contained in:
@@ -459,6 +459,12 @@ void FunctionBuilder::Return() {
|
||||
EndBlock();
|
||||
}
|
||||
|
||||
void FunctionBuilder::SetReturnAddress(Value* value) {
|
||||
Instr* i = AppendInstr(OPCODE_SET_RETURN_ADDRESS_info, 0);
|
||||
i->set_src1(value);
|
||||
i->src2.value = i->src3.value = NULL;
|
||||
}
|
||||
|
||||
void FunctionBuilder::Branch(Label* label, uint32_t branch_flags) {
|
||||
Instr* i = AppendInstr(OPCODE_BRANCH_info, branch_flags);
|
||||
i->src1.label = label;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
void CallIndirect(Value* value, uint32_t call_flags = 0);
|
||||
void CallIndirectTrue(Value* cond, Value* value, uint32_t call_flags = 0);
|
||||
void Return();
|
||||
void SetReturnAddress(Value* value);
|
||||
|
||||
void Branch(Label* label, uint32_t branch_flags = 0);
|
||||
void BranchIf(Value* cond, Label* true_label, Label* false_label,
|
||||
|
||||
@@ -75,6 +75,7 @@ enum Opcode {
|
||||
OPCODE_CALL_INDIRECT,
|
||||
OPCODE_CALL_INDIRECT_TRUE,
|
||||
OPCODE_RETURN,
|
||||
OPCODE_SET_RETURN_ADDRESS,
|
||||
|
||||
OPCODE_BRANCH,
|
||||
OPCODE_BRANCH_IF,
|
||||
|
||||
@@ -74,6 +74,12 @@ DEFINE_OPCODE(
|
||||
OPCODE_SIG_X,
|
||||
OPCODE_FLAG_BRANCH);
|
||||
|
||||
DEFINE_OPCODE(
|
||||
OPCODE_SET_RETURN_ADDRESS,
|
||||
"set_return_address",
|
||||
OPCODE_SIG_X_V,
|
||||
0);
|
||||
|
||||
DEFINE_OPCODE(
|
||||
OPCODE_BRANCH,
|
||||
"branch",
|
||||
|
||||
Reference in New Issue
Block a user