From bb6de2520ae076b0ce64063f888e52f53f4a9fbb Mon Sep 17 00:00:00 2001 From: duk <37@cmail.nu> Date: Sat, 10 Jun 2023 23:17:35 -0400 Subject: [PATCH] Fix RV32 gen_opi_immediate default case This manifested itself through broken multiplication when the RHS was an immediate. --- riscv32-gen.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/riscv32-gen.c b/riscv32-gen.c index f7101cef..bd581e80 100644 --- a/riscv32-gen.c +++ b/riscv32-gen.c @@ -1370,6 +1370,13 @@ static int gen_opi_immediate( int op, int fc, int ll ) vset_VT_CMP( op ); vtop->cmp_r = a | 0 << 8; return 0; + default: + /* + default case means we have to bail, since otherwise we're pretending we handled it properly + as an example, '*' will hit this if RHS is an immediate since RV32M doesn't have MULI, + so we used to just... not actually compile a multiplication instruction in at all + */ + return 1; } // push the value to the stack (general case)