codegen.c: allow `OP_EXT` before `OP_ADDI` and `OP_SUBI`.

This is preparation for integer constant folding.
parent 43f6f765
...@@ -584,14 +584,14 @@ gen_addsub(codegen_scope *s, uint8_t op, uint16_t dst) ...@@ -584,14 +584,14 @@ gen_addsub(codegen_scope *s, uint8_t op, uint16_t dst)
data.b = data.insn - OP_LOADI_0; data.b = data.insn - OP_LOADI_0;
/* fall through */ /* fall through */
case OP_LOADI: case OP_LOADI:
case OP_LOADI16:
replace: replace:
if (data.b >= 128) goto normal;
s->pc = s->lastpc; s->pc = s->lastpc;
if (op == OP_ADD) { if (op == OP_ADD) {
genop_2(s, OP_ADDI, dst, (uint8_t)data.b); genop_2(s, OP_ADDI, dst, data.b);
} }
else { else {
genop_2(s, OP_SUBI, dst, (uint8_t)data.b); genop_2(s, OP_SUBI, dst, data.b);
} }
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment