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.
180 lines
4.4 KiB
C
180 lines
4.4 KiB
C
/******************************** -*- C -*- ****************************
|
|
*
|
|
* Floating-point miscellanea using GNU lightning
|
|
*
|
|
***********************************************************************/
|
|
|
|
|
|
/***********************************************************************
|
|
*
|
|
* Copyright 2000, 2002, 2004 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"
|
|
|
|
#ifdef JIT_FPR
|
|
static jit_insn codeBuffer[300];
|
|
static double a;
|
|
|
|
void
|
|
int_test(char *what, jit_code code, double b, double c, double d, double e, double f)
|
|
{
|
|
a = b; printf("%s\t\t%d ", what, code.iptr ());
|
|
a = c; printf("%d ", code.iptr());
|
|
a = d; printf("%d ", code.iptr());
|
|
a = e; printf("%d ", code.iptr());
|
|
a = f; printf("%d\n", code.iptr());
|
|
}
|
|
|
|
int
|
|
main()
|
|
{
|
|
jit_code code;
|
|
volatile double x = 0.0;
|
|
code.ptr = (char *) codeBuffer;
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_movi_d(JIT_FPR1, 0.0);
|
|
jit_gtr_d(JIT_R0, JIT_FPR0, JIT_FPR1);
|
|
jit_ltr_d(JIT_R1, JIT_FPR0, JIT_FPR1);
|
|
jit_subr_i(JIT_RET, JIT_R0, JIT_R1); /* [greater] - [less] = -1/0/1 */
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("compare", code, -2.6, -2.4, 0, 2.4, 2.6);
|
|
|
|
#ifdef __GNUC__
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_movi_d(JIT_FPR1, 0.0);
|
|
jit_eqr_d(JIT_R0, JIT_FPR0, JIT_FPR1);
|
|
jit_ltgtr_d(JIT_R1, JIT_FPR0, JIT_FPR1);
|
|
jit_lshi_i(JIT_R1, JIT_R1, 1);
|
|
jit_orr_i(JIT_RET, JIT_R0, JIT_R1);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("nans", code, x / x, 1 / (a - a), -1 / (a - a), 0.0, -2.0);
|
|
#else
|
|
printf ("nans\t\t1 3 3 0 3\n");
|
|
#endif
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_truncr_d_i(JIT_RET, JIT_FPR0);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("trunc", code, -2.6, -2.4, 0, 2.4, 2.6);
|
|
int_test("trunc", code, -3, -2, 0, 2, 3);
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_ceilr_d_i(JIT_RET, JIT_FPR0);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("ceil", code, -2.6, -2.4, 0, 2.4, 2.6);
|
|
int_test("ceil", code, -3, -2, 0, 2, 3);
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_floorr_d_i(JIT_RET, JIT_FPR0);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("floor", code, -2.6, -2.4, 0, 2.4, 2.6);
|
|
int_test("floor", code, -3, -2, 0, 2, 3);
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jit_ldi_d(JIT_FPR0, &a);
|
|
jit_roundr_d_i(JIT_RET, JIT_FPR0);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
int_test("round", code, -2.6, -2.4, 0, 2.4, 2.6);
|
|
int_test("round", code, -3, -2, 0, 2, 3);
|
|
|
|
#if 0 && defined JIT_TRANSCENDENTAL
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jitfp_sti_d(&a,
|
|
jitfp_log(
|
|
jitfp_exp(jitfp_imm(1.0))
|
|
)
|
|
);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
code.vptr();
|
|
printf("log e = \t%f\n", a);
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jitfp_sti_d(&a,
|
|
jitfp_atn(
|
|
jitfp_imm(1.732050807657)
|
|
)
|
|
);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
code.vptr();
|
|
printf("pi = \t%f\n", a*3);
|
|
|
|
jit_set_ip(codeBuffer);
|
|
jit_leaf(0);
|
|
jitfp_sti_d(&a,
|
|
jitfp_tan(
|
|
jitfp_ldi_d(&a)
|
|
)
|
|
);
|
|
jit_ret();
|
|
|
|
jit_flush_code(codeBuffer, jit_get_ip().ptr);
|
|
code.vptr();
|
|
printf("tan^2 pi/3 = \t%f\n", a*a);
|
|
|
|
#endif /* JIT_TRANSCEDENTAL */
|
|
|
|
return (0);
|
|
}
|
|
#else
|
|
int
|
|
main()
|
|
{
|
|
return (77);
|
|
}
|
|
#endif
|