generate optimized OP_DIV instruction

This commit is contained in:
Yukihiro Matsumoto
2012-06-13 15:37:11 +09:00
parent b692b39d2e
commit 3894177233
+8
View File
@@ -648,6 +648,9 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val)
else if (!noop && name[0] == '*' && strlen(name) == 1) {
genop(s, MKOP_ABC(OP_MUL, cursp(), idx, n));
}
else if (!noop && name[0] == '/' && strlen(name) == 1) {
genop(s, MKOP_ABC(OP_DIV, cursp(), idx, n));
}
else if (!noop && name[0] == '<' && strlen(name) == 1) {
genop(s, MKOP_ABC(OP_LT, cursp(), idx, n));
}
@@ -2163,6 +2166,11 @@ codedump(mrb_state *mrb, int n)
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
GETARG_C(c));
break;
case OP_DIV:
printf("OP_DIV\tR%d\t'%s'\t%d\n", GETARG_A(c),
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
GETARG_C(c));
break;
case OP_LT:
printf("OP_LT\tR%d\t'%s'\t%d\n", GETARG_A(c),
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),