aboutsummaryrefslogtreecommitdiff
path: root/tests/ldxi_f.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ldxi_f.c')
-rw-r--r--tests/ldxi_f.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/ldxi_f.c b/tests/ldxi_f.c
index 015d816..eb2ad58 100644
--- a/tests/ldxi_f.c
+++ b/tests/ldxi_f.c
@@ -1,27 +1,25 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static float data[] = { -1.0, 0.0, 0.5 };
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_ldxi_f(j, JIT_F0, JIT_R0, (uintptr_t)data);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(float), 1, operands);
- float (*f)(jit_uword_t) = jit_end(j, NULL);
+ ejit_ldxi_d(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data);
+ ejit_retr_f(f, EJIT_FPR(0));
- ASSERT(f(0) == data[0]);
- ASSERT(f(4) == data[1]);
- ASSERT(f(8) == data[2]);
-}
+ ejit_select_compile_func(f, 1, 1, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(erff1(f, EJIT_ARG(sizeof(float) * 0, long)) == data[0]);
+ assert(erff1(f, EJIT_ARG(sizeof(float) * 1, long)) == data[1]);
+ assert(erff1(f, EJIT_ARG(sizeof(float) * 2, long)) == data[2]);
+
+ ejit_destroy_func(f);
}