From dbe13aecea0d1309509ea0d220cc2150571e25e5 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 14 Jun 2008 18:16:23 -0700 Subject: [PATCH] Signed load-and-add for arrays. The load-and-add for vectors %load/vp0/s can be combined with the load-and-add for array words, and the %load/avp0/s added to round out the combinations. This can make for fewer instructions when words are padded in arithmetic expressions. --- tgt-vvp/eval_expr.c | 12 ++++++------ vvp/codes.h | 1 + vvp/compile.cc | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 37f6af26c..a9931423e 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -1987,17 +1987,17 @@ static void draw_signal_dest(ivl_expr_t exp, struct vector_info res, draw_eval_expr_into_integer(ix, 3); if (add_index < 0) { - fprintf(vvp_out, " %%load/av %u, v%p, %u;\n", + fprintf(vvp_out, " %%load/av %u, v%p, %u;\n", res.base, sig, swid); + pad_expr_in_place(exp, res, swid); } else { - assert(add_index == 0); + const char*sign_flag = (add_index>0)? "/s" : ""; /* Add an immediate value to an array value. */ - fprintf(vvp_out, " %%ix/load 0, %lu;\n", immediate); - fprintf(vvp_out, " %%load/avp0 %u, v%p, %u;\n", - res.base, sig, swid); + fprintf(vvp_out, " %%ix/load 0, %lu;\n", immediate); + fprintf(vvp_out, " %%load/avp0%s %u, v%p, %u;\n", + sign_flag, res.base, sig, res.wid); } - pad_expr_in_place(exp, res, swid); return; } diff --git a/vvp/codes.h b/vvp/codes.h index 58e1ee4be..6fe3f2489 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -97,6 +97,7 @@ extern bool of_JMP1(vthread_t thr, vvp_code_t code); extern bool of_JOIN(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AV(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AVP0(vthread_t thr, vvp_code_t code); +extern bool of_LOAD_AVP0_S(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AVX_P(vthread_t thr, vvp_code_t code); extern bool of_LOAD_VEC(vthread_t thr, vvp_code_t code); extern bool of_LOAD_VP0(vthread_t thr, vvp_code_t code); diff --git a/vvp/compile.cc b/vvp/compile.cc index 1b426498d..18174c937 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -140,6 +140,7 @@ const static struct opcode_table_s opcode_table[] = { { "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} }, { "%load/av",of_LOAD_AV,3, {OA_BIT1, OA_ARR_PTR, OA_BIT2} }, { "%load/avp0",of_LOAD_AVP0,3, {OA_BIT1, OA_ARR_PTR, OA_BIT2} }, + { "%load/avp0/s",of_LOAD_AVP0_S,3,{OA_BIT1, OA_ARR_PTR, OA_BIT2} }, { "%load/avx.p",of_LOAD_AVX_P,3,{OA_BIT1, OA_ARR_PTR, OA_BIT2} }, { "%load/v", of_LOAD_VEC,3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} }, { "%load/vp0",of_LOAD_VP0,3,{OA_BIT1, OA_FUNC_PTR, OA_BIT2} },