mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
2012-12-01 Paulo Andrade <pcpa@gnu.org> * opcode/Makefile.am, opcode/Makefile.in, opcode/ansidecl.h, opcode/bfd.h, opcode/dis-asm.h, opcode/dis-buf.c, opcode/disass.c, opcode/i386-dis.c, opcode/i386.h, opcode/ppc-dis.c, opcode/ppc-opc.c, opcode/ppc.h, opcode/sparc-dis.c, opcode/sparc-opc.c, opcode/sparc.h, opcode/sysdep.h: Removed. Do not bundle GNU binutils files. * aclocal.m4, configure, Makefile.in, config.h.in, doc/Makefile.in, lightning/Makefile.in, tests/Makefile.in: Removed. Do not maintain autogenerated files that also generate too much diff noise when regenerated in git. * build-aux/help2man, build-aux/texinfo.tex, build-aux/texi2dvi: Removed. Buildenvironment must have an up to date version from upstream installed. * build-aux/config.guess, build-aux/config.sub, build-aux/depcomp, build-aux/install-sh build-aux/mdate-sh build-aux/missing: Removed. Do not maintain a copy of automake files in git. Release tarballs must use an up to date version. * lightningize.in, doc/lightningize.1: Removed. Do not encourage bundling lightning in other packages. It should use a system package or a proper thirdy part subdirectory. * INSTALL: Removed. Autoreconf removes it and creates a symlink when regenerating files, so, avoid conflicts in git and let automake create the symlink. * .gitignore: Add INSTALL and autogenerated files. * configure.ac, Makefile.am: Update for removal of opcode subdir, auto generated files and lightningize. * tests/Makefile.am, tests/3to2.c, tests/add.c, tests/bp.c, tests/fib.c, tests/fibdelay.c, tests/fibit.c, tests/funcfp.c, tests/incr.c, tests/printf.c, tests/rpn.c, tests/rpnfp.c, tests/sete.c, tests/testfp.c: Update for removal of opcode subdir. * doc/Makefile.am: Update for removal of lightningize. * configure.ac, lightning/ppc/funcs.h, lightning/sparc/funcs.h, lightning/i386/fp.h, lightning/i386/core.h, lightning/i386/asm.h, tests/3to2.c, tests/add.c, tests/bp.c, tests/fib.c, tests/fibdelay.c, tests/fibit.c, tests/funcfp.c, tests/incr.c, tests/printf.c, tests/rpn.c, tests/rpnfp.c, tests/sete.c, tests/testfp.c: Remove LIGHTNING_CROSS, it is half supported and incomplete. * tests/3to2.c, tests/funcfp.c, tests/rpnfp.c: Remove preprocessor check on JIT_FPR. If no hardware registers are available, the backend must provide an alternative for software float. * lightning/ppc/core.h, lightning/sparc/core.h, tests/Makefile.am: Remove JIT_NEED_PUSH_POP. It is absolutely not trivial to implement properly on some backends due to stack alignment constraints, and whenever it is required, using jit_allocai and using a properly aligned stack vector, or a heap buffer, is better. * tests/push-pop.c, tests/push-pop.ok: Removed due to JIT_NEED_PUSH_POP no longer available.
76 lines
2.6 KiB
C
76 lines
2.6 KiB
C
/******************************** -*- C -*- ****************************
|
|
*
|
|
* Sample example of recursion and forward references
|
|
*
|
|
***********************************************************************/
|
|
|
|
|
|
/***********************************************************************
|
|
*
|
|
* Copyright 2000 Free Software Foundation, Inc.
|
|
* Written by Paolo Bonzini.
|
|
*
|
|
* This file is part of GNU lightning.
|
|
*
|
|
* GNU lightning is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation; either version 3, or (at your option)
|
|
* any later version.
|
|
*
|
|
* GNU lightning is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
* License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with GNU lightning; see the file COPYING.LESSER; if not, write to the
|
|
* Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301, USA.
|
|
*
|
|
***********************************************************************/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include "lightning.h"
|
|
|
|
static jit_insn codeBuffer[1024];
|
|
|
|
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
|
|
|
|
int main()
|
|
{
|
|
pifi nfibs = (pifi) (jit_set_ip(codeBuffer).iptr);
|
|
int in; /* offset of the argument */
|
|
jit_insn *ref; /* to patch the forward reference */
|
|
|
|
jit_prolog (1);
|
|
in = jit_arg_ui ();
|
|
jit_getarg_ui(JIT_V0, in); /* V0 = n */
|
|
ref = jit_blti_ui (jit_forward(), JIT_V0, 2);
|
|
jit_subi_ui (JIT_V1, JIT_V0, 1); /* V1 = n-1 */
|
|
jit_subi_ui (JIT_V2, JIT_V0, 2); /* V2 = n-2 */
|
|
jit_prepare_i(1);
|
|
jit_pusharg_ui(JIT_V1);
|
|
jit_finish(nfibs);
|
|
jit_retval_i (JIT_V1); /* V1 = nfibs(n-1) */
|
|
jit_prepare_i(1);
|
|
jit_pusharg_ui(JIT_V2);
|
|
jit_finish(nfibs);
|
|
jit_retval_i (JIT_V2); /* V2 = nfibs(n-2) */
|
|
jit_addi_ui(JIT_V1, JIT_V1, 1);
|
|
jit_addr_ui(JIT_RET, JIT_V1, JIT_V2); /* RET = V1 + V2 + 1 */
|
|
jit_ret();
|
|
|
|
jit_patch(ref); /* patch jump */
|
|
jit_movi_i(JIT_RET, 1); /* RET = 1 */
|
|
jit_ret();
|
|
|
|
/* call the generated code, passing 32 as an argument */
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
|
|
printf("nfibs(%d) = %d\n", 32, nfibs(32));
|
|
return 0;
|
|
}
|