mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Add new opcode subtract immediate.
This commit is contained in:
parent
f73b8c550a
commit
b5d3c87253
@ -138,6 +138,7 @@ static const JanetInstructionDef janet_ops[] = {
|
|||||||
{"sru", JOP_SHIFT_RIGHT_UNSIGNED},
|
{"sru", JOP_SHIFT_RIGHT_UNSIGNED},
|
||||||
{"sruim", JOP_SHIFT_RIGHT_UNSIGNED_IMMEDIATE},
|
{"sruim", JOP_SHIFT_RIGHT_UNSIGNED_IMMEDIATE},
|
||||||
{"sub", JOP_SUBTRACT},
|
{"sub", JOP_SUBTRACT},
|
||||||
|
{"subim", JOP_SUBTRACT_IMMEDIATE},
|
||||||
{"tcall", JOP_TAILCALL},
|
{"tcall", JOP_TAILCALL},
|
||||||
{"tchck", JOP_TYPECHECK}
|
{"tchck", JOP_TYPECHECK}
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,7 @@ enum JanetInstructionType janet_instructions[JOP_INSTRUCTION_COUNT] = {
|
|||||||
JINT_0, /* JOP_RETURN_NIL, */
|
JINT_0, /* JOP_RETURN_NIL, */
|
||||||
JINT_SSI, /* JOP_ADD_IMMEDIATE, */
|
JINT_SSI, /* JOP_ADD_IMMEDIATE, */
|
||||||
JINT_SSS, /* JOP_ADD, */
|
JINT_SSS, /* JOP_ADD, */
|
||||||
|
JINT_SSI, /* JOP_SUBTRACT_IMMEDIATE, */
|
||||||
JINT_SSS, /* JOP_SUBTRACT, */
|
JINT_SSS, /* JOP_SUBTRACT, */
|
||||||
JINT_SSI, /* JOP_MULTIPLY_IMMEDIATE, */
|
JINT_SSI, /* JOP_MULTIPLY_IMMEDIATE, */
|
||||||
JINT_SSS, /* JOP_MULTIPLY, */
|
JINT_SSS, /* JOP_MULTIPLY, */
|
||||||
@ -251,6 +252,7 @@ void janet_bytecode_movopt(JanetFuncDef *def) {
|
|||||||
case JOP_SIGNAL:
|
case JOP_SIGNAL:
|
||||||
/* Write A, Read B */
|
/* Write A, Read B */
|
||||||
case JOP_ADD_IMMEDIATE:
|
case JOP_ADD_IMMEDIATE:
|
||||||
|
case JOP_SUBTRACT_IMMEDIATE:
|
||||||
case JOP_MULTIPLY_IMMEDIATE:
|
case JOP_MULTIPLY_IMMEDIATE:
|
||||||
case JOP_DIVIDE_IMMEDIATE:
|
case JOP_DIVIDE_IMMEDIATE:
|
||||||
case JOP_SHIFT_LEFT_IMMEDIATE:
|
case JOP_SHIFT_LEFT_IMMEDIATE:
|
||||||
|
@ -260,7 +260,7 @@ static JanetSlot do_add(JanetFopts opts, JanetSlot *args) {
|
|||||||
return opreduce(opts, args, JOP_ADD, JOP_ADD_IMMEDIATE, janet_wrap_integer(0), janet_wrap_integer(0));
|
return opreduce(opts, args, JOP_ADD, JOP_ADD_IMMEDIATE, janet_wrap_integer(0), janet_wrap_integer(0));
|
||||||
}
|
}
|
||||||
static JanetSlot do_sub(JanetFopts opts, JanetSlot *args) {
|
static JanetSlot do_sub(JanetFopts opts, JanetSlot *args) {
|
||||||
return opreduce(opts, args, JOP_SUBTRACT, -JOP_ADD_IMMEDIATE, janet_wrap_integer(0), janet_wrap_integer(0));
|
return opreduce(opts, args, JOP_SUBTRACT, JOP_SUBTRACT_IMMEDIATE, janet_wrap_integer(0), janet_wrap_integer(0));
|
||||||
}
|
}
|
||||||
static JanetSlot do_mul(JanetFopts opts, JanetSlot *args) {
|
static JanetSlot do_mul(JanetFopts opts, JanetSlot *args) {
|
||||||
return opreduce(opts, args, JOP_MULTIPLY, JOP_MULTIPLY_IMMEDIATE, janet_wrap_integer(1), janet_wrap_integer(1));
|
return opreduce(opts, args, JOP_MULTIPLY, JOP_MULTIPLY_IMMEDIATE, janet_wrap_integer(1), janet_wrap_integer(1));
|
||||||
|
@ -347,6 +347,7 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
&&label_JOP_RETURN_NIL,
|
&&label_JOP_RETURN_NIL,
|
||||||
&&label_JOP_ADD_IMMEDIATE,
|
&&label_JOP_ADD_IMMEDIATE,
|
||||||
&&label_JOP_ADD,
|
&&label_JOP_ADD,
|
||||||
|
&&label_JOP_SUBTRACT_IMMEDIATE,
|
||||||
&&label_JOP_SUBTRACT,
|
&&label_JOP_SUBTRACT,
|
||||||
&&label_JOP_MULTIPLY_IMMEDIATE,
|
&&label_JOP_MULTIPLY_IMMEDIATE,
|
||||||
&&label_JOP_MULTIPLY,
|
&&label_JOP_MULTIPLY,
|
||||||
@ -593,7 +594,6 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
&&label_unknown_op,
|
&&label_unknown_op,
|
||||||
&&label_unknown_op,
|
&&label_unknown_op,
|
||||||
&&label_unknown_op,
|
&&label_unknown_op,
|
||||||
&&label_unknown_op,
|
|
||||||
&&label_unknown_op
|
&&label_unknown_op
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -683,6 +683,9 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
VM_OP(JOP_ADD)
|
VM_OP(JOP_ADD)
|
||||||
vm_binop(+);
|
vm_binop(+);
|
||||||
|
|
||||||
|
VM_OP(JOP_SUBTRACT_IMMEDIATE)
|
||||||
|
vm_binop_immediate(-);
|
||||||
|
|
||||||
VM_OP(JOP_SUBTRACT)
|
VM_OP(JOP_SUBTRACT)
|
||||||
vm_binop(-);
|
vm_binop(-);
|
||||||
|
|
||||||
|
@ -1262,6 +1262,7 @@ enum JanetOpCode {
|
|||||||
JOP_RETURN_NIL,
|
JOP_RETURN_NIL,
|
||||||
JOP_ADD_IMMEDIATE,
|
JOP_ADD_IMMEDIATE,
|
||||||
JOP_ADD,
|
JOP_ADD,
|
||||||
|
JOP_SUBTRACT_IMMEDIATE,
|
||||||
JOP_SUBTRACT,
|
JOP_SUBTRACT,
|
||||||
JOP_MULTIPLY_IMMEDIATE,
|
JOP_MULTIPLY_IMMEDIATE,
|
||||||
JOP_MULTIPLY,
|
JOP_MULTIPLY,
|
||||||
|
Loading…
Reference in New Issue
Block a user