From 77e08c9193e573b283c3ef5e1d09e622e745814b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 1 Dec 2024 19:16:54 +0900 Subject: [PATCH] ops.h: rename OP_LOADI to OP_LOADI8 OP_LOADI stores an 8 bit integer to a register, so we renamed the instruction name to describe the behavior more precisely, like OP_LOADI16 and OP_LOADI32. --- doc/internal/opcode.md | 2 +- include/mruby/ops.h | 2 +- mrbgems/mruby-compiler/core/codegen.c | 8 ++++---- src/codedump.c | 4 ++-- src/vm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/internal/opcode.md b/doc/internal/opcode.md index 7f4fc6982..bef081c21 100644 --- a/doc/internal/opcode.md +++ b/doc/internal/opcode.md @@ -33,7 +33,7 @@ See also `OP_EXT1`, `OP_EXT2` and `OP_EXT3`. | 0 | `OP_NOP` | `-` | `no operation` | 1 | `OP_MOVE` | `BB` | `R(a) = R(b)` | 2 | `OP_LOADL` | `BB` | `R(a) = Pool(b)` -| 3 | `OP_LOADI` | `BB` | `R(a) = mrb_int(b)` +| 3 | `OP_LOADI8` | `BB` | `R(a) = mrb_int(b)` | 4 | `OP_LOADINEG` | `BB` | `R(a) = mrb_int(-b)` | 5 | `OP_LOADI__1` | `B` | `R(a) = mrb_int(-1)` | 6 | `OP_LOADI_0` | `B` | `R(a) = mrb_int(0)` diff --git a/include/mruby/ops.h b/include/mruby/ops.h index cda796f08..05bf30fe0 100644 --- a/include/mruby/ops.h +++ b/include/mruby/ops.h @@ -15,7 +15,7 @@ operation code operands semantics OPCODE(NOP, Z) /* no operation */ OPCODE(MOVE, BB) /* R[a] = R[b] */ OPCODE(LOADL, BB) /* R[a] = Pool[b] */ -OPCODE(LOADI, BB) /* R[a] = mrb_int(b) */ +OPCODE(LOADI8, BB) /* R[a] = mrb_int(b) */ OPCODE(LOADINEG, BB) /* R[a] = mrb_int(-b) */ OPCODE(LOADI__1, B) /* R[a] = mrb_int(-1) */ OPCODE(LOADI_0, B) /* R[a] = mrb_int(0) */ diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index fc9f0d0e6..b34d44b35 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -549,7 +549,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val) } } break; - case OP_LOADT: case OP_LOADI: case OP_LOADINEG: case OP_LOADI__1: + case OP_LOADT: case OP_LOADI8: case OP_LOADINEG: case OP_LOADI__1: case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3: case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7: if (data.a == a || data.a > s->nlocals) { @@ -623,7 +623,7 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) case OP_HASH: if (data.b != 0) goto normal; /* fall through */ - case OP_LOADI: case OP_LOADINEG: + case OP_LOADI8: case OP_LOADINEG: case OP_LOADL: case OP_LOADSYM: case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV: case OP_GETCONST: case OP_STRING: @@ -765,7 +765,7 @@ get_int_operand(codegen_scope *s, struct mrb_insn_data *data, mrb_int *n) *n = data->insn - OP_LOADI_0; return TRUE; - case OP_LOADI: + case OP_LOADI8: case OP_LOADI16: *n = (int16_t)data->b; return TRUE; @@ -1177,7 +1177,7 @@ gen_int(codegen_scope *s, uint16_t dst, mrb_int i) else goto int_lit; } else if (i < 8) genop_1(s, OP_LOADI_0 + (uint8_t)i, dst); - else if (i <= 0xff) genop_2(s, OP_LOADI, dst, (uint16_t)i); + else if (i <= 0xff) genop_2(s, OP_LOADI8, dst, (uint16_t)i); else if (i <= INT16_MAX) genop_2S(s, OP_LOADI16, dst, (uint16_t)i); else if (i <= INT32_MAX) genop_2SS(s, OP_LOADI32, dst, (uint32_t)i); else { diff --git a/src/codedump.c b/src/codedump.c index 556e4f62d..ef916ff2b 100644 --- a/src/codedump.c +++ b/src/codedump.c @@ -185,8 +185,8 @@ codedump(mrb_state *mrb, const mrb_irep *irep, FILE *out) } print_lv_a(mrb, irep, a, out); break; - CASE(OP_LOADI, BB): - fprintf(out, "LOADI\t\tR%d\t%d\t", a, b); + CASE(OP_LOADI8, BB): + fprintf(out, "LOADI8\tR%d\t%d\t", a, b); print_lv_a(mrb, irep, a, out); break; CASE(OP_LOADINEG, BB): diff --git a/src/vm.c b/src/vm.c index 1621445e6..8bb6e7968 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1471,7 +1471,7 @@ RETRY_TRY_BLOCK: NEXT; } - CASE(OP_LOADI, BB) { + CASE(OP_LOADI8, BB) { SET_FIXNUM_VALUE(regs[a], b); NEXT; }