diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-06-29 20:11:34 +0300 | 
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-06-29 20:11:34 +0300 | 
| commit | 9fe8ccf4ae09018fdde01a9d83f9db10ad354221 (patch) | |
| tree | 664f802240a2810b5db3e783400351f1eb51c1a0 /tests/bgtr_f.c | |
| parent | 322c7fba3d2f4c9b5b0d78b44feefd38ae44d017 (diff) | |
| download | ejit-9fe8ccf4ae09018fdde01a9d83f9db10ad354221.tar.gz ejit-9fe8ccf4ae09018fdde01a9d83f9db10ad354221.zip | |
work through branching instructions
Diffstat (limited to 'tests/bgtr_f.c')
| -rw-r--r-- | tests/bgtr_f.c | 57 | 
1 files changed, 31 insertions, 26 deletions
| diff --git a/tests/bgtr_f.c b/tests/bgtr_f.c index 6245644..0b5b7f4 100644 --- a/tests/bgtr_f.c +++ b/tests/bgtr_f.c @@ -1,34 +1,39 @@ -#include "test.h" +#include <ejit/ejit.h> +#include <assert.h> +#include "do_jit.h" -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_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0), -	                jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1)); +	struct ejit_operand operands[2] = { +		EJIT_OPERAND_FPR(0, EJIT_TYPE(double)), +		EJIT_OPERAND_FPR(1, EJIT_TYPE(double)) +	}; -	jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1); -	jit_leave_jit_abi(j, 0, 0, align); -	jit_reti(j, 0); -	jit_patch_here(j, r); -	jit_leave_jit_abi(j, 0, 0, align); -	jit_reti(j, 1); +	struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); +	struct ejit_reloc r = ejit_bgtr_f(f, EJIT_FPR(0), EJIT_FPR(1)); +	ejit_reti(f, 0); -	jit_word_t (*f)(float, float) = jit_end(j, NULL); +	struct ejit_label l = ejit_label(f); +	ejit_patch(f, r, l); +	ejit_reti(f, 1); -	ASSERT(f(0, 0) == 0); -	ASSERT(f(0, 1) == 0); -	ASSERT(f(1, 0) == 1); -	ASSERT(f(-1, 0) == 0); -	ASSERT(f(0, -1) == 1); +	ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit); -	ASSERT(f(0, 0.0/0.0) == 0); -	ASSERT(f(0.0/0.0, 0) == 0); -} +	assert(ejit_run_func_2(f, EJIT_ARG(0, double), +	                       EJIT_ARG(0, double)) == 0); +	assert(ejit_run_func_2(f, EJIT_ARG(0, double), +	                       EJIT_ARG(1, double)) == 0); +	assert(ejit_run_func_2(f, EJIT_ARG(1, double), +	                       EJIT_ARG(0, double)) == 1); +	assert(ejit_run_func_2(f, EJIT_ARG(-1, double), +	                       EJIT_ARG(0, double)) == 0); +	assert(ejit_run_func_2(f, EJIT_ARG(0, double), +	                       EJIT_ARG(-1, double)) == 1); -int -main (int argc, char *argv[]) -{ -	return main_helper(argc, argv, run_test); +	assert(ejit_run_func_2(f, EJIT_ARG(0, double), +	                       EJIT_ARG(0.0/0.0, double)) == 0); +	assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), +	                       EJIT_ARG(0, double)) == 0); + +	ejit_destroy_func(f);  } | 
