renamed CALL_FALLBACK to FALLBACK

This commit is contained in:
Anthony Pesch 2017-05-11 19:11:29 -04:00
parent 52e5095933
commit eb2e1b6bcd
7 changed files with 34 additions and 28 deletions

View File

@ -654,6 +654,17 @@ static void x64_backend_reset(struct jit_backend *base) {
x64_backend_emit_constants(backend); x64_backend_emit_constants(backend);
} }
EMITTER(FALLBACK) {
void *fallback = (void *)instr->arg[0]->i64;
uint32_t addr = instr->arg[1]->i32;
uint32_t raw_instr = instr->arg[2]->i32;
e.mov(arg0, reinterpret_cast<uint64_t>(backend->base.jit));
e.mov(arg1, addr);
e.mov(arg2, raw_instr);
e.call(fallback);
}
EMITTER(LOAD) { EMITTER(LOAD) {
const Xbyak::Reg a = x64_backend_reg(backend, instr->arg[0]); const Xbyak::Reg a = x64_backend_reg(backend, instr->arg[0]);
@ -1594,17 +1605,6 @@ EMITTER(CALL) {
} }
} }
EMITTER(CALL_FALLBACK) {
void *fallback = (void *)instr->arg[0]->i64;
uint32_t addr = instr->arg[1]->i32;
uint32_t raw_instr = instr->arg[2]->i32;
e.mov(arg0, reinterpret_cast<uint64_t>(backend->base.jit));
e.mov(arg1, addr);
e.mov(arg2, raw_instr);
e.call(fallback);
}
EMITTER(DEBUG_INFO) {} EMITTER(DEBUG_INFO) {}
EMITTER(DEBUG_BREAK) { EMITTER(DEBUG_BREAK) {

View File

@ -5,5 +5,5 @@
void armv3_emit_instr(struct armv3_frontend *frontend, struct ir *ir, int flags, void armv3_emit_instr(struct armv3_frontend *frontend, struct ir *ir, int flags,
uint32_t addr, uint32_t instr) { uint32_t addr, uint32_t instr) {
void *fallback = armv3_fallback(instr); void *fallback = armv3_fallback(instr);
ir_call_fallback(ir, fallback, addr, instr); ir_fallback(ir, fallback, addr, instr);
} }

View File

@ -373,6 +373,16 @@ uint64_t ir_zext_constant(const struct ir_value *v) {
} }
} }
void ir_fallback(struct ir *ir, void *fallback, uint32_t addr,
uint32_t raw_instr) {
CHECK(fallback);
struct ir_instr *instr = ir_append_instr(ir, OP_FALLBACK, VALUE_V);
ir_set_arg0(ir, instr, ir_alloc_ptr(ir, fallback));
ir_set_arg1(ir, instr, ir_alloc_i32(ir, addr));
ir_set_arg2(ir, instr, ir_alloc_i32(ir, raw_instr));
}
struct ir_value *ir_load(struct ir *ir, struct ir_value *addr, struct ir_value *ir_load(struct ir *ir, struct ir_value *addr,
enum ir_type type) { enum ir_type type) {
CHECK_EQ(VALUE_I64, addr->type); CHECK_EQ(VALUE_I64, addr->type);
@ -946,16 +956,6 @@ void ir_call_2(struct ir *ir, struct ir_value *fn, struct ir_value *arg0,
ir_set_arg2(ir, instr, arg1); ir_set_arg2(ir, instr, arg1);
} }
void ir_call_fallback(struct ir *ir, void *fallback, uint32_t addr,
uint32_t raw_instr) {
CHECK(fallback);
struct ir_instr *instr = ir_append_instr(ir, OP_CALL_FALLBACK, VALUE_V);
ir_set_arg0(ir, instr, ir_alloc_ptr(ir, fallback));
ir_set_arg1(ir, instr, ir_alloc_i32(ir, addr));
ir_set_arg2(ir, instr, ir_alloc_i32(ir, raw_instr));
}
void ir_debug_info(struct ir *ir, const char *desc, uint32_t addr, void ir_debug_info(struct ir *ir, const char *desc, uint32_t addr,
uint32_t raw_instr) { uint32_t raw_instr) {
struct ir_instr *instr = ir_append_instr(ir, OP_DEBUG_INFO, VALUE_V); struct ir_instr *instr = ir_append_instr(ir, OP_DEBUG_INFO, VALUE_V);

View File

@ -266,6 +266,10 @@ void ir_replace_uses(struct ir_value *v, struct ir_value *other);
uint64_t ir_zext_constant(const struct ir_value *v); uint64_t ir_zext_constant(const struct ir_value *v);
/* call into interpeter fallback */
void ir_fallback(struct ir *ir, void *fallback, uint32_t addr,
uint32_t raw_instr);
/* direct access to host memory */ /* direct access to host memory */
struct ir_value *ir_load(struct ir *ir, struct ir_value *addr, struct ir_value *ir_load(struct ir *ir, struct ir_value *addr,
enum ir_type type); enum ir_type type);
@ -394,8 +398,6 @@ void ir_call(struct ir *ir, struct ir_value *fn);
void ir_call_1(struct ir *ir, struct ir_value *fn, struct ir_value *arg0); void ir_call_1(struct ir *ir, struct ir_value *fn, struct ir_value *arg0);
void ir_call_2(struct ir *ir, struct ir_value *fn, struct ir_value *arg0, void ir_call_2(struct ir *ir, struct ir_value *fn, struct ir_value *arg0,
struct ir_value *arg1); struct ir_value *arg1);
void ir_call_fallback(struct ir *ir, void *fallback, uint32_t addr,
uint32_t raw_instr);
/* debug */ /* debug */
void ir_debug_info(struct ir *ir, const char *desc, uint32_t addr, void ir_debug_info(struct ir *ir, const char *desc, uint32_t addr,

View File

@ -1,3 +1,4 @@
IR_OP(FALLBACK)
IR_OP(LOAD) IR_OP(LOAD)
IR_OP(STORE) IR_OP(STORE)
IR_OP(LOAD_FAST) IR_OP(LOAD_FAST)
@ -50,7 +51,6 @@ IR_OP(BRANCH)
IR_OP(BRANCH_FALSE) IR_OP(BRANCH_FALSE)
IR_OP(BRANCH_TRUE) IR_OP(BRANCH_TRUE)
IR_OP(CALL) IR_OP(CALL)
IR_OP(CALL_FALLBACK)
IR_OP(DEBUG_INFO) IR_OP(DEBUG_INFO)
IR_OP(DEBUG_BREAK) IR_OP(DEBUG_BREAK)
IR_OP(ASSERT_LT) IR_OP(ASSERT_LT)

View File

@ -133,7 +133,9 @@ static void lse_set_available(struct lse *lse, int offset, struct ir_value *v) {
static void lse_eliminate_loads_r(struct lse *lse, struct ir *ir, static void lse_eliminate_loads_r(struct lse *lse, struct ir *ir,
struct ir_block *block) { struct ir_block *block) {
list_for_each_entry_safe(instr, &block->instrs, struct ir_instr, it) { list_for_each_entry_safe(instr, &block->instrs, struct ir_instr, it) {
if (instr->op == OP_LABEL) { if (instr->op == OP_FALLBACK) {
lse_clear_available(lse);
} else if (instr->op == OP_LABEL) {
lse_clear_available(lse); lse_clear_available(lse);
} else if (instr->op == OP_BRANCH) { } else if (instr->op == OP_BRANCH) {
if (instr->arg[0]->type != VALUE_BLOCK) { if (instr->arg[0]->type != VALUE_BLOCK) {
@ -215,7 +217,9 @@ static void lse_eliminate_stores_r(struct lse *lse, struct ir *ir,
} }
list_for_each_entry_safe_reverse(instr, &block->instrs, struct ir_instr, it) { list_for_each_entry_safe_reverse(instr, &block->instrs, struct ir_instr, it) {
if (instr->op == OP_LABEL) { if (instr->op == OP_FALLBACK) {
lse_clear_available(lse);
} else if (instr->op == OP_LABEL) {
lse_clear_available(lse); lse_clear_available(lse);
} else if (instr->op == OP_BRANCH) { } else if (instr->op == OP_BRANCH) {
if (instr->arg[0]->type != VALUE_BLOCK) { if (instr->arg[0]->type != VALUE_BLOCK) {

View File

@ -44,7 +44,7 @@ static void sanitize_ir(struct ir *ir) {
list_for_each_entry(instr, &block->instrs, struct ir_instr, it) { list_for_each_entry(instr, &block->instrs, struct ir_instr, it) {
if (instr->op != OP_BRANCH && instr->op != OP_BRANCH_FALSE && if (instr->op != OP_BRANCH && instr->op != OP_BRANCH_FALSE &&
instr->op != OP_BRANCH_TRUE && instr->op != OP_CALL && instr->op != OP_BRANCH_TRUE && instr->op != OP_CALL &&
instr->op != OP_CALL_FALLBACK) { instr->op != OP_FALLBACK) {
continue; continue;
} }