From faed72573b1f5ea31116fb1e723eab5f8d79010d Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 27 Jun 2021 14:01:10 +0800 Subject: [PATCH] Remove VCODE_OP_ADDI --- src/elab.c | 57 ----------------------------------------------------- src/lower.c | 8 +++----- 2 files changed, 3 insertions(+), 62 deletions(-) diff --git a/src/elab.c b/src/elab.c index d37c2f76..89e1617f 100644 --- a/src/elab.c +++ b/src/elab.c @@ -2023,37 +2023,6 @@ static void elab_decls(tree_t container, elab_ctx_t *ctx) } } -static void elab_process_driver_fn(tree_t t, void *_ctx) -{ - elab_ctx_t *ctx = (elab_ctx_t *)_ctx; - - tree_t ref = name_to_ref(tree_target(t)); - if (ref == NULL) - return; - - tree_t decl = tree_ref(ref); - const tree_kind_t kind = tree_kind(decl); - if (kind != T_SIGNAL_DECL && kind != T_PORT_DECL) - return; - - e_node_t s = elab_find_signal(decl, ctx); - - const int nnexus = e_nexuses(s); - for (int i = 0; i < nnexus; i++) { - e_node_t n = e_nexus(s, i); - - bool have = false; - const int np = e_nexuses(ctx->cursor); - for (int j = 0; !have && j < np; j++) - have = e_nexus(ctx->cursor, j) == n; - - if (!have) { - e_add_nexus(ctx->cursor, n); - e_add_proc(n, ctx->cursor); - } - } -} - static void elab_process(tree_t proc, elab_ctx_t *ctx) { ident_t name = tree_ident(proc); @@ -2065,14 +2034,6 @@ static void elab_process(tree_t proc, elab_ctx_t *ctx) e_set_path(e, ctx->npath); e_set_vcode(e, ident_prefix(tree_ident(ctx->arch), name, '.')); -#if 0 - // TODO: just a hack to get things working - e_node_t cursor = ctx->cursor; - ctx->cursor = e; - tree_visit_only(proc, elab_process_driver_fn, ctx, T_SIGNAL_ASSIGN); - ctx->cursor = cursor; -#endif - drv_extract(e, ctx); e_add_proc(ctx->cursor, e); @@ -2370,24 +2331,6 @@ static void drv_extract(e_node_t proc, elab_ctx_t *ctx) } break; - case VCODE_OP_ADDI: - { - vcode_reg_t arg0 = vcode_get_arg(op, 0); - - vcode_reg_t result = vcode_get_result(op); - assert(result != VCODE_INVALID_REG); - - if (regs[arg0].state == SIGNAL) { - regs[result] = regs[arg0]; - regs[result].ival += vcode_get_value(op); - } - else if (regs[arg0].state == UNKNOWN_SIGNAL) - regs[result] = regs[arg0]; - else - regs[result].state = UNKNOWN; - } - break; - case VCODE_OP_SUB: case VCODE_OP_ADD: case VCODE_OP_MUL: diff --git a/src/lower.c b/src/lower.c index 2f292700..1e7c12ad 100644 --- a/src/lower.c +++ b/src/lower.c @@ -362,12 +362,10 @@ static vcode_reg_t lower_array_len(type_t type, int dim, vcode_reg_t reg) break; } - vcode_reg_t inc_reg = emit_const(vcode_reg_type(diff), 1); - vcode_reg_t len_reg = emit_add(diff, inc_reg); - vcode_type_t offset_type = vtype_offset(); vcode_reg_t cast_reg = - emit_cast(offset_type, VCODE_INVALID_TYPE, len_reg); - vcode_reg_t zero_reg = emit_const(offset_type, 0); + emit_cast(vtype_offset(), VCODE_INVALID_TYPE, diff); + vcode_reg_t len_reg = emit_add(diff, emit_const(vtype_offset(), 1)); + vcode_reg_t zero_reg = emit_const(vtype_offset(), 0); vcode_reg_t neg_reg = emit_cmp(VCODE_CMP_LT, cast_reg, zero_reg); return emit_select(neg_reg, zero_reg, cast_reg); -- 2.39.2