1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 21:10:27 +02:00

added ret test and clarified JIT_RET documentation

Patches applied:

 * lcourtes@laas.fr--2005-libre/lightning--sparc-fixes--1.2--base-0
   tag of lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-18

 * lcourtes@laas.fr--2005-libre/lightning--sparc-fixes--1.2--patch-1
   tests/push-pop.c: Use more `pushr's.

 * lcourtes@laas.fr--2005-libre/lightning--sparc-fixes--1.2--patch-3
   Added a test for `JIT_RET' (fails on SPARC).

 * lcourtes@laas.fr--2005-libre/lightning--sparc-fixes--1.2--patch-4
   Fixed use of `JIT_RET': Move %o0 into %i0 after `calli' and `callr'.

 * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-19
   Merge from `sparc-fixes': Fixed `pushr' and `popr', fixed `JIT_RET'.

 * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-20
   Undoed `lightning--sparc-fixes--1.2--patch-4' (about `JIT_RET') which was wrong.

 * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-21
   tests/ret.c: Use `jit_retval_i' to copy the function's return value.

 * lcourtes@laas.fr--2005-libre/lightning--stable--1.2--patch-22
   Doc: Clarified the use of `JIT_RET' and documented `jit_retval'.

git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-32
This commit is contained in:
Paolo Bonzini 2006-10-31 14:45:37 +00:00
parent 147efb8d90
commit e2cb4af6aa
5 changed files with 117 additions and 13 deletions

72
tests/ret.c Normal file
View file

@ -0,0 +1,72 @@
/******************************** -*- C -*- ****************************
*
* Test `JIT_RET'
*
***********************************************************************/
/* 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)
{
return arg;
}
static int_return_int_t
generate_function_proxy (int_return_int_t func)
{
static char buffer[1024];
int_return_int_t result;
int arg;
result = (int_return_int_t)(jit_set_ip (buffer).ptr);
jit_prolog (1);
arg = jit_arg_i ();
jit_getarg_i (JIT_R1, arg);
/* Reset `JIT_RET'. */
jit_movi_i (JIT_RET, -1);
/* Invoke a FUNC. */
jit_prepare (1);
jit_pusharg_i (JIT_R1);
(void)jit_finish (func);
/* Copy the result of FUNC from `JIT_RET' into our own result register. */
jit_retval_i (JIT_RET);
jit_ret ();
jit_flush_code (buffer, jit_get_ip ().ptr);
return result;
}
int
main (int argc, char *argv[])
{
int_return_int_t identity_proxy;
identity_proxy = generate_function_proxy (identity);
if (identity_proxy (7777) != 7777)
{
printf ("failed: got %i instead of %i\n",
identity_proxy (7777), 7777);
return 1;
}
else
printf ("succeeded\n");
return 0;
}