1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-20 18:50:21 +02:00

first merge of x86-64 backend and related configury changes

Patches applied:

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--base-0
   tag of bonzini@gnu.org--2004b/lightning--stable--1.2--patch-28

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--patch-1
   start merging from mzscheme...

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--patch-2
   fix i386

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--patch-3
   fix distribution hiccups

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--patch-4
   adapt for usage outside distribution.

 * bonzini@gnu.org--2004b/lightning--x86-64--1.3--patch-6
   fixes for GNU Smalltalk

git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-30
This commit is contained in:
Paolo Bonzini 2006-10-30 08:48:47 +00:00
parent 065bc52d7f
commit 1f7feaffe2
29 changed files with 900 additions and 305 deletions

View file

@ -1,18 +1,32 @@
DISTCLEANFILES = asm.h core.h funcs.h fp.h
LIGHTNING_FILES = funcs-common.h core-common.h fp-common.h \
asm-common.h \
i386/asm.h i386/core.h i386/funcs.h i386/fp.h \
sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
EXTRA_DIST = i386/Makefile.frag \
i386/asm-32.h i386/asm-64.h i386/asm-i386.h \
i386/core-32.h i386/core-64.h i386/core-i386.h \
i386/fp-32.h i386/fp-64.h \
i386/funcs.h \
sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
@lightning_frag@
LIGHTNING_FILES = funcs-common.h core-common.h fp-common.h asm-common.h \
asm.h core.h funcs.h fp.h $(LIGHTNING_TARGET_FILES)
if LIGHTNING_MAIN
lightningdir = $(includedir)/lightning
dist_pkgdata_DATA = Makefile.am
nobase_dist_lightning_HEADERS = $(LIGHTNING_FILES)
nodist_lightning_HEADERS = asm.h core.h funcs.h fp.h
dist_lightning_HEADERS = $(LIGHTNING_FILES)
else
dist_noinst_HEADERS = $(LIGHTNING_FILES)
all-am:
@set frob $(LIGHTNING_TARGET_FILES); shift; \
for i; \
do \
echo $(LN_S) -f $(srcdir)/$$i `basename $$i`; \
$(LN_S) -f $(srcdir)/$$i `basename $$i`; \
done
dist-hook:
cp -p $(srcdir)/lightning.h $(distdir)

View file

@ -39,12 +39,12 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = lightning
DIST_COMMON = $(am__dist_noinst_HEADERS_DIST) \
$(am__dist_pkgdata_DATA_DIST) \
$(am__nobase_dist_lightning_HEADERS_DIST) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(am__dist_lightning_HEADERS_DIST) \
$(am__dist_pkgdata_DATA_DIST) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/build-aux/lightning.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@ -60,21 +60,13 @@ am__vpath_adj = case $$p in \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(pkgdatadir)" \
"$(DESTDIR)$(lightningdir)" "$(DESTDIR)$(lightningdir)"
"$(DESTDIR)$(lightningdir)"
dist_pkgdataDATA_INSTALL = $(INSTALL_DATA)
DATA = $(dist_pkgdata_DATA)
am__dist_noinst_HEADERS_DIST = funcs-common.h core-common.h \
fp-common.h asm-common.h i386/asm.h i386/core.h i386/funcs.h \
i386/fp.h sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
am__nobase_dist_lightning_HEADERS_DIST = funcs-common.h core-common.h \
fp-common.h asm-common.h i386/asm.h i386/core.h i386/funcs.h \
i386/fp.h sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
nobase_dist_lightningHEADERS_INSTALL = $(install_sh_DATA)
nodist_lightningHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(dist_noinst_HEADERS) $(nobase_dist_lightning_HEADERS) \
$(nodist_lightning_HEADERS)
am__dist_lightning_HEADERS_DIST = funcs-common.h core-common.h \
fp-common.h asm-common.h asm.h core.h funcs.h fp.h
dist_lightningHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(dist_lightning_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -144,6 +136,7 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cpu = @cpu@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
@ -178,17 +171,20 @@ target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
DISTCLEANFILES = asm.h core.h funcs.h fp.h
LIGHTNING_FILES = funcs-common.h core-common.h fp-common.h \
asm-common.h \
i386/asm.h i386/core.h i386/funcs.h i386/fp.h \
sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
EXTRA_DIST = i386/Makefile.frag \
i386/asm-32.h i386/asm-64.h i386/asm-i386.h \
i386/core-32.h i386/core-64.h i386/core-i386.h \
i386/fp-32.h i386/fp-64.h \
i386/funcs.h \
sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \
ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h
LIGHTNING_FILES = funcs-common.h core-common.h fp-common.h asm-common.h \
asm.h core.h funcs.h fp.h $(LIGHTNING_TARGET_FILES)
@LIGHTNING_MAIN_TRUE@lightningdir = $(includedir)/lightning
@LIGHTNING_MAIN_TRUE@dist_pkgdata_DATA = Makefile.am
@LIGHTNING_MAIN_TRUE@nobase_dist_lightning_HEADERS = $(LIGHTNING_FILES)
@LIGHTNING_MAIN_TRUE@nodist_lightning_HEADERS = asm.h core.h funcs.h fp.h
@LIGHTNING_MAIN_FALSE@dist_noinst_HEADERS = $(LIGHTNING_FILES)
@LIGHTNING_MAIN_TRUE@dist_lightning_HEADERS = $(LIGHTNING_FILES)
all: all-am
.SUFFIXES:
@ -239,38 +235,19 @@ uninstall-dist_pkgdataDATA:
echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \
rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \
done
install-nobase_dist_lightningHEADERS: $(nobase_dist_lightning_HEADERS)
install-dist_lightningHEADERS: $(dist_lightning_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(lightningdir)" || $(mkdir_p) "$(DESTDIR)$(lightningdir)"
@$(am__vpath_adj_setup) \
list='$(nobase_dist_lightning_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
$(am__vpath_adj) \
echo " $(nobase_dist_lightningHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(lightningdir)/$$f'"; \
$(nobase_dist_lightningHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(lightningdir)/$$f"; \
done
uninstall-nobase_dist_lightningHEADERS:
@$(NORMAL_UNINSTALL)
@$(am__vpath_adj_setup) \
list='$(nobase_dist_lightning_HEADERS)'; for p in $$list; do \
$(am__vpath_adj) \
echo " rm -f '$(DESTDIR)$(lightningdir)/$$f'"; \
rm -f "$(DESTDIR)$(lightningdir)/$$f"; \
done
install-nodist_lightningHEADERS: $(nodist_lightning_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(lightningdir)" || $(mkdir_p) "$(DESTDIR)$(lightningdir)"
@list='$(nodist_lightning_HEADERS)'; for p in $$list; do \
@list='$(dist_lightning_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(nodist_lightningHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(lightningdir)/$$f'"; \
$(nodist_lightningHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(lightningdir)/$$f"; \
echo " $(dist_lightningHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(lightningdir)/$$f'"; \
$(dist_lightningHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(lightningdir)/$$f"; \
done
uninstall-nodist_lightningHEADERS:
uninstall-dist_lightningHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(nodist_lightning_HEADERS)'; for p in $$list; do \
@list='$(dist_lightning_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(lightningdir)/$$f'"; \
rm -f "$(DESTDIR)$(lightningdir)/$$f"; \
@ -360,7 +337,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(DATA) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(lightningdir)" "$(DESTDIR)$(lightningdir)"; do \
for dir in "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(lightningdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
@ -406,9 +383,8 @@ info: info-am
info-am:
install-data-am: install-dist_pkgdataDATA \
install-nobase_dist_lightningHEADERS \
install-nodist_lightningHEADERS
install-data-am: install-dist_lightningHEADERS \
install-dist_pkgdataDATA
install-exec-am:
@ -434,26 +410,32 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-dist_pkgdataDATA uninstall-info-am \
uninstall-nobase_dist_lightningHEADERS \
uninstall-nodist_lightningHEADERS
uninstall-am: uninstall-dist_lightningHEADERS \
uninstall-dist_pkgdataDATA uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
ctags dist-hook distclean distclean-generic distclean-tags \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am \
install-dist_pkgdataDATA install-exec install-exec-am \
install-info install-info-am install-man \
install-nobase_dist_lightningHEADERS \
install-nodist_lightningHEADERS install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-dist_pkgdataDATA uninstall-info-am \
uninstall-nobase_dist_lightningHEADERS \
uninstall-nodist_lightningHEADERS
install-dist_lightningHEADERS install-dist_pkgdataDATA \
install-exec install-exec-am install-info install-info-am \
install-man install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
uninstall uninstall-am uninstall-dist_lightningHEADERS \
uninstall-dist_pkgdataDATA uninstall-info-am
@lightning_frag@
@LIGHTNING_MAIN_FALSE@all-am:
@LIGHTNING_MAIN_FALSE@ @set frob $(LIGHTNING_TARGET_FILES); shift; \
@LIGHTNING_MAIN_FALSE@ for i; \
@LIGHTNING_MAIN_FALSE@ do \
@LIGHTNING_MAIN_FALSE@ echo $(LN_S) $(srcdir)/$$i `basename $$i`; \
@LIGHTNING_MAIN_FALSE@ $(LN_S) $(srcdir)/$$i `basename $$i`; \
@LIGHTNING_MAIN_FALSE@ done
@LIGHTNING_MAIN_FALSE@dist-hook:
@LIGHTNING_MAIN_FALSE@ cp -p $(srcdir)/lightning.h $(distdir)
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View file

@ -480,8 +480,12 @@ typedef union jit_code {
/* ALU */
#define jit_addi_l(d, rs, is) jit_addi_i((d), (rs), (is))
#define jit_addr_l(d, s1, s2) jit_addr_i((d), (s1), (s2))
#ifndef jit_addci_l
#define jit_addci_l(d, rs, is) jit_addci_i((d), (rs), (is))
#endif
#ifndef jit_addcr_l
#define jit_addcr_l(d, s1, s2) jit_addcr_i((d), (s1), (s2))
#endif
#define jit_addxi_l(d, rs, is) jit_addxi_i((d), (rs), (is))
#define jit_addxr_l(d, s1, s2) jit_addxr_i((d), (s1), (s2))
#define jit_andi_l(d, rs, is) jit_andi_i((d), (rs), (is))
@ -496,6 +500,9 @@ typedef union jit_code {
#define jit_modr_l(d, s1, s2) jit_modr_i((d), (s1), (s2))
#define jit_muli_l(d, rs, is) jit_muli_i((d), (rs), (is))
#define jit_mulr_l(d, s1, s2) jit_mulr_i((d), (s1), (s2))
#ifndef jit_negr_l
#define jit_negr_l(d, s1) jit_negr_i((d), (s1))
#endif
#define jit_ori_l(d, rs, is) jit_ori_i((d), (rs), (is))
#define jit_orr_l(d, s1, s2) jit_orr_i((d), (s1), (s2))
#define jit_rshi_l(d, rs, is) jit_rshi_i((d), (rs), (is))

View file

@ -0,0 +1 @@
LIGHTNING_TARGET_FILES += i386/asm-i386.h i386/core-i386.h

61
lightning/i386/asm-32.h Normal file
View file

@ -0,0 +1,61 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler for the i386
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2006 Free Software Foundation, Inc.
*
* 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 2.1, 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, 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
***********************************************************************/
#ifndef __lightning_asm_h
#define __lightning_asm_h
/* OPCODE + i = immediate operand
* + r = register operand
* + m = memory operand (disp,base,index,scale)
* + sr/sm = a star preceding a register or memory
*/
#include "asm-i386.h"
#ifndef LIGHTNING_DEBUG
#define _r_D( R, D ) (_Mrm(_b00,_rN(R),_b101 ) ,_jit_I((long)(D)))
#define CALLm(D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D32 (0xe8 ,(long)(D) ) : \
JITFAIL("illegal mode in direct jump"))
#define JCCim(CC,D,B,I,S) ((_r0P(B) && _r0P(I)) ? _OO_D32 (0x0f80|(CC) ,(long)(D) ) : \
JITFAIL("illegal mode in conditional jump"))
#define JMPm(D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D32 (0xe9 ,(long)(D) ) : \
JITFAIL("illegal mode in direct jump"))
#endif
#endif /* __lightning_asm_h */

134
lightning/i386/asm-64.h Normal file
View file

@ -0,0 +1,134 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler for the x86-64
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2006 Matthew Flatt
*
* 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 2.1, 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, 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
***********************************************************************/
#ifndef __lightning_asm_h
#define __lightning_asm_h
#include "asm-i386.h"
/* OPCODE + i = immediate operand
* + r = register operand
* + m = memory operand (disp,base,index,scale)
* + sr/sm = a star preceding a register or memory
*/
#ifndef LIGHTNING_DEBUG
#define _R12 0x4C
#define _R13 0x4D
#define JIT_CALLTMPSTART 0x48
#define JIT_REXTMP 0x4B
#define _qMrm(Md,R,M) _jit_B((_M(Md)<<6)|(_r((R & 0x7))<<3)|_m((M & 0x7)))
#define _r_D( R, D ) (_Mrm(_b00,_rN(R),_b100 ),_SIB(0,_b100,_b101) ,_jit_I((long)(D)))
#define _r_Q( R, D ) (_qMrm(_b00,_rN(R),_b100 ),_SIB(0,_b100,_b101) ,_jit_I((long)(D)))
#define _REX(R,X,B) ( _jit_B(0x48|((R&0x8)>>1)|((X&0x8)>>2)|((B&0x8)>>3)) )
#define _qO( OP, R,X,B ) ( _REX(R,X,B), _jit_B( OP ) )
#define _qOr( OP,R ) ( _REX(0,0,R), _jit_B( (OP)|_r(R&0x7)) )
#define _qOs( OP, B, R, M ) ( _REX(0, M, R), _Os(OP, B) )
#define ADDQrr(RS, RD) _qO_Mrm (0x01 ,_b11,_r8(RS),_r8(RD) )
#define ADDQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b000 ,_r8(RD) ,IM )
#define ANDQrr(RS, RD) _qO_Mrm (0x21 ,_b11,_r8(RS),_r8(RD) )
#define ANDQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b100 ,_r8(RD) ,IM )
#define CALLm(D,B,I,S) (MOVQir((D), JIT_REXTMP), CALLQsr(JIT_REXTMP))
#define CALLsr(R) _O_Mrm (0xff ,_b11,_b010,_r4(R) )
#define CALLQsr(R) _qO_Mrm (0xff ,_b11,_b010,_r8(R))
#define CMPQrr(RS, RD) _qO_Mrm (0x39 ,_b11,_r8(RS),_r8(RD) )
#define CMPQir(IM, RD) _qO_Mrm_L (0x81 ,_b11,_b111 ,_r8(RD) ,IM )
#define JCCim(CC,D,B,I,S) (!_jitl.long_jumps \
? _OO_D32(0x0f80|(CC), (long)(D) ) \
: (_O_D8(0x71^(CC), _jit_UL(_jit.x.pc) + 13), JMPm((long)D, 0, 0, 0)))
#define JMPm(D,B,I,S) (!_jitl.long_jumps \
? _O_D32(0xe9, (long)(D)) \
: (MOVQir((D), JIT_REXTMP), _qO_Mrm(0xff,_b11,_b100,_r8(JIT_REXTMP))))
#define LEAQmr(MD, MB, MI, MS, RD) _qO_r_X (0x8d ,_r8(RD) ,MD,MB,MI,MS )
#define MOVQmr(MD, MB, MI, MS, RD) _qO_r_X (0x8b ,_r8(RD) ,MD,MB,MI,MS )
#define MOVQrm(RS, MD, MB, MI, MS) _qO_r_X (0x89 ,_r8(RS) ,MD,MB,MI,MS )
#define MOVQrQm(RS, MD, MB, MI, MS) _qO_r_XB (0x89 ,_r8(RS) ,MD,MB,MI,MS )
#define MOVQir(IM, R) _qOr_Q (0xb8,_r8(R) ,IM )
#define MOVQrr(RS, RD) _qO_Mrm (0x89 ,_b11,_r8(RS),_r8(RD) )
#define NEGQr(RD) _qO_Mrm (0xf7 ,_b11,_b011 ,_r8(RD) )
#define ORQrr(RS, RD) _qO_Mrm (0x09 ,_b11,_r8(RS),_r8(RD) )
#define ORQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b001 ,_r8(RD) ,IM )
#define POPQr(RD) _qOr (0x58,_r8(RD) )
#define PUSHQr(R) _qOr (0x50,_r8(R) )
#define SALQir SHLQir
#define SALQim SHLQim
#define SALQrr SHLQrr
#define SALQrm SHLQrm
#define SARQir(IM,RD) (((IM)==1) ? _qO_Mrm (0xd1 ,_b11,_b111,_r8(RD) ) : \
_qO_Mrm_B (0xc1 ,_b11,_b111,_r4(RD) ,_u8(IM) ) )
#define SARQrr(RS,RD) (((RS)==_CL) ? _qO_Mrm (0xd3 ,_b11,_b111,_r8(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHLQir(IM,RD) (((IM)==1) ? _qO_Mrm (0xd1 ,_b11,_b100,_r8(RD) ) : \
_qO_Mrm_B (0xc1 ,_b11,_b100,_r8(RD) ,_u8(IM) ) )
#define SHLQrr(RS,RD) (((RS)==_CL) ? _qO_Mrm (0xd3 ,_b11,_b100,_r8(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHRQir(IM,RD) (((IM)==1) ? _qO_Mrm (0xd1 ,_b11,_b101,_r8(RD) ) : \
_qO_Mrm_B (0xc1 ,_b11,_b101,_r8(RD) ,_u8(IM) ) )
#define SHRQrr(RS,RD) (((RS)==_CL) ? _qO_Mrm (0xd3 ,_b11,_b101,_r8(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SUBQrr(RS, RD) _qO_Mrm (0x29 ,_b11,_r8(RS),_r8(RD) )
#define SUBQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b101 ,_r8(RD) ,IM )
#define TESTQrr(RS, RD) _qO_Mrm (0x85 ,_b11,_r8(RS),_r8(RD) )
#define TESTQir(IM, RD) _qO_Mrm_L (0xf7 ,_b11,_b000 ,_r8(RD) ,IM )
#define XORQrr(RS, RD) _qO_Mrm (0x31 ,_b11,_r8(RS),_r8(RD) )
#define XORQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b110 ,_r8(RD) ,IM )
#endif
#endif /* __lightning_asm_h */

View file

@ -31,8 +31,8 @@
#ifndef __lightning_asm_h
#define __lightning_asm_h
#ifndef __lightning_asm_i386_h
#define __lightning_asm_i386_h
/* OPCODE + i = immediate operand
* + r = register operand
@ -147,7 +147,6 @@ typedef _uc jit_insn;
/* memory subformats - urgh! */
#define _r_D( R, D ) (_Mrm(_b00,_rN(R),_b101 ) ,_jit_L((long)(D)))
#define _r_0B( R, B ) (_Mrm(_b00,_rN(R),_r4(B)) )
#define _r_0BIS(R, B,I,S) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B)) )
#define _r_1B( R, D,B ) (_Mrm(_b01,_rN(R),_r4(B)) ,_jit_B((long)(D)))
@ -334,9 +333,6 @@ typedef _uc jit_insn;
#define BTSLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fab ,_r4(RS) ,MD,MB,MI,MS )
#define CALLm(D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D32 (0xe8 ,(int)(D) ) : \
JITFAIL("illegal mode in direct jump"))
#define CALLsr(R) _O_Mrm (0xff ,_b11,_b010,_r4(R) )
#define CALLsm(D,B,I,S) _O_r_X (0xff ,_b010 ,(int)(D),B,I,S )
@ -482,9 +478,6 @@ typedef _uc jit_insn;
#define JNLESm(D,B,I,S) JCCSim(0xf,D,B,I,S)
#define JGSm(D,B,I,S) JCCSim(0xf,D,B,I,S)
#define JCCim(CC,D,B,I,S) ((_r0P(B) && _r0P(I)) ? _OO_D32 (0x0f80|(CC) ,(int)(D) ) : \
JITFAIL("illegal mode in conditional jump"))
#define JOm(D,B,I,S) JCCim(0x0,D,B,I,S)
#define JNOm(D,B,I,S) JCCim(0x1,D,B,I,S)
#define JCm(D,B,I,S) JCCim(0x2,D,B,I,S)
@ -520,9 +513,6 @@ typedef _uc jit_insn;
#define JMPSm(D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D8 (0xeb ,(int)(D) ) : \
JITFAIL("illegal mode in short jump"))
#define JMPm(D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D32 (0xe9 ,(int)(D) ) : \
JITFAIL("illegal mode in direct jump"))
#define JMPsr(R) _O_Mrm (0xff ,_b11,_b100,_r4(R) )
#define JMPsm(D,B,I,S) _O_r_X (0xff ,_b100 ,(int)(D),B,I,S )
@ -1062,5 +1052,5 @@ typedef _uc jit_insn;
/* Intel Corporation 1997. */
#endif
#endif /* __lightning_asm_h */
#endif /* __lightning_asm_i386_h */

80
lightning/i386/core-32.h Normal file
View file

@ -0,0 +1,80 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer (i386 version)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002, 2003 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 2.1, 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, 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
***********************************************************************/
#ifndef __lightning_core_h
#define __lightning_core_h
#include "core-i386.h"
#define JIT_CAN_16 1
struct jit_local_state {
int framesize;
int argssize;
};
#define jit_base_prolog() (PUSHLr(_EBP), MOVLrr(_ESP, _EBP), PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI))
#define jit_prolog(n) (_jitl.framesize = 8, jit_base_prolog())
/* The += allows for stack pollution */
#ifdef __APPLE__
/* Stack must stay 16-byte aligned: */
# define jit_prepare_i(ni) (((ni & 0x3) \
? SUBLir(4 * ((((ni) + 3) & ~(0x3)) - (ni)), JIT_SP) \
: (void)0), \
_jitl.argssize += (((ni) + 3) & ~(0x3)))
#else
# define jit_prepare_i(ni) (_jitl.argssize += (ni))
#endif
#define jit_pusharg_i(rs) PUSHLr(rs)
#define jit_finish(sub) ((void)jit_calli((sub)), ADDLir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0)
#define jit_finishr(reg) (jit_callr((reg)), ADDLir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0)
#define jit_arg_c() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_uc() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_s() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_us() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_i() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_ui() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_l() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_arg_ul() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_arg_p() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_patch_long_at(jump_pc,v) (*_PSL((jump_pc) - sizeof(long)) = _jit_SL((jit_insn *)(v) - (jump_pc)))
#define jit_patch_at(jump_pc,v) jit_patch_long_at(jump_pc, v)
#define jit_ret() (POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), POPLr(_EBP), RET_())
#endif /* __lightning_core_h */

202
lightning/i386/core-64.h Normal file
View file

@ -0,0 +1,202 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer (i386 version)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002, 2003 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 2.1, 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, 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
***********************************************************************/
#ifndef __lightning_core_h
#define __lightning_core_h
#include "core-i386.h"
struct jit_local_state {
int long_jumps;
int nextarg_geti;
int argssize;
};
/* 3-parameter operation */
#define jit_qopr_(d, s1, s2, op1d, op2d) \
( (s2 == d) ? op1d : \
( ((s1 == d) ? (void)0 : (void)MOVQrr(s1, d)), op2d ) \
)
/* 3-parameter operation, with immediate */
#define jit_qop_(d, s1, op2d) \
#define jit_bra_qr(s1, s2, op) (CMPQrr(s2, s1), op, _jit.x.pc)
#define _jit_bra_l(rs, is, op) (CMPQir(is, rs), op, _jit.x.pc)
#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)))
/* When CMP with 0 can be replaced with TEST */
#define jit_bra_l0(rs, is, op, op0) \
( (is) == 0 ? (TESTQrr(rs, rs), op0, _jit.x.pc) : jit_bra_l(rs, is, op))
/* Used to implement ldc, stc, ... */
#define JIT_CAN_16 0
#define jit_reduceQ(op, is, rs) \
(_u8P(is) && jit_check8(rs) ? jit_reduce_(op##Bir(is, jit_reg8(rs))) : \
jit_reduce_(op##Qir(is, rs)) )
#define jit_addi_l(d, rs, is) jit_opi_((d), (rs), ADDQir((is), (d)), LEAQmr((is), (rs), 0, 0, (d)) )
#define jit_addr_l(d, s1, s2) jit_opo_((d), (s1), (s2), ADDQrr((s2), (d)), ADDQrr((s1), (d)), LEAQmr(0, (s1), (s2), 1, (d)) )
#define jit_andi_l(d, rs, is) jit_qop_ ((d), (rs), ANDQir((is), (d)) )
#define jit_andr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ANDQrr((s1), (d)), ANDQrr((s2), (d)) )
#define jit_orr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ORQrr((s1), (d)), ORQrr((s2), (d)) )
#define jit_subr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), (SUBQrr((s1), (d)), NEGQr(d)), SUBQrr((s2), (d)) )
#define jit_xorr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), XORQrr((s1), (d)), XORQrr((s2), (d)) )
/* These can sometimes use byte or word versions! */
#define jit_ori_i(d, rs, is) jit_op_ ((d), (rs), jit_reduce(OR, (is), (d)) )
#define jit_xori_i(d, rs, is) jit_op_ ((d), (rs), jit_reduce(XOR, (is), (d)) )
#define jit_ori_l(d, rs, is) jit_qop_ ((d), (rs), jit_reduceQ(OR, (is), (d)) )
#define jit_xori_l(d, rs, is) jit_qop_ ((d), (rs), jit_reduceQ(XOR, (is), (d)) )
#define jit_lshi_l(d, rs, is) ((is) <= 3 ? LEAQmr(0, 0, (rs), 1 << (is), (d)) : jit_qop_ ((d), (rs), SHLQir((is), (d)) ))
#define jit_rshi_l(d, rs, is) jit_qop_ ((d), (rs), SARQir((is), (d)) )
#define jit_rshi_ul(d, rs, is) jit_qop_ ((d), (rs), SHRQir((is), (d)) )
#define jit_lshr_l(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SHLQrr(_CL, (d)) ))
#define jit_rshr_l(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SARQrr(_CL, (d)) ))
#define jit_rshr_ul(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SHRQrr(_CL, (d)) ))
/* Stack */
#define jit_pushr_l(rs) PUSHQr(rs)
#define jit_popr_l(rs) POPQr(rs)
#define jit_base_prolog() (PUSHQr(_EBP), MOVQrr(_ESP, _EBP), PUSHQr(_EBX), PUSHQr(_R12), PUSHQr(_R13))
#define jit_prolog(n) (_jitl.nextarg_geti = 0, jit_base_prolog())
/* Stack isn't used for arguments: */
#define jit_prepare_i(ni) (_jitl.argssize = 0)
#define jit_pusharg_i(rs) (_jitl.argssize++, MOVQrr(rs, JIT_CALLTMPSTART + _jitl.argssize - 1))
#define jit_finish(sub) (jit_shift_args(), (void)jit_calli((sub)), jit_restore_locals())
#define jit_reg_is_arg(reg) ((reg == _EDI) || (reg ==_ESI) || (reg == _EDX))
#define jit_finishr(reg) ((jit_reg_is_arg((reg)) ? MOVQrr(reg, JIT_REXTMP) : (void)0), \
jit_shift_args(), \
jit_reg_is_arg((reg)) ? CALQsr((JIT_REXTMP)) : jit_callr((reg)), \
jit_restore_locals())
/* R12 and R13 are callee-save, instead of EDI and ESI. Can be improved. */
#define jit_shift_args() \
(MOVQrr(_ESI, _R12), MOVQrr(_EDI, _R13), \
(_jitl.argssize-- \
? (MOVQrr(JIT_CALLTMPSTART + _jitl.argssize, jit_arg_reg_order[0]), \
(_jitl.argssize-- \
? (MOVQrr(JIT_CALLTMPSTART + _jitl.argssize, jit_arg_reg_order[1]), \
(_jitl.argssize-- \
? MOVQrr(JIT_CALLTMPSTART, jit_arg_reg_order[2]) \
: (void)0)) \
: (void)0)) \
: (void)0))
#define jit_restore_locals() \
(MOVQrr(_R12, _ESI), MOVQrr(_R13, _EDI))
#define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX))
#define jit_arg_i() (_jitl.nextarg_geti++)
#define jit_arg_l() (_jitl.nextarg_geti++)
#define jit_arg_p() (_jitl.nextarg_geti++)
#define jit_arg_reg(p) (jit_arg_reg_order[p])
static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX };
#define jit_negr_l(d, rs) jit_opi_((d), (rs), NEGQr(d), (XORQrr((d), (d)), SUBQrr((rs), (d))) )
#define jit_movr_l(d, rs) ((void)((rs) == (d) ? 0 : MOVQrr((rs), (d))))
#define jit_movi_l(d, is) ((is) \
? (_u32P((long)(is)) \
? MOVLir((is), (d)) \
: MOVQir((is), (d))) \
: XORLrr ((d), (d)) )
#define jit_bmsr_l(label, s1, s2) (TESTQrr((s1), (s2)), JNZm(label,0,0,0), _jit.x.pc)
#define jit_bmcr_l(label, s1, s2) (TESTQrr((s1), (s2)), JZm(label,0,0,0), _jit.x.pc)
#define jit_boaddr_l(label, s1, s2) (ADDQrr((s2), (s1)), JOm(label,0,0,0), _jit.x.pc)
#define jit_bosubr_l(label, s1, s2) (SUBQrr((s2), (s1)), JOm(label,0,0,0), _jit.x.pc)
#define jit_boaddr_ul(label, s1, s2) (ADDQrr((s2), (s1)), JCm(label,0,0,0), _jit.x.pc)
#define jit_bosubr_ul(label, s1, s2) (SUBQrr((s2), (s1)), JCm(label,0,0,0), _jit.x.pc)
#define jit_boaddi_l(label, rs, is) (ADDQir((is), (rs)), JOm(label,0,0,0), _jit.x.pc)
#define jit_bosubi_l(label, rs, is) (SUBQir((is), (rs)), JOm(label,0,0,0), _jit.x.pc)
#define jit_boaddi_ul(label, rs, is) (ADDQir((is), (rs)), JCm(label,0,0,0), _jit.x.pc)
#define jit_bosubi_ul(label, rs, is) (SUBQir((is), (rs)), JCm(label,0,0,0), _jit.x.pc)
#define jit_patch_long_at(jump_pc,v) (*_PSL((jump_pc) - sizeof(long)) = _jit_SL((jit_insn *)(v)))
#define jit_patch_short_at(jump_pc,v) (*_PSI((jump_pc) - sizeof(int)) = _jit_SI((jit_insn *)(v) - (jump_pc)))
#define jit_patch_at(jump_pc,v) (_jitl.long_jumps ? jit_patch_long_at((jump_pc)-3, v) : jit_patch_short_at(jump_pc, v))
#define jit_ret() (POPQr(_R13), POPQr(_R12), POPQr(_EBX), POPQr(_EBP), RET_())
#define _jit_ldi_l(d, is) MOVQmr((is), 0, 0, 0, (d))
#define jit_ldr_l(d, rs) MOVQmr(0, (rs), 0, 0, (d))
#define jit_ldxr_l(d, s1, s2) MOVQmr(0, (s1), (s2), 1, (d))
#define jit_ldxi_l(d, rs, is) MOVQmr((is), (rs), 0, 0, (d))
#define _jit_sti_l(id, rs) MOVQrm((rs), (id), 0, 0, 0)
#define jit_str_l(rd, rs) MOVQrm((rs), 0, (rd), 0, 0)
#define jit_stxr_l(d1, d2, rs) MOVQrm((rs), 0, (d1), (d2), 1)
#define jit_stxi_l(id, rd, rs) MOVQrm((rs), (id), (rd), 0, 0)
#define jit_ldi_l(d, is) (_u32P((long)(is)) ? _jit_ldi_l(d, is) : (jit_movi_l(d, is), jit_ldr_l(d, d)))
#define jit_sti_l(id, rs) (_u32P((long)(id)) ? _jit_sti_l(id, rs) : (jit_movi_l(JIT_REXTMP, id), MOVQrQm(rs, 0, JIT_REXTMP, 0, 0)))
#define jit_blti_l(label, rs, is) jit_bra_l0((rs), (is), JLm(label, 0,0,0), JSm(label, 0,0,0) )
#define jit_blei_l(label, rs, is) jit_bra_l ((rs), (is), JLEm(label,0,0,0) )
#define jit_bgti_l(label, rs, is) jit_bra_l ((rs), (is), JGm(label, 0,0,0) )
#define jit_bgei_l(label, rs, is) jit_bra_l0((rs), (is), JGEm(label,0,0,0), JNSm(label,0,0,0) )
#define jit_beqi_l(label, rs, is) jit_bra_l0((rs), (is), JEm(label, 0,0,0), JEm(label, 0,0,0) )
#define jit_bnei_l(label, rs, is) jit_bra_l0((rs), (is), JNEm(label,0,0,0), JNEm(label,0,0,0) )
#define jit_blti_ul(label, rs, is) jit_bra_l ((rs), (is), JBm(label, 0,0,0) )
#define jit_blei_ul(label, rs, is) jit_bra_l0((rs), (is), JBEm(label,0,0,0), JEm(label, 0,0,0) )
#define jit_bgti_ul(label, rs, is) jit_bra_l0((rs), (is), JAm(label, 0,0,0), JNEm(label,0,0,0) )
#define jit_bgei_ul(label, rs, is) jit_bra_l ((rs), (is), JAEm(label,0,0,0) )
#define jit_bmsi_l(label, rs, is) jit_bmsi_i(label, rs, is)
#define jit_bmci_l(label, rs, is) jit_bmci_i(label, rs, is)
#define jit_pushr_l(rs) jit_pushr_i(rs)
#define jit_popr_l(rs) jit_popr_i(rs)
#define jit_pusharg_l(rs) jit_pusharg_i(rs)
#define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX))
#define jit_bltr_l(label, s1, s2) jit_bra_qr((s1), (s2), JLm(label, 0,0,0) )
#define jit_bler_l(label, s1, s2) jit_bra_qr((s1), (s2), JLEm(label,0,0,0) )
#define jit_bgtr_l(label, s1, s2) jit_bra_qr((s1), (s2), JGm(label, 0,0,0) )
#define jit_bger_l(label, s1, s2) jit_bra_qr((s1), (s2), JGEm(label,0,0,0) )
#define jit_beqr_l(label, s1, s2) jit_bra_qr((s1), (s2), JEm(label, 0,0,0) )
#define jit_bner_l(label, s1, s2) jit_bra_qr((s1), (s2), JNEm(label,0,0,0) )
#define jit_bltr_ul(label, s1, s2) jit_bra_qr((s1), (s2), JBm(label, 0,0,0) )
#define jit_bler_ul(label, s1, s2) jit_bra_qr((s1), (s2), JBEm(label,0,0,0) )
#define jit_bgtr_ul(label, s1, s2) jit_bra_qr((s1), (s2), JAm(label, 0,0,0) )
#define jit_bger_ul(label, s1, s2) jit_bra_qr((s1), (s2), JAEm(label,0,0,0) )
#endif /* __lightning_core_h */

View file

@ -16,23 +16,23 @@
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1, or (at your option)
* any later version.
*
* GNU lightning is distributed in the hope that it will be useful, but
*
* 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.
* Free Software Foundation, 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
***********************************************************************/
#ifndef __lightning_core_h
#define __lightning_core_h
#ifndef __lightning_core_i386_h
#define __lightning_core_i386_h
#define JIT_FP _EBP
#define JIT_SP _ESP
@ -43,10 +43,6 @@
#define JIT_R(i) (_EAX + (i))
#define JIT_V(i) ((i) == 0 ? _EBX : _ESI + (i) - 1)
struct jit_local_state {
int framesize;
int argssize;
};
/* 3-parameter operation */
#define jit_opr_(d, s1, s2, op1d, op2d) \
@ -56,7 +52,7 @@ struct jit_local_state {
/* 3-parameter operation, with immediate */
#define jit_op_(d, s1, op2d) \
((s1 == d) ? op2d : (MOVLrr(s1, d), op2d)) \
((s1 == d) ? op2d : (MOVLrr(s1, d), op2d))
/* 3-parameter operation, optimizable */
#define jit_opo_(d, s1, s2, op1d, op2d, op12d) \
@ -110,10 +106,15 @@ struct jit_local_state {
: jit_replace(_EBX, rs, _EAX, MOVBrm(_AL, dd, db, di, ds)))
/* Reduce arguments of XOR/OR/TEST */
#ifdef JIT_X86_64
# define JIT_CAN_16 0
#else
# define JIT_CAN_16 1
#endif
#define jit_reduce_(op) op
#define jit_reduce(op, is, rs) \
(_u8P(is) && jit_check8(rs) ? jit_reduce_(op##Bir(is, jit_reg8(rs))) : \
(_u16P(is) ? jit_reduce_(op##Wir(is, jit_reg16(rs))) : \
(_u16P(is) && JIT_CAN_16 ? jit_reduce_(op##Wir(is, jit_reg16(rs))) : \
jit_reduce_(op##Lir(is, rs)) ))
/* Helper macros for MUL/DIV/IDIV */
@ -207,6 +208,7 @@ struct jit_local_state {
#define jit_subxi_i(d, rs, is) jit_op_ ((d), (rs), SBBLir((is), (d)) )
#define jit_xorr_i(d, s1, s2) jit_opr_((d), (s1), (s2), XORLrr((s1), (d)), XORLrr((s2), (d)) )
/* These can sometimes use byte or word versions! */
#define jit_ori_i(d, rs, is) jit_op_ ((d), (rs), jit_reduce(OR, (is), (d)) )
#define jit_xori_i(d, rs, is) jit_op_ ((d), (rs), jit_reduce(XOR, (is), (d)) )
@ -260,39 +262,21 @@ struct jit_local_state {
/* Stack */
#define jit_pushr_i(rs) PUSHLr(rs)
#define jit_popr_i(rs) POPLr(rs)
#define jit_prolog(n) (_jitl.framesize = 8, PUSHLr(_EBP), MOVLrr(_ESP, _EBP), PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI))
/* The += allows for stack pollution */
#define jit_prepare_i(ni) (_jitl.argssize += (ni))
#define jit_prepare_f(nf) (_jitl.argssize += (nf))
#define jit_prepare_d(nd) (_jitl.argssize += 2 * (nd))
#define jit_pusharg_i(rs) PUSHLr(rs)
#define jit_finish(sub) (jit_calli((sub)), ADDLir(4 * _jitl.argssize, JIT_SP), _jitl.argssize = 0)
#define jit_finishr(reg) (jit_callr((reg)), ADDLir(4 * _jitl.argssize, JIT_SP), _jitl.argssize = 0)
#define jit_retval_i(rd) jit_movr_i ((rd), _EAX)
#define jit_arg_c() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_uc() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_s() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_us() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_i() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_ui() ((_jitl.framesize += sizeof(int)) - sizeof(int))
#define jit_arg_l() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_arg_ul() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_arg_p() ((_jitl.framesize += sizeof(long)) - sizeof(long))
#define jit_retval_i(rd) ((void)jit_movr_i ((rd), _EAX))
#define jit_arg_f() ((_jitl.framesize += sizeof(float)) - sizeof(float))
#define jit_arg_d() ((_jitl.framesize += sizeof(double)) - sizeof(double))
/* Unary */
#define jit_negr_i(d, rs) jit_opi_((d), (rs), NEGLr(d), (XORLrr((d), (d)), SUBLrr((rs), (d))) )
#define jit_negr_l(d, rs) jit_opi_((d), (rs), NEGLr(d), (XORLrr((d), (d)), SUBLrr((rs), (d))) )
#define jit_movr_i(d, rs) ((rs) == (d) ? 0 : MOVLrr((rs), (d)))
#define jit_movr_i(d, rs) ((void)((rs) == (d) ? 0 : MOVLrr((rs), (d))))
#define jit_movi_i(d, is) ((is) ? MOVLir((is), (d)) : XORLrr ((d), (d)) )
#define jit_movi_p(d, is) (MOVLir((is), (d)), _jit.x.pc)
#define jit_patch_movi(pa,pv) (*_PSL((pa) - 4) = _jit_SL((pv)))
#define jit_movi_p(d, is) (jit_movi_l(d, ((long)(is))), _jit.x.pc)
#define jit_patch_movi(pa,pv) (*_PSL((pa) - sizeof(long)) = _jit_SL((pv)))
#define jit_ntoh_ui(d, rs) jit_op_((d), (rs), BSWAPLr(d))
#define jit_ntoh_us(d, rs) jit_op_((d), (rs), RORWir(8, d))
@ -360,8 +344,6 @@ struct jit_local_state {
#define jit_calli(label) (CALLm( ((unsigned long) (label)), 0, 0, 0), _jit.x.pc)
#define jit_callr(reg) (CALLsr(reg))
#define jit_jmpr(reg) JMPsr(reg)
#define jit_patch_at(jump_pc,v) (*_PSL((jump_pc) - 4) = _jit_SL((v) - (jump_pc)))
#define jit_ret() (POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), POPLr(_EBP), RET_())
/* Memory */
#define jit_ldi_c(d, is) MOVSBLmr((is), 0, 0, 0, (d))
@ -404,10 +386,12 @@ struct jit_local_state {
#define jit_stxr_i(d1, d2, rs) MOVLrm((rs), 0, (d1), (d2), 1)
#define jit_stxi_i(id, rd, rs) MOVLrm((rs), (id), (rd), 0, 0)
/* Extra */
#define jit_nop() NOP_()
#define _jit_alignment(pc, n) (((pc ^ _MASK(4)) + 1) & _MASK(n))
#define jit_align(n) NOPi(_jit_alignment(_jit_UL(_jit.x.pc), (n)))
#endif /* __lightning_core_h */
#endif /* __lightning_core_i386_h */

View file

@ -84,8 +84,8 @@
FST ST3
move FPR3 to FPR1
FLD ST1
FST ST4 Stack is rotated, so FPRn becomes STn+1 */
FLD ST3
FST ST2 Stack is rotated, so FPRn becomes STn+1 */
#define jit_movr_d(rd,s1) \
((s1) == (rd) ? 0 \

38
lightning/i386/fp-64.h Normal file
View file

@ -0,0 +1,38 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler & support macros for the i386 math coprocessor
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 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 2.1, 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.
*
***********************************************************************/
#ifndef __lightning_fp_h
#define __lightning_fp_h
#warning SSE math not yet supported
#endif /* __lightning_fp_h */

View file

@ -34,6 +34,8 @@
#ifndef __lightning_funcs_h
#define __lightning_funcs_h
#include <string.h>
#if !defined(__GNUC__) && !defined(__GNUG__)
#error Go get GNU C, I do not know how to flush the cache
#error with this compiler.
@ -97,7 +99,7 @@ _jit_epilog(jit_state *jit)
frame_size += 15; /* the stack must be quad-word */
frame_size &= ~15; /* aligned */
#ifdef _CALL_DARWIN
#ifdef __APPLE__
LWZrm(0, frame_size + 8, 1); /* lwz r0, x+8(r1) (ret.addr.) */
#else
LWZrm(0, frame_size + 4, 1); /* lwz r0, x+4(r1) (ret.addr.) */
@ -150,7 +152,7 @@ _jit_prolog(jit_state *jit, int n)
ofs = frame_size - num_saved_regs * 4;
STMWrm(first_saved_reg, ofs, 1); /* stmw rI, ofs(r1) */
#ifdef _CALL_DARWIN
#ifdef __APPLE__
STWrm(0, frame_size + 8, 1); /* stw r0, x+8(r1) */
#else
STWrm(0, frame_size + 4, 1); /* stw r0, x+4(r1) */