1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-29 08:20:20 +02:00

add 3to2 test and fix bug

2008-01-02  Paolo Bonzini  <bonzini@gnu.org>

	* lightning/i386/fp-32.h: Fix sub(a,b,a) with a ~= JIT_FPR0.
	* lightning/tests/3to2.c: New.
	* lightning/tests/3to2.ok: New.

git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-58
This commit is contained in:
Paolo Bonzini 2008-01-02 11:50:25 +00:00
parent f4500a8e95
commit 329b8a8a68
7 changed files with 177 additions and 12 deletions

View file

@ -1,3 +1,9 @@
2008-01-02 Paolo Bonzini <bonzini@gnu.org>
* lightning/i386/fp-32.h: Fix sub(a,b,a) with a ~= JIT_FPR0.
* lightning/tests/3to2.c: New.
* lightning/tests/3to2.ok: New.
2007-11-07 Paolo Bonzini <bonzini@gnu.org>
* opcode/Makefile.am: Fix AM_CPPFLAGS.

View file

@ -63,7 +63,7 @@
((s2) == 0 ? opr(0, (rd)) \
: (s2) == (s1) ? jit_fxch((rd), op(0, 0)) \
: jit_fxch((rd), op((s2), 0))) \
: (rd) == (s2) ? jit_fxch((s2), opr((rd) == 0 ? (s1) : (rd), 0)) \
: (rd) == (s2) ? jit_fxch((s2), opr((s1), 0)) \
: (FLDr (s1), op((s2)+1, 0), FSTPr((rd)+1)))
#define jit_addr_d(rd,s1,s2) jit_fp_binary((rd),(s1),(s2),FADDrr,FADDrr)

View file

@ -173,7 +173,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
EXTRA_LIBRARIES = libdisass.a
noinst_LIBRARIES = @LIBDISASS@
AM_CPPFLAGS = -I$(top_srcdir)
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lightning/$(cpu)
libdisass_a_SOURCES = dis-buf.c i386-dis.c ppc-dis.c ppc-opc.c sparc-dis.c \
sparc-opc.c disass.c

135
tests/3to2.c Normal file
View file

@ -0,0 +1,135 @@
/******************************** -*- C -*- ****************************
*
* Test ternary->binary op conversion
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2008 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 <stdlib.h>
#include "lightning.h"
#ifdef JIT_FPR
static jit_insn codeBuffer[1024];
double
test_double (int a, int b, int c)
{
double x;
int ofs;
jit_set_ip (codeBuffer);
jit_leaf (2);
ofs = jit_arg_d ();
jit_getarg_d (b, ofs);
ofs = jit_arg_d ();
jit_getarg_d (c, ofs);
jit_subr_d (a,b,c);
jit_movr_d (JIT_FPRET, a);
jit_ret ();
jit_flush_code ((char *) codeBuffer, jit_get_ip ().ptr);
#ifdef LIGHTNING_DISASSEMBLE
disassemble (stderr, (char *) codeBuffer, jit_get_ip ().ptr);
#endif
#ifndef LIGHTNING_CROSS
x = ((double (*) (double, double)) codeBuffer) (3.0, 2.0);
printf ("%g %g\n", ((b == c) ? 0.0 : 1.0), x);
#endif
return x;
}
double
test_int (int a, int b, int c)
{
int x;
int ofs;
jit_set_ip (codeBuffer);
jit_leaf (2);
ofs = jit_arg_i ();
jit_getarg_i (b, ofs);
ofs = jit_arg_i ();
jit_getarg_i (c, ofs);
jit_subr_i (a,b,c);
jit_movr_i (JIT_RET, a);
jit_ret ();
jit_flush_code ((char *) codeBuffer, jit_get_ip ().ptr);
#ifdef LIGHTNING_DISASSEMBLE
disassemble (stderr, (char *) codeBuffer, jit_get_ip ().ptr);
#endif
#ifndef LIGHTNING_CROSS
x = ((int (*) (int, int)) codeBuffer) (3, 2);
printf ("%d %d\n", ((b == c) ? 0 : 1), x);
#endif
return x;
}
int
main ()
{
test_double (JIT_FPR0, JIT_FPR0, JIT_FPR0);
test_double (JIT_FPR0, JIT_FPR0, JIT_FPR1);
test_double (JIT_FPR0, JIT_FPR1, JIT_FPR0);
test_double (JIT_FPR0, JIT_FPR1, JIT_FPR2);
test_double (JIT_FPR3, JIT_FPR3, JIT_FPR3);
test_double (JIT_FPR3, JIT_FPR3, JIT_FPR1);
test_double (JIT_FPR3, JIT_FPR1, JIT_FPR3);
test_double (JIT_FPR3, JIT_FPR1, JIT_FPR2);
test_int (JIT_R0, JIT_R0, JIT_R0);
test_int (JIT_R0, JIT_R0, JIT_R1);
test_int (JIT_R0, JIT_R1, JIT_R0);
test_int (JIT_R0, JIT_R1, JIT_R2);
test_int (JIT_V0, JIT_V0, JIT_V0);
test_int (JIT_V0, JIT_V0, JIT_R1);
test_int (JIT_V0, JIT_R1, JIT_V0);
test_int (JIT_V0, JIT_R1, JIT_R2);
return 0;
}
#else
int
main()
{
return (77);
}
#endif

16
tests/3to2.ok Normal file
View file

@ -0,0 +1,16 @@
0 0
1 1
1 1
1 1
0 0
1 1
1 1
1 1
0 0
1 1
1 1
1 1
0 0
1 1
1 1
1 1

View file

@ -2,12 +2,12 @@ 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 \
allocai push-pop sete
allocai push-pop sete 3to2
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 \
allocai.ok push-pop.ok sete.ok
allocai.ok push-pop.ok sete.ok 3to2.ok
EXTRA_DIST = $(noinst_DATA) run-test
@ -18,7 +18,7 @@ endif
if REGRESSION_TESTING
TESTS = fib fibit fibdelay incr printf printf2 rpn add bp \
testfp funcfp rpnfp modi ldxi divi movi ret allocai \
push-pop sete
push-pop sete 3to2
TESTS_ENVIRONMENT=$(srcdir)/run-test
endif

View file

@ -42,7 +42,7 @@ check_PROGRAMS = fibit$(EXEEXT) incr$(EXEEXT) printf$(EXEEXT) \
add$(EXEEXT) bp$(EXEEXT) testfp$(EXEEXT) funcfp$(EXEEXT) \
rpnfp$(EXEEXT) modi$(EXEEXT) ldxi$(EXEEXT) divi$(EXEEXT) \
movi$(EXEEXT) ret$(EXEEXT) allocai$(EXEEXT) push-pop$(EXEEXT) \
sete$(EXEEXT)
sete$(EXEEXT) 3to2$(EXEEXT)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -53,6 +53,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
3to2_SOURCES = 3to2.c
3to2_OBJECTS = 3to2.$(OBJEXT)
3to2_LDADD = $(LDADD)
@DISASS_TRUE@3to2_DEPENDENCIES = $(top_builddir)/opcode/libdisass.a
add_SOURCES = add.c
add_OBJECTS = add.$(OBJEXT)
add_LDADD = $(LDADD)
@ -144,12 +148,12 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = add.c allocai.c bp.c divi.c fib.c fibdelay.c fibit.c \
funcfp.c incr.c ldxi.c modi.c movi.c printf.c printf2.c \
push-pop.c ret.c rpn.c rpnfp.c sete.c testfp.c
DIST_SOURCES = add.c allocai.c bp.c divi.c fib.c fibdelay.c fibit.c \
SOURCES = 3to2.c add.c allocai.c bp.c divi.c fib.c fibdelay.c fibit.c \
funcfp.c incr.c ldxi.c modi.c movi.c printf.c printf2.c \
push-pop.c ret.c rpn.c rpnfp.c sete.c testfp.c
DIST_SOURCES = 3to2.c add.c allocai.c bp.c divi.c fib.c fibdelay.c \
fibit.c funcfp.c incr.c ldxi.c modi.c movi.c printf.c \
printf2.c push-pop.c ret.c rpn.c rpnfp.c sete.c testfp.c
DATA = $(noinst_DATA)
ETAGS = etags
CTAGS = ctags
@ -258,13 +262,13 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/lightning/$(cpu)
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 \
allocai.ok push-pop.ok sete.ok
allocai.ok push-pop.ok sete.ok 3to2.ok
EXTRA_DIST = $(noinst_DATA) run-test
@DISASS_TRUE@LDADD = $(top_builddir)/opcode/libdisass.a
@REGRESSION_TESTING_TRUE@TESTS = fib fibit fibdelay incr printf printf2 rpn add bp \
@REGRESSION_TESTING_TRUE@ testfp funcfp rpnfp modi ldxi divi movi ret allocai \
@REGRESSION_TESTING_TRUE@ push-pop sete
@REGRESSION_TESTING_TRUE@ push-pop sete 3to2
@REGRESSION_TESTING_TRUE@TESTS_ENVIRONMENT = $(srcdir)/run-test
all: all-am
@ -303,6 +307,9 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
3to2$(EXEEXT): $(3to2_OBJECTS) $(3to2_DEPENDENCIES)
@rm -f 3to2$(EXEEXT)
$(LINK) $(3to2_LDFLAGS) $(3to2_OBJECTS) $(3to2_LDADD) $(LIBS)
add$(EXEEXT): $(add_OBJECTS) $(add_DEPENDENCIES)
@rm -f add$(EXEEXT)
$(LINK) $(add_LDFLAGS) $(add_OBJECTS) $(add_LDADD) $(LIBS)
@ -370,6 +377,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3to2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocai.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bp.Po@am__quote@