mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-17 11:10:18 +02:00
2006-10-31 Paolo Bonzini <bonzini@gnu.org> Ludovic Courtes <ludo@chbouib.org> * tests/divi.c, tests/divi.ok, tests/movi.c, tests/movi.ok: New. * tests/ldxi.c: Ensure large pointer is generated. * tests/Makefile.am: Point to new tests. * lightning.h: Include funcs-common.h before funcs.h. * lightning/sparc/core.h: Fix bugs in modi/divi. Patches applied: * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-11 Fixed a typo in `lightning/sparc/core.h'. * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-12 SPARC: Fixed `jit_immsize' (untested!). * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-13 Added a `divi' test case (does not catch the bug fixed by the previous patch). * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-14 `divi' test case: Return non-zero on failure. * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-15 `ldxi.c' (test case): Make sure we use a large pointer operand. * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-16 Added a `movi' test case (for `jit_movi_p' with large operands). git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-31
63 lines
1.3 KiB
C
63 lines
1.3 KiB
C
/******************************** -*- C -*- ****************************
|
||
*
|
||
* Test jit_movi_p
|
||
*
|
||
***********************************************************************/
|
||
|
||
|
||
/* Contributed by Ludovic Courtès. */
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
# include "config.h"
|
||
#endif
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include "lightning.h"
|
||
|
||
typedef void * (* mover_t) (void);
|
||
|
||
static mover_t
|
||
generate_movi (const void *operand)
|
||
{
|
||
static char buffer[1024];
|
||
mover_t result;
|
||
|
||
/* printf ("si?=%i ui?=%i\n", _siP (16, operand), _uiP (16, operand)); */
|
||
|
||
result = (mover_t)(jit_set_ip (buffer).iptr);
|
||
jit_leaf (1);
|
||
|
||
jit_movi_p (JIT_R0, operand);
|
||
jit_movr_p (JIT_RET, JIT_R0);
|
||
|
||
jit_ret ();
|
||
jit_flush_code (buffer, jit_get_ip ().ptr);
|
||
|
||
return result;
|
||
}
|
||
|
||
|
||
int
|
||
main (int argc, char *argv[])
|
||
{
|
||
static const char the_array[] = "GNU Lightning";
|
||
mover_t get_array;
|
||
const void *large_pointer;
|
||
|
||
if (the_array > (char *)&get_array)
|
||
large_pointer = the_array;
|
||
else
|
||
large_pointer = &get_array;
|
||
|
||
/* On RISC machines, moving a large immediate may require several
|
||
instructions (e.g., `sethi' followed by `ori' on SPARC). */
|
||
get_array = generate_movi (large_pointer);
|
||
|
||
if (get_array () == large_pointer)
|
||
printf ("`jit_movi_p' succeeded\n");
|
||
else
|
||
printf ("`jit_movi_p' failed\n");
|
||
|
||
return (get_array () != large_pointer);
|
||
}
|