aboutsummaryrefslogtreecommitdiff
path: root/ops/common.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-06-24 20:48:32 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-06-24 22:10:50 +0300
commit422b6c976e28445d2a6e14586fa416b0f16c093f (patch)
treea6bf3364cec45ed0c5d48e346a76a98fe9d0094a /ops/common.h
downloadcopyjit-422b6c976e28445d2a6e14586fa416b0f16c093f.tar.gz
copyjit-422b6c976e28445d2a6e14586fa416b0f16c093f.zip
initial commit
Diffstat (limited to 'ops/common.h')
-rw-r--r--ops/common.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/ops/common.h b/ops/common.h
new file mode 100644
index 0000000..b447aab
--- /dev/null
+++ b/ops/common.h
@@ -0,0 +1,24 @@
+#ifndef OPS_COMMON_H
+#define OPS_COMMON_H
+
+typedef unsigned long reg_t;
+typedef signed long sreg_t;
+
+typedef void (*op_call)(reg_t *sp, reg_t a, reg_t x, reg_t y, reg_t o);
+
+#define NEXT_OP(sp, a, x, y, o) \
+ ((op_call)(&&_next_op))((sp), (a), (x), (y), (o)); _next_op: (void)1;
+
+#define JUMP(target, sp, a, x, y, o) \
+ ((op_call)(target))((sp), (a), (x), (y), (o));
+
+#define BRANCH(target, cond, sp, a, x, y, o) \
+ ((op_call)((cond) ? (void *)(target) : (void *)&&_next_op)) \
+ ((sp), (a), (x), (y), (o)); \
+_next_op: (void)1;
+
+#define DEFINE_OP(name) void name(reg_t *sp, reg_t a, reg_t x, reg_t y, reg_t o)
+
+#define UNUSED(x) (void)(x);
+
+#endif /* OPS_COMMON_H */