summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-07-20 11:07:37 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-07-20 11:07:37 +0900
commitcdf54f3159b90a0c87d53ddba931c3a48d13337b (patch)
tree07aec21b70cb6302d3b81fb8048dc82b025b334a
parent43f6f765b03c0e7e48ddcea1de958306e1b8303a (diff)
downloadmruby-cdf54f3159b90a0c87d53ddba931c3a48d13337b.tar.gz
mruby-cdf54f3159b90a0c87d53ddba931c3a48d13337b.zip
codegen.c: allow `OP_EXT` before `OP_ADDI` and `OP_SUBI`.
This is preparation for integer constant folding.
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index a673bd274..44beef6a5 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -584,14 +584,14 @@ gen_addsub(codegen_scope *s, uint8_t op, uint16_t dst)
data.b = data.insn - OP_LOADI_0;
/* fall through */
case OP_LOADI:
+ case OP_LOADI16:
replace:
- if (data.b >= 128) goto normal;
s->pc = s->lastpc;
if (op == OP_ADD) {
- genop_2(s, OP_ADDI, dst, (uint8_t)data.b);
+ genop_2(s, OP_ADDI, dst, data.b);
}
else {
- genop_2(s, OP_SUBI, dst, (uint8_t)data.b);
+ genop_2(s, OP_SUBI, dst, data.b);
}
break;
default: