aboutsummaryrefslogtreecommitdiff
path: root/ops
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-09-07 21:25:36 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-09-07 21:25:36 +0300
commit23db5514bf626801c8e752f12171eb45d2598946 (patch)
tree8a5fbd619ddb4d5c22b6c6fb1c1027c1fd2e7af4 /ops
parent4d8fdd4288cc3ca5e0a2bd6ac80b725c2ee52118 (diff)
downloadcopyjit-23db5514bf626801c8e752f12171eb45d2598946.tar.gz
copyjit-23db5514bf626801c8e752f12171eb45d2598946.zip
allow fibonacci in jit-comparison
Diffstat (limited to 'ops')
-rw-r--r--ops/branchi/call.c6
-rw-r--r--ops/branchi/xlei.c7
-rw-r--r--ops/common.h6
-rw-r--r--ops/le/source.mk2
-rw-r--r--ops/le/xle2.c5
-rw-r--r--ops/li/liom1.c7
-rw-r--r--ops/li/lixm1.c7
-rw-r--r--ops/popx.c6
-rw-r--r--ops/pushx.c7
-rw-r--r--ops/source.mk1
10 files changed, 52 insertions, 2 deletions
diff --git a/ops/branchi/call.c b/ops/branchi/call.c
new file mode 100644
index 0000000..23d88d0
--- /dev/null
+++ b/ops/branchi/call.c
@@ -0,0 +1,6 @@
+#include "../common.h"
+
+DEFINE_OP(call) {
+ x = ((op_call)IMM())(sp, a, x, y, o);
+ NEXT_OP(sp, a, x, y, o);
+}
diff --git a/ops/branchi/xlei.c b/ops/branchi/xlei.c
new file mode 100644
index 0000000..f42d9fb
--- /dev/null
+++ b/ops/branchi/xlei.c
@@ -0,0 +1,7 @@
+#include "../common.h"
+
+DEFINE_OP(xlei)
+{
+ UNUSED(a);
+ NEXT_OP(sp, x <= IMM(), x, y, o);
+}
diff --git a/ops/common.h b/ops/common.h
index 6d3119a..d283651 100644
--- a/ops/common.h
+++ b/ops/common.h
@@ -18,8 +18,10 @@ typedef reg_t (*op_call)(reg_t *sp, reg_t a, reg_t x, reg_t y, reg_t o);
return CALL(target, sp, a, x, y, o);
#define BRANCH(target, cond, sp, a, x, y, o) \
- return ((op_call)((cond) ? (void *)(target) : (void *)&__next_op)) \
- ((sp), (a), (x), (y), (o)); \
+ do {\
+ if (cond) {JUMP(target, sp, a, x, y, o);}\
+ else {NEXT_OP(sp, a, x, y, o);}\
+ } while (0)
#define DEFINE_OP(name) reg_t _op(reg_t *sp, reg_t a, reg_t x, reg_t y, reg_t o)
diff --git a/ops/le/source.mk b/ops/le/source.mk
new file mode 100644
index 0000000..cf09ad8
--- /dev/null
+++ b/ops/le/source.mk
@@ -0,0 +1,2 @@
+LE_SRC != echo ops/le/*.c
+OP_SOURCES += $(LE_SRC)
diff --git a/ops/le/xle2.c b/ops/le/xle2.c
new file mode 100644
index 0000000..aa06057
--- /dev/null
+++ b/ops/le/xle2.c
@@ -0,0 +1,5 @@
+#include "../common.h"
+
+DEFINE_OP(xle2) {
+ NEXT_OP(sp, x <= 2, x, y, o);
+}
diff --git a/ops/li/liom1.c b/ops/li/liom1.c
new file mode 100644
index 0000000..959b256
--- /dev/null
+++ b/ops/li/liom1.c
@@ -0,0 +1,7 @@
+#include "../common.h"
+
+DEFINE_OP(liom1)
+{
+ UNUSED(o);
+ NEXT_OP(sp, a, x, y, -1);
+}
diff --git a/ops/li/lixm1.c b/ops/li/lixm1.c
new file mode 100644
index 0000000..46c3816
--- /dev/null
+++ b/ops/li/lixm1.c
@@ -0,0 +1,7 @@
+#include "../common.h"
+
+DEFINE_OP(lixm1)
+{
+ UNUSED(x);
+ NEXT_OP(sp, a, -1, y, o);
+}
diff --git a/ops/popx.c b/ops/popx.c
new file mode 100644
index 0000000..e2b601c
--- /dev/null
+++ b/ops/popx.c
@@ -0,0 +1,6 @@
+#include "common.h"
+
+DEFINE_OP(popx) {
+ UNUSED(x);
+ NEXT_OP(sp - 1, a, *(sp - 1), y, o);
+}
diff --git a/ops/pushx.c b/ops/pushx.c
new file mode 100644
index 0000000..7c70578
--- /dev/null
+++ b/ops/pushx.c
@@ -0,0 +1,7 @@
+#include "common.h"
+
+DEFINE_OP(pushx)
+{
+ *sp = x;
+ NEXT_OP(sp + 1, a, x, y, o);
+}
diff --git a/ops/source.mk b/ops/source.mk
index 8db98bc..38f0830 100644
--- a/ops/source.mk
+++ b/ops/source.mk
@@ -4,6 +4,7 @@ OP_SOURCES += $(OP_SRC)
include ops/addi/source.mk
include ops/bs/source.mk
include ops/li/source.mk
+include ops/le/source.mk
include ops/sl/source.mk
include ops/sr/source.mk
include ops/branchi/source.mk