mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-03 02:36:19 +02:00
Add int/int reg/imm compare-and-branch tests
This commit is contained in:
parent
ab0d17286a
commit
329fc7936c
10 changed files with 310 additions and 0 deletions
31
tests/beqi.c
Normal file
31
tests/beqi.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_beqi(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/bgei.c
Normal file
31
tests/bgei.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgei(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/bgei_u.c
Normal file
31
tests/bgei_u.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgei_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/bgti.c
Normal file
31
tests/bgti.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgti(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/bgti_u.c
Normal file
31
tests/bgti_u.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgti_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/blei.c
Normal file
31
tests/blei.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blei(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/blei_u.c
Normal file
31
tests/blei_u.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blei_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/blti.c
Normal file
31
tests/blti.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blti(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/blti_u.c
Normal file
31
tests/blti_u.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blti_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
31
tests/bnei.c
Normal file
31
tests/bnei.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bnei(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue