1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-04 05:50:26 +02:00
guile/tests/ldxi.c
Paolo Bonzini 147efb8d90 cherrypick from ludovic courtes
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
2008-01-09 15:49:46 +01:00

71 lines
1.5 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************** -*- C -*- ****************************
*
* Test jit_ldxi_i
*
***********************************************************************/
/* Contributed by Ludovic Courtes. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <string.h>
#include "lightning.h"
typedef char (* loader_t) (int);
/* Check `ldxi' with a big operand (OPERAND is assumed to be ``big'', e.g.,
more than one octet-long on PowerPC). */
static loader_t
generate_ldxi_big_operand (const void *operand)
{
static char buffer[1024];
loader_t result;
int arg;
/* printf ("si?=%i ui?=%i\n", _siP (16, operand), _uiP (16, operand)); */
result = (loader_t)(jit_set_ip (buffer).iptr);
jit_leaf (1);
arg = jit_arg_i ();
jit_getarg_i (JIT_R1, arg);
jit_ldxi_c (JIT_R0, JIT_R1, operand);
jit_movr_i (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";
char the_on_stack_array[] = "GNU Lightning";
unsigned i;
loader_t array_loader;
const char *large_pointer;
if (the_array > the_on_stack_array)
large_pointer = the_array;
else
large_pointer = the_on_stack_array;
array_loader = generate_ldxi_big_operand (large_pointer);
for (i = 0; i < sizeof (the_array) - 1; i++)
{
printf ("array[%i] = %c, array_loader (%i) = %c\n",
i, large_pointer[i], i, array_loader (i));
if (large_pointer[i] != array_loader (i))
return 1;
}
return 0;
}