[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 52/437: improve set* encoding for i386, add testcase
From: |
Andy Wingo |
Subject: |
[Guile-commits] 52/437: improve set* encoding for i386, add testcase |
Date: |
Mon, 2 Jul 2018 05:13:45 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit d0d493b41755f22432397bdb109ad1a5eae47841
Author: Paolo Bonzini <address@hidden>
Date: Mon Aug 13 08:00:13 2007 +0000
improve set* encoding for i386, add testcase
2007-08-12 Paolo Bonzini <address@hidden>
* lightning/i386/core-i386.h: Improve encoding of set* instructions.
* lightning/i386/core-64.h: Fix jit_bra_l.
* tests/sete.c: New.
* tests/sete.ok: New.
git-archimport-id: address@hidden/lightning--stable--1.2--patch-56
git-archimport-id: address@hidden/lightning--stable--1.2--patch-60
---
ChangeLog | 7 +++++
lightning/i386/core-64.h | 2 +-
lightning/i386/core-i386.h | 14 +++++-----
tests/Makefile.am | 6 ++---
tests/Makefile.in | 19 +++++++++----
tests/sete.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++
tests/sete.ok | 2 ++
7 files changed, 101 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6faf6aa..15c02f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-08-12 Paolo Bonzini <address@hidden>
+
+ * lightning/i386/core-i386.h: Improve encoding of set* instructions.
+ * lightning/i386/core-64.h: Fix jit_bra_l.
+ * tests/sete.c: New.
+ * tests/sete.ok: New.
+
2007-06-29 Paolo Bonzini <address@hidden>
* tests/bp.c: Upgrade to GPL/LGPLv3.
diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h
index 7baa943..03d1053 100644
--- a/lightning/i386/core-64.h
+++ b/lightning/i386/core-64.h
@@ -84,7 +84,7 @@ struct jit_local_state {
#define jit_bra_l(rs, is, op) (_s32P((long)(is)) \
? _jit_bra_l(rs, is, op) \
- : (jit_movi_l(JIT_REXTMP, is),
jit_bra_qr(JIT_REXTMP, rs, op)))
+ : (MOVQir(is, JIT_REXTMP),
jit_bra_qr(JIT_REXTMP, rs, op)))
/* When CMP with 0 can be replaced with TEST */
#define jit_bra_l0(rs, is, op, op0) \
diff --git a/lightning/i386/core-i386.h b/lightning/i386/core-i386.h
index be10dc4..754cdff 100644
--- a/lightning/i386/core-i386.h
+++ b/lightning/i386/core-i386.h
@@ -69,22 +69,22 @@
(rs == forced) ? op : (jit_pushr_i(forced), MOVLrr(rs, forced), op,
jit_popr_i(forced)))
/* For LT, LE, ... */
-#define jit_replace8(d, op) \
+#define jit_replace8(d, cmp, op) \
(jit_check8(d) \
- ? (MOVLir(0, d), op(d)) \
- : (jit_pushr_i(_EAX), MOVLir(0, _EAX), op(_EAX), MOVLrr(_EAX, (d)),
jit_popr_i(_EAX)))
+ ? (XORLrr(d, d), (cmp), op(_rN(d) | _AL))
\
+ : (jit_pushr_i(_EAX), XORLrr(_EAX, _EAX), (cmp), op(_AL),
MOVLrr(_EAX, (d)), jit_popr_i(_EAX)))
#define jit_bool_r(d, s1, s2, op) \
- (CMPLrr(s2, s1), jit_replace8(d, op))
+ (jit_replace8(d, CMPLrr(s2, s1), op))
#define jit_bool_i(d, rs, is, op) \
- (CMPLir(is, rs), jit_replace8(d, op))
+ (jit_replace8(d, CMPLir(is, rs), op))
/* When CMP with 0 can be replaced with TEST */
#define jit_bool_i0(d, rs, is, op, op0)
\
((is) != 0 \
- ? (CMPLir(is, rs), jit_replace8(d, op)) \
- : (TESTLrr(rs, rs), jit_replace8(d, op0)))
+ ? (jit_replace8(d, CMPLir(is, rs), op)) \
+ : (jit_replace8(d, TESTLrr(rs, rs), op0)))
/* For BLT, BLE, ... */
#define jit_bra_r(s1, s2, op) (CMPLrr(s2, s1), op, _jit.x.pc)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c9cac9e..47cf1db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
+ allocai push-pop sete
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
+ allocai.ok push-pop.ok sete.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
+ push-pop sete
TESTS_ENVIRONMENT=$(srcdir)/run-test
endif
diff --git a/tests/Makefile.in b/tests/Makefile.in
index eda7bca..846766b 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -41,7 +41,8 @@ check_PROGRAMS = fibit$(EXEEXT) incr$(EXEEXT) printf$(EXEEXT)
\
printf2$(EXEEXT) rpn$(EXEEXT) fib$(EXEEXT) fibdelay$(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)
+ movi$(EXEEXT) ret$(EXEEXT) allocai$(EXEEXT) push-pop$(EXEEXT) \
+ sete$(EXEEXT)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -128,6 +129,10 @@ rpnfp_SOURCES = rpnfp.c
rpnfp_OBJECTS = rpnfp.$(OBJEXT)
rpnfp_LDADD = $(LDADD)
@address@hidden = $(top_builddir)/opcode/libdisass.a
+sete_SOURCES = sete.c
+sete_OBJECTS = sete.$(OBJEXT)
+sete_LDADD = $(LDADD)
address@hidden@sete_DEPENDENCIES = $(top_builddir)/opcode/libdisass.a
testfp_SOURCES = testfp.c
testfp_OBJECTS = testfp.$(OBJEXT)
testfp_LDADD = $(LDADD)
@@ -141,10 +146,10 @@ 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 testfp.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 \
funcfp.c incr.c ldxi.c modi.c movi.c printf.c printf2.c \
- push-pop.c ret.c rpn.c rpnfp.c testfp.c
+ push-pop.c ret.c rpn.c rpnfp.c sete.c testfp.c
DATA = $(noinst_DATA)
ETAGS = etags
CTAGS = ctags
@@ -253,13 +258,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
+ allocai.ok push-pop.ok sete.ok
EXTRA_DIST = $(noinst_DATA) run-test
@address@hidden = $(top_builddir)/opcode/libdisass.a
@address@hidden = fib fibit fibdelay incr printf printf2 rpn add bp \
@REGRESSION_TESTING_TRUE@ testfp funcfp rpnfp modi ldxi divi movi ret
allocai \
address@hidden@ push-pop
address@hidden@ push-pop sete
@address@hidden = $(srcdir)/run-test
all: all-am
@@ -352,6 +357,9 @@ rpn$(EXEEXT): $(rpn_OBJECTS) $(rpn_DEPENDENCIES)
rpnfp$(EXEEXT): $(rpnfp_OBJECTS) $(rpnfp_DEPENDENCIES)
@rm -f rpnfp$(EXEEXT)
$(LINK) $(rpnfp_LDFLAGS) $(rpnfp_OBJECTS) $(rpnfp_LDADD) $(LIBS)
+sete$(EXEEXT): $(sete_OBJECTS) $(sete_DEPENDENCIES)
+ @rm -f sete$(EXEEXT)
+ $(LINK) $(sete_LDFLAGS) $(sete_OBJECTS) $(sete_LDADD) $(LIBS)
testfp$(EXEEXT): $(testfp_OBJECTS) $(testfp_DEPENDENCIES)
@rm -f testfp$(EXEEXT)
$(LINK) $(testfp_LDFLAGS) $(testfp_OBJECTS) $(testfp_LDADD) $(LIBS)
@@ -380,6 +388,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
.c.o:
diff --git a/tests/sete.c b/tests/sete.c
new file mode 100644
index 0000000..6442bd5
--- /dev/null
+++ b/tests/sete.c
@@ -0,0 +1,67 @@
+/******************************** -*- C -*- ****************************
+ *
+ * Sample call for using arguments in GNU lightning
+ *
+ ***********************************************************************/
+
+
+/***********************************************************************
+ *
+ * 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 char codeBuffer[1024];
+
+typedef int (*pifii)(int, int); /* Pointer to Int Function of Int, Int
*/
+
+int main()
+{
+ pifii myFunction= (pifii) (jit_set_ip(codeBuffer).iptr);
+ int arg; /* offset of the argument */
+
+ jit_leaf(2);
+ arg = jit_arg_i();
+ jit_getarg_i(JIT_R0, arg);
+ arg = jit_arg_i();
+ jit_getarg_i(JIT_R1, arg);
+ jit_eqr_i(JIT_V0, JIT_R0, JIT_R1);
+ jit_movr_i(JIT_RET, JIT_V0);
+ jit_ret();
+ jit_flush_code(codeBuffer, jit_get_ip().ptr);
+
+ /* call the generated code, passing its size as argument */
+#ifdef LIGHTNING_DISASSEMBLE
+ disassemble(stderr, codeBuffer, jit_get_ip().ptr);
+#endif
+#ifndef LIGHTNING_CROSS
+ printf("%d == %d? %s\n", 5, 4, myFunction(5, 4) ? "yes" : "no");
+ printf("%d == %d? %s\n", 5, 5, myFunction(5, 5) ? "yes" : "no");
+#endif
+ return 0;
+}
diff --git a/tests/sete.ok b/tests/sete.ok
new file mode 100644
index 0000000..aa736b4
--- /dev/null
+++ b/tests/sete.ok
@@ -0,0 +1,2 @@
+5 == 4? no
+5 == 5? yes
- [Guile-commits] 47/437: refine ludovic's doc patch, (continued)
- [Guile-commits] 47/437: refine ludovic's doc patch, Andy Wingo, 2018/07/02
- [Guile-commits] 38/437: add JIT_NEED_PUSH_POP and merge correct implementation of push/pop for SPARC, Andy Wingo, 2018/07/02
- [Guile-commits] 50/437: fix imprecisions in the ChangeLog, Andy Wingo, 2018/07/02
- [Guile-commits] 48/437: use CVTT instruction, fix lightning/Makefile.am, Andy Wingo, 2018/07/02
- [Guile-commits] 53/437: fix -I flags for opcode subdirectory, Andy Wingo, 2018/07/02
- [Guile-commits] 55/437: add Matthew Flatt to THANKS file, Andy Wingo, 2018/07/02
- [Guile-commits] 39/437: merge 64-bit cleanliness changes from mzscheme, Andy Wingo, 2018/07/02
- [Guile-commits] 49/437: add clean-local target to lightning/Makefile.am, Andy Wingo, 2018/07/02
- [Guile-commits] 56/437: fix i386 floating-point sub(a,0,a), Andy Wingo, 2018/07/02
- [Guile-commits] 54/437: add 3to2 test and fix bug, Andy Wingo, 2018/07/02
- [Guile-commits] 52/437: improve set* encoding for i386, add testcase,
Andy Wingo <=
- [Guile-commits] 57/437: don't truncate function pointers on amd64, Andy Wingo, 2018/07/02
- [Guile-commits] 68/437: cast memory address to long for JCCim, Andy Wingo, 2018/07/02
- [Guile-commits] 59/437: add --with-lightning-prefix option to lightning.m4, Andy Wingo, 2018/07/02
- [Guile-commits] 67/437: add underscores around __unused__ attribute, Andy Wingo, 2018/07/02
- [Guile-commits] 65/437: fix some problems (not all) with lightningize, Andy Wingo, 2018/07/02
- [Guile-commits] 63/437: Fix stxr_c(_EAX, _EBX, _ESI)., Andy Wingo, 2018/07/02
- [Guile-commits] 64/437: avoid "value computed is not used" in jit_allocai, Andy Wingo, 2018/07/02
- [Guile-commits] 66/437: warning patrol (allocai.c, ppc), Andy Wingo, 2018/07/02
- [Guile-commits] 75/437: fix uses of jit_qop_ with 4 parameters, Andy Wingo, 2018/07/02
- [Guile-commits] 61/437: avoid redefinition of _r1, Andy Wingo, 2018/07/02