mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-19 19:20:23 +02:00
add jit_allocai for SPARC
Patches applied: * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-28 Implemented `jit_allocai' for SPARC. * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-29 tests/allocai.c: New test case. * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-30 Fixed `_d22 ()' on SPARC (fixes "displacement too large" errors). git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-35
This commit is contained in:
parent
54c573d8d7
commit
4290adb33a
5 changed files with 169 additions and 6 deletions
|
@ -1,11 +1,13 @@
|
|||
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/lightning/$(cpu)
|
||||
|
||||
check_PROGRAMS = fibit incr printf printf2 rpn fib fibdelay \
|
||||
add bp testfp funcfp rpnfp modi ldxi divi movi ret
|
||||
add bp testfp funcfp rpnfp modi ldxi divi movi ret \
|
||||
allocai
|
||||
|
||||
noinst_DATA = fibit.ok incr.ok printf.ok printf2.ok rpn.ok \
|
||||
fib.ok fibdelay.ok testfp.ok funcfp.ok rpnfp.ok add.ok \
|
||||
bp.ok modi.ok ldxi.ok divi.ok movi.ok ret.ok
|
||||
bp.ok modi.ok ldxi.ok divi.ok movi.ok ret.ok \
|
||||
allocai.ok
|
||||
|
||||
EXTRA_DIST = $(noinst_DATA) run-test
|
||||
|
||||
|
@ -15,7 +17,7 @@ endif
|
|||
|
||||
if REGRESSION_TESTING
|
||||
TESTS = fib fibit fibdelay incr printf printf2 rpn add bp \
|
||||
testfp funcfp rpnfp modi ldxi divi movi ret
|
||||
testfp funcfp rpnfp modi ldxi divi movi ret allocai
|
||||
|
||||
TESTS_ENVIRONMENT=$(srcdir)/run-test
|
||||
endif
|
||||
|
|
109
tests/allocai.c
Normal file
109
tests/allocai.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/******************************** -*- C -*- ****************************
|
||||
*
|
||||
* Test `jit_allocai'
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
/* Contributed by Ludovic Courtès. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "lightning.h"
|
||||
|
||||
typedef int (* int_return_int_t) (int);
|
||||
|
||||
static int
|
||||
identity (int arg)
|
||||
{
|
||||
printf ("received %i\n", arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
static int_return_int_t
|
||||
generate_function_proxy (int_return_int_t func)
|
||||
{
|
||||
static const char failure_message[] = "numbers don't add up to zero\n";
|
||||
static char buffer[1024];
|
||||
|
||||
int_return_int_t result;
|
||||
int arg, arg_offset, argneg_offset;
|
||||
jit_insn *branch;
|
||||
|
||||
result = (int_return_int_t)(jit_set_ip (buffer).ptr);
|
||||
jit_prolog (1);
|
||||
arg = jit_arg_i ();
|
||||
jit_getarg_i (JIT_R1, arg);
|
||||
|
||||
/* Store the argument on the stack. */
|
||||
arg_offset = jit_allocai (sizeof (int));
|
||||
jit_stxi_i (arg_offset, JIT_FP, JIT_R1);
|
||||
|
||||
/* Store the negative of the argument on the stack. */
|
||||
argneg_offset = jit_allocai (sizeof (int));
|
||||
jit_negr_i (JIT_R2, JIT_R1);
|
||||
jit_stxi_i (argneg_offset, JIT_FP, JIT_R2);
|
||||
|
||||
/* Invoke FUNC. */
|
||||
jit_prepare (1);
|
||||
jit_pusharg_i (JIT_R1);
|
||||
(void)jit_finish (func);
|
||||
|
||||
/* Ignore the result. */
|
||||
|
||||
/* Restore the negative and the argument from the stack. */
|
||||
jit_ldxi_i (JIT_R2, JIT_FP, argneg_offset);
|
||||
jit_ldxi_i (JIT_V1, JIT_FP, arg_offset);
|
||||
|
||||
/* Make sure they still add to zero. */
|
||||
jit_addr_i (JIT_R0, JIT_V1, JIT_R2);
|
||||
branch = jit_bnei_i (jit_forward (), JIT_R0, 0);
|
||||
|
||||
/* Return it. */
|
||||
jit_movr_i (JIT_RET, JIT_V1);
|
||||
jit_ret ();
|
||||
|
||||
/* Display a failure message. */
|
||||
jit_patch (branch);
|
||||
jit_movi_p (JIT_R2, failure_message);
|
||||
jit_prepare (1);
|
||||
jit_pusharg_p (JIT_R2);
|
||||
jit_finish (printf);
|
||||
|
||||
/* Leave. */
|
||||
jit_movr_i (JIT_RET, JIT_V1);
|
||||
jit_ret ();
|
||||
|
||||
jit_flush_code (buffer, jit_get_ip ().ptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int_return_int_t identity_func;
|
||||
|
||||
identity_func = generate_function_proxy (identity);
|
||||
if (identity_func (7777) != 7777)
|
||||
{
|
||||
printf ("failed: got %i instead of %i\n",
|
||||
identity_func (7777), 7777);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
printf ("succeeded\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
coding: latin-1
|
||||
End:
|
||||
*/
|
2
tests/allocai.ok
Normal file
2
tests/allocai.ok
Normal file
|
@ -0,0 +1,2 @@
|
|||
received 7777
|
||||
succeeded
|
Loading…
Add table
Add a link
Reference in a new issue