Compare commits

..

1 commit

Author SHA1 Message Date
jpenner bdc5bcbe62 Initial checkin 2004-08-14 21:15:33 +00:00
25 changed files with 37 additions and 4906 deletions

View file

@ -1,4 +1,3 @@
SUBDIRS = . lightning
lib_LIBRARIES = libclosure.a
libclosure_a_SOURCES = src/closure.c src/closure.h

View file

@ -119,7 +119,6 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = . lightning
lib_LIBRARIES = libclosure.a
libclosure_a_SOURCES = src/closure.c src/closure.h
@ -161,21 +160,14 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(libclosure_a_SOURCES) $(tests_test_SOURCES)
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
ps-recursive install-info-recursive uninstall-info-recursive \
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive
DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \
COPYING COPYING.DOC COPYING.LESSER ChangeLog INSTALL \
Makefile.am NEWS acinclude.m4 aclocal.m4 compile config.guess \
config.sub configure configure.in depcomp install-sh missing \
mkinstalldirs
DIST_SUBDIRS = $(SUBDIRS)
SOURCES = $(libclosure_a_SOURCES) $(tests_test_SOURCES)
all: all-recursive
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
@ -317,65 +309,6 @@ tests_test-test.obj: tests/test.c
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_test_CFLAGS) $(CFLAGS) -c -o tests_test-test.obj `if test -f 'tests/test.c'; then $(CYGPATH_W) 'tests/test.c'; else $(CYGPATH_W) '$(srcdir)/tests/test.c'; fi`
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ETAGS = etags
ETAGSFLAGS =
@ -393,21 +326,10 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if (etags --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
else \
include_option=--include; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@ -419,7 +341,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
@ -557,19 +479,6 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" \
distdir=../$(distdir)/$$subdir \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
@ -641,21 +550,20 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-recursive
check: check-am
all-am: Makefile $(LIBRARIES) $(PROGRAMS)
installdirs: installdirs-recursive
installdirs-am:
$(mkinstalldirs) $(DESTDIR)$(libdir)
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir)
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@ -672,23 +580,23 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean: clean-am
clean-am: clean-generic clean-libLIBRARIES clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-recursive
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-recursive
dvi: dvi-am
dvi-am:
info: info-recursive
info: info-am
info-am:
@ -696,54 +604,45 @@ install-data-am:
install-exec-am: install-libLIBRARIES
install-info: install-info-recursive
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-recursive
pdf: pdf-am
pdf-am:
ps: ps-recursive
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLIBRARIES
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-TESTS \
check-am clean clean-generic clean-libLIBRARIES \
clean-noinstPROGRAMS clean-recursive ctags ctags-recursive dist \
dist-all dist-gzip distcheck distclean distclean-compile \
distclean-generic distclean-recursive distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am \
dvi-recursive info info-am info-recursive install install-am \
install-data install-data-am install-data-recursive \
install-exec install-exec-am install-exec-recursive \
install-info install-info-am install-info-recursive \
install-libLIBRARIES install-man install-recursive \
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
clean-generic clean-libLIBRARIES clean-noinstPROGRAMS ctags \
dist dist-all dist-gzip distcheck distclean distclean-compile \
distclean-generic distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am info info-am install install-am \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-libLIBRARIES install-man \
install-strip installcheck installcheck-am installdirs \
installdirs-am installdirs-recursive maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-recursive \
pdf pdf-am pdf-recursive ps ps-am ps-recursive tags \
tags-recursive uninstall uninstall-am uninstall-info-am \
uninstall-info-recursive uninstall-libLIBRARIES \
uninstall-recursive
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View file

@ -24,8 +24,7 @@ fi
ifdef([AC_HELP_STRING], [
dnl autoconf 2.50 style
if test -n "$cpu_subdir"; then
AC_CONFIG_LINKS(lightning.h:lightning/lightning.h
lightning/asm.h:lightning/$cpu_subdir/asm.h
AC_CONFIG_LINKS(lightning/asm.h:lightning/$cpu_subdir/asm.h
lightning/core.h:lightning/$cpu_subdir/core.h
lightning/fp.h:lightning/$cpu_subdir/fp.h
lightning/funcs.h:lightning/$cpu_subdir/funcs.h, , [

3
aclocal.m4 vendored
View file

@ -37,8 +37,7 @@ fi
ifdef([AC_HELP_STRING], [
dnl autoconf 2.50 style
if test -n "$cpu_subdir"; then
AC_CONFIG_LINKS(lightning.h:lightning/lightning.h
lightning/asm.h:lightning/$cpu_subdir/asm.h
AC_CONFIG_LINKS(lightning/asm.h:lightning/$cpu_subdir/asm.h
lightning/core.h:lightning/$cpu_subdir/core.h
lightning/fp.h:lightning/$cpu_subdir/fp.h
lightning/funcs.h:lightning/$cpu_subdir/funcs.h, , [

6
configure vendored
View file

@ -3701,7 +3701,7 @@ fi
if test -n "$cpu_subdir"; then
ac_config_links="$ac_config_links lightning.h:lightning/lightning.h lightning/asm.h:lightning/$cpu_subdir/asm.h lightning/core.h:lightning/$cpu_subdir/core.h lightning/fp.h:lightning/$cpu_subdir/fp.h lightning/funcs.h:lightning/$cpu_subdir/funcs.h"
ac_config_links="$ac_config_links lightning/asm.h:lightning/$cpu_subdir/asm.h lightning/core.h:lightning/$cpu_subdir/core.h lightning/fp.h:lightning/$cpu_subdir/fp.h lightning/funcs.h:lightning/$cpu_subdir/funcs.h"
fi
@ -3719,7 +3719,7 @@ else
fi
ac_config_files="$ac_config_files Makefile lightning/Makefile"
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@ -4316,8 +4316,6 @@ do
case "$ac_config_target" in
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"lightning/Makefile" ) CONFIG_FILES="$CONFIG_FILES lightning/Makefile" ;;
"lightning.h" ) CONFIG_LINKS="$CONFIG_LINKS lightning.h:lightning/lightning.h" ;;
"lightning/asm.h" ) CONFIG_LINKS="$CONFIG_LINKS lightning/asm.h:lightning/$cpu_subdir/asm.h" ;;
"lightning/core.h" ) CONFIG_LINKS="$CONFIG_LINKS lightning/core.h:lightning/$cpu_subdir/core.h" ;;
"lightning/fp.h" ) CONFIG_LINKS="$CONFIG_LINKS lightning/fp.h:lightning/$cpu_subdir/fp.h" ;;

View file

@ -5,4 +5,4 @@ AC_PROG_RANLIB
AC_PROG_INSTALL
AC_EXEEXT
LIGHTNING_CONFIGURE_IF_NOT_FOUND
AC_OUTPUT([Makefile lightning/Makefile])
AC_OUTPUT([Makefile])

View file

@ -1,16 +0,0 @@
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
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
else
dist_noinst_HEADERS = $(LIGHTNING_FILES) lightning.h
endif

View file

@ -1,197 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Dynamic assembler support
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_asm_common_h
#define __lightning_asm_common_h_
#ifndef _ASM_SAFETY
#define JITFAIL(MSG) 0
#else
#if defined __GNUC__ && (__GNUC__ == 3 ? __GNUC_MINOR__ >= 2 : __GNUC__ > 3)
#define JITFAIL(MSG) jit_fail(MSG, __FILE__, __LINE__, __func__)
#else
#define JITFAIL(MSG) jit_fail(MSG, __FILE__, __LINE__, __FUNCTION__)
#endif
#endif
#if defined __GNUC__ && (__GNUC__ == 3 ? __GNUC_MINOR__ >= 2 : __GNUC__ > 3)
#define JITSORRY(MSG) jit_fail("sorry, unimplemented: " MSG, __FILE__, __LINE__, __func__)
#else
#define JITSORRY(MSG) jit_fail("sorry, unimplemented: " MSG, __FILE__, __LINE__, __FUNCTION__)
#endif
#ifdef __GNUC__
#define JIT_UNUSED __attribute__((unused))
#else
#define JIT_UNUSED
#endif
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
does not implement __extension__. But that compiler doesn't define
__GNUC_MINOR__. */
#ifdef __GNUC__
#if __GNUC__ < 2 || (defined(__NeXT__) && !__GNUC_MINOR__)
#define __extension__
#endif
#define _TEMPD(type, var)
#define _TEMP(type, var, val, body) __extension__ ({ \
register struct { type var } _jitl; _jitl.var = val; \
body; \
})
#else
/* Between loading a global and calling a subroutine, we choose the lesser
* evil. */
#define _TEMPD(type, var) static type var;
#define _TEMP(type, var, val, body) ((var = val), body)
#endif
typedef char _sc;
typedef unsigned char _uc;
typedef unsigned short _us;
typedef unsigned int _ui;
typedef long _sl;
typedef unsigned long _ul;
#define _UC(X) ((_uc )(X))
#define _US(X) ((_us )(X))
#define _UI(X) ((_ui )(X))
#define _SL(X) ((_sl )(X))
#define _UL(X) ((_ul )(X))
# define _PUC(X) ((_uc *)(X))
# define _PUS(X) ((_us *)(X))
# define _PUI(X) ((_ui *)(X))
# define _PSL(X) ((_sl *)(X))
# define _PUL(X) ((_ul *)(X))
#define _B(B) ((*_PUC(_jit.pc)++)= _UC((B)& 0xff))
#define _W(W) ((*_PUS(_jit.pc)++)= _US((W)&0xffff))
#define _I(I) ((*_PUI(_jit.pc)++)= _UI((I) ))
#define _L(L) ((*_PUL(_jit.pc)++)= _UL((L) ))
#define _MASK(N) ((unsigned)((1<<(N)))-1)
#define _siP(N,I) (!((((unsigned)(I))^(((unsigned)(I))<<1))&~_MASK(N)))
#define _uiP(N,I) (!(((unsigned)(I))&~_MASK(N)))
#define _suiP(N,I) (_siP(N,I) | _uiP(N,I))
#ifndef _ASM_SAFETY
#define _ck_s(W,I) (_UL(I) & _MASK(W))
#define _ck_u(W,I) (_UL(I) & _MASK(W))
#define _ck_su(W,I) (_UL(I) & _MASK(W))
#define _ck_d(W,I) (_UL(I) & _MASK(W))
#else
#define _ck_s(W,I) (_siP(W,I) ? (_UL(I) & _MASK(W)) : JITFAIL( "signed integer `"#I"' too large for "#W"-bit field"))
#define _ck_u(W,I) (_uiP(W,I) ? (_UL(I) & _MASK(W)) : JITFAIL("unsigned integer `"#I"' too large for "#W"-bit field"))
#define _ck_su(W,I) (_suiP(W,I) ? (_UL(I) & _MASK(W)) : JITFAIL( "integer `"#I"' too large for "#W"-bit field"))
#define _ck_d(W,I) (_siP(W,I) ? (_UL(I) & _MASK(W)) : JITFAIL( "displacement `"#I"' too large for "#W"-bit field"))
#endif
#define _s0P(I) ((I)==0)
#define _s8P(I) _siP(8,I)
#define _s16P(I) _siP(16,I)
#define _u8P(I) _uiP(8,I)
#define _u16P(I) _uiP(16,I)
#define _su8(I) _ck_su(8,I)
#define _su16(I) _ck_su(16,I)
#define _s1(I) _ck_s( 1,I)
#define _s2(I) _ck_s( 2,I)
#define _s3(I) _ck_s( 3,I)
#define _s4(I) _ck_s( 4,I)
#define _s5(I) _ck_s( 5,I)
#define _s6(I) _ck_s( 6,I)
#define _s7(I) _ck_s( 7,I)
#define _s8(I) _ck_s( 8,I)
#define _s9(I) _ck_s( 9,I)
#define _s10(I) _ck_s(10,I)
#define _s11(I) _ck_s(11,I)
#define _s12(I) _ck_s(12,I)
#define _s13(I) _ck_s(13,I)
#define _s14(I) _ck_s(14,I)
#define _s15(I) _ck_s(15,I)
#define _s16(I) _ck_s(16,I)
#define _s17(I) _ck_s(17,I)
#define _s18(I) _ck_s(18,I)
#define _s19(I) _ck_s(19,I)
#define _s20(I) _ck_s(20,I)
#define _s21(I) _ck_s(21,I)
#define _s22(I) _ck_s(22,I)
#define _s23(I) _ck_s(23,I)
#define _s24(I) _ck_s(24,I)
#define _s25(I) _ck_s(25,I)
#define _s26(I) _ck_s(26,I)
#define _s27(I) _ck_s(27,I)
#define _s28(I) _ck_s(28,I)
#define _s29(I) _ck_s(29,I)
#define _s30(I) _ck_s(30,I)
#define _s31(I) _ck_s(31,I)
#define _u1(I) _ck_u( 1,I)
#define _u2(I) _ck_u( 2,I)
#define _u3(I) _ck_u( 3,I)
#define _u4(I) _ck_u( 4,I)
#define _u5(I) _ck_u( 5,I)
#define _u6(I) _ck_u( 6,I)
#define _u7(I) _ck_u( 7,I)
#define _u8(I) _ck_u( 8,I)
#define _u9(I) _ck_u( 9,I)
#define _u10(I) _ck_u(10,I)
#define _u11(I) _ck_u(11,I)
#define _u12(I) _ck_u(12,I)
#define _u13(I) _ck_u(13,I)
#define _u14(I) _ck_u(14,I)
#define _u15(I) _ck_u(15,I)
#define _u16(I) _ck_u(16,I)
#define _u17(I) _ck_u(17,I)
#define _u18(I) _ck_u(18,I)
#define _u19(I) _ck_u(19,I)
#define _u20(I) _ck_u(20,I)
#define _u21(I) _ck_u(21,I)
#define _u22(I) _ck_u(22,I)
#define _u23(I) _ck_u(23,I)
#define _u24(I) _ck_u(24,I)
#define _u25(I) _ck_u(25,I)
#define _u26(I) _ck_u(26,I)
#define _u27(I) _ck_u(27,I)
#define _u28(I) _ck_u(28,I)
#define _u29(I) _ck_u(29,I)
#define _u30(I) _ck_u(30,I)
#define _u31(I) _ck_u(31,I)
#endif /* __lightning_asm_common_h */

View file

@ -1,570 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer support
*
***********************************************************************/
/***********************************************************************
*
* 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_common_h
#define __lightning_core_common_h_
typedef struct {
jit_insn *pc;
struct jit_fp *fp;
struct jit_local_state jitl;
} jit_state;
static jit_state _jit;
#define JIT_NOREG (-1)
#define _jitl _jit.jitl
#define jit_get_ip() (*(jit_code *) &_jit.pc)
#define jit_set_ip(ptr) (_jit.pc = (jit_insn *) ptr, jit_get_ip())
#define jit_get_label() (_jit.pc)
#define jit_forward() (_jit.pc)
#define jit_field(struc, f) ( ((long) (&((struc *) 8)->f) ) - 8)
#define jit_ptr_field(struc_p, f) ( ((long) (&((struc_p) 8)->f) ) - 8)
/* realignment via N-byte no-ops */
#ifndef jit_align
#define jit_align(n)
#endif
/* jit_code: union of many possible function pointer types. Returned
* by jit_get_ip().
*/
typedef union jit_code {
char *ptr;
void (*vptr)();
char (*cptr)();
unsigned char (*ucptr)();
short (*sptr)();
unsigned short (*usptr)();
int (*iptr)();
unsigned int (*uiptr)();
long (*lptr)();
unsigned long (*ulptr)();
void * (*pptr)();
float (*fptr)();
double (*dptr)();
} jit_code;
#ifndef jit_fill_delay_after
#define jit_fill_delay_after(branch) (branch)
#endif
#define jit_delay(insn, branch) ((insn), jit_fill_delay_after(branch))
/* ALU synonyms */
#define jit_addi_ui(d, rs, is) jit_addi_i((d), (rs), (is))
#define jit_addr_ui(d, s1, s2) jit_addr_i((d), (s1), (s2))
#define jit_addci_ui(d, rs, is) jit_addci_i((d), (rs), (is))
#define jit_addcr_ui(d, s1, s2) jit_addcr_i((d), (s1), (s2))
#define jit_addxi_ui(d, rs, is) jit_addxi_i((d), (rs), (is))
#define jit_addxr_ui(d, s1, s2) jit_addxr_i((d), (s1), (s2))
#define jit_andi_ui(d, rs, is) jit_andi_i((d), (rs), (is))
#define jit_andr_ui(d, s1, s2) jit_andr_i((d), (s1), (s2))
#define jit_lshi_ui(d, rs, is) jit_lshi_i((d), (rs), (is))
#define jit_lshr_ui(d, s1, s2) jit_lshr_i((d), (s1), (s2))
#define jit_movi_ui(d, rs) jit_movi_i((d), (rs))
#define jit_movr_ui(d, rs) jit_movr_i((d), (rs))
#define jit_ori_ui(d, rs, is) jit_ori_i((d), (rs), (is))
#define jit_orr_ui(d, s1, s2) jit_orr_i((d), (s1), (s2))
#define jit_rsbi_ui(d, rs, is) jit_rsbi_i((d), (rs), (is))
#define jit_rsbr_ui(d, s1, s2) jit_rsbr_i((d), (s1), (s2))
#define jit_subi_ui(d, rs, is) jit_subi_i((d), (rs), (is))
#define jit_subr_ui(d, s1, s2) jit_subr_i((d), (s1), (s2))
#define jit_subci_ui(d, rs, is) jit_subci_i((d), (rs), (is))
#define jit_subcr_ui(d, s1, s2) jit_subcr_i((d), (s1), (s2))
#define jit_subxi_ui(d, rs, is) jit_subxi_i((d), (rs), (is))
#define jit_subxr_ui(d, s1, s2) jit_subxr_i((d), (s1), (s2))
#define jit_xori_ui(d, rs, is) jit_xori_i((d), (rs), (is))
#define jit_xorr_ui(d, s1, s2) jit_xorr_i((d), (s1), (s2))
#define jit_addi_ul(d, rs, is) jit_addi_l((d), (rs), (is))
#define jit_addr_ul(d, s1, s2) jit_addr_l((d), (s1), (s2))
#define jit_addci_ul(d, rs, is) jit_addci_l((d), (rs), (is))
#define jit_addcr_ul(d, s1, s2) jit_addcr_l((d), (s1), (s2))
#define jit_addxi_ul(d, rs, is) jit_addxi_l((d), (rs), (is))
#define jit_addxr_ul(d, s1, s2) jit_addxr_l((d), (s1), (s2))
#define jit_andi_ul(d, rs, is) jit_andi_l((d), (rs), (is))
#define jit_andr_ul(d, s1, s2) jit_andr_l((d), (s1), (s2))
#define jit_lshi_ul(d, rs, is) jit_lshi_l((d), (rs), (is))
#define jit_lshr_ul(d, s1, s2) jit_lshr_l((d), (s1), (s2))
#define jit_movi_ul(d, rs) jit_movi_l((d), (rs))
#define jit_movr_ul(d, rs) jit_movr_l((d), (rs))
#define jit_ori_ul(d, rs, is) jit_ori_l((d), (rs), (is))
#define jit_orr_ul(d, s1, s2) jit_orr_l((d), (s1), (s2))
#define jit_rsbi_ul(d, rs, is) jit_rsbi_l((d), (rs), (is))
#define jit_rsbr_ul(d, s1, s2) jit_rsbr_l((d), (s1), (s2))
#define jit_subi_ul(d, rs, is) jit_subi_l((d), (rs), (is))
#define jit_subr_ul(d, s1, s2) jit_subr_l((d), (s1), (s2))
#define jit_subci_ul(d, rs, is) jit_subci_l((d), (rs), (is))
#define jit_subcr_ul(d, s1, s2) jit_subcr_l((d), (s1), (s2))
#define jit_subxi_ui(d, rs, is) jit_subxi_i((d), (rs), (is))
#define jit_subxr_ui(d, s1, s2) jit_subxr_i((d), (s1), (s2))
#define jit_xori_ul(d, rs, is) jit_xori_l((d), (rs), (is))
#define jit_xorr_ul(d, s1, s2) jit_xorr_l((d), (s1), (s2))
#define jit_addr_p(d, s1, s2) jit_addr_ul((d), (s1), (s2))
#define jit_addi_p(d, rs, is) jit_addi_ul((d), (rs), (long) (is))
#define jit_movr_p(d, rs) jit_movr_ul((d), (rs))
#define jit_movi_p(d, is) jit_movi_ul((d), (long) (is))
#define jit_subr_p(d, s1, s2) jit_subr_ul((d), (s1), (s2))
#define jit_subi_p(d, rs, is) jit_subi_ul((d), (rs), (long) (is))
#ifndef jit_addci_i
#define jit_addci_i(d, rs, is) jit_addi_i((d), (rs), (is))
#define jit_addcr_i(d, s1, s2) jit_addr_i((d), (s1), (s2))
#define jit_addci_l(d, rs, is) jit_addi_l((d), (rs), (is))
#define jit_addcr_l(d, s1, s2) jit_addr_l((d), (s1), (s2))
#endif
#ifndef jit_subcr_i
#define jit_subcr_i(d, s1, s2) jit_subr_i((d), (s1), (s2))
#endif
/* NEG is not mandatory -- pick an appropriate implementation */
#ifndef jit_negr_i
# ifdef JIT_RZERO
# define jit_negr_i(d, rs) jit_subr_i((d), JIT_RZERO, (rs))
# define jit_negr_l(d, rs) jit_subr_l((d), JIT_RZERO, (rs))
# else /* !JIT_RZERO */
# ifndef jit_rsbi_i
# define jit_negr_i(d, rs) (jit_xori_i((d), (rs), -1), jit_addi_l((d), (d), 1))
# define jit_negr_l(d, rs) (jit_xori_l((d), (rs), -1), jit_addi_l((d), (d), 1))
# else /* jit_rsbi_i */
# define jit_negr_i(d, rs) jit_rsbi_i((d), (rs), 0)
# define jit_negr_l(d, rs) jit_rsbi_l((d), (rs), 0)
# endif /* jit_rsbi_i */
# endif /* !JIT_RZERO */
#endif /* !jit_negr_i */
/* RSB is not mandatory */
#ifndef jit_rsbi_i
# define jit_rsbi_i(d, rs, is) (jit_subi_i((d), (rs), (is)), jit_negr_i((d), (d)))
# ifndef jit_rsbi_l
# define jit_rsbi_l(d, rs, is) (jit_subi_l((d), (rs), (is)), jit_negr_l((d), (d)))
# endif
#endif
/* Common 'shortcut' implementations */
#define jit_subi_i(d, rs, is) jit_addi_i((d), (rs), -(is))
#define jit_subi_l(d, rs, is) jit_addi_l((d), (rs), -(is))
#define jit_subci_i(d, rs, is) jit_addci_i((d), (rs), -(is))
#define jit_subci_l(d, rs, is) jit_addci_l((d), (rs), -(is))
#define jit_rsbr_i(d, s1, s2) jit_subr_i((d), (s2), (s1))
#define jit_rsbr_l(d, s1, s2) jit_subr_l((d), (s2), (s1))
/* Unary */
#define jit_notr_c(d, rs) jit_xori_c((d), (rs), 255)
#define jit_notr_uc(d, rs) jit_xori_c((d), (rs), 255)
#define jit_notr_s(d, rs) jit_xori_s((d), (rs), 65535)
#define jit_notr_us(d, rs) jit_xori_s((d), (rs), 65535)
#if SIZEOF_LONG != 4
#define jit_notr_i(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFF)
#define jit_notr_ui(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFF)
#define jit_notr_l(d, rs) jit_xori_l((d), (rs), 0xFFFFFFFFFFFFFFFFL)
#define jit_notr_ul(d, rs) jit_xori_l((d), (rs), 0xFFFFFFFFFFFFFFFFL)
#else
#define jit_notr_i(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFFL)
#define jit_notr_ui(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFFL)
#define jit_notr_l(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFFL)
#define jit_notr_ul(d, rs) jit_xori_i((d), (rs), 0xFFFFFFFFL)
#endif
#ifndef jit_extr_c_ui
#define jit_extr_c_ui(d, rs) jit_andi_ui((d), (rs), 0xFF)
#endif
#ifndef jit_extr_s_ui
#define jit_extr_s_ui(d, rs) jit_andi_ui((d), (rs), 0xFFFF)
#endif
#ifndef jit_extr_c_i
#define jit_extr_c_i(d, rs) (jit_lshi_i((d), (rs), 24), jit_rshi_i((d), (d), 24))
#endif
#ifndef jit_extr_s_i
#define jit_extr_s_i(d, rs) (jit_lshi_i((d), (rs), 16), jit_rshi_i((d), (d), 16))
#endif
#define jit_extr_uc_i(d, rs) jit_extr_c_ui((d), (rs))
#define jit_extr_uc_ui(d, rs) jit_extr_c_ui((d), (rs))
#define jit_extr_us_i(d, rs) jit_extr_s_ui((d), (rs))
#define jit_extr_us_ui(d, rs) jit_extr_s_ui((d), (rs))
#ifndef jit_extr_i_ul
#ifdef jit_addi_l /* sizeof(long) != sizeof(int) */
#define jit_extr_i_ul(d, rs) jit_andi_ui((d), (rs), 0xFF)
#else /* sizeof(long) == sizeof(int) */
#define jit_extr_i_ul(d, rs) jit_movr_i(d, rs)
#endif /* sizeof(long) == sizeof(int) */
#endif
#define jit_extr_ui_l(d, rs) jit_extr_i_ul((d), (rs))
#define jit_extr_ui_ul(d, rs) jit_extr_i_ul((d), (rs))
/* NTOH/HTON is not mandatory for big endian architectures */
#ifndef jit_ntoh_ui /* big endian */
#define jit_ntoh_ui(d, rs) ((d) == (rs) ? (void)0 : jit_movr_i((d), (rs)))
#define jit_ntoh_us(d, rs) ((d) == (rs) ? (void)0 : jit_movr_i((d), (rs)))
#endif /* big endian */
/* hton is a synonym for ntoh */
#define jit_hton_ui(d, rs) jit_ntoh_ui((d), (rs))
#define jit_hton_us(d, rs) jit_ntoh_us((d), (rs))
/* Stack synonyms */
#define jit_pushr_ui(rs) jit_pushr_i(rs)
#define jit_popr_ui(rs) jit_popr_i(rs)
#define jit_pushr_ul(rs) jit_pushr_l(rs)
#define jit_popr_ul(rs) jit_popr_l(rs)
#define jit_pushr_p(rs) jit_pushr_ul(rs)
#define jit_popr_p(rs) jit_popr_ul(rs)
#define jit_prepare(nint) jitfp_prepare((nint), 0, 0)
#define jit_pusharg_c(rs) jit_pusharg_i(rs)
#define jit_pusharg_s(rs) jit_pusharg_i(rs)
#define jit_pusharg_uc(rs) jit_pusharg_i(rs)
#define jit_pusharg_us(rs) jit_pusharg_i(rs)
#define jit_pusharg_ui(rs) jit_pusharg_i(rs)
#define jit_pusharg_ul(rs) jit_pusharg_l(rs)
#define jit_pusharg_p(rs) jit_pusharg_ul(rs)
/* Memory synonyms */
#ifdef JIT_RZERO
#ifndef jit_ldi_c
#define jit_ldi_c(rd, is) jit_ldxi_c((rd), JIT_RZERO, (is))
#define jit_sti_c(id, rs) jit_stxi_c((id), JIT_RZERO, (rs))
#define jit_ldi_s(rd, is) jit_ldxi_s((rd), JIT_RZERO, (is))
#define jit_sti_s(id, rs) jit_stxi_s((id), JIT_RZERO, (rs))
#define jit_ldi_i(rd, is) jit_ldxi_i((rd), JIT_RZERO, (is))
#define jit_sti_i(id, rs) jit_stxi_i((id), JIT_RZERO, (rs))
#define jit_ldi_l(rd, is) jit_ldxi_l((rd), JIT_RZERO, (is))
#define jit_sti_l(id, rs) jit_stxi_l((id), JIT_RZERO, (rs))
#define jit_ldi_uc(rd, is) jit_ldxi_uc((rd), JIT_RZERO, (is))
#define jit_ldi_us(rd, is) jit_ldxi_us((rd), JIT_RZERO, (is))
#define jit_ldi_ui(rd, is) jit_ldxi_ui((rd), JIT_RZERO, (is))
#define jit_ldi_ul(rd, is) jit_ldxi_ul((rd), JIT_RZERO, (is))
#endif
#ifndef jit_ldr_c
#define jit_ldr_c(rd, rs) jit_ldxr_c((rd), JIT_RZERO, (rs))
#define jit_str_c(rd, rs) jit_stxr_c(JIT_RZERO, (rd), (rs))
#define jit_ldr_s(rd, rs) jit_ldxr_s((rd), JIT_RZERO, (rs))
#define jit_str_s(rd, rs) jit_stxr_s(JIT_RZERO, (rd), (rs))
#define jit_ldr_i(rd, rs) jit_ldxr_i((rd), JIT_RZERO, (rs))
#define jit_str_i(rd, rs) jit_stxr_i(JIT_RZERO, (rd), (rs))
#define jit_ldr_l(rd, rs) jit_ldxr_l((rd), JIT_RZERO, (rs))
#define jit_str_l(rd, rs) jit_stxr_l(JIT_RZERO, (rd), (rs))
#define jit_ldr_uc(rd, rs) jit_ldxr_uc((rd), JIT_RZERO, (rs))
#define jit_ldr_us(rd, rs) jit_ldxr_us((rd), JIT_RZERO, (rs))
#define jit_ldr_ui(rd, rs) jit_ldxr_ui((rd), JIT_RZERO, (rs))
#define jit_ldr_ul(rd, rs) jit_ldxr_ul((rd), JIT_RZERO, (rs))
#endif
#endif
#define jit_str_uc(rd, rs) jit_str_c((rd), (rs))
#define jit_sti_uc(id, rs) jit_sti_c((id), (rs))
#define jit_stxr_uc(d1, d2, rs) jit_stxr_c((d1), (d2), (rs))
#define jit_stxi_uc(id, rd, is) jit_stxi_c((id), (rd), (is))
#define jit_str_us(rd, rs) jit_str_s((rd), (rs))
#define jit_sti_us(id, rs) jit_sti_s((id), (rs))
#define jit_stxr_us(d1, d2, rs) jit_stxr_s((d1), (d2), (rs))
#define jit_stxi_us(id, rd, is) jit_stxi_s((id), (rd), (is))
#define jit_str_ui(rd, rs) jit_str_i((rd), (rs))
#define jit_sti_ui(id, rs) jit_sti_i((id), (rs))
#define jit_stxr_ui(d1, d2, rs) jit_stxr_i((d1), (d2), (rs))
#define jit_stxi_ui(id, rd, is) jit_stxi_i((id), (rd), (is))
#define jit_str_ul(rd, rs) jit_str_l((rd), (rs))
#define jit_sti_ul(id, rs) jit_sti_l((id), (rs))
#define jit_stxr_ul(d1, d2, rs) jit_stxr_l((d1), (d2), (rs))
#define jit_stxi_ul(id, rd, is) jit_stxi_l((id), (rd), (is))
#define jit_str_p(rd, rs) jit_str_l((rd), (rs))
#define jit_sti_p(id, rs) jit_sti_l((id), (rs))
#define jit_stxr_p(d1, d2, rs) jit_stxr_l((d1), (d2), (rs))
#define jit_stxi_p(id, rd, is) jit_stxi_l((id), (rd), (is))
#define jit_ldr_p(rd, rs) jit_ldr_l((rd), (rs))
#define jit_ldi_p(rd, is) jit_ldi_l((rd), (is))
#define jit_ldxr_p(rd, s1, s2) jit_ldxr_l((rd), (s1), (s2))
#define jit_ldxi_p(rd, rs, is) jit_ldxi_l((rd), (rs), (is))
/* Boolean & branch synonyms */
#define jit_eqr_ui(d, s1, s2) jit_eqr_i((d), (s1), (s2))
#define jit_eqi_ui(d, rs, is) jit_eqi_i((d), (rs), (is))
#define jit_ner_ui(d, s1, s2) jit_ner_i((d), (s1), (s2))
#define jit_nei_ui(d, rs, is) jit_nei_i((d), (rs), (is))
#define jit_eqr_ul(d, s1, s2) jit_eqr_l((d), (s1), (s2))
#define jit_eqi_ul(d, rs, is) jit_eqi_l((d), (rs), (is))
#define jit_ner_ul(d, s1, s2) jit_ner_l((d), (s1), (s2))
#define jit_nei_ul(d, rs, is) jit_nei_l((d), (rs), (is))
#define jit_beqr_ui(label, s1, s2) jit_beqr_i((label), (s1), (s2))
#define jit_beqi_ui(label, rs, is) jit_beqi_i((label), (rs), (is))
#define jit_bner_ui(label, s1, s2) jit_bner_i((label), (s1), (s2))
#define jit_bnei_ui(label, rs, is) jit_bnei_i((label), (rs), (is))
#define jit_bmcr_ui(label, s1, s2) jit_bmcr_i((label), (s1), (s2))
#define jit_bmci_ui(label, rs, is) jit_bmci_i((label), (rs), (is))
#define jit_bmsr_ui(label, s1, s2) jit_bmsr_i((label), (s1), (s2))
#define jit_bmsi_ui(label, rs, is) jit_bmsi_i((label), (rs), (is))
#define jit_beqr_ul(label, s1, s2) jit_beqr_l((label), (s1), (s2))
#define jit_beqi_ul(label, rs, is) jit_beqi_l((label), (rs), (is))
#define jit_bner_ul(label, s1, s2) jit_bner_l((label), (s1), (s2))
#define jit_bnei_ul(label, rs, is) jit_bnei_l((label), (rs), (is))
#define jit_bmcr_ul(label, s1, s2) jit_bmcr_l((label), (s1), (s2))
#define jit_bmci_ul(label, rs, is) jit_bmci_l((label), (rs), (is))
#define jit_bmsr_ul(label, s1, s2) jit_bmsr_l((label), (s1), (s2))
#define jit_bmsi_ul(label, rs, is) jit_bmsi_l((label), (rs), (is))
#define jit_ltr_p(d, s1, s2) jit_ltr_ul((d), (s1), (s2))
#define jit_lti_p(d, rs, is) jit_lti_ul((d), (rs), (is))
#define jit_ler_p(d, s1, s2) jit_ler_ul((d), (s1), (s2))
#define jit_lei_p(d, rs, is) jit_lei_ul((d), (rs), (is))
#define jit_gtr_p(d, s1, s2) jit_gtr_ul((d), (s1), (s2))
#define jit_gti_p(d, rs, is) jit_gti_ul((d), (rs), (is))
#define jit_ger_p(d, s1, s2) jit_ger_ul((d), (s1), (s2))
#define jit_gei_p(d, rs, is) jit_gei_ul((d), (rs), (is))
#define jit_eqr_p(d, s1, s2) jit_eqr_ul((d), (s1), (s2))
#define jit_eqi_p(d, rs, is) jit_eqi_ul((d), (rs), (is))
#define jit_ner_p(d, s1, s2) jit_ner_ul((d), (s1), (s2))
#define jit_nei_p(d, rs, is) jit_nei_ul((d), (rs), (is))
#define jit_bltr_p(label, s1, s2) jit_bltr_ul((label), (s1), (s2))
#define jit_blti_p(label, rs, is) jit_blti_ul((label), (rs), (is))
#define jit_bler_p(label, s1, s2) jit_bler_ul((label), (s1), (s2))
#define jit_blei_p(label, rs, is) jit_blei_ul((label), (rs), (is))
#define jit_bgtr_p(label, s1, s2) jit_bgtr_ul((label), (s1), (s2))
#define jit_bgti_p(label, rs, is) jit_bgti_ul((label), (rs), (is))
#define jit_bger_p(label, s1, s2) jit_bger_ul((label), (s1), (s2))
#define jit_bgei_p(label, rs, is) jit_bgei_ul((label), (rs), (is))
#define jit_beqr_p(label, s1, s2) jit_beqr_ul((label), (s1), (s2))
#define jit_beqi_p(label, rs, is) jit_beqi_ul((label), (rs), (is))
#define jit_bner_p(label, s1, s2) jit_bner_ul((label), (s1), (s2))
#define jit_bnei_p(label, rs, is) jit_bnei_ul((label), (rs), (is))
#define jit_retval_ui(rd) jit_retval_i((rd))
#define jit_retval_uc(rd) jit_retval_i((rd))
#define jit_retval_us(rd) jit_retval_i((rd))
#define jit_retval_ul(rd) jit_retval_l((rd))
#define jit_retval_p(rd) jit_retval_ul((rd))
#define jit_retval_c(rd) jit_retval_i((rd))
#define jit_retval_s(rd) jit_retval_i((rd))
#ifndef jit_finish
#define jit_finish(sub) jit_calli(sub)
#endif
#ifndef jit_prolog
#define jit_prolog(numargs)
#endif
#ifndef jit_leaf
#define jit_leaf(numargs) jit_prolog(numargs)
#endif
#ifndef jit_getarg_c
#ifndef JIT_FP
#define jit_getarg_c(reg, ofs) jit_extr_c_i ((reg), (ofs))
#define jit_getarg_i(reg, ofs) jit_movr_i ((reg), (ofs))
#define jit_getarg_l(reg, ofs) jit_movr_l ((reg), (ofs))
#define jit_getarg_p(reg, ofs) jit_movr_p ((reg), (ofs))
#define jit_getarg_s(reg, ofs) jit_extr_s_i ((reg), (ofs))
#define jit_getarg_uc(reg, ofs) jit_extr_uc_ui((reg), (ofs))
#define jit_getarg_ui(reg, ofs) jit_movr_ui ((reg), (ofs))
#define jit_getarg_ul(reg, ofs) jit_extr_uc_ul((reg), (ofs))
#define jit_getarg_us(reg, ofs) jit_extr_us_ul((reg), (ofs))
#else
#define jit_getarg_c(reg, ofs) jit_ldxi_c((reg), JIT_FP, (ofs));
#define jit_getarg_uc(reg, ofs) jit_ldxi_uc((reg), JIT_FP, (ofs));
#define jit_getarg_s(reg, ofs) jit_ldxi_s((reg), JIT_FP, (ofs));
#define jit_getarg_us(reg, ofs) jit_ldxi_us((reg), JIT_FP, (ofs));
#define jit_getarg_i(reg, ofs) jit_ldxi_i((reg), JIT_FP, (ofs));
#define jit_getarg_ui(reg, ofs) jit_ldxi_ui((reg), JIT_FP, (ofs));
#define jit_getarg_l(reg, ofs) jit_ldxi_l((reg), JIT_FP, (ofs));
#define jit_getarg_ul(reg, ofs) jit_ldxi_ul((reg), JIT_FP, (ofs));
#define jit_getarg_p(reg, ofs) jit_ldxi_p((reg), JIT_FP, (ofs));
#endif
#endif
/* Common definitions when sizeof(long) = sizeof(int) */
#ifndef jit_addi_l
#define JIT_LONG_IS_INT
/* 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))
#define jit_addci_l(d, rs, is) jit_addci_i((d), (rs), (is))
#define jit_addcr_l(d, s1, s2) jit_addcr_i((d), (s1), (s2))
#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))
#define jit_andr_l(d, s1, s2) jit_andr_i((d), (s1), (s2))
#define jit_divi_l(d, rs, is) jit_divi_i((d), (rs), (is))
#define jit_divr_l(d, s1, s2) jit_divr_i((d), (s1), (s2))
#define jit_hmuli_l(d, rs, is) jit_hmuli_i((d), (rs), (is))
#define jit_hmulr_l(d, s1, s2) jit_hmulr_i((d), (s1), (s2))
#define jit_lshi_l(d, rs, is) jit_lshi_i((d), (rs), (is))
#define jit_lshr_l(d, s1, s2) jit_lshr_i((d), (s1), (s2))
#define jit_modi_l(d, rs, is) jit_modi_i((d), (rs), (is))
#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))
#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))
#define jit_rshr_l(d, s1, s2) jit_rshr_i((d), (s1), (s2))
#define jit_subr_l(d, s1, s2) jit_subr_i((d), (s1), (s2))
#define jit_subcr_l(d, s1, s2) jit_subcr_i((d), (s1), (s2))
#define jit_subxi_l(d, rs, is) jit_subxi_i((d), (rs), (is))
#define jit_subxr_l(d, s1, s2) jit_subxr_i((d), (s1), (s2))
#define jit_xori_l(d, rs, is) jit_xori_i((d), (rs), (is))
#define jit_xorr_l(d, s1, s2) jit_xorr_i((d), (s1), (s2))
#ifndef jit_rsbi_l
#define jit_rsbi_l(d, rs, is) jit_rsbi_i((d), (rs), (is))
#endif
#define jit_divi_ul(d, rs, is) jit_divi_ui((d), (rs), (is))
#define jit_divr_ul(d, s1, s2) jit_divr_ui((d), (s1), (s2))
#define jit_hmuli_ul(d, rs, is) jit_hmuli_ui((d), (rs), (is))
#define jit_hmulr_ul(d, s1, s2) jit_hmulr_ui((d), (s1), (s2))
#define jit_modi_ul(d, rs, is) jit_modi_ui((d), (rs), (is))
#define jit_modr_ul(d, s1, s2) jit_modr_ui((d), (s1), (s2))
#define jit_muli_ul(d, rs, is) jit_muli_ui((d), (rs), (is))
#define jit_mulr_ul(d, s1, s2) jit_mulr_ui((d), (s1), (s2))
#define jit_rshi_ul(d, rs, is) jit_rshi_ui((d), (rs), (is))
#define jit_rshr_ul(d, s1, s2) jit_rshr_ui((d), (s1), (s2))
/* Unary */
#define jit_movi_l(d, rs) jit_movi_i((d), (rs))
#define jit_movr_l(d, rs) jit_movr_i((d), (rs))
/* Stack */
#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)
/* Memory */
#ifndef JIT_RZERO
#define jit_ldr_l(d, rs) jit_ldr_i((d), (rs))
#define jit_ldi_l(d, is) jit_ldi_i((d), (is))
#define jit_str_l(d, rs) jit_str_i((d), (rs))
#define jit_sti_l(d, is) jit_sti_i((d), (is))
#define jit_ldr_ui(d, rs) jit_ldr_i((d), (rs))
#define jit_ldi_ui(d, is) jit_ldi_i((d), (is))
#define jit_ldr_ul(d, rs) jit_ldr_ui((d), (rs))
#define jit_ldi_ul(d, is) jit_ldi_ui((d), (is))
#endif
#define jit_ldxr_l(d, s1, s2) jit_ldxr_i((d), (s1), (s2))
#define jit_ldxi_l(d, rs, is) jit_ldxi_i((d), (rs), (is))
#define jit_stxr_l(d, s1, s2) jit_stxr_i((d), (s1), (s2))
#define jit_stxi_l(d, rs, is) jit_stxi_i((d), (rs), (is))
#define jit_ldxr_ui(d, s1, s2) jit_ldxr_i((d), (s1), (s2))
#define jit_ldxi_ui(d, rs, is) jit_ldxi_i((d), (rs), (is))
#define jit_ldxr_ul(d, s1, s2) jit_ldxr_ui((d), (s1), (s2))
#define jit_ldxi_ul(d, rs, is) jit_ldxi_ui((d), (rs), (is))
/* Boolean */
#define jit_ltr_l(d, s1, s2) jit_ltr_i((d), (s1), (s2))
#define jit_lti_l(d, rs, is) jit_lti_i((d), (rs), (is))
#define jit_ler_l(d, s1, s2) jit_ler_i((d), (s1), (s2))
#define jit_lei_l(d, rs, is) jit_lei_i((d), (rs), (is))
#define jit_gtr_l(d, s1, s2) jit_gtr_i((d), (s1), (s2))
#define jit_gti_l(d, rs, is) jit_gti_i((d), (rs), (is))
#define jit_ger_l(d, s1, s2) jit_ger_i((d), (s1), (s2))
#define jit_gei_l(d, rs, is) jit_gei_i((d), (rs), (is))
#define jit_eqr_l(d, s1, s2) jit_eqr_i((d), (s1), (s2))
#define jit_eqi_l(d, rs, is) jit_eqi_i((d), (rs), (is))
#define jit_ner_l(d, s1, s2) jit_ner_i((d), (s1), (s2))
#define jit_nei_l(d, rs, is) jit_nei_i((d), (rs), (is))
#define jit_ltr_ul(d, s1, s2) jit_ltr_ui((d), (s1), (s2))
#define jit_lti_ul(d, rs, is) jit_lti_ui((d), (rs), (is))
#define jit_ler_ul(d, s1, s2) jit_ler_ui((d), (s1), (s2))
#define jit_lei_ul(d, rs, is) jit_lei_ui((d), (rs), (is))
#define jit_gtr_ul(d, s1, s2) jit_gtr_ui((d), (s1), (s2))
#define jit_gti_ul(d, rs, is) jit_gti_ui((d), (rs), (is))
#define jit_ger_ul(d, s1, s2) jit_ger_ui((d), (s1), (s2))
#define jit_gei_ul(d, rs, is) jit_gei_ui((d), (rs), (is))
/* Branches */
#define jit_bltr_l(label, s1, s2) jit_bltr_i((label), (s1), (s2))
#define jit_blti_l(label, rs, is) jit_blti_i((label), (rs), (is))
#define jit_bler_l(label, s1, s2) jit_bler_i((label), (s1), (s2))
#define jit_blei_l(label, rs, is) jit_blei_i((label), (rs), (is))
#define jit_bgtr_l(label, s1, s2) jit_bgtr_i((label), (s1), (s2))
#define jit_bgti_l(label, rs, is) jit_bgti_i((label), (rs), (is))
#define jit_bger_l(label, s1, s2) jit_bger_i((label), (s1), (s2))
#define jit_bgei_l(label, rs, is) jit_bgei_i((label), (rs), (is))
#define jit_beqr_l(label, s1, s2) jit_beqr_i((label), (s1), (s2))
#define jit_beqi_l(label, rs, is) jit_beqi_i((label), (rs), (is))
#define jit_bner_l(label, s1, s2) jit_bner_i((label), (s1), (s2))
#define jit_bnei_l(label, rs, is) jit_bnei_i((label), (rs), (is))
#define jit_bmcr_l(label, s1, s2) jit_bmcr_i((label), (s1), (s2))
#define jit_bmci_l(label, rs, is) jit_bmci_i((label), (rs), (is))
#define jit_bmsr_l(label, s1, s2) jit_bmsr_i((label), (s1), (s2))
#define jit_bmsi_l(label, rs, is) jit_bmsi_i((label), (rs), (is))
#define jit_boaddr_l(label, s1, s2) jit_boaddr_i((label), (s1), (s2))
#define jit_boaddi_l(label, rs, is) jit_boaddi_i((label), (rs), (is))
#define jit_bosubr_l(label, s1, s2) jit_bosubr_i((label), (s1), (s2))
#define jit_bosubi_l(label, rs, is) jit_bosubi_i((label), (rs), (is))
#define jit_bltr_ul(label, s1, s2) jit_bltr_ui((label), (s1), (s2))
#define jit_blti_ul(label, rs, is) jit_blti_ui((label), (rs), (is))
#define jit_bler_ul(label, s1, s2) jit_bler_ui((label), (s1), (s2))
#define jit_blei_ul(label, rs, is) jit_blei_ui((label), (rs), (is))
#define jit_bgtr_ul(label, s1, s2) jit_bgtr_ui((label), (s1), (s2))
#define jit_bgti_ul(label, rs, is) jit_bgti_ui((label), (rs), (is))
#define jit_bger_ul(label, s1, s2) jit_bger_ui((label), (s1), (s2))
#define jit_bgei_ul(label, rs, is) jit_bgei_ui((label), (rs), (is))
#define jit_boaddr_ul(label, s1, s2) jit_boaddr_ui((label), (s1), (s2))
#define jit_boaddi_ul(label, rs, is) jit_boaddi_ui((label), (rs), (is))
#define jit_bosubr_ul(label, s1, s2) jit_bosubr_ui((label), (s1), (s2))
#define jit_bosubi_ul(label, rs, is) jit_bosubi_ui((label), (rs), (is))
#define jit_retval_l(rd) jit_retval_i((rd))
#endif
#endif /* __lightning_core_common_h_ */

View file

@ -1,260 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer floating-point interface
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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.
*
***********************************************************************/
struct jit_fp {
char kind;
char subkind;
union {
struct {
int displ;
char reg1;
char reg2;
} addr;
union {
double number;
long split[sizeof(double) / sizeof(long)];
} imm;
struct {
struct jit_fp *lhs, *rhs;
} ops;
} d;
};
#ifdef jit_trunc
enum { JIT_NULL, /* unused */
JIT_CMP, JIT_FLOOR, JIT_CEIL, JIT_ROUND, JIT_TRUNC, /* integer */
JIT_XI, JIT_ADD, JIT_XR, JIT_SUB, /* subkinds */
JIT_I, JIT_MUL, JIT_R, JIT_DIV,
JIT_INT,
JIT_ABS, JIT_SIN, JIT_COS, JIT_TAN, JIT_ATN, /* functions */
JIT_EXP, JIT_LOG, JIT_NEG, JIT_SQRT,
JIT_OP, JIT_FN, JIT_LD, JIT_IMM }; /* kinds */
/* Declarations */
static void _jit_emit(jit_state *, struct jit_fp *,
int, int, int, int) JIT_UNUSED;
static struct jit_fp *_jit_op(struct jit_fp *, int,
struct jit_fp *, struct jit_fp *) JIT_UNUSED;
static struct jit_fp *_jit_ld(struct jit_fp *, int,
int, int) JIT_UNUSED;
static struct jit_fp *_jit_fn(struct jit_fp *, int,
struct jit_fp *) JIT_UNUSED;
static struct jit_fp *_jit_imm(struct jit_fp *, double) JIT_UNUSED;
/* Internal function to walk the tree */
void
_jit_emit(jit_state *jit, struct jit_fp *head,
int store_kind, int store1, int store2, int reg0)
{
#define _jit (*jit)
switch (head->kind) {
case JIT_OP:
_jit_emit(jit, head->d.ops.lhs, JIT_NULL, 0, 0, reg0);
_jit_emit(jit, head->d.ops.rhs, JIT_NULL, 0, 0, reg0 + 1);
switch (head->subkind) {
case JIT_ADD: jit_add_two(reg0); break;
case JIT_SUB: jit_sub_two(reg0); break;
case JIT_MUL: jit_mul_two(reg0); break;
case JIT_DIV: jit_div_two(reg0); break;
}
break;
case JIT_IMM:
#ifdef JIT_LONG_IS_INT
jit_fpimm(reg0, head->d.imm.split[0], head->d.imm.split[1]);
#else
jit_fpimm(reg0, head->d.imm.split[0]);
#endif
break;
case JIT_FN:
_jit_emit(jit, head->d.ops.lhs, JIT_NULL, 0, 0, reg0);
switch (head->subkind) {
case JIT_ABS: jit_abs(reg0); break;
#ifdef JIT_TRANSCENDENTAL
case JIT_SIN: jit_sin(reg0); break;
case JIT_SQRT: jit_sqrt(reg0); break;
case JIT_COS: jit_cos(reg0); break;
case JIT_TAN: jit_tan(reg0); break;
case JIT_ATN: jit_atn(reg0); break;
case JIT_EXP: jit_exp(reg0); break;
case JIT_LOG: jit_log(reg0); break;
case JIT_NEG: jit_neg(reg0); break;
#endif
}
break;
case JIT_LD:
switch (head->subkind) {
case JIT_INT: jit_exti_d(reg0, head->d.addr.reg1); break;
case JIT_XI: jit_ldxi_f(reg0, head->d.addr.reg1, head->d.addr.displ); break;
case JIT_XR: jit_ldxr_f(reg0, head->d.addr.reg1, head->d.addr.reg2); break;
case JIT_XI | 1: jit_ldxi_d(reg0, head->d.addr.reg1, head->d.addr.displ); break;
case JIT_XR | 1: jit_ldxr_d(reg0, head->d.addr.reg1, head->d.addr.reg2); break;
#ifndef JIT_RZERO
case JIT_I: jit_ldi_f(reg0, head->d.addr.displ); break;
case JIT_R: jit_ldr_f(reg0, head->d.addr.reg1); break;
case JIT_I | 1: jit_ldi_d(reg0, head->d.addr.displ); break;
case JIT_R | 1: jit_ldr_d(reg0, head->d.addr.reg1); break;
#endif
}
break;
}
switch (store_kind) {
case JIT_FLOOR: jit_floor(store1, reg0); break;
case JIT_CEIL: jit_ceil(store1, reg0); break;
case JIT_TRUNC: jit_trunc(store1, reg0); break;
case JIT_ROUND: jit_round(store1, reg0); break;
case JIT_CMP: jit_cmp(store1, store2, reg0); break;
case JIT_XI: jit_stxi_f(store2, store1, reg0); break;
case JIT_XR: jit_stxr_f(store2, store1, reg0); break;
case JIT_XI | 1: jit_stxi_d(store2, store1, reg0); break;
case JIT_XR | 1: jit_stxr_d(store2, store1, reg0); break;
#ifndef JIT_RZERO
case JIT_I: jit_sti_f(store2, reg0); break;
case JIT_R: jit_str_f(store2, reg0); break;
case JIT_I | 1: jit_sti_d(store2, reg0); break;
case JIT_R | 1: jit_str_d(store2, reg0); break;
case JIT_NULL: break;
#endif
}
#undef _jit
}
/* Internal functions to build the tree */
struct jit_fp *
_jit_op(struct jit_fp *where, int which,
struct jit_fp *op1, struct jit_fp *op2)
{
where->kind = JIT_OP;
where->subkind = which;
where->d.ops.lhs = op1;
where->d.ops.rhs = op2;
return (where);
}
struct jit_fp *
_jit_ld(struct jit_fp *where, int which, int op1, int op2)
{
where->kind = JIT_LD;
where->subkind = which;
switch (which & ~1) {
case JIT_XI: where->d.addr.reg1 = op1;
case JIT_I: where->d.addr.displ = op2; break;
case JIT_XR: where->d.addr.reg2 = op2;
case JIT_INT:
case JIT_R: where->d.addr.reg1 = op1; break;
}
return (where);
}
struct jit_fp *
_jit_fn(struct jit_fp *where, int which, struct jit_fp *op1)
{
where->kind = JIT_FN;
where->subkind = which;
where->d.ops.lhs = op1;
return (where);
}
struct jit_fp *
_jit_imm(struct jit_fp *where, double number)
{
where->kind = JIT_IMM;
where->d.imm.number = number;
return (where);
}
#define jitfp_begin(buf) (_jit.fp = (buf), --_jit.fp)
#define jitfp_add(op1, op2) _jit_op(++_jit.fp, JIT_ADD, (op1), (op2))
#define jitfp_sub(op1, op2) _jit_op(++_jit.fp, JIT_SUB, (op1), (op2))
#define jitfp_mul(op1, op2) _jit_op(++_jit.fp, JIT_MUL, (op1), (op2))
#define jitfp_div(op1, op2) _jit_op(++_jit.fp, JIT_DIV, (op1), (op2))
#define jitfp_imm(imm) _jit_imm(++_jit.fp, (imm))
#define jitfp_exti_d(reg1) _jit_ld(++_jit.fp, JIT_INT, (reg1), 0)
#define jitfp_ldxi_f(reg1, imm) _jit_ld(++_jit.fp, JIT_XI, (reg1), (long)(imm))
#define jitfp_ldxr_f(reg1, reg2) _jit_ld(++_jit.fp, JIT_XR, (reg1), (reg2))
#define jitfp_ldxi_d(reg1, imm) _jit_ld(++_jit.fp, JIT_XI | 1, (reg1), (long)(imm))
#define jitfp_ldxr_d(reg1, reg2) _jit_ld(++_jit.fp, JIT_XR | 1, (reg1), (reg2))
#define jitfp_abs(op1) _jit_fn(++_jit.fp, JIT_ABS, (op1))
#define jitfp_sqrt(op1) _jit_fn(++_jit.fp, JIT_SQRT, (op1))
#define jitfp_neg(op1) _jit_fn(++_jit.fp, JIT_NEG, (op1))
#define jitfp_stxi_f(imm, reg1, op1) _jit_emit(&_jit, (op1), JIT_XI, (reg1), (long)(imm), 0)
#define jitfp_stxr_f(reg1, reg2, op2) _jit_emit(&_jit, (op1), JIT_XR, (reg1), (reg2), 0)
#define jitfp_stxi_d(imm, reg1, op1) _jit_emit(&_jit, (op1), JIT_XI | 1, (reg1), (long)(imm), 0)
#define jitfp_stxr_d(reg1, reg2, op2) _jit_emit(&_jit, (op1), JIT_XR | 1, (reg1), (reg2), 0)
#define jitfp_cmp(regle, regge, op1) _jit_emit(&_jit, (op1), JIT_CMP, regle, regge, 0)
#define jitfp_floor(reg1, op1) _jit_emit(&_jit, (op1), JIT_FLOOR, reg1, 0, 0)
#define jitfp_ceil(reg1, op1) _jit_emit(&_jit, (op1), JIT_CEIL, reg1, 0, 0)
#define jitfp_trunc(reg1, op1) _jit_emit(&_jit, (op1), JIT_TRUNC, reg1, 0, 0)
#define jitfp_round(reg1, op1) _jit_emit(&_jit, (op1), JIT_ROUND, reg1, 0, 0)
#ifdef JIT_TRANSCENDENTAL
#define jitfp_sin(op1) _jit_fn(++_jit.fp, JIT_SIN, (op1))
#define jitfp_cos(op1) _jit_fn(++_jit.fp, JIT_COS, (op1))
#define jitfp_tan(op1) _jit_fn(++_jit.fp, JIT_TAN, (op1))
#define jitfp_atn(op1) _jit_fn(++_jit.fp, JIT_ATN, (op1))
#define jitfp_exp(op1) _jit_fn(++_jit.fp, JIT_EXP, (op1))
#define jitfp_log(op1) _jit_fn(++_jit.fp, JIT_LOG, (op1))
#endif
#ifdef JIT_RZERO
#define jitfp_ldi_f(imm) _jit_ld(++_jit.fp, JIT_XI, JIT_RZERO, (long)(imm))
#define jitfp_ldr_f(reg1) _jit_ld(++_jit.fp, JIT_XR, JIT_RZERO, (reg1))
#define jitfp_ldi_d(imm) _jit_ld(++_jit.fp, JIT_XI | 1, JIT_RZERO, (long)(imm))
#define jitfp_ldr_d(reg1) _jit_ld(++_jit.fp, JIT_XR | 1, JIT_RZERO, (reg1))
#define jitfp_sti_f(imm, op1) _jit_emit(&_jit, (op1), JIT_XI, JIT_RZERO, (long)(imm), 0)
#define jitfp_str_f(reg1, op1) _jit_emit(&_jit, (op1), JIT_XR, JIT_RZERO, (reg1), 0)
#define jitfp_sti_d(imm, op1) _jit_emit(&_jit, (op1), JIT_XI | 1, JIT_RZERO, (long)(imm), 0)
#define jitfp_str_d(reg1, op1) _jit_emit(&_jit, (op1), JIT_XR | 1, JIT_RZERO, (reg1), 0)
#else
#define jitfp_ldi_f(imm) _jit_ld(++_jit.fp, JIT_I, 0, (long)(imm))
#define jitfp_ldr_f(reg1) _jit_ld(++_jit.fp, JIT_R, 0, (reg1))
#define jitfp_ldi_d(imm) _jit_ld(++_jit.fp, JIT_I | 1, 0, (long)(imm))
#define jitfp_ldr_d(reg1) _jit_ld(++_jit.fp, JIT_R | 1, 0, (reg1))
#define jitfp_sti_f(imm, op1) _jit_emit(&_jit, (op1), JIT_I, 0, (long)(imm), 0)
#define jitfp_str_f(reg1, op1) _jit_emit(&_jit, (op1), JIT_R, 0, (reg1), 0)
#define jitfp_sti_d(imm, op1) _jit_emit(&_jit, (op1), JIT_I | 1, 0, (long)(imm), 0)
#define jitfp_str_d(reg1, op1) _jit_emit(&_jit, (op1), JIT_R | 1, 0, (reg1), 0)
#endif
#endif

View file

@ -1,48 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer inline functions (common part)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_funcs_common_h
#define __lightning_funcs_common_h
#include <stdio.h>
static int jit_fail(char *, char*, int, char *) JIT_UNUSED;
int
jit_fail(char *msg, char *file, int line, char *function)
{
fprintf(stderr, "%s: In function `%s':\n", file, function);
fprintf(stderr, "%s:%d: %s\n", file, line, msg);
abort();
return 0;
}
#endif /* __lightning_funcs_common_h */

View file

@ -1,982 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler for the i386
*
***********************************************************************/
/***********************************************************************
*
* Copyright 1999, 2000, 2001, 2002 Ian Piumarta
*
* 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
*/
typedef _uc jit_insn;
#define _b00 0
#define _b01 1
#define _b10 2
#define _b11 3
#define _b000 0
#define _b001 1
#define _b010 2
#define _b011 3
#define _b100 4
#define _b101 5
#define _b110 6
#define _b111 7
/*** REGISTERS ***/ /* [size,,number] */
#define _AL 0x10
#define _CL 0x11
#define _DL 0x12
#define _BL 0x13
#define _AH 0x14
#define _CH 0x15
#define _DH 0x16
#define _BH 0x17
#define _AX 0x20
#define _CX 0x21
#define _DX 0x22
#define _BX 0x23
#define _SP 0x24
#define _BP 0x25
#define _SI 0x26
#define _DI 0x27
#define _EAX 0x40
#define _ECX 0x41
#define _EDX 0x42
#define _EBX 0x43
#define _ESP 0x44
#define _EBP 0x45
#define _ESI 0x46
#define _EDI 0x47
#define _rS(R) ((R)>>4)
#define _rN(R) ((R)&0x7)
#define _r0P(R) ((R)==0)
#ifndef _ASM_SAFETY
#define _r1(R) _rN(R)
#define _r2(R) _rN(R)
#define _r4(R) _rN(R)
#else
#define _r1(R) ((_rS(R)==1) ? _rN(R) : JITFAIL( "8-bit register required"))
#define _r2(R) ((_rS(R)==2) ? _rN(R) : JITFAIL("16-bit register required"))
#define _r4(R) ((_rS(R)==4) ? _rN(R) : JITFAIL("32-bit register required"))
#endif
/*** ASSEMBLER ***/
#define _OFF4(D) (_UL(D) - _UL(_jit.pc))
#define _CKD8(D) _ck_d(8, ((_uc) _OFF4(D)) )
#define _D8(D) (_B(0), ((*(_PUC(_jit.pc)-1))= _CKD8(D)))
#define _D32(D) (_L(0), ((*(_PUL(_jit.pc)-1))= _OFF4(D)))
#ifndef _ASM_SAFETY
# define _M(M) (M)
# define _r(R) (R)
# define _m(M) (M)
# define _s(S) (S)
# define _i(I) (I)
# define _b(B) (B)
# define _noESP(I,OK) (OK)
#else
# define _M(M) (((M)>3) ? JITFAIL("internal error: mod = " #M) : (M))
# define _r(R) (((R)>7) ? JITFAIL("internal error: reg = " #R) : (R))
# define _m(M) (((M)>7) ? JITFAIL("internal error: r/m = " #M) : (M))
# define _s(S) (((S)>3) ? JITFAIL("internal error: memory scale = " #S) : (S))
# define _i(I) (((I)>7) ? JITFAIL("internal error: memory index = " #I) : (I))
# define _b(B) (((B)>7) ? JITFAIL("internal error: memory base = " #B) : (B))
# define _noESP(I,OK) (((I)==_ESP) ? JITFAIL("illegal index register: %esp") : (OK))
#endif
#define _Mrm(Md,R,M) _B((_M(Md)<<6)|(_r(R)<<3)|_m(M))
#define _SIB(Sc,I, B) _B((_s(Sc)<<6)|(_i(I)<<3)|_b(B))
#define _SCL(S) ((((S)==1) ? _b00 : \
(((S)==2) ? _b01 : \
(((S)==4) ? _b10 : \
(((S)==8) ? _b11 : JITFAIL("illegal scale: " #S))))))
/* memory subformats - urgh! */
#define _r_D( R, D ) (_Mrm(_b00,_rN(R),_b101 ) ,_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)) ,_B((long)(D)))
#define _r_1BIS(R, D,B,I,S) (_Mrm(_b01,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B)),_B((long)(D)))
#define _r_4B( R, D,B ) (_Mrm(_b10,_rN(R),_r4(B)) ,_L((long)(D)))
#define _r_4IS( R, D,I,S) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_b101 ),_L((long)(D)))
#define _r_4BIS(R, D,B,I,S) (_Mrm(_b10,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B)),_L((long)(D)))
#define _r_DB( R, D,B ) ((_s0P(D) && (B != _EBP) ? _r_0B (R, B ) : (_s8P(D) ? _r_1B( R,D,B ) : _r_4B( R,D,B ))))
#define _r_DBIS(R, D,B,I,S) ((_s0P(D) ? _r_0BIS(R, B,I,S) : (_s8P(D) ? _r_1BIS(R,D,B,I,S) : _r_4BIS(R,D,B,I,S))))
#define _r_X( R, D,B,I,S) (_r0P(I) ? (_r0P(B) ? _r_D (R,D ) : \
(_ESP==(B) ? _r_DBIS(R,D,_ESP,_ESP,1) : \
_r_DB (R,D, B ))) : \
(_r0P(B) ? _r_4IS (R,D, I,S) : \
(((I)!=_ESP) ? _r_DBIS(R,D, B, I,S) : \
JITFAIL("illegal index register: %esp"))))
/* instruction formats */
/* _format Opcd ModR/M dN(rB,rI,Sc) imm... */
#define _d16() ( _B(0x66 ) )
#define _O( OP ) ( _B( OP ) )
#define _Or( OP,R ) ( _B( (OP)|_r(R)) )
#define _OO( OP ) ( _B((OP)>>8), _B( (OP) ) )
#define _OOr( OP,R ) ( _B((OP)>>8), _B( (OP)|_r(R)) )
#define _Os( OP,B ) ( _s8P(B) ? _B(((OP)|_b10)) : _B(OP) )
#define _sW( W ) ( _s8P(W) ? _B(W):_W(W) )
#define _sL( L ) ( _s8P(L) ? _B(L):_L(L) )
#define _O_W( OP ,W ) ( _O ( OP ) ,_W(W) )
#define _O_D8( OP ,D ) ( _O ( OP ) ,_D8(D) )
#define _O_D32( OP ,D ) ( _O ( OP ) ,_D32(D) )
#define _OO_D32( OP ,D ) ( _OO ( OP ) ,_D32(D) )
#define _Os_sW( OP ,W ) ( _Os ( OP,W) ,_sW(W) )
#define _Os_sL( OP ,L ) ( _Os ( OP,L) ,_sL(L) )
#define _O_W_B( OP ,W,B) ( _O ( OP ) ,_W(W),_B(B))
#define _Or_B( OP,R ,B ) ( _Or ( OP,R) ,_B(B) )
#define _Or_W( OP,R ,W ) ( _Or ( OP,R) ,_W(W) )
#define _Or_L( OP,R ,L ) ( _Or ( OP,R) ,_L(L) )
#define _O_Mrm( OP ,MO,R,M ) ( _O ( OP ),_Mrm(MO,R,M ) )
#define _OO_Mrm( OP ,MO,R,M ) ( _OO ( OP ),_Mrm(MO,R,M ) )
#define _O_Mrm_B( OP ,MO,R,M ,B ) ( _O ( OP ),_Mrm(MO,R,M ) ,_B(B) )
#define _O_Mrm_W( OP ,MO,R,M ,W ) ( _O ( OP ),_Mrm(MO,R,M ) ,_W(W) )
#define _O_Mrm_L( OP ,MO,R,M ,L ) ( _O ( OP ),_Mrm(MO,R,M ) ,_L(L) )
#define _OO_Mrm_B( OP ,MO,R,M ,B ) ( _OO ( OP ),_Mrm(MO,R,M ) ,_B(B) )
#define _Os_Mrm_sW(OP ,MO,R,M ,W ) ( _Os ( OP,W),_Mrm(MO,R,M ),_sW(W) )
#define _Os_Mrm_sL(OP ,MO,R,M ,L ) ( _Os ( OP,L),_Mrm(MO,R,M ),_sL(L) )
#define _O_r_X( OP ,R ,MD,MB,MI,MS ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS) )
#define _OO_r_X( OP ,R ,MD,MB,MI,MS ) ( _OO ( OP ),_r_X( R ,MD,MB,MI,MS) )
#define _O_r_X_B( OP ,R ,MD,MB,MI,MS,B ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS) ,_B(B) )
#define _O_r_X_W( OP ,R ,MD,MB,MI,MS,W ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS) ,_W(W) )
#define _O_r_X_L( OP ,R ,MD,MB,MI,MS,L ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS) ,_L(L) )
#define _OO_r_X_B( OP ,R ,MD,MB,MI,MS,B ) ( _OO ( OP ),_r_X( R ,MD,MB,MI,MS) ,_B(B) )
#define _Os_r_X_sW(OP ,R ,MD,MB,MI,MS,W ) ( _Os ( OP,W),_r_X( R ,MD,MB,MI,MS),_sW(W) )
#define _Os_r_X_sL(OP ,R ,MD,MB,MI,MS,L ) ( _Os ( OP,L),_r_X( R ,MD,MB,MI,MS),_sL(L) )
#define _O_X_B( OP ,MD,MB,MI,MS,B ) ( _O_r_X_B( OP ,0 ,MD,MB,MI,MS ,B) )
#define _O_X_W( OP ,MD,MB,MI,MS,W ) ( _O_r_X_W( OP ,0 ,MD,MB,MI,MS ,W) )
#define _O_X_L( OP ,MD,MB,MI,MS,L ) ( _O_r_X_L( OP ,0 ,MD,MB,MI,MS ,L) )
#define _wO( OP ) (_d16(), _O( OP ) )
#define _wOr( OP,R ) (_d16(), _Or( OP,R ) )
#define _wOr_W( OP,R ,W ) (_d16(), _Or_W( OP,R ,W) )
#define _wOs_sW( OP ,W ) (_d16(), _Os_sW( OP ,W) )
#define _wO_Mrm( OP ,MO,R,M ) (_d16(), _O_Mrm( OP ,MO,R,M ) )
#define _wOO_Mrm( OP ,MO,R,M ) (_d16(),_OO_Mrm( OP ,MO,R,M ) )
#define _wO_Mrm_B( OP ,MO,R,M ,B ) (_d16(), _O_Mrm_B( OP ,MO,R,M ,B) )
#define _wOO_Mrm_B( OP ,MO,R,M ,B ) (_d16(),_OO_Mrm_B( OP ,MO,R,M ,B) )
#define _wO_Mrm_W( OP ,MO,R,M ,W ) (_d16(), _O_Mrm_W( OP ,MO,R,M ,W) )
#define _wOs_Mrm_sW(OP ,MO,R,M ,W ) (_d16(), _Os_Mrm_sW(OP ,MO,R,M ,W) )
#define _wO_X_W( OP ,MD,MB,MI,MS,W ) (_d16(), _O_X_W( OP ,MD,MB,MI,MS ,W) )
#define _wO_r_X( OP ,R ,MD,MB,MI,MS ) (_d16(), _O_r_X( OP ,R ,MD,MB,MI,MS ) )
#define _wOO_r_X( OP ,R ,MD,MB,MI,MS ) (_d16(),_OO_r_X( OP ,R ,MD,MB,MI,MS ) )
#define _wO_r_X_B( OP ,R ,MD,MB,MI,MS,B ) (_d16(), _O_r_X_B( OP ,R ,MD,MB,MI,MS ,B) )
#define _wOO_r_X_B( OP ,R ,MD,MB,MI,MS,B ) (_d16(),_OO_r_X_B( OP ,R ,MD,MB,MI,MS ,B) )
#define _wO_r_X_W( OP ,R ,MD,MB,MI,MS,W ) (_d16(), _O_r_X_W( OP ,R ,MD,MB,MI,MS ,W) )
#define _wOs_r_X_sW(OP ,R ,MD,MB,MI,MS,W ) (_d16(), _Os_r_X_sW(OP ,R ,MD,MB,MI,MS ,W) )
/* +++ fully-qualified intrinsic instructions */
/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */
#define ADCBrr(RS, RD) _O_Mrm (0x10 ,_b11,_r1(RS),_r1(RD) )
#define ADCBmr(MD, MB, MI, MS, RD) _O_r_X (0x12 ,_r1(RD) ,MD,MB,MI,MS )
#define ADCBrm(RS, MD, MB, MI, MS) _O_r_X (0x10 ,_r1(RS) ,MD,MB,MI,MS )
#define ADCBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b010 ,_r1(RD) ,_su8(IM))
#define ADCBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b010 ,MD,MB,MI,MS ,_su8(IM))
#define ADCWrr(RS, RD) _wO_Mrm (0x11 ,_b11,_r2(RS),_r2(RD) )
#define ADCWmr(MD, MB, MI, MS, RD) _wO_r_X (0x13 ,_r2(RD) ,MD,MB,MI,MS )
#define ADCWrm(RS, MD, MB, MI, MS) _wO_r_X (0x11 ,_r2(RS) ,MD,MB,MI,MS )
#define ADCWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b010 ,_r2(RD) ,_su16(IM))
#define ADCWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b010 ,MD,MB,MI,MS ,_su16(IM))
#define ADCLrr(RS, RD) _O_Mrm (0x11 ,_b11,_r4(RS),_r4(RD) )
#define ADCLmr(MD, MB, MI, MS, RD) _O_r_X (0x13 ,_r4(RD) ,MD,MB,MI,MS )
#define ADCLrm(RS, MD, MB, MI, MS) _O_r_X (0x11 ,_r4(RS) ,MD,MB,MI,MS )
#define ADCLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b010 ,_r4(RD) ,IM )
#define ADCLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b010 ,MD,MB,MI,MS ,IM )
#define ADDBrr(RS, RD) _O_Mrm (0x00 ,_b11,_r1(RS),_r1(RD) )
#define ADDBmr(MD, MB, MI, MS, RD) _O_r_X (0x02 ,_r1(RD) ,MD,MB,MI,MS )
#define ADDBrm(RS, MD, MB, MI, MS) _O_r_X (0x00 ,_r1(RS) ,MD,MB,MI,MS )
#define ADDBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b000 ,_r1(RD) ,_su8(IM))
#define ADDBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b000 ,MD,MB,MI,MS ,_su8(IM))
#define ADDWrr(RS, RD) _wO_Mrm (0x01 ,_b11,_r2(RS),_r2(RD) )
#define ADDWmr(MD, MB, MI, MS, RD) _wO_r_X (0x03 ,_r2(RD) ,MD,MB,MI,MS )
#define ADDWrm(RS, MD, MB, MI, MS) _wO_r_X (0x01 ,_r2(RS) ,MD,MB,MI,MS )
#define ADDWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b000 ,_r2(RD) ,_su16(IM))
#define ADDWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b000 ,MD,MB,MI,MS ,_su16(IM))
#define ADDLrr(RS, RD) _O_Mrm (0x01 ,_b11,_r4(RS),_r4(RD) )
#define ADDLmr(MD, MB, MI, MS, RD) _O_r_X (0x03 ,_r4(RD) ,MD,MB,MI,MS )
#define ADDLrm(RS, MD, MB, MI, MS) _O_r_X (0x01 ,_r4(RS) ,MD,MB,MI,MS )
#define ADDLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b000 ,_r4(RD) ,IM )
#define ADDLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b000 ,MD,MB,MI,MS ,IM )
#define ANDBrr(RS, RD) _O_Mrm (0x20 ,_b11,_r1(RS),_r1(RD) )
#define ANDBmr(MD, MB, MI, MS, RD) _O_r_X (0x22 ,_r1(RD) ,MD,MB,MI,MS )
#define ANDBrm(RS, MD, MB, MI, MS) _O_r_X (0x20 ,_r1(RS) ,MD,MB,MI,MS )
#define ANDBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b100 ,_r1(RD) ,_su8(IM))
#define ANDBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b100 ,MD,MB,MI,MS ,_su8(IM))
#define ANDWrr(RS, RD) _wO_Mrm (0x21 ,_b11,_r2(RS),_r2(RD) )
#define ANDWmr(MD, MB, MI, MS, RD) _wO_r_X (0x23 ,_r2(RD) ,MD,MB,MI,MS )
#define ANDWrm(RS, MD, MB, MI, MS) _wO_r_X (0x21 ,_r2(RS) ,MD,MB,MI,MS )
#define ANDWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b100 ,_r2(RD) ,_su16(IM))
#define ANDWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b100 ,MD,MB,MI,MS ,_su16(IM))
#define ANDLrr(RS, RD) _O_Mrm (0x21 ,_b11,_r4(RS),_r4(RD) )
#define ANDLmr(MD, MB, MI, MS, RD) _O_r_X (0x23 ,_r4(RD) ,MD,MB,MI,MS )
#define ANDLrm(RS, MD, MB, MI, MS) _O_r_X (0x21 ,_r4(RS) ,MD,MB,MI,MS )
#define ANDLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b100 ,_r4(RD) ,IM )
#define ANDLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b100 ,MD,MB,MI,MS ,IM )
#define BSWAPLr(R) _OOr (0x0fc8,_r4(R) )
#define BTWir(IM,RD) _wOO_Mrm_B (0x0fba ,_b11,_b100 ,_r2(RD) ,_u8(IM))
#define BTWim(IM,MD,MB,MI,MS) _wOO_r_X_B (0x0fba ,_b100 ,MD,MB,MI,MS ,_u8(IM))
#define BTWrr(RS,RD) _wOO_Mrm (0x0fa3 ,_b11,_r2(RS),_r2(RD) )
#define BTWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fa3 ,_r2(RS) ,MD,MB,MI,MS )
#define BTLir(IM,RD) _OO_Mrm_B (0x0fba ,_b11,_b100 ,_r4(RD) ,_u8(IM))
#define BTLim(IM,MD,MB,MI,MS) _OO_r_X_B (0x0fba ,_b100 ,MD,MB,MI,MS ,_u8(IM))
#define BTLrr(RS,RD) _OO_Mrm (0x0fa3 ,_b11,_r4(RS),_r4(RD) )
#define BTLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fa3 ,_r4(RS) ,MD,MB,MI,MS )
#define BTCWir(IM,RD) _wOO_Mrm_B (0x0fba ,_b11,_b111 ,_r2(RD) ,_u8(IM))
#define BTCWim(IM,MD,MB,MI,MS) _wOO_r_X_B (0x0fba ,_b111 ,MD,MB,MI,MS ,_u8(IM))
#define BTCWrr(RS,RD) _wOO_Mrm (0x0fbb ,_b11,_r2(RS),_r2(RD) )
#define BTCWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fbb ,_r2(RS) ,MD,MB,MI,MS )
#define BTCLir(IM,RD) _OO_Mrm_B (0x0fba ,_b11,_b111 ,_r4(RD) ,_u8(IM))
#define BTCLim(IM,MD,MB,MI,MS) _OO_r_X_B (0x0fba ,_b111 ,MD,MB,MI,MS ,_u8(IM))
#define BTCLrr(RS,RD) _OO_Mrm (0x0fbb ,_b11,_r4(RS),_r4(RD) )
#define BTCLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fbb ,_r4(RS) ,MD,MB,MI,MS )
#define BTRWir(IM,RD) _wOO_Mrm_B (0x0fba ,_b11,_b110 ,_r2(RD) ,_u8(IM))
#define BTRWim(IM,MD,MB,MI,MS) _wOO_r_X_B (0x0fba ,_b110 ,MD,MB,MI,MS ,_u8(IM))
#define BTRWrr(RS,RD) _wOO_Mrm (0x0fb3 ,_b11,_r2(RS),_r2(RD) )
#define BTRWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fb3 ,_r2(RS) ,MD,MB,MI,MS )
#define BTRLir(IM,RD) _OO_Mrm_B (0x0fba ,_b11,_b110 ,_r4(RD) ,_u8(IM))
#define BTRLim(IM,MD,MB,MI,MS) _OO_r_X_B (0x0fba ,_b110 ,MD,MB,MI,MS ,_u8(IM))
#define BTRLrr(RS,RD) _OO_Mrm (0x0fb3 ,_b11,_r4(RS),_r4(RD) )
#define BTRLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fb3 ,_r4(RS) ,MD,MB,MI,MS )
#define BTSWir(IM,RD) _wOO_Mrm_B (0x0fba ,_b11,_b101 ,_r2(RD) ,_u8(IM))
#define BTSWim(IM,MD,MB,MI,MS) _wOO_r_X_B (0x0fba ,_b101 ,MD,MB,MI,MS ,_u8(IM))
#define BTSWrr(RS,RD) _wOO_Mrm (0x0fab ,_b11,_r2(RS),_r2(RD) )
#define BTSWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fab ,_r2(RS) ,MD,MB,MI,MS )
#define BTSLir(IM,RD) _OO_Mrm_B (0x0fba ,_b11,_b101 ,_r4(RD) ,_u8(IM))
#define BTSLim(IM,MD,MB,MI,MS) _OO_r_X_B (0x0fba ,_b101 ,MD,MB,MI,MS ,_u8(IM))
#define BTSLrr(RS,RD) _OO_Mrm (0x0fab ,_b11,_r4(RS),_r4(RD) )
#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 )
#define CBW() _O (0x98 )
#define CLC() _O (0xf8 )
#define CLTD() _O (0x99 )
#define CMC() _O (0xf5 )
#define CMPBrr(RS, RD) _O_Mrm (0x38 ,_b11,_r1(RS),_r1(RD) )
#define CMPBmr(MD, MB, MI, MS, RD) _O_r_X (0x3a ,_r1(RD) ,MD,MB,MI,MS )
#define CMPBrm(RS, MD, MB, MI, MS) _O_r_X (0x38 ,_r1(RS) ,MD,MB,MI,MS )
#define CMPBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b111 ,_r1(RD) ,_su8(IM))
#define CMPBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b111 ,MD,MB,MI,MS ,_su8(IM))
#define CMPWrr(RS, RD) _wO_Mrm (0x39 ,_b11,_r2(RS),_r2(RD) )
#define CMPWmr(MD, MB, MI, MS, RD) _wO_r_X (0x3b ,_r2(RD) ,MD,MB,MI,MS )
#define CMPWrm(RS, MD, MB, MI, MS) _wO_r_X (0x39 ,_r2(RS) ,MD,MB,MI,MS )
#define CMPWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b111 ,_r2(RD) ,_su16(IM))
#define CMPWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b111 ,MD,MB,MI,MS ,_su16(IM))
#define CMPLrr(RS, RD) _O_Mrm (0x39 ,_b11,_r4(RS),_r4(RD) )
#define CMPLmr(MD, MB, MI, MS, RD) _O_r_X (0x3b ,_r4(RD) ,MD,MB,MI,MS )
#define CMPLrm(RS, MD, MB, MI, MS) _O_r_X (0x39 ,_r4(RS) ,MD,MB,MI,MS )
#define CMPLir(IM, RD) _O_Mrm_L (0x81 ,_b11,_b111 ,_r4(RD) ,IM )
#define CMPLim(IM, MD, MB, MI, MS) _O_r_X_L (0x81 ,_b111 ,MD,MB,MI,MS ,IM )
#define CWD() _O (0x99 )
#define CMPXCHGBrr(RS,RD) _OO_Mrm (0x0fb0 ,_b11,_r1(RS),_r1(RD) )
#define CMPXCHGBrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fb0 ,_r1(RS) ,MD,MB,MI,MS )
#define CMPXCHGWrr(RS,RD) _wOO_Mrm (0x0fb1 ,_b11,_r2(RS),_r2(RD) )
#define CMPXCHGWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fb1 ,_r2(RS) ,MD,MB,MI,MS )
#define CMPXCHGLrr(RS,RD) _OO_Mrm (0x0fb1 ,_b11,_r4(RS),_r4(RD) )
#define CMPXCHGLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fb1 ,_r4(RS) ,MD,MB,MI,MS )
#define DECBr(RD) _O_Mrm (0xfe ,_b11,_b001 ,_r1(RD) )
#define DECBm(MD,MB,MI,MS) _O_r_X (0xfe ,_b001 ,MD,MB,MI,MS )
#define DECWr(RD) _wOr (0x48,_r2(RD) )
#define DECWm(MD,MB,MI,MS) _wO_r_X (0xff ,_b001 ,MD,MB,MI,MS )
#define DECLr(RD) _Or (0x48,_r4(RD) )
#define DECLm(MD,MB,MI,MS) _O_r_X (0xff ,_b001 ,MD,MB,MI,MS )
#define DIVBr(RS) _O_Mrm (0xf6 ,_b11,_b110 ,_r1(RS) )
#define DIVBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b110 ,MD,MB,MI,MS )
#define DIVWr(RS) _wO_Mrm (0xf7 ,_b11,_b110 ,_r2(RS) )
#define DIVWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b110 ,MD,MB,MI,MS )
#define DIVLr(RS) _O_Mrm (0xf7 ,_b11,_b110 ,_r4(RS) )
#define DIVLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b110 ,MD,MB,MI,MS )
#define ENTERii(W, B) _O_W_B (0xc8 ,_su16(W),_su8(B))
#define HLT() _O (0xf4 )
#define IDIVBr(RS) _O_Mrm (0xf6 ,_b11,_b111 ,_r1(RS) )
#define IDIVBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b111 ,MD,MB,MI,MS )
#define IDIVWr(RS) _wO_Mrm (0xf7 ,_b11,_b111 ,_r2(RS) )
#define IDIVWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b111 ,MD,MB,MI,MS )
#define IDIVLr(RS) _O_Mrm (0xf7 ,_b11,_b111 ,_r4(RS) )
#define IDIVLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b111 ,MD,MB,MI,MS )
#define IMULBr(RS) _O_Mrm (0xf6 ,_b11,_b101 ,_r1(RS) )
#define IMULBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b101 ,MD,MB,MI,MS )
#define IMULWr(RS) _wO_Mrm (0xf7 ,_b11,_b101 ,_r2(RS) )
#define IMULWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b101 ,MD,MB,MI,MS )
#define IMULLr(RS) _O_Mrm (0xf7 ,_b11,_b101 ,_r4(RS) )
#define IMULLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b101 ,MD,MB,MI,MS )
#define IMULWrr(RS,RD) _wOO_Mrm (0x0faf ,_b11,_r2(RS),_r2(RD) )
#define IMULWmr(MD,MB,MI,MS,RD) _wOO_r_X (0x0faf ,_r2(RD) ,MD,MB,MI,MS )
#define IMULWirr(IM,RS,RD) _wOs_Mrm_sW (0x69 ,_b11,_r2(RS),_r2(RD) ,_su16(IM) )
#define IMULWimr(IM,MD,MB,MI,MS,RD) _wOs_r_X_sW (0x69 ,_r2(RD) ,MD,MB,MI,MS ,_su16(IM) )
#define IMULLir(IM,RD) _Os_Mrm_sL (0x69 ,_b11,_r4(RD),_r4(RD) ,IM )
#define IMULLrr(RS,RD) _OO_Mrm (0x0faf ,_b11,_r4(RD),_r4(RS) )
#define IMULLmr(MD,MB,MI,MS,RD) _OO_r_X (0x0faf ,_r4(RD) ,MD,MB,MI,MS )
#define IMULLirr(IM,RS,RD) _Os_Mrm_sL (0x69 ,_b11,_r4(RS),_r4(RD) ,IM )
#define IMULLimr(IM,MD,MB,MI,MS,RD) _Os_r_X_sL (0x69 ,_r4(RD) ,MD,MB,MI,MS ,IM )
#define INCBr(RD) _O_Mrm (0xfe ,_b11,_b000 ,_r1(RD) )
#define INCBm(MD,MB,MI,MS) _O_r_X (0xfe ,_b000 ,MD,MB,MI,MS )
#define INCWr(RD) _wOr (0x40,_r2(RD) )
#define INCWm(MD,MB,MI,MS) _wO_r_X (0xff ,_b000 ,MD,MB,MI,MS )
#define INCLr(RD) _Or (0x40,_r4(RD) )
#define INCLm(MD,MB,MI,MS) _O_r_X (0xff ,_b000 ,MD,MB,MI,MS )
#define INVD() _OO (0x0f08 )
#define INVLPGm(MD, MB, MI, MS) _OO_r_X (0x0f01 ,_b111 ,MD,MB,MI,MS )
#define JCCSim(CC,D,B,I,S) ((_r0P(B) && _r0P(I)) ? _O_D8 (0x70|(CC) ,(int)(D) ) : \
JITFAIL("illegal mode in conditional jump"))
#define JOSm(D,B,I,S) JCCSim(0x0,D,B,I,S)
#define JNOSm(D,B,I,S) JCCSim(0x1,D,B,I,S)
#define JBSm(D,B,I,S) JCCSim(0x2,D,B,I,S)
#define JNAESm(D,B,I,S) JCCSim(0x2,D,B,I,S)
#define JNBSm(D,B,I,S) JCCSim(0x3,D,B,I,S)
#define JAESm(D,B,I,S) JCCSim(0x3,D,B,I,S)
#define JESm(D,B,I,S) JCCSim(0x4,D,B,I,S)
#define JZSm(D,B,I,S) JCCSim(0x4,D,B,I,S)
#define JNESm(D,B,I,S) JCCSim(0x5,D,B,I,S)
#define JNZSm(D,B,I,S) JCCSim(0x5,D,B,I,S)
#define JBESm(D,B,I,S) JCCSim(0x6,D,B,I,S)
#define JNASm(D,B,I,S) JCCSim(0x6,D,B,I,S)
#define JNBESm(D,B,I,S) JCCSim(0x7,D,B,I,S)
#define JASm(D,B,I,S) JCCSim(0x7,D,B,I,S)
#define JSSm(D,B,I,S) JCCSim(0x8,D,B,I,S)
#define JNSSm(D,B,I,S) JCCSim(0x9,D,B,I,S)
#define JPSm(D,B,I,S) JCCSim(0xa,D,B,I,S)
#define JPESm(D,B,I,S) JCCSim(0xa,D,B,I,S)
#define JNPSm(D,B,I,S) JCCSim(0xb,D,B,I,S)
#define JPOSm(D,B,I,S) JCCSim(0xb,D,B,I,S)
#define JLSm(D,B,I,S) JCCSim(0xc,D,B,I,S)
#define JNGESm(D,B,I,S) JCCSim(0xc,D,B,I,S)
#define JNLSm(D,B,I,S) JCCSim(0xd,D,B,I,S)
#define JGESm(D,B,I,S) JCCSim(0xd,D,B,I,S)
#define JLESm(D,B,I,S) JCCSim(0xe,D,B,I,S)
#define JNGSm(D,B,I,S) JCCSim(0xe,D,B,I,S)
#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 JBm(D,B,I,S) JCCim(0x2,D,B,I,S)
#define JNAEm(D,B,I,S) JCCim(0x2,D,B,I,S)
#define JNBm(D,B,I,S) JCCim(0x3,D,B,I,S)
#define JAEm(D,B,I,S) JCCim(0x3,D,B,I,S)
#define JEm(D,B,I,S) JCCim(0x4,D,B,I,S)
#define JZm(D,B,I,S) JCCim(0x4,D,B,I,S)
#define JNEm(D,B,I,S) JCCim(0x5,D,B,I,S)
#define JNZm(D,B,I,S) JCCim(0x5,D,B,I,S)
#define JBEm(D,B,I,S) JCCim(0x6,D,B,I,S)
#define JNAm(D,B,I,S) JCCim(0x6,D,B,I,S)
#define JNBEm(D,B,I,S) JCCim(0x7,D,B,I,S)
#define JAm(D,B,I,S) JCCim(0x7,D,B,I,S)
#define JSm(D,B,I,S) JCCim(0x8,D,B,I,S)
#define JNSm(D,B,I,S) JCCim(0x9,D,B,I,S)
#define JPm(D,B,I,S) JCCim(0xa,D,B,I,S)
#define JPEm(D,B,I,S) JCCim(0xa,D,B,I,S)
#define JNPm(D,B,I,S) JCCim(0xb,D,B,I,S)
#define JPOm(D,B,I,S) JCCim(0xb,D,B,I,S)
#define JLm(D,B,I,S) JCCim(0xc,D,B,I,S)
#define JNGEm(D,B,I,S) JCCim(0xc,D,B,I,S)
#define JNLm(D,B,I,S) JCCim(0xd,D,B,I,S)
#define JGEm(D,B,I,S) JCCim(0xd,D,B,I,S)
#define JLEm(D,B,I,S) JCCim(0xe,D,B,I,S)
#define JNGm(D,B,I,S) JCCim(0xe,D,B,I,S)
#define JNLEm(D,B,I,S) JCCim(0xf,D,B,I,S)
#define JGm(D,B,I,S) JCCim(0xf,D,B,I,S)
#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 )
#define LAHF() _O (0x9f )
#define LEALmr(MD, MB, MI, MS, RD) _O_r_X (0x8d ,_r4(RD) ,MD,MB,MI,MS )
#define LEAVE() _O (0xc9 )
#define LMSWr(RS) _OO_Mrm (0x0f01 ,_b11,_b110,_r4(RS) )
#define LMSWm(MD,MB,MI,MS) _OO_r_X (0x0f01 ,_b110 ,MD,MB,MI,MS )
#define LOOPm(MD,MB,MI,MS) ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe2 ,MD ) : \
JITFAIL("illegal mode in loop"))
#define LOOPEm(MD,MB,MI,MS) ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe1 ,MD ) : \
JITFAIL("illegal mode in loope"))
#define LOOPZm(MD,MB,MI,MS) ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe1 ,MD ) : \
JITFAIL("illegal mode in loopz"))
#define LOOPNEm(MD,MB,MI,MS) ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe0 ,MD ) : \
JITFAIL("illegal mode in loopne"))
#define LOOPNZm(MD,MB,MI,MS) ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe0 ,MD ) : \
JITFAIL("illegal mode in loopnz"))
#define MOVBrr(RS, RD) _O_Mrm (0x80 ,_b11,_r1(RS),_r1(RD) )
#define MOVBmr(MD, MB, MI, MS, RD) _O_r_X (0x8a ,_r1(RD) ,MD,MB,MI,MS )
#define MOVBrm(RS, MD, MB, MI, MS) _O_r_X (0x88 ,_r1(RS) ,MD,MB,MI,MS )
#define MOVBir(IM, R) _Or_B (0xb0,_r1(R) ,_su8(IM))
#define MOVBim(IM, MD, MB, MI, MS) _O_X_B (0xc6 ,MD,MB,MI,MS ,_su8(IM))
#define MOVWrr(RS, RD) _wO_Mrm (0x89 ,_b11,_r2(RS),_r2(RD) )
#define MOVWmr(MD, MB, MI, MS, RD) _wO_r_X (0x8b ,_r2(RD) ,MD,MB,MI,MS )
#define MOVWrm(RS, MD, MB, MI, MS) _wO_r_X (0x89 ,_r2(RS) ,MD,MB,MI,MS )
#define MOVWir(IM, R) _wOr_W (0xb8,_r2(R) ,_su16(IM))
#define MOVWim(IM, MD, MB, MI, MS) _wO_X_W (0xc7 ,MD,MB,MI,MS ,_su16(IM))
#define MOVLrr(RS, RD) _O_Mrm (0x89 ,_b11,_r4(RS),_r4(RD) )
#define MOVLmr(MD, MB, MI, MS, RD) _O_r_X (0x8b ,_r4(RD) ,MD,MB,MI,MS )
#define MOVLrm(RS, MD, MB, MI, MS) _O_r_X (0x89 ,_r4(RS) ,MD,MB,MI,MS )
#define MOVLir(IM, R) _Or_L (0xb8,_r4(R) ,IM )
#define MOVLim(IM, MD, MB, MI, MS) _O_X_L (0xc7 ,MD,MB,MI,MS ,IM )
#define MULBr(RS) _O_Mrm (0xf6 ,_b11,_b100 ,_r1(RS) )
#define MULBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b100 ,MD,MB,MI,MS )
#define MULWr(RS) _wO_Mrm (0xf7 ,_b11,_b100 ,_r2(RS) )
#define MULWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b100 ,MD,MB,MI,MS )
#define MULLr(RS) _O_Mrm (0xf7 ,_b11,_b100 ,_r4(RS) )
#define MULLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b100 ,MD,MB,MI,MS )
#define NEGBr(RD) _O_Mrm (0xf6 ,_b11,_b011 ,_r1(RD) )
#define NEGBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b011 ,MD,MB,MI,MS )
#define NEGWr(RD) _wO_Mrm (0xf7 ,_b11,_b011 ,_r2(RD) )
#define NEGWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b011 ,MD,MB,MI,MS )
#define NEGLr(RD) _O_Mrm (0xf7 ,_b11,_b011 ,_r4(RD) )
#define NEGLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b011 ,MD,MB,MI,MS )
#define NOP() _O (0x90 )
#define NOTBr(RD) _O_Mrm (0xf6 ,_b11,_b010 ,_r1(RD) )
#define NOTBm(MD,MB,MI,MS) _O_r_X (0xf6 ,_b010 ,MD,MB,MI,MS )
#define NOTWr(RD) _wO_Mrm (0xf7 ,_b11,_b010 ,_r2(RD) )
#define NOTWm(MD,MB,MI,MS) _wO_r_X (0xf7 ,_b010 ,MD,MB,MI,MS )
#define NOTLr(RD) _O_Mrm (0xf7 ,_b11,_b010 ,_r4(RD) )
#define NOTLm(MD,MB,MI,MS) _O_r_X (0xf7 ,_b010 ,MD,MB,MI,MS )
#define ORBrr(RS, RD) _O_Mrm (0x08 ,_b11,_r1(RS),_r1(RD) )
#define ORBmr(MD, MB, MI, MS, RD) _O_r_X (0x0a ,_r1(RD) ,MD,MB,MI,MS )
#define ORBrm(RS, MD, MB, MI, MS) _O_r_X (0x08 ,_r1(RS) ,MD,MB,MI,MS )
#define ORBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b001 ,_r1(RD) ,_su8(IM))
#define ORBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b001 ,MD,MB,MI,MS ,_su8(IM))
#define ORWrr(RS, RD) _wO_Mrm (0x09 ,_b11,_r2(RS),_r2(RD) )
#define ORWmr(MD, MB, MI, MS, RD) _wO_r_X (0x0b ,_r2(RD) ,MD,MB,MI,MS )
#define ORWrm(RS, MD, MB, MI, MS) _wO_r_X (0x09 ,_r2(RS) ,MD,MB,MI,MS )
#define ORWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b001 ,_r2(RD) ,_su16(IM))
#define ORWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b001 ,MD,MB,MI,MS ,_su16(IM))
#define ORLrr(RS, RD) _O_Mrm (0x09 ,_b11,_r4(RS),_r4(RD) )
#define ORLmr(MD, MB, MI, MS, RD) _O_r_X (0x0b ,_r4(RD) ,MD,MB,MI,MS )
#define ORLrm(RS, MD, MB, MI, MS) _O_r_X (0x09 ,_r4(RS) ,MD,MB,MI,MS )
#define ORLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b001 ,_r4(RD) ,IM )
#define ORLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b001 ,MD,MB,MI,MS ,IM )
#define POPWr(RD) _wOr (0x58,_r2(RD) )
#define POPWm(MD,MB,MI,MS) _wO_r_X (0x8f ,_b000 ,MD,MB,MI,MS )
#define POPLr(RD) _Or (0x58,_r4(RD) )
#define POPLm(MD,MB,MI,MS) _O_r_X (0x8f ,_b000 ,MD,MB,MI,MS )
#define POPA() _wO (0x61 )
#define POPAD() _O (0x61 )
#define POPF() _wO (0x9d )
#define POPFD() _O (0x9d )
#define PUSHWr(R) _wOr (0x50,_r2(R) )
#define PUSHWm(MD,MB,MI,MS) _wO_r_X (0xff, ,_b110 ,MD,MB,MI,MS )
#define PUSHWi(IM) _wOs_sW (0x68 ,IM )
#define PUSHLr(R) _Or (0x50,_r4(R) )
#define PUSHLm(MD,MB,MI,MS) _O_r_X (0xff ,_b110 ,MD,MB,MI,MS )
#define PUSHLi(IM) _Os_sL (0x68 ,IM )
#define PUSHA() _wO (0x60 )
#define PUSHAD() _O (0x60 )
#define PUSHF() _O (0x9c )
#define PUSHFD() _wO (0x9c )
#define RET() _O (0xc3 )
#define RETi(IM) _O_W (0xc2 ,_su16(IM))
#define ROLBir(IM,RD) (((IM)==1) ? _O_Mrm (0xd0 ,_b11,_b000,_r1(RD) ) : \
_O_Mrm_B (0xc0 ,_b11,_b000,_r1(RD) ,_u8(IM) ) )
#define ROLBim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd0 ,_b000 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc0 ,_b000 ,MD,MB,MI,MS ,_u8(IM) ) )
#define ROLBrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd2 ,_b11,_b000,_r1(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define ROLBrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd2 ,_b000 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define ROLWir(IM,RD) (((IM)==1) ? _wO_Mrm (0xd1 ,_b11,_b000,_r2(RD) ) : \
_wO_Mrm_B (0xc1 ,_b11,_b000,_r2(RD) ,_u8(IM) ) )
#define ROLWim(IM,MD,MB,MS,MI) (((IM)==1) ? _wO_r_X (0xd1 ,_b000 ,MD,MB,MI,MS ) : \
_wO_r_X_B (0xc1 ,_b000 ,MD,MB,MI,MS ,_u8(IM) ) )
#define ROLWrr(RS,RD) (((RS)==_CL) ? _wO_Mrm (0xd3 ,_b11,_b000,_r2(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define ROLWrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _wO_r_X (0xd3 ,_b000 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define ROLLir(IM,RD) (((IM)==1) ? _O_Mrm (0xd1 ,_b11,_b000,_r4(RD) ) : \
_O_Mrm_B (0xc1 ,_b11,_b000,_r4(RD) ,_u8(IM) ) )
#define ROLLim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd1 ,_b000 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc1 ,_b000 ,MD,MB,MI,MS ,_u8(IM) ) )
#define ROLLrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd3 ,_b11,_b000,_r4(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define ROLLrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd3 ,_b000 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define RORBir(IM,RD) (((IM)==1) ? _O_Mrm (0xd0 ,_b11,_b001,_r1(RD) ) : \
_O_Mrm_B (0xc0 ,_b11,_b001,_r1(RD) ,_u8(IM) ) )
#define RORBim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd0 ,_b001 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc0 ,_b001 ,MD,MB,MI,MS ,_u8(IM) ) )
#define RORBrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd2 ,_b11,_b001,_r1(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define RORBrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd2 ,_b001 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define RORWir(IM,RD) (((IM)==1) ? _wO_Mrm (0xd1 ,_b11,_b001,_r2(RD) ) : \
_wO_Mrm_B (0xc1 ,_b11,_b001,_r2(RD) ,_u8(IM) ) )
#define RORWim(IM,MD,MB,MS,MI) (((IM)==1) ? _wO_r_X (0xd1 ,_b001 ,MD,MB,MI,MS ) : \
_wO_r_X_B (0xc1 ,_b001 ,MD,MB,MI,MS ,_u8(IM) ) )
#define RORWrr(RS,RD) (((RS)==_CL) ? _wO_Mrm (0xd3 ,_b11,_b001,_r2(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define RORWrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _wO_r_X (0xd3 ,_b001 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define RORLir(IM,RD) (((IM)==1) ? _O_Mrm (0xd1 ,_b11,_b001,_r4(RD) ) : \
_O_Mrm_B (0xc1 ,_b11,_b001,_r4(RD) ,_u8(IM) ) )
#define RORLim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd1 ,_b001 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc1 ,_b001 ,MD,MB,MI,MS ,_u8(IM) ) )
#define RORLrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd3 ,_b11,_b001,_r4(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define RORLrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd3 ,_b001 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SAHF() _O (0x9e )
#define SALBir SHLBir
#define SALBim SHLBim
#define SALBrr SHLBrr
#define SALBrm SHLBrm
#define SALWir SHLWir
#define SALWim SHLWim
#define SALWrr SHLWrr
#define SALWrm SHLWrm
#define SALLir SHLLir
#define SALLim SHLLim
#define SALLrr SHLLrr
#define SALLrm SHLLrm
#define SARBir(IM,RD) (((IM)==1) ? _O_Mrm (0xd0 ,_b11,_b111,_r1(RD) ) : \
_O_Mrm_B (0xc0 ,_b11,_b111,_r1(RD) ,_u8(IM) ) )
#define SARBim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd0 ,_b111 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc0 ,_b111 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SARBrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd2 ,_b11,_b111,_r1(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SARBrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd2 ,_b111 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SARWir(IM,RD) (((IM)==1) ? _wO_Mrm (0xd1 ,_b11,_b111,_r2(RD) ) : \
_wO_Mrm_B (0xc1 ,_b11,_b111,_r2(RD) ,_u8(IM) ) )
#define SARWim(IM,MD,MB,MS,MI) (((IM)==1) ? _wO_r_X (0xd1 ,_b111 ,MD,MB,MI,MS ) : \
_wO_r_X_B (0xc1 ,_b111 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SARWrr(RS,RD) (((RS)==_CL) ? _wO_Mrm (0xd3 ,_b11,_b111,_r2(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SARWrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _wO_r_X (0xd3 ,_b111 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SARLir(IM,RD) (((IM)==1) ? _O_Mrm (0xd1 ,_b11,_b111,_r4(RD) ) : \
_O_Mrm_B (0xc1 ,_b11,_b111,_r4(RD) ,_u8(IM) ) )
#define SARLim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd1 ,_b111 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc1 ,_b111 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SARLrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd3 ,_b11,_b111,_r4(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SARLrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd3 ,_b111 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SBBBrr(RS, RD) _O_Mrm (0x18 ,_b11,_r1(RS),_r1(RD) )
#define SBBBmr(MD, MB, MI, MS, RD) _O_r_X (0x1a ,_r1(RD) ,MD,MB,MI,MS )
#define SBBBrm(RS, MD, MB, MI, MS) _O_r_X (0x18 ,_r1(RS) ,MD,MB,MI,MS )
#define SBBBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b011 ,_r1(RD) ,_su8(IM))
#define SBBBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b011 ,MD,MB,MI,MS ,_su8(IM))
#define SBBWrr(RS, RD) _wO_Mrm (0x19 ,_b11,_r2(RS),_r2(RD) )
#define SBBWmr(MD, MB, MI, MS, RD) _wO_r_X (0x1b ,_r2(RD) ,MD,MB,MI,MS )
#define SBBWrm(RS, MD, MB, MI, MS) _wO_r_X (0x19 ,_r2(RS) ,MD,MB,MI,MS )
#define SBBWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b011 ,_r2(RD) ,_su16(IM))
#define SBBWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b011 ,MD,MB,MI,MS ,_su16(IM))
#define SBBLrr(RS, RD) _O_Mrm (0x19 ,_b11,_r4(RS),_r4(RD) )
#define SBBLmr(MD, MB, MI, MS, RD) _O_r_X (0x1b ,_r4(RD) ,MD,MB,MI,MS )
#define SBBLrm(RS, MD, MB, MI, MS) _O_r_X (0x19 ,_r4(RS) ,MD,MB,MI,MS )
#define SBBLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b011 ,_r4(RD) ,IM )
#define SBBLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b011 ,MD,MB,MI,MS ,IM )
#define SETCCir(CC,RD) _OO_Mrm (0x0f90|(CC) ,_b11,_b000,_r1(RD) )
#define SETOr(RD) SETCCir(0x0,RD)
#define SETNOr(RD) SETCCir(0x1,RD)
#define SETBr(RD) SETCCir(0x2,RD)
#define SETNAEr(RD) SETCCir(0x2,RD)
#define SETNBr(RD) SETCCir(0x3,RD)
#define SETAEr(RD) SETCCir(0x3,RD)
#define SETEr(RD) SETCCir(0x4,RD)
#define SETZr(RD) SETCCir(0x4,RD)
#define SETNEr(RD) SETCCir(0x5,RD)
#define SETNZr(RD) SETCCir(0x5,RD)
#define SETBEr(RD) SETCCir(0x6,RD)
#define SETNAr(RD) SETCCir(0x6,RD)
#define SETNBEr(RD) SETCCir(0x7,RD)
#define SETAr(RD) SETCCir(0x7,RD)
#define SETSr(RD) SETCCir(0x8,RD)
#define SETNSr(RD) SETCCir(0x9,RD)
#define SETPr(RD) SETCCir(0xa,RD)
#define SETPEr(RD) SETCCir(0xa,RD)
#define SETNPr(RD) SETCCir(0xb,RD)
#define SETPOr(RD) SETCCir(0xb,RD)
#define SETLr(RD) SETCCir(0xc,RD)
#define SETNGEr(RD) SETCCir(0xc,RD)
#define SETNLr(RD) SETCCir(0xd,RD)
#define SETGEr(RD) SETCCir(0xd,RD)
#define SETLEr(RD) SETCCir(0xe,RD)
#define SETNGr(RD) SETCCir(0xe,RD)
#define SETNLEr(RD) SETCCir(0xf,RD)
#define SETGr(RD) SETCCir(0xf,RD)
#define SETCCim(CC,MD,MB,MI,MS) _OO_r_X (0x0f90|(CC) ,_b000 ,MD,MB,MI,MS )
#define SETOm(D,B,I,S) SETCCim(0x0,D,B,I,S)
#define SETNOm(D,B,I,S) SETCCim(0x1,D,B,I,S)
#define SETBm(D,B,I,S) SETCCim(0x2,D,B,I,S)
#define SETNAEm(D,B,I,S) SETCCim(0x2,D,B,I,S)
#define SETNBm(D,B,I,S) SETCCim(0x3,D,B,I,S)
#define SETAEm(D,B,I,S) SETCCim(0x3,D,B,I,S)
#define SETEm(D,B,I,S) SETCCim(0x4,D,B,I,S)
#define SETZm(D,B,I,S) SETCCim(0x4,D,B,I,S)
#define SETNEm(D,B,I,S) SETCCim(0x5,D,B,I,S)
#define SETNZm(D,B,I,S) SETCCim(0x5,D,B,I,S)
#define SETBEm(D,B,I,S) SETCCim(0x6,D,B,I,S)
#define SETNAm(D,B,I,S) SETCCim(0x6,D,B,I,S)
#define SETNBEm(D,B,I,S) SETCCim(0x7,D,B,I,S)
#define SETAm(D,B,I,S) SETCCim(0x7,D,B,I,S)
#define SETSm(D,B,I,S) SETCCim(0x8,D,B,I,S)
#define SETNSm(D,B,I,S) SETCCim(0x9,D,B,I,S)
#define SETPm(D,B,I,S) SETCCim(0xa,D,B,I,S)
#define SETPEm(D,B,I,S) SETCCim(0xa,D,B,I,S)
#define SETNPm(D,B,I,S) SETCCim(0xb,D,B,I,S)
#define SETPOm(D,B,I,S) SETCCim(0xb,D,B,I,S)
#define SETLm(D,B,I,S) SETCCim(0xc,D,B,I,S)
#define SETNGEm(D,B,I,S) SETCCim(0xc,D,B,I,S)
#define SETNLm(D,B,I,S) SETCCim(0xd,D,B,I,S)
#define SETGEm(D,B,I,S) SETCCim(0xd,D,B,I,S)
#define SETLEm(D,B,I,S) SETCCim(0xe,D,B,I,S)
#define SETNGm(D,B,I,S) SETCCim(0xe,D,B,I,S)
#define SETNLEm(D,B,I,S) SETCCim(0xf,D,B,I,S)
#define SETGm(D,B,I,S) SETCCim(0xf,D,B,I,S)
#define SHLBir(IM,RD) (((IM)==1) ? _O_Mrm (0xd0 ,_b11,_b100,_r1(RD) ) : \
_O_Mrm_B (0xc0 ,_b11,_b100,_r1(RD) ,_u8(IM) ) )
#define SHLBim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd0 ,_b100 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc0 ,_b100 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHLBrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd2 ,_b11,_b100,_r1(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHLBrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd2 ,_b100 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SHLWir(IM,RD) (((IM)==1) ? _wO_Mrm (0xd1 ,_b11,_b100,_r2(RD) ) : \
_wO_Mrm_B (0xc1 ,_b11,_b100,_r2(RD) ,_u8(IM) ) )
#define SHLWim(IM,MD,MB,MS,MI) (((IM)==1) ? _wO_r_X (0xd1 ,_b100 ,MD,MB,MI,MS ) : \
_wO_r_X_B (0xc1 ,_b100 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHLWrr(RS,RD) (((RS)==_CL) ? _wO_Mrm (0xd3 ,_b11,_b100,_r2(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHLWrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _wO_r_X (0xd3 ,_b100 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SHLLir(IM,RD) (((IM)==1) ? _O_Mrm (0xd1 ,_b11,_b100,_r4(RD) ) : \
_O_Mrm_B (0xc1 ,_b11,_b100,_r4(RD) ,_u8(IM) ) )
#define SHLLim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd1 ,_b100 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc1 ,_b100 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHLLrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd3 ,_b11,_b100,_r4(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHLLrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd3 ,_b100 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SHRBir(IM,RD) (((IM)==1) ? _O_Mrm (0xd0 ,_b11,_b101,_r1(RD) ) : \
_O_Mrm_B (0xc0 ,_b11,_b101,_r1(RD) ,_u8(IM) ) )
#define SHRBim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd0 ,_b101 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc0 ,_b101 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHRBrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd2 ,_b11,_b101,_r1(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHRBrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd2 ,_b101 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SHRWir(IM,RD) (((IM)==1) ? _wO_Mrm (0xd1 ,_b11,_b101,_r2(RD) ) : \
_wO_Mrm_B (0xc1 ,_b11,_b101,_r2(RD) ,_u8(IM) ) )
#define SHRWim(IM,MD,MB,MS,MI) (((IM)==1) ? _wO_r_X (0xd1 ,_b101 ,MD,MB,MI,MS ) : \
_wO_r_X_B (0xc1 ,_b101 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHRWrr(RS,RD) (((RS)==_CL) ? _wO_Mrm (0xd3 ,_b11,_b101,_r2(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHRWrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _wO_r_X (0xd3 ,_b101 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define SHRLir(IM,RD) (((IM)==1) ? _O_Mrm (0xd1 ,_b11,_b101,_r4(RD) ) : \
_O_Mrm_B (0xc1 ,_b11,_b101,_r4(RD) ,_u8(IM) ) )
#define SHRLim(IM,MD,MB,MS,MI) (((IM)==1) ? _O_r_X (0xd1 ,_b101 ,MD,MB,MI,MS ) : \
_O_r_X_B (0xc1 ,_b101 ,MD,MB,MI,MS ,_u8(IM) ) )
#define SHRLrr(RS,RD) (((RS)==_CL) ? _O_Mrm (0xd3 ,_b11,_b101,_r4(RD) ) : \
JITFAIL ("source register must be CL" ) )
#define SHRLrm(RS,MD,MB,MS,MI) (((RS)==_CL) ? _O_r_X (0xd3 ,_b101 ,MD,MB,MI,MS ) : \
JITFAIL ("source register must be CL" ) )
#define STC() _O (0xf9 )
#define SUBBrr(RS, RD) _O_Mrm (0x28 ,_b11,_r1(RS),_r1(RD) )
#define SUBBmr(MD, MB, MI, MS, RD) _O_r_X (0x2a ,_r1(RD) ,MD,MB,MI,MS )
#define SUBBrm(RS, MD, MB, MI, MS) _O_r_X (0x28 ,_r1(RS) ,MD,MB,MI,MS )
#define SUBBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b101 ,_r1(RD) ,_su8(IM))
#define SUBBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b101 ,MD,MB,MI,MS ,_su8(IM))
#define SUBWrr(RS, RD) _wO_Mrm (0x29 ,_b11,_r2(RS),_r2(RD) )
#define SUBWmr(MD, MB, MI, MS, RD) _wO_r_X (0x2b ,_r2(RD) ,MD,MB,MI,MS )
#define SUBWrm(RS, MD, MB, MI, MS) _wO_r_X (0x29 ,_r2(RS) ,MD,MB,MI,MS )
#define SUBWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b101 ,_r2(RD) ,_su16(IM))
#define SUBWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b101 ,MD,MB,MI,MS ,_su16(IM))
#define SUBLrr(RS, RD) _O_Mrm (0x29 ,_b11,_r4(RS),_r4(RD) )
#define SUBLmr(MD, MB, MI, MS, RD) _O_r_X (0x2b ,_r4(RD) ,MD,MB,MI,MS )
#define SUBLrm(RS, MD, MB, MI, MS) _O_r_X (0x29 ,_r4(RS) ,MD,MB,MI,MS )
#define SUBLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b101 ,_r4(RD) ,IM )
#define SUBLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b101 ,MD,MB,MI,MS ,IM )
#define TESTBrr(RS, RD) _O_Mrm (0x84 ,_b11,_r1(RS),_r1(RD) )
#define TESTBrm(RS, MD, MB, MI, MS) _O_r_X (0x84 ,_r1(RS) ,MD,MB,MI,MS )
#define TESTBir(IM, RD) _O_Mrm_B (0xf6 ,_b11,_b000 ,_r1(RD) ,_u8(IM))
#define TESTBim(IM, MD, MB, MI, MS) _O_r_X_B (0xf6 ,_b000 ,MD,MB,MI,MS ,_u8(IM))
#define TESTWrr(RS, RD) _wO_Mrm (0x85 ,_b11,_r2(RS),_r2(RD) )
#define TESTWrm(RS, MD, MB, MI, MS) _wO_r_X (0x85 ,_r2(RS) ,MD,MB,MI,MS )
#define TESTWir(IM, RD) _wO_Mrm_W (0xf7 ,_b11,_b000 ,_r2(RD) ,_u16(IM))
#define TESTWim(IM, MD, MB, MI, MS) _wO_r_X_W (0xf7 ,_b000 ,MD,MB,MI,MS ,_u16(IM))
#define TESTLrr(RS, RD) _O_Mrm (0x85 ,_b11,_r4(RS),_r4(RD) )
#define TESTLrm(RS, MD, MB, MI, MS) _O_r_X (0x85 ,_r4(RS) ,MD,MB,MI,MS )
#define TESTLir(IM, RD) _O_Mrm_L (0xf7 ,_b11,_b000 ,_r4(RD) ,IM )
#define TESTLim(IM, MD, MB, MI, MS) _O_r_X_L (0xf7 ,_b000 ,MD,MB,MI,MS ,IM )
#define XADDBrr(RS,RD) _OO_Mrm (0x0fc0 ,_b11,_r1(RS),_r1(RD) )
#define XADDBrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fc0 ,_r1(RS) ,MD,MB,MI,MS )
#define XADDWrr(RS,RD) _wOO_Mrm (0x0fc1 ,_b11,_r2(RS),_r2(RD) )
#define XADDWrm(RS,MD,MB,MI,MS) _wOO_r_X (0x0fc1 ,_r2(RS) ,MD,MB,MI,MS )
#define XADDLrr(RS,RD) _OO_Mrm (0x0fc1 ,_b11,_r4(RS),_r4(RD) )
#define XADDLrm(RS,MD,MB,MI,MS) _OO_r_X (0x0fc1 ,_r4(RS) ,MD,MB,MI,MS )
#define XCHGBrr(RS,RD) _O_Mrm (0x86 ,_b11,_r1(RS),_r1(RD) )
#define XCHGBrm(RS,MD,MB,MI,MS) _O_r_X (0x86 ,_r1(RS) ,MD,MB,MI,MS )
#define XCHGWrr(RS,RD) _wO_Mrm (0x87 ,_b11,_r2(RS),_r2(RD) )
#define XCHGWrm(RS,MD,MB,MI,MS) _wO_r_X (0x87 ,_r2(RS) ,MD,MB,MI,MS )
#define XCHGLrr(RS,RD) _O_Mrm (0x87 ,_b11,_r4(RS),_r4(RD) )
#define XCHGLrm(RS,MD,MB,MI,MS) _O_r_X (0x87 ,_r4(RS) ,MD,MB,MI,MS )
#define XORBrr(RS, RD) _O_Mrm (0x30 ,_b11,_r1(RS),_r1(RD) )
#define XORBmr(MD, MB, MI, MS, RD) _O_r_X (0x32 ,_r1(RD) ,MD,MB,MI,MS )
#define XORBrm(RS, MD, MB, MI, MS) _O_r_X (0x30 ,_r1(RS) ,MD,MB,MI,MS )
#define XORBir(IM, RD) _O_Mrm_B (0x80 ,_b11,_b110 ,_r1(RD) ,_su8(IM))
#define XORBim(IM, MD, MB, MI, MS) _O_r_X_B (0x80 ,_b110 ,MD,MB,MI,MS ,_su8(IM))
#define XORWrr(RS, RD) _wO_Mrm (0x31 ,_b11,_r2(RS),_r2(RD) )
#define XORWmr(MD, MB, MI, MS, RD) _wO_r_X (0x33 ,_r2(RD) ,MD,MB,MI,MS )
#define XORWrm(RS, MD, MB, MI, MS) _wO_r_X (0x31 ,_r2(RS) ,MD,MB,MI,MS )
#define XORWir(IM, RD) _wOs_Mrm_sW (0x81 ,_b11,_b110 ,_r2(RD) ,_su16(IM))
#define XORWim(IM, MD, MB, MI, MS) _wOs_r_X_sW (0x81 ,_b110 ,MD,MB,MI,MS ,_su16(IM))
#define XORLrr(RS, RD) _O_Mrm (0x31 ,_b11,_r4(RS),_r4(RD) )
#define XORLmr(MD, MB, MI, MS, RD) _O_r_X (0x33 ,_r4(RD) ,MD,MB,MI,MS )
#define XORLrm(RS, MD, MB, MI, MS) _O_r_X (0x31 ,_r4(RS) ,MD,MB,MI,MS )
#define XORLir(IM, RD) _Os_Mrm_sL (0x81 ,_b11,_b110 ,_r4(RD) ,IM )
#define XORLim(IM, MD, MB, MI, MS) _Os_r_X_sL (0x81 ,_b110 ,MD,MB,MI,MS ,IM )
/* N byte NOPs */
#define _NOPi(N) ((( (N) >= 8) ? (_B(0x8d),_B(0xb4),_B(0x26),_L(0x00),_B(0x90)) : (void) 0), \
(( ((N)&7) == 7) ? (_B(0x8d),_B(0xb4),_B(0x26),_L(0x00)) : \
( ((N)&7) == 6) ? (_B(0x8d),_B(0xb6),_L(0x00)) : \
( ((N)&7) == 5) ? (_B(0x90),_B(0x8d),_B(0x74),_B(0x26),_B(0x00)) : \
/* leal 0(,%esi), %esi */ ( ((N)&7) == 4) ? (_B(0x8d),_B(0x74),_B(0x26),_B(0x00)) : \
/* leal (,%esi), %esi */ ( ((N)&7) == 3) ? (_B(0x8d),_B(0x76),_B(0x00)) : \
/* movl %esi, %esi */ ( ((N)&7) == 2) ? (_B(0x89),_B(0xf6)) : \
( ((N)&7) == 1) ? (_B(0x90)) : \
( ((N)&7) == 0) ? 0 : \
JITFAIL(".align argument too large")))
/*** References: */
/* */
/* [1] "Intel Architecture Software Developer's Manual Volume 1: Basic Architecture", */
/* Intel Corporation 1997. */
/* */
/* [2] "Intel Architecture Software Developer's Manual Volume 2: Instruction Set Reference", */
/* Intel Corporation 1997. */
#endif /* __lightning_asm_h */

View file

@ -1,421 +0,0 @@
/******************************** -*- 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
#define JIT_R0 _EAX
#define JIT_R1 _ECX
#define JIT_R2 _EDX
#define JIT_V0 _EBX
#define JIT_V1 _ESI
#define JIT_V2 _EDI
#define JIT_FP _EBP
#define JIT_SP _ESP
#define JIT_RET _EAX
struct jit_local_state {
int framesize;
int argssize;
};
/* 3-parameter operation */
#define jit_opr_(d, s1, s2, op1d, op2d) \
( (s2 == d) ? op1d : \
( ((s1 == d) ? (void)0 : (void)MOVLrr(s1, d)), op2d ) \
)
/* 3-parameter operation, with immediate */
#define jit_op_(d, s1, op2d) \
((s1 == d) ? op2d : (MOVLrr(s1, d), op2d)) \
/* 3-parameter operation, optimizable */
#define jit_opo_(d, s1, s2, op1d, op2d, op12d) \
((s2 == d) ? op2d : \
((s1 == d) ? op1d : op12d))
/* 3-parameter operation, optimizable, with immediate */
#define jit_opi_(d, rs, opdi, opdri) \
((rs == d) ? opdi : opdri)
/* An operand is forced into a register */
#define jit_replace(rd, rs, forced, op) \
((rd == forced) ? JITSORRY("Register conflict for " # op) : \
(rs == forced) ? op : (PUSHLr(forced), MOVLrr(rs, forced), op, POPLr(forced)))
/* For LT, LE, ... */
#define jit_bool_r(d, s1, s2, op) \
(CMPLrr(s2, s1), op, ANDLir(1, d))
#define jit_bool_i(d, rs, is, op) \
(CMPLir(is, rs), op, ANDLir(1, d))
/* When CMP with 0 can be replaced with TEST */
#define jit_bool_i0(d, rs, is, op, op0) \
( ((is) != 0 ? (CMPLir(is, rs), op) : (TESTLrr(rs, rs), op0)), \
ANDLir(1, d))
/* For BLT, BLE, ... */
#define jit_bra_r(s1, s2, op) (CMPLrr(s2, s1), op, _jit.pc)
#define jit_bra_i(rs, is, op) (CMPLir(is, rs), op, _jit.pc)
/* When CMP with 0 can be replaced with TEST */
#define jit_bra_i0(rs, is, op, op0) \
( (is) == 0 ? (TESTLrr(rs, rs), op0, _jit.pc) : (CMPLir(is, rs), op, _jit.pc))
/* Used to implement ldc, stc, ... */
#define jit_check8(rs) ( (rs) <= _EBX )
#define jit_reg8(rs) ( ((rs) & _BH) | _AL )
#define jit_reg16(rs) ( ((rs) & _BH) | _AX )
#define jit_movbmr(sd, sb, si, ss, d, ext) \
((jit_check8(d) \
? MOVBmr(sd, sb, si, ss, jit_reg8(d)) \
: MOVWmr(sd, sb, si, ss, jit_reg16(d))), ext)
/* In jit_replace below, _EBX is dummy */
#define jit_movbrm(rs, dd, db, di, ds) \
(jit_check8(rs) \
? MOVBrm(jit_reg8(rs), dd, db, di, ds) \
: jit_replace(_EBX, rs, _EAX, MOVBrm(_AL, dd, db, di, ds)))
/* Reduce arguments of XOR/OR/TEST */
#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))) : \
jit_reduce_(op##Lir(is, rs)) ))
/* Helper macros for MUL/DIV/IDIV */
#define jit_might(d, s1, op) \
((s1 == d) ? (void)0 : (void)op)
#define jit_mulr_ui_(s1, s2) jit_opr_(_EAX, s1, s2, MULLr(s1), MULLr(s2))
#define jit_mulr_i_(s1, s2) jit_opr_(_EAX, s1, s2, IMULLr(s1), IMULLr(s2))
#define jit_muli_i_(is, rs) \
(MOVLir(is, rs == _EAX ? _EDX : _EAX), \
IMULLr(rs == _EAX ? _EDX : rs))
#define jit_muli_ui_(is, rs) \
(MOVLir(is, rs == _EAX ? _EDX : _EAX), \
IMULLr(rs == _EAX ? _EDX : rs))
#define jit_divi_i_(result, d, rs, is) \
(jit_might (d, _EAX, PUSHLr(_EAX)), \
jit_might (d, _ECX, PUSHLr(_ECX)), \
jit_might (d, _EDX, PUSHLr(_EDX)), \
jit_might (rs, _EAX, MOVLrr(rs, _EAX)), \
jit_might (rs, _EDX, MOVLrr(rs, _EDX)), \
MOVLir(is, _ECX), \
SARLir(31, _EDX), \
IDIVLr(_ECX), \
jit_might(d, result, MOVLrr(result, d)), \
jit_might(d, _EDX, POPLr(_EDX)), \
jit_might(d, _ECX, POPLr(_ECX)), \
jit_might(d, _EAX, POPLr(_EAX)))
#define jit_divr_i_(result, d, s1, s2) \
(jit_might (d, _EAX, PUSHLr(_EAX)), \
jit_might (d, _ECX, PUSHLr(_ECX)), \
jit_might (d, _EDX, PUSHLr(_EDX)), \
((s1 == _ECX) ? PUSHLr(_ECX) : 0), \
jit_might (s2, _ECX, MOVLrr(s2, _ECX)), \
((s1 == _ECX) ? POPLr(_EDX) : \
jit_might (s1, _EDX, MOVLrr(s1, _EDX))), \
MOVLrr(_EDX, _EAX), \
SARLir(31, _EDX), \
IDIVLr(_ECX), \
jit_might(d, result, MOVLrr(result, d)), \
jit_might(d, _EDX, POPLr(_EDX)), \
jit_might(d, _ECX, POPLr(_ECX)), \
jit_might(d, _EAX, POPLr(_EAX)))
#define jit_divi_ui_(result, d, rs, is) \
(jit_might (d, _EAX, PUSHLr(_EAX)), \
jit_might (d, _ECX, PUSHLr(_ECX)), \
jit_might (d, _EDX, PUSHLr(_EDX)), \
jit_might (rs, _EAX, MOVLrr(rs, _EAX)), \
MOVLir(is, _ECX), \
XORLrr(_EDX, _EDX), \
DIVLr(_ECX), \
jit_might(d, result, MOVLrr(result, d)), \
jit_might(d, _EDX, POPLr(_EDX)), \
jit_might(d, _ECX, POPLr(_ECX)), \
jit_might(d, _EAX, POPLr(_EAX)))
#define jit_divr_ui_(result, d, s1, s2) \
(jit_might (d, _EAX, PUSHLr(_EAX)), \
jit_might (d, _ECX, PUSHLr(_ECX)), \
jit_might (d, _EDX, PUSHLr(_EDX)), \
((s1 == _ECX) ? PUSHLr(_ECX) : 0), \
jit_might (s2, _ECX, MOVLrr(s2, _ECX)), \
((s1 == _ECX) ? POPLr(_EAX) : \
jit_might (s1, _EAX, MOVLrr(s1, _EAX))), \
XORLrr(_EDX, _EDX), \
DIVLr(_ECX), \
jit_might(d, result, MOVLrr(result, d)), \
jit_might(d, _EDX, POPLr(_EDX)), \
jit_might(d, _ECX, POPLr(_ECX)), \
jit_might(d, _EAX, POPLr(_EAX)))
/* ALU */
#define jit_addi_i(d, rs, is) jit_opi_((d), (rs), ADDLir((is), (d)), LEALmr((is), (rs), 0, 0, (d)) )
#define jit_addr_i(d, s1, s2) jit_opo_((d), (s1), (s2), ADDLrr((s2), (d)), ADDLrr((s1), (d)), LEALmr(0, (s1), (s2), 1, (d)) )
#define jit_addci_i(d, rs, is) jit_op_ ((d), (rs), ADDLir((is), (d)) )
#define jit_addcr_i(d, s1, s2) jit_opr_((d), (s1), (s2), ADDLrr((s1), (d)), ADDLrr((s2), (d)) )
#define jit_addxi_i(d, rs, is) jit_op_ ((d), (rs), ADCLir((is), (d)) )
#define jit_addxr_i(d, s1, s2) jit_opr_((d), (s1), (s2), ADCLrr((s1), (d)), ADCLrr((s2), (d)) )
#define jit_andi_i(d, rs, is) jit_op_ ((d), (rs), ANDLir((is), (d)) )
#define jit_andr_i(d, s1, s2) jit_opr_((d), (s1), (s2), ANDLrr((s1), (d)), ANDLrr((s2), (d)) )
#define jit_orr_i(d, s1, s2) jit_opr_((d), (s1), (s2), ORLrr((s1), (d)), ORLrr((s2), (d)) )
#define jit_subr_i(d, s1, s2) jit_opr_((d), (s1), (s2), (SUBLrr((s1), (d)), NEGLr(d)), SUBLrr((s2), (d)) )
#define jit_subcr_i(d, s1, s2) jit_subr_i((d), (s1), (s2))
#define jit_subxr_i(d, s1, s2) jit_opr_((d), (s1), (s2), SBBLrr((s1), (d)), SBBLrr((s2), (d)) )
#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)) )
#define jit_muli_i(d, rs, is) jit_op_ ((d), (rs), IMULLir((is), (d)) )
#define jit_mulr_i(d, s1, s2) jit_opr_((d), (s1), (s2), IMULLrr((s1), (d)), IMULLrr((s2), (d)) )
#define jit_muli_ui(d, rs, is) jit_op_ ((d), (rs), IMULLir((is), (d)) )
#define jit_mulr_ui(d, s1, s2) jit_opr_((d), (s1), (s2), IMULLrr((s1), (d)), IMULLrr((s2), (d)) )
/* As far as low bits are concerned, signed and unsigned multiplies are
* exactly the same. */
#ifdef not_needed
#undef jit_muli_i
#undef jit_muli_ui
#define jit_muli_ui(d, rs, is) \
((d) == _EDX ? ( PUSHLr(_EAX), MOVLir((is), _EAX), MULLr(rs), MOVLrr(_EAX, _EDX), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), MOVLir((is), _EAX), MULLr(rs), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), MOVLir((is), _EAX), MULLr(rs), MOVLrr(_EAX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#define jit_mulr_ui(d, s1, s2) \
((d) == _EDX ? ( PUSHLr(_EAX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EAX, _EDX), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), jit_mulr_ui_((s1), (s2)), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EAX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#endif /* not_needed */
#define jit_hmuli_i(d, rs, is) \
((d) == _EDX ? ( PUSHLr(_EAX), jit_muli_i_((is), (rs)), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), jit_muli_i_((is), (rs)), MOVLrr(_EDX, _EAX), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), jit_muli_i_((is), (rs)), MOVLrr(_EDX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#define jit_hmulr_i(d, s1, s2) \
((d) == _EDX ? ( PUSHLr(_EAX), jit_mulr_i_((s1), (s2)), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), jit_mulr_i_((s1), (s2)), MOVLrr(_EDX, _EAX), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), jit_mulr_i_((s1), (s2)), MOVLrr(_EDX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#define jit_hmuli_ui(d, rs, is) \
((d) == _EDX ? ( PUSHLr(_EAX), jit_muli_ui_((is), (rs)), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), jit_muli_ui_((is), (rs)), MOVLrr(_EDX, _EAX), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), jit_muli_ui_((is), (rs)), MOVLrr(_EDX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#define jit_hmulr_ui(d, s1, s2) \
((d) == _EDX ? ( PUSHLr(_EAX), jit_mulr_ui_((s1), (s2)), POPLr(_EAX) ) : \
((d) == _EAX ? (PUSHLr(_EDX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EDX, _EAX), POPLr(_EDX) ) : \
(PUSHLr(_EDX), PUSHLr(_EAX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EDX, (d)), POPLr(_EAX), POPLr(_EDX) )))
#define jit_divi_i(d, rs, is) jit_divi_i_(_EAX, (d), (rs), (is))
#define jit_divi_ui(d, rs, is) jit_divi_ui_(_EAX, (d), (rs), (is))
#define jit_modi_i(d, rs, is) jit_divi_i_(_EDX, (d), (rs), (is))
#define jit_modi_ui(d, rs, is) jit_divi_ui_(_EDX, (d), (rs), (is))
#define jit_divr_i(d, s1, s2) jit_divr_i_(_EAX, (d), (s1), (s2))
#define jit_divr_ui(d, s1, s2) jit_divr_ui_(_EAX, (d), (s1), (s2))
#define jit_modr_i(d, s1, s2) jit_divr_i_(_EDX, (d), (s1), (s2))
#define jit_modr_ui(d, s1, s2) jit_divr_ui_(_EDX, (d), (s1), (s2))
/* Shifts */
#define jit_lshi_i(d, rs, is) ((is) <= 3 ? LEALmr(0, 0, (rs), 1 << (is), (d)) : jit_op_ ((d), (rs), SHLLir((is), (d)) ))
#define jit_rshi_i(d, rs, is) jit_op_ ((d), (rs), SARLir((is), (d)) )
#define jit_rshi_ui(d, rs, is) jit_op_ ((d), (rs), SHRLir((is), (d)) )
#define jit_lshr_i(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_op_ ((d), (r1), SHLLrr(_CL, (d)) ))
#define jit_rshr_i(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_op_ ((d), (r1), SARLrr(_CL, (d)) ))
#define jit_rshr_ui(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_op_ ((d), (r1), SHRLrr(_CL, (d)) ))
/* 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 jitfp_prepare(ni,nf,nd) ((void) (_jitl.argssize += (ni) + (nf) + 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_retval(rd) ((void) ( (rd) == _EAX ? 0 : MOVLrr(_EAX, (rd)) ))
#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_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) MOVLrr((rs), (d))
#define jit_movi_i(d, is) ((is) ? MOVLir((is), (d)) : XORLrr ((d), (d)) )
#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))
/* Boolean */
#define jit_ltr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETLr(jit_reg8(d)) )
#define jit_ler_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETLEr(jit_reg8(d)) )
#define jit_gtr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETGr(jit_reg8(d)) )
#define jit_ger_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETGEr(jit_reg8(d)) )
#define jit_eqr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETEr(jit_reg8(d)) )
#define jit_ner_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETNEr(jit_reg8(d)) )
#define jit_ltr_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETBr(jit_reg8(d)) )
#define jit_ler_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETBEr(jit_reg8(d)) )
#define jit_gtr_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETAr(jit_reg8(d)) )
#define jit_ger_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETAEr(jit_reg8(d)) )
#define jit_lti_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETLr(jit_reg8(d)), SETSr(jit_reg8(d)) )
#define jit_lei_i(d, rs, is) jit_bool_i ((d), (rs), (is), SETLEr(jit_reg8(d)) )
#define jit_gti_i(d, rs, is) jit_bool_i ((d), (rs), (is), SETGr(jit_reg8(d)) )
#define jit_gei_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETGEr(jit_reg8(d)), SETNSr(jit_reg8(d)) )
#define jit_eqi_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETEr(jit_reg8(d)), SETEr(jit_reg8(d)) )
#define jit_nei_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETNEr(jit_reg8(d)), SETNEr(jit_reg8(d)) )
#define jit_lti_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETBr(jit_reg8(d)), XORLrr((d), (d)) )
#define jit_lei_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETBEr(jit_reg8(d)), SETEr(jit_reg8(d)) )
#define jit_gti_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETAr(jit_reg8(d)), SETNEr(jit_reg8(d)) )
#define jit_gei_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETAEr(jit_reg8(d)), INCLr((d)) )
/* Jump */
#define jit_bltr_i(label, s1, s2) jit_bra_r((s1), (s2), JLm(label, 0,0,0) )
#define jit_bler_i(label, s1, s2) jit_bra_r((s1), (s2), JLEm(label,0,0,0) )
#define jit_bgtr_i(label, s1, s2) jit_bra_r((s1), (s2), JGm(label, 0,0,0) )
#define jit_bger_i(label, s1, s2) jit_bra_r((s1), (s2), JGEm(label,0,0,0) )
#define jit_beqr_i(label, s1, s2) jit_bra_r((s1), (s2), JEm(label, 0,0,0) )
#define jit_bner_i(label, s1, s2) jit_bra_r((s1), (s2), JNEm(label,0,0,0) )
#define jit_bltr_ui(label, s1, s2) jit_bra_r((s1), (s2), JBm(label, 0,0,0) )
#define jit_bler_ui(label, s1, s2) jit_bra_r((s1), (s2), JBEm(label,0,0,0) )
#define jit_bgtr_ui(label, s1, s2) jit_bra_r((s1), (s2), JAm(label, 0,0,0) )
#define jit_bger_ui(label, s1, s2) jit_bra_r((s1), (s2), JAEm(label,0,0,0) )
#define jit_bmsr_i(label, s1, s2) (TESTLrr((s1), (s2)), JNZm(label,0,0,0), _jit.pc)
#define jit_bmcr_i(label, s1, s2) (TESTLrr((s1), (s2)), JZm(label,0,0,0), _jit.pc)
#define jit_boaddr_i(label, s1, s2) (ADDLrr((s2), (s1)), JOm(label,0,0,0), _jit.pc)
#define jit_bosubr_i(label, s1, s2) (SUBLrr((s2), (s1)), JOm(label,0,0,0), _jit.pc)
#define jit_boaddr_ui(label, s1, s2) (ADDLrr((s2), (s1)), JCm(label,0,0,0), _jit.pc)
#define jit_bosubr_ui(label, s1, s2) (SUBLrr((s2), (s1)), JCm(label,0,0,0), _jit.pc)
#define jit_blti_i(label, rs, is) jit_bra_i0((rs), (is), JLm(label, 0,0,0), JSm(label, 0,0,0) )
#define jit_blei_i(label, rs, is) jit_bra_i ((rs), (is), JLEm(label,0,0,0) )
#define jit_bgti_i(label, rs, is) jit_bra_i ((rs), (is), JGm(label, 0,0,0) )
#define jit_bgei_i(label, rs, is) jit_bra_i0((rs), (is), JGEm(label,0,0,0), JNSm(label,0,0,0) )
#define jit_beqi_i(label, rs, is) jit_bra_i0((rs), (is), JEm(label, 0,0,0), JEm(label, 0,0,0) )
#define jit_bnei_i(label, rs, is) jit_bra_i0((rs), (is), JNEm(label,0,0,0), JNEm(label,0,0,0) )
#define jit_blti_ui(label, rs, is) jit_bra_i ((rs), (is), JLm(label, 0,0,0) )
#define jit_blei_ui(label, rs, is) jit_bra_i0((rs), (is), JLEm(label,0,0,0), JEm(label, 0,0,0) )
#define jit_bgti_ui(label, rs, is) jit_bra_i0((rs), (is), JGm(label, 0,0,0), JNEm(label,0,0,0) )
#define jit_bgei_ui(label, rs, is) jit_bra_i ((rs), (is), JGEm(label,0,0,0) )
#define jit_boaddi_i(label, rs, is) (ADDLir((is), (rs)), JOm(label,0,0,0), _jit.pc)
#define jit_bosubi_i(label, rs, is) (SUBLir((is), (rs)), JOm(label,0,0,0), _jit.pc)
#define jit_boaddi_ui(label, rs, is) (ADDLir((is), (rs)), JCm(label,0,0,0), _jit.pc)
#define jit_bosubi_ui(label, rs, is) (SUBLir((is), (rs)), JCm(label,0,0,0), _jit.pc)
#define jit_bmsi_i(label, rs, is) (jit_reduce(TEST, (is), (rs)), JNZm(label,0,0,0), _jit.pc)
#define jit_bmci_i(label, rs, is) (jit_reduce(TEST, (is), (rs)), JZm(label,0,0,0), _jit.pc)
#define jit_jmpi(label) (JMPm( ((unsigned long) (label)), 0, 0, 0), _jit.pc)
#define jit_calli(label) (CALLm( ((unsigned long) (label)), 0, 0, 0), _jit.pc)
#define jit_jmpr(reg) JMPsr(reg)
#define jit_patch(jump_pc) (*_PSL((jump_pc) - 4) = _SL(_jit.pc - (jump_pc)))
#define jit_ret() (POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), POPLr(_EBP), RET())
/* Memory */
#define jit_ldi_c(d, is) jit_movbmr((is), 0, 0, 0, (d), jit_extr_c_i((d), (d)))
#define jit_ldr_c(d, rs) jit_movbmr(0, (rs), 0, 0, (d), jit_extr_c_i((d), (d)))
#define jit_ldxr_c(d, s1, s2) jit_movbmr(0, (s1), (s2), 1, (d), jit_extr_c_i((d), (d)))
#define jit_ldxi_c(d, rs, is) jit_movbmr((is), (rs), 0, 0, (d), jit_extr_c_i((d), (d)))
#define jit_ldi_uc(d, is) jit_movbmr((is), 0, 0, 0, (d), jit_extr_uc_ui((d), (d)))
#define jit_ldr_uc(d, rs) jit_movbmr(0, (rs), 0, 0, (d), jit_extr_uc_ui((d), (d)))
#define jit_ldxr_uc(d, s1, s2) jit_movbmr(0, (s1), (s2), 1, (d), jit_extr_uc_ui((d), (d)))
#define jit_ldxi_uc(d, rs, is) jit_movbmr((is), (rs), 0, 0, (d), jit_extr_uc_ui((d), (d)))
#define jit_sti_c(id, rs) jit_movbrm((rs), (id), 0, 0, 0)
#define jit_str_c(rd, rs) jit_movbrm((rs), 0, (rd), 0, 0)
#define jit_stxr_c(d1, d2, rs) jit_movbrm((rs), 0, (d1), (d2), 1)
#define jit_stxi_c(id, rd, rs) jit_movbrm((rs), (id), (rd), 0, 0)
#define jit_ldi_s(d, is) (MOVWmr((is), 0, 0, 0, jit_reg16(d)), jit_extr_s_i((d), (d)))
#define jit_ldr_s(d, rs) (MOVWmr(0, (rs), 0, 0, jit_reg16(d)), jit_extr_s_i((d), (d)))
#define jit_ldxr_s(d, s1, s2) (MOVWmr(0, (s1), (s2), 1, jit_reg16(d)), jit_extr_s_i((d), (d)))
#define jit_ldxi_s(d, rs, is) (MOVWmr((is), (rs), 0, 0, jit_reg16(d)), jit_extr_s_i((d), (d)))
#define jit_ldi_us(d, is) (XORLrr((d), (d)), MOVWmr((is), 0, 0, 0, jit_reg16(d)))
#define jit_ldr_us(d, rs) (XORLrr((d), (d)), MOVWmr(0, (rs), 0, 0, jit_reg16(d)))
#define jit_ldxr_us(d, s1, s2) (XORLrr((d), (d)), MOVWmr(0, (s1), (s2), 1, jit_reg16(d)))
#define jit_ldxi_us(d, rs, is) (XORLrr((d), (d)), MOVWmr((is), (rs), 0, 0, jit_reg16(d)))
#define jit_sti_s(id, rs) MOVWrm(jit_reg16(rs), (id), 0, 0, 0)
#define jit_str_s(rd, rs) MOVWrm(jit_reg16(rs), 0, (rd), 0, 0)
#define jit_stxr_s(d1, d2, rs) MOVWrm(jit_reg16(rs), 0, (d1), (d2), 1)
#define jit_stxi_s(id, rd, rs) MOVWrm(jit_reg16(rs), (id), (rd), 0, 0)
#define jit_ldi_i(d, is) MOVLmr((is), 0, 0, 0, (d))
#define jit_ldr_i(d, rs) MOVLmr(0, (rs), 0, 0, (d))
#define jit_ldxr_i(d, s1, s2) MOVLmr(0, (s1), (s2), 1, (d))
#define jit_ldxi_i(d, rs, is) MOVLmr((is), (rs), 0, 0, (d))
#define jit_sti_i(id, rs) MOVLrm((rs), (id), 0, 0, 0)
#define jit_str_i(rd, rs) MOVLrm((rs), 0, (rd), 0, 0)
#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(_UL(_jit.pc), (n)))
#endif /* __lightning_core_h */

View file

@ -1,205 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler & support macros for the i386 math coprocessor
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_asm_fp_h
#define __lightning_asm_fp_h
#define ESCmi(D,B,I,S,OP) _O_r_X(0xd8|(OP & 7), (OP >> 3), D,B,I,S)
#define FLDSm(D,B,I,S) ESCmi(D,B,I,S,001) /* fld m32real */
#define FILDLm(D,B,I,S) ESCmi(D,B,I,S,003) /* fild m32int */
#define FLDLm(D,B,I,S) ESCmi(D,B,I,S,005) /* fld m64real */
#define FILDWm(D,B,I,S) ESCmi(D,B,I,S,007) /* fild m16int */
#define FSTSm(D,B,I,S) ESCmi(D,B,I,S,021) /* fst m32real */
#define FISTLm(D,B,I,S) ESCmi(D,B,I,S,023) /* fist m32int */
#define FSTLm(D,B,I,S) ESCmi(D,B,I,S,025) /* fst m64real */
#define FISTWm(D,B,I,S) ESCmi(D,B,I,S,027) /* fist m16int */
#define FSTPSm(D,B,I,S) ESCmi(D,B,I,S,031) /* fstp m32real */
#define FISTPLm(D,B,I,S) ESCmi(D,B,I,S,033) /* fistp m32int */
#define FSTPLm(D,B,I,S) ESCmi(D,B,I,S,035) /* fstp m64real */
#define FISTPWm(D,B,I,S) ESCmi(D,B,I,S,037) /* fistp m16int */
#define FLDTm(D,B,I,S) ESCmi(D,B,I,S,053) /* fld m80real */
#define FILDQm(D,B,I,S) ESCmi(D,B,I,S,057) /* fild m64int */
#define FSTPTm(D,B,I,S) ESCmi(D,B,I,S,073) /* fstp m80real */
#define FISTPQm(D,B,I,S) ESCmi(D,B,I,S,077) /* fistp m64int */
#define jit_add_two(reg0) _OO(0xdec1) /* faddp */
#define jit_sub_two(reg0) _OO(0xdee9) /* fsubp */
#define jit_mul_two(reg0) _OO(0xdec9) /* fmulp */
#define jit_div_two(reg0) _OO(0xdef9) /* fdivp */
#define jit_abs(reg0) _OO(0xd9e1) /* fabs */
#define jit_sqr(reg0) _OO(0xdcc8) /* fmul st */
#define jit_sqrt(reg0) _OO(0xd9fa) /* fsqrt */
#define jit_exti_d(reg0, rs) (PUSHLr((rs)), FILDLm(0, _ESP, 0, 0), POPLr((rs)))
#define jit_neg(reg0) _OO(0xd9e0) /* fchs */
#define jit_ldxr_f(reg0, s1, s2) FLDSm(0, (s1), (s2), 1)
#define jit_ldxi_f(reg0, rs, is) FLDSm((is), (rs), 0, 0)
#define jit_ldxr_f(reg0, s1, s2) FLDSm(0, (s1), (s2), 1)
#define jit_ldxi_d(reg0, rs, is) FLDLm((is), (rs), 0, 0)
#define jit_ldxr_d(reg0, s1, s2) FLDLm(0, (s1), (s2), 1)
#define jit_ldi_f(reg0, is) FLDSm((is), 0, 0, 0)
#define jit_ldr_f(reg0, rs) FLDSm(0, (rs), 0, 0)
#define jit_ldi_d(reg0, is) FLDLm((is), 0, 0, 0)
#define jit_ldr_d(reg0, rs) FLDLm(0, (rs), 0, 0)
#define jit_stxi_f(id, rd, reg0) FSTPSm((id), (rd), 0, 0)
#define jit_stxr_f(d1, d2, reg0) FSTPSm(0, (d1), (d2), 1)
#define jit_stxi_d(id, rd, reg0) FSTPLm((id), (rd), 0, 0)
#define jit_stxr_d(d1, d2, reg0) FSTPLm(0, (d1), (d2), 1)
#define jit_sti_f(id, reg0) FSTPSm((id), 0, 0, 0)
#define jit_str_f(rd, reg0) FSTPSm(0, (rd), 0, 0)
#define jit_sti_d(id, reg0) FSTPLm((id), 0, 0, 0)
#define jit_str_d(rd, reg0) FSTPLm(0, (rd), 0, 0)
#define jit_fpimm(reg0, first, second) \
(PUSHLi(second), \
PUSHLi(first), \
FLDLm(0, _ESP, 0, 0), \
ADDLir(8, _ESP))
/* Assume round to near mode */
#define jit_floor(rd, reg0) \
jit_floor2((rd), ((rd) == _EDX ? _EAX : _EDX))
#define jit_ceil(rd, reg0) \
jit_ceil2((rd), ((rd) == _EDX ? _EAX : _EDX))
#define jit_trunc(rd, reg0) \
jit_trunc2((rd), ((rd) == _EDX ? _EAX : _EDX))
#define jit_calc_diff(ofs) \
FISTLm(ofs, _ESP, 0, 0), \
FILDLm(ofs, _ESP, 0, 0), \
_OO(0xdee9), /* fsubp */ \
FSTPSm(4+ofs, _ESP, 0, 0) \
/* The real meat */
#define jit_floor2(rd, aux) \
(PUSHLr(aux), \
SUBLir(8, _ESP), \
jit_calc_diff(0), \
POPLr(rd), /* floor in rd */ \
POPLr(aux), /* x-round(x) in aux */ \
ADDLir(0x7FFFFFFF, aux), /* carry if x-round(x) < -0 */ \
SBBLir(0, rd), /* subtract 1 if carry */ \
POPLr(aux))
#define jit_ceil2(rd, aux) \
(PUSHLr(aux), \
SUBLir(8, _ESP), \
jit_calc_diff(0), \
POPLr(rd), /* floor in rd */ \
POPLr(aux), /* x-round(x) in aux */ \
TESTLrr(aux, aux), \
SETGr(jit_reg8(aux)), \
SHRLir(1, aux), \
ADCLir(0, rd), \
POPLr(aux))
/* a mingling of the two above */
#define jit_trunc2(rd, aux) \
(PUSHLr(aux), \
SUBLir(12, _ESP), \
FSTSm(0, _ESP, 0, 0), \
jit_calc_diff(4), \
POPLr(aux), \
POPLr(rd), \
TESTLrr(aux, aux), \
POPLr(aux), \
JSSm(_jit.pc + 11, 0, 0, 0), \
ADDLir(0x7FFFFFFF, aux), /* 6 */ \
SBBLir(0, rd), /* 3 */ \
JMPSm(_jit.pc + 10, 0, 0, 0), /* 2 */ \
TESTLrr(aux, aux), /* 2 */ \
SETGr(jit_reg8(aux)), /* 3 */ \
SHRLir(1, aux), /* 2 */ \
ADCLir(0, rd), /* 3 */ \
POPLr(aux))
/* the easy one */
#define jit_round(rd, reg0) \
(PUSHLr(_EAX), \
FISTPLm(0, _ESP, 0, 0), \
POPLr((rd)))
#define jit_cmp(le, ge, reg0) ( \
((le) == _EAX || (ge) == _EAX ? 0 : PUSHLr(_EAX)), \
_OO(0xd8d0), /* fcom st(0) */ \
_d16(), _OO(0xdfe0), /* fnstsw ax */ \
TESTBir(0x40, _AH), \
MOVBir(0, ((le) & 15) | 0x10), \
MOVBir(0, ((ge) & 15) | 0x10), \
JZSm(_jit.pc + 12, 0, 0, 0), \
_OO(0xd9e4), /* ftst */ /* 2 */ \
_d16(), _OO(0xdfe0), /* fnstsw ax */ /* 3 */ \
SAHF(), /* 1 */ \
SETLEr( ((le) & 15) | 0x10), /* 3 */ \
SETGEr( ((ge) & 15) | 0x10), /* 3 */ \
ANDLir( 1, (le)), \
ANDLir( 1, (ge)), \
((le) == _EAX || (ge) == _EAX ? 0 : POPLr(_EAX)) )
#define jitfp_getarg_f(ofs) jitfp_ldxi_f(JIT_FP,(ofs))
#define jitfp_getarg_d(ofs) jitfp_ldxi_d(JIT_FP,(ofs))
#define jitfp_pusharg_d(op1) (jit_subi_i(JIT_SP,JIT_SP,sizeof(double)), jitfp_str_d(JIT_SP,(op1)))
#define jitfp_pusharg_f(op1) (jit_subi_i(JIT_SP,JIT_SP,sizeof(float)), jitfp_str_f(JIT_SP,(op1)))
#define jitfp_retval(op1) _jit_emit(&_jit, (op1), JIT_NULL, 0, 0, 0)
#ifdef JIT_TRANSCENDENTAL
#define jit_sin(reg0) _OO(0xd9fe) /* fsin */
#define jit_cos(reg0) _OO(0xd9ff) /* fcos */
#define jit_tan(reg0) (_OO(0xd9f2), /* fptan */ \
_OO(0xddd8)) /* fstp st */
#define jit_atn(reg0) (_OO(0xd9e8), /* fld1 */ \
_OO(0xd9f3)) /* fpatan */
#define jit_exp(reg0) (_OO(0xd9ea), /* fldl2e */ \
_OO(0xdec9), /* fmulp */ \
_OO(0xd9c0), /* fld st */ \
_OO(0xd9fc), /* frndint */ \
_OO(0xdce9), /* fsubr */ \
_OO(0xd9c9), /* fxch st(1) */ \
_OO(0xd9f0), /* f2xm1 */ \
_OO(0xd9e8), /* fld1 */ \
_OO(0xdec1), /* faddp */ \
_OO(0xd9fd), /* fscale */ \
_OO(0xddd9)) /* fstp st(1) */
#define jit_log(reg0) (_OO(0xd9ed), /* fldln2 */ \
_OO(0xd9c9), /* fxch st(1) */ \
_OO(0xd9f1)) /* fyl2x */
#endif
#endif /* __lightning_asm_h */

View file

@ -1,39 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer inline functions (i386)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_funcs_h
#define __lightning_funcs_h
#define jit_flush_code(dest, end)
#endif /* __lightning_funcs_h */

View file

@ -1,65 +0,0 @@
/******************************** -*- C -*- ****************************
*
* lightning main include file
*
***********************************************************************/
/***********************************************************************
*
* 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 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_h
#define __lightning_h
#ifdef __cplusplus
extern "C" {
#endif
#include <lightning/asm-common.h>
#include <lightning/funcs-common.h>
#ifndef LIGHTNING_DEBUG
#include <lightning/asm.h>
#endif
#include <lightning/core.h>
#include <lightning/core-common.h>
#include <lightning/funcs.h>
#include <lightning/fp.h>
#ifdef jit_cmp
#include <lightning/fp-common.h>
#endif
#ifndef JIT_R0
#error GNU lightning does not support the current target
#endif
#ifdef __cplusplus
}
#endif
#endif /* __lightning_h */

View file

@ -1,597 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler for the PowerPC
*
***********************************************************************/
/***********************************************************************
*
* Copyright 1999, 2000, 2001, 2002 Ian Piumarta
*
* 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
/* <imm> = [0-9]+ | (.+) -> add i, one parameter (imm)
* <reg> = r<imm> -> add r, one parameter (imm)
* <mem> = <imm>(<reg>) -> add m, two parameters (imm,reg)
* <idx> = <reg>(<reg>) -> add x, two parameters (reg,reg)
*
* `x' operands have two forms. For example `stwu source, rega(regb)'
* could be written as either
* STWUrx(source, rega, regb)
* or
* STWUXrrr(source, rega, regb)
*/
/*** a brief NOTE about halfwords and "shifted" operands
*
* LOGICAL insns require UNSIGNED args in 0..65535, whether or not shifted
*
* ARITHMETIC insns require SIGNED args in -32768..32767, even when shifted
*
* as a special case: "lis/addis" also accepts UNSIGNED arguments in
* 0..65535 since it is often used immediately before "ori" to load a 32-bit
* constant (this is consistent with the GNU rs/6000 and PowerPC assemblers)
*
* thus: lis rD, expression@hi
* ori rD, rD, expression@lo ; load 32-bit constant
*/
typedef unsigned int jit_insn;
#define _cr0 0
#define _cr1 1
#define _cr2 2
#define _cr3 3
#define _cr4 4
#define _cr5 5
#define _cr6 6
#define _cr7 7
#define _lt 0
#define _gt 1
#define _eq 2
#define _so 3
#define _un 3
#define _d16(D) (_ck_d(16,(_UL(D)-_UL(_jit.pc))) & ~3)
#define _d26(D) (_ck_d(26,(_UL(D)-_UL(_jit.pc))) & ~3)
/* primitive instruction forms [1, Section A.4] */
#define _FB( OP, BD,AA,LK ) _I((_u6(OP)<<26)| _d26(BD)| (_u1(AA)<<1)|_u1(LK))
#define _FBA( OP, BD,AA,LK ) _I((_u6(OP)<<26)| (_u26(BD)&~3)| (_u1(AA)<<1)|_u1(LK))
#define _BB( OP,BO,BI, BD,AA,LK ) _I((_u6(OP)<<26)|(_u5(BO)<<21)|(_u5(BI)<<16)| _d16(BD)| (_u1(AA)<<1)|_u1(LK))
#define _D( OP,RD,RA, DD ) _I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _s16(DD) )
#define _Du( OP,RD,RA, DD ) _I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _u16(DD) )
#define _Ds( OP,RD,RA, DD ) _I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _su16(DD) )
#define _X( OP,RD,RA,RB, XO,RC ) _I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)|( _u5(RB)<<11)| (_u10(XO)<<1)|_u1(RC))
#define _XL( OP,BO,BI, XO,LK ) _I((_u6(OP)<<26)|(_u5(BO)<<21)|(_u5(BI)<<16)|( _u5(00)<<11)| (_u10(XO)<<1)|_u1(LK))
#define _XFX( OP,RD, SR,XO ) _I((_u6(OP)<<26)|(_u5(RD)<<21)| (_u10(SR)<<11)| (_u10(XO)<<1)|_u1(00))
#define _XO( OP,RD,RA,RB,OE,XO,RC ) _I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)|( _u5(RB)<<11)|(_u1(OE)<<10)|( _u9(XO)<<1)|_u1(RC))
#define _M( OP,RS,RA,SH,MB,ME,RC ) _I((_u6(OP)<<26)|(_u5(RS)<<21)|(_u5(RA)<<16)|( _u5(SH)<<11)|(_u5(MB)<< 6)|( _u5(ME)<<1)|_u1(RC))
/* special purpose registers (form XFX) [1, Section 8.2, page 8-138] */
#define SPR_LR ((8<<5)|(0))
/* +++ intrinsic instructions */
#define ADDrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 266, 0)
#define ADD_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 266, 1)
#define ADDCrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 10, 0)
#define ADDC_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 10, 1)
#define ADDErrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 138, 0)
#define ADDE_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 138, 1)
#define ADDOrrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 266, 0)
#define ADDO_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 266, 1)
#define ADDIrri(RD, RA, IMM) _D (14, RD, RA, IMM)
#define ADDICrri(RD, RA, IMM) _D (12, RD, RA, IMM)
#define ADDIC_rri(RD, RA, IMM) _D (13, RD, RA, IMM)
#define ADDISrri(RD, RA, IMM) _Ds (15, RD, RA, IMM)
#define ANDrrr(RA, RS, RB) _X (31, RS, RA, RB, 28, 0)
#define AND_rrr(RA, RS, RB) _X (31, RS, RA, RB, 28, 1)
#define ANDCrrr(RA, RS, RB) _X (31, RS, RA, RB, 60, 0)
#define ANDC_rrr(RA, RS, RB) _X (31, RS, RA, RB, 60, 1)
#define ANDI_rri(RA, RS, IMM) _Du (28, RS, RA, IMM)
#define ANDIS_rri(RA, RS, IMM) _Du (29, RS, RA, IMM)
#define Bi(BD) _FB (18, BD, 0, 0)
#define BAi(BD) _FBA (18, BD, 1, 0)
#define BLi(BD) _FB (18, BD, 0, 1)
#define BLAi(BD) _FBA (18, BD, 1, 1)
#define BCiii(BO,BI,BD) _BB (16, BO, BI, BD, 0, 0)
#define BCAiii(BO,BI,BD) _BB (16, BO, BI, BD, 1, 0)
#define BCLiii(BO,BI,BD) _BB (16, BO, BI, BD, 0, 1)
#define BCLAiii(BO,BI,BD) _BB (16, BO, BI, BD, 1, 1)
#define BCCTRii(BO,BI) _XL (19, BO, BI, 528, 0)
#define BCCTRLii(BO,BI) _XL (19, BO, BI, 528, 1)
#define BCLRii(BO,BI) _XL (19, BO, BI, 16, 0)
#define BCLRLii(BO,BI) _XL (19, BO, BI, 16, 1)
#define CMPiirr(CR, LL, RA, RB) _X (31, ((CR)<<2)|(LL), RA, RB, 0, 0)
#define CMPIiiri(CR, LL, RA, IMM) _D (11, ((CR)<<2)|(LL), RA, IMM)
#define CMPLiirr(CR, LL, RA, RB) _X (31, ((CR)<<2)|(LL), RA, RB, 32, 0)
#define CMPLIiiri(CR, LL, RA, IMM) _D (10, ((CR)<<2)|(LL), RA, IMM)
#define CRANDiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 257, 0)
#define CRANDCiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 129, 0)
#define CREQViii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 289, 0)
#define CRNANDiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 225, 0)
#define CRNORiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 33, 0)
#define CRORiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 449, 0)
#define CRORCiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 417, 0)
#define CRXORiii(CRD,CRA,CRB) _X (19, CRD, CRA, CRB, 193, 0)
#define DCBSTrr(RA,RB) _X (31, 00, RA, RB, 54, 0)
#define DIVWrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 491, 0)
#define DIVW_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 491, 1)
#define DIVWOrrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 491, 0)
#define DIVWO_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 491, 1)
#define DIVWUrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 459, 0)
#define DIVWU_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 459, 1)
#define DIVWUOrrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 459, 0)
#define DIVWUO_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 459, 1)
#define EQVrrr(Ra,RS,RB) _X (31, RS, RA, RB, 284, 0)
#define EQV_rrr(Ra,RS,RB) _X (31, RS, RA, RB, 284, 1)
#define EXTSBrr(RA,RS) _X (31, RS, RA, 0, 954, 0)
#define EXTSB_rr(RA,RS) _X (31, RS, RA, 0, 954, 1)
#define EXTSHrr(RA,RS) _X (31, RS, RA, 0, 922, 0)
#define EXTSH_rr(RA,RS) _X (31, RS, RA, 0, 922, 1)
#define ICBIrr(RA,RB) _X (31, 00, RA, RB, 982, 0)
#define ISYNC() _X (19, 00, 00, 00, 150, 0)
#define LBZrm(RD,ID,RA) _D (34, RD, RA, ID)
#define LBZUrm(RD,ID,RA) _D (35, RD, RA, ID)
#define LBZUXrrr(RD,RA,RB) _X (31, RD, RA, RB, 119, 0)
#define LBZXrrr(RD,RA,RB) _X (31, RD, RA, RB, 87, 0)
#define LHArm(RD,ID,RA) _D (42, RD, RA, ID)
#define LHAUrm(RD,ID,RA) _D (43, RD, RA, ID)
#define LHAUXrrr(RD,RA,RB) _X (31, RD, RA, RB, 375, 0)
#define LHAXrrr(RD,RA,RB) _X (31, RD, RA, RB, 343, 0)
#define LHBRXrrr(RD,RA,RB) _X (31, RD, RA, RB, 790, 0)
#define LHZrm(RD,ID,RA) _D (40, RD, RA, ID)
#define LHZUrm(RD,ID,RA) _D (41, RD, RA, ID)
#define LHZUXrrr(RD,RA,RB) _X (31, RD, RA, RB, 311, 0)
#define LHZXrrr(RD,RA,RB) _X (31, RD, RA, RB, 279, 0)
#define LMWrm(RD,ID,RA) _D (46, RD, RA, ID)
#define LWBRXrrr(RD,RA,RB) _X (31, RD, RA, RB, 534, 0)
#define LWZrm(RD, DISP, RA) _D (32, RD, RA, DISP)
#define LWZUrm(RD, DISP, RA) _D (33, RD, RA, DISP)
#define LWZUXrrr(RD, RA, RB) _X (31, RD, RA, RB, 56, 0)
#define LWZXrrr(RD, RA, RB) _X (31, RD, RA, RB, 23, 0)
#define MCRFii(CD,CS) _X (19, ((CD)<<2), ((CS)<<2), 0, 0, 0)
#define MFCRr(RD) _X (31, RD, 0, 0, 19, 0)
#define MCRXRi(RD) _XFX (31, (RD)<<2, 0, 512)
#define MFSPRri(RD, SPR) _XFX (31, RD, (SPR)<<5, 339)
#define MTSPRir(SPR, RS) _XFX (31, RS, (SPR)<<5, 467)
#define MULHWrrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 75, 0)
#define MULHW_rrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 75, 1)
#define MULHWUrrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 11, 0)
#define MULHWU_rrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 11, 1)
#define MULLIrri(RD,RA,IM) _D (07, RD, RA, IM)
#define MULLWrrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 235, 0)
#define MULLW_rrr(RD,RA,RB) _XO (31, RD, RA, RB, 0, 235, 1)
#define MULLWOrrr(RD,RA,RB) _XO (31, RD, RA, RB, 1, 235, 0)
#define MULLWO_rrr(RD,RA,RB) _XO (31, RD, RA, RB, 1, 235, 1)
#define NANDrrr(RA,RS,RB) _X (31, RS, RA, RB, 476, 0)
#define NAND_rrr(RA,RS,RB) _X (31, RS, RA, RB, 476, 1)
#define NEGrr(RD,RA) _XO (31, RD, RA, 0, 0, 104, 0)
#define NEG_rr(RD,RA) _XO (31, RD, RA, 0, 0, 104, 1)
#define NEGOrr(RD,RA) _XO (31, RD, RA, 0, 1, 104, 0)
#define NEGO_rr(RD,RA) _XO (31, RD, RA, 0, 1, 104, 1)
#define NORrrr(RA,RS,RB) _X (31, RS, RA, RB, 124, 0)
#define NOR_rrr(RA,RS,RB) _X (31, RS, RA, RB, 124, 1)
#define ORrrr(RA,RS,RB) _X (31, RS, RA, RB, 444, 0)
#define OR_rrr(RA,RS,RB) _X (31, RS, RA, RB, 444, 1)
#define ORCrrr(RA,RS,RB) _X (31, RS, RA, RB, 412, 0)
#define ORC_rrr(RA,RS,RB) _X (31, RS, RA, RB, 412, 1)
#define ORIrri(RA,RS,IM) _Du (24, RS, RA, IM)
#define ORISrri(RA,RS,IM) _Du (25, RS, RA, IM)
#define RLWIMIrriii(RA,RS,SH,MB,ME) _M (20, RS, RA, SH, MB, ME, 0)
#define RLWIMI_rriii(RA,RS,SH,MB,ME) _M (20, RS, RA, SH, MB, ME, 1)
#define RLWINMrriii(RA,RS,SH,MB,ME) _M (21, RS, RA, SH, MB, ME, 0)
#define RLWINM_rriii(RA,RS,SH,MB,ME) _M (21, RS, RA, SH, MB, ME, 1)
#define RLWNMrrrii(RA,RS,RB,MB,ME) _M (23, RS, RA, RB, MB, ME, 0)
#define RLWNM_rrrii(RA,RS,RB,MB,ME) _M (23, RS, RA, RB, MB, ME, 1)
#define SLWrrr(RA,RS,RB) _X (31, RS, RA, RB, 24, 0)
#define SLW_rrr(RA,RS,RB) _X (31, RS, RA, RB, 24, 1)
#define SRAWrrr(RA,RS,RB) _X (31, RS, RA, RB, 792, 0)
#define SRAW_rrr(RA,RS,RB) _X (31, RS, RA, RB, 792, 1)
#define SRAWIrri(RD, RS, SH) _X (31, RS, RD, SH, 824, 0)
#define SRAWI_rri(RD, RS, SH) _X (31, RS, RD, SH, 824, 1)
#define SRWrrr(RA,RS,RB) _X (31, RS, RA, RB, 536, 0)
#define SRW_rrr(RA,RS,RB) _X (31, RS, RA, RB, 536, 1)
#define STBrm(RS,ID,RA) _D (38, RS, RA, ID)
#define STBUrm(RS,ID,RA) _D (39, RS, RA, ID)
#define STBUXrrr(RS,RA,RB) _X (31, RS, RA, RB, 247, 0)
#define STBXrrr(RS,RA,RB) _X (31, RS, RA, RB, 215, 0)
#define STHrm(RS,ID,RA) _D (44, RS, RA, ID)
#define STHUrm(RS,ID,RA) _D (45, RS, RA, ID)
#define STHBRXrrr(RS,RA,RB) _X (31, RS, RA, RB, 918, 0)
#define STHUXrrr(RS,RA,RB) _X (31, RS, RA, RB, 439, 0)
#define STHXrrr(RS,RA,RB) _X (31, RS, RA, RB, 407, 0)
#define STMWrm(RS,ID,RA) _D (47, RS, RA, ID)
#define STWrm(RS,ID,RA) _D (36, RS, RA, ID)
#define STWBRXrrr(RS,RA,RB) _X (31, RS, RA, RB, 662, 0)
#define STWCXrrr(RS,RA,RB) _X (31, RS, RA, RB, 150, 0)
#define STWCX_rrr(RS,RA,RB) _X (31, RS, RA, RB, 150, 1)
#define STWUrm(RS,ID,RA) _D (37, RS, RA, ID)
#define STWUXrrr(RS,RA,RB) _X (31, RS, RA, RB, 183, 0)
#define STWXrrr(RS,RA,RB) _X (31, RS, RA, RB, 151, 0)
#define SUBFrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 40, 0)
#define SUBF_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 40, 1)
#define SUBFrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 40, 0)
#define SUBF_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 40, 1)
#define SUBFErrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 136, 0)
#define SUBFE_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 136, 1)
#define SUBFCrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 8, 0)
#define SUBFC_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 8, 1)
#define SUBFCOrrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 8, 0)
#define SUBFCO_rrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 8, 1)
#define SUBFICrri(RD, RA, IMM) _D (8, RD, RA, IMM)
#define ADDrrr(RD, RA, RB) _XO (31, RD, RA, RB, 0, 266, 0)
#define ADDOrrr(RD, RA, RB) _XO (31, RD, RA, RB, 1, 266, 0)
#define ADDIrri(RD, RA, IMM) _D (14, RD, RA, IMM)
#define ADDISrri(RD, RA, IMM) _Ds (15, RD, RA, IMM)
#define SYNC() _X (31, 00, 00, 00, 598, 0)
#define TWirr(TO,RA,RB) _X (31, TO, RA, RB, 4, 0)
#define TWIiri(TO,RA,IM) _D (03, TO, RA, IM)
#define XORrrr(RA,RS,RB) _X (31, RS, RA, RB, 316, 0)
#define XOR_rrr(RA,RS,RB) _X (31, RS, RA, RB, 316, 1)
#define XORIrri(RA,RS,IM) _Du (26, RS, RA, IM)
#define XORISrri(RA,RS,IM) _Du (27, RS, RA, IM)
/* simplified mnemonics [1, Appendix F] */
#define MOVEIri2(R,H,L) (LISri(R,H), (L ? ORIrri(R,R,L) : 0))
#define MOVEIri(R,I) (_siP(16,I) ? LIri(R,I) : \
MOVEIri2(R, _HI(I), _LO(I)) )
#define SUBIrri(RD,RA,IM) ADDIrri(RD,RA,-_L((IM))) /* [1, Section F.2.1] */
#define SUBISrri(RD,RA,IM) ADDISrri(RD,RA,-_L((IM)))
#define SUBICrri(RD,RA,IM) ADDICrri(RD,RA,-_L((IM)))
#define SUBIC_rri(RD,RA,IM) ADDIC_rri(RD,RA,-_L((IM)))
#define SUBrrr(RD,RA,RB) SUBFrrr(RD,RB,RA) /* [1, Section F.2.2] */
#define SUBOrrr(RD,RA,RB) SUBFOrrr(RD,RB,RA)
#define SUB_rrr(RD,RA,RB) SUBF_rrr(RD,RB,RA)
#define SUBCrrr(RD,RA,RB) SUBFCrrr(RD,RB,RA)
#define SUBCOrrr(RD,RA,RB) SUBFCOrrr(RD,RB,RA)
#define SUBC_rrr(RD,RA,RB) SUBFC_rrr(RD,RB,RA)
#define SUBErrr(RD,RA,RB) SUBFErrr(RD,RB,RA)
#define SUBE_rrr(RD,RA,RB) SUBFE_rrr(RD,RB,RA)
#define CMPWIiri(C,RA,IM) CMPIiiri(C,0,RA,IM) /* [1, Table F-2] */
#define CMPWirr(C,RA,RB) CMPiirr(C,0,RA,RB)
#define CMPLWIiri(C,RA,IM) CMPLIiiri(C,0,RA,IM)
#define CMPLWirr(C,RA,RB) CMPLiirr(C,0,RA,RB)
#define CMPWIri(RA,IM) CMPWIiri(0,RA,IM) /* with implicit _cr0 */
#define CMPWrr(RA,RB) CMPWirr(0,RA,RB)
#define CMPLWIri(RA,IM) CMPLWIiri(0,RA,IM)
#define CMPLWrr(RA,RB) CMPLWirr(0,RA,RB)
#define EXTLWIrrii(RA,RS,N,B) RLWINMrriii(RA, RS, B, 0, (N)-1) /* [1, Table F-3] */
#define EXTRWIrrii(RA,RS,N,B) RLWINMrriii(RA, RS, (B)+(N), 32-(N), 31)
#define INSLWIrrii(RA,RS,N,B) RLWIMIrriii(RA, RS, 32-(B), B, (B)+(N)-1)
#define INSRWIrrii(RA,RS,N,B) RLWIMIrriii(RA, RS, 32-((B)+(N)), B, (B)+(N)-1)
#define ROTLWIrri(RA,RS,N) RLWINMrriii(RA, RS, N, 0, 31)
#define ROTRWIrri(RA,RS,N) RLWINMrriii(RA, RS, 32-(N), 0, 31)
#define ROTLWrrr(RA,RS,RB) RLWNMrrrii( RA, RS, RB, 0, 31)
#define SLWIrri(RA,RS,N) RLWINMrriii(RA, RS, N, 0, 31-(N))
#define SRWIrri(RA,RS,N) RLWINMrriii(RA, RS, 32-(N), N, 31)
#define CLRLWIrri(RA,RS,N) RLWINMrriii(RA, RS, 0, N, 31)
#define CLRRWIrri(RA,RS,N) RLWINMrriii(RA, RS, 0, 0, 31-(N))
#define CLRLSLWIrrii(RA,RS,B,N) RLWINMrriii(RA, RS, N, (B)-(N), 31-(N))
/* 9 below inverts the branch condition and the branch prediction.
* This has an incestuous knowledge of the fact that register 26
* is used as auxiliary!!! */
#define BC_EXT(A, C, D) (_siP(16, _UL(D)-_UL(_jit.pc)) \
? BCiii((A), (C), (D)) \
: (BCiii((A)^9, (C), _jit.pc+5), LISri(26,_HI(D)), ORIrri(26,26,_LO(D)), \
MTLRr(26), BLR() ))
#define B_EXT(D) (_siP(16, _UL(D)-_UL(_jit.pc)) \
? Bi((D)) \
: (LISri(26,_HI(D)), ORIrri(26,26,_LO(D)), MTLRr(26), BLR()) )
#define BTii(C,D) BC_EXT(12, C, D) /* [1, Table F-5] */
#define BFii(C,D) BC_EXT( 4, C, D)
#define BDNZi(D) BCiii(16, 0, D)
#define BDNZTii(C,D) BC_EXT( 8, C, D)
#define BDNZFii(C,D) BC_EXT( 0, C, D)
#define BDZi(D) BCiii(18, 0, D)
#define BDZTii(C,D) BC_EXT(10, C, D)
#define BDZFii(C,D) BC_EXT( 2, C, D)
#define BCTR() BCCTRii(20, 0) /* [1, Table F-6] */
#define BCTRL() BCCTRLii(20, 0)
#define BLR() BCLRii(20, 0) /* [1, Table F-6] */
#define BLRL() BCLRLii(20, 0)
#define BLTLRi(CR) BCLRii(12, ((CR)<<2)+0) /* [1, Table F-10] */
#define BLELRi(CR) BCLRii( 4 ((CR)<<2)+1)
#define BEQLRi(CR) BCLRii(12, ((CR)<<2)+2)
#define BGELRi(CR) BCLRii( 4, ((CR)<<2)+0)
#define BGTLRi(CR) BCLRii(12, ((CR)<<2)+1)
#define BNLLRi(CR) BCLRii( 4, ((CR)<<2)+0)
#define BNELRi(CR) BCLRii( 4, ((CR)<<2)+2)
#define BNGLRi(CR) BCLRii( 4, ((CR)<<2)+1)
#define BSOLRi(CR) BCLRii(12, ((CR)<<2)+3)
#define BNSLRi(CR) BCLRii( 4, ((CR)<<2)+3)
#define BUNLRi(CR) BCLRii(12, ((CR)<<2)+3)
#define BNULRi(CR) BCLRii( 4, ((CR)<<2)+3)
#define BLTLRLi(CR) BCLRLii(12, ((CR)<<2)+0) /* [1, Table F-10] */
#define BLELRLi(CR) BCLRLii( 4, ((CR)<<2)+1)
#define BEQLRLi(CR) BCLRLii(12, ((CR)<<2)+2)
#define BGELRLi(CR) BCLRLii( 4, ((CR)<<2)+0)
#define BGTLRLi(CR) BCLRLii(12, ((CR)<<2)+1)
#define BNLLRLi(CR) BCLRLii( 4, ((CR)<<2)+0)
#define BNELRLi(CR) BCLRLii( 4, ((CR)<<2)+2)
#define BNGLRLi(CR) BCLRLii( 4, ((CR)<<2)+1)
#define BSOLRLi(CR) BCLRLii(12, ((CR)<<2)+3)
#define BNSLRLi(CR) BCLRLii( 4, ((CR)<<2)+3)
#define BUNLRLi(CR) BCLRLii(12, ((CR)<<2)+3)
#define BNULRLi(CR) BCLRLii( 4, ((CR)<<2)+3)
#define BLTCTRi(CR) BCCTRii(12, ((CR)<<2)+0) /* [1, Table F-10] */
#define BLECTRi(CR) BCCTRii( 4 ((CR)<<2)+1)
#define BEQCTRi(CR) BCCTRii(12, ((CR)<<2)+2)
#define BGECTRi(CR) BCCTRii( 4, ((CR)<<2)+0)
#define BGTCTRi(CR) BCCTRii(12, ((CR)<<2)+1)
#define BNLCTRi(CR) BCCTRii( 4, ((CR)<<2)+0)
#define BNECTRi(CR) BCCTRii( 4, ((CR)<<2)+2)
#define BNGCTRi(CR) BCCTRii( 4, ((CR)<<2)+1)
#define BSOCTRi(CR) BCCTRii(12, ((CR)<<2)+3)
#define BNSCTRi(CR) BCCTRii( 4, ((CR)<<2)+3)
#define BUNCTRi(CR) BCCTRii(12, ((CR)<<2)+3)
#define BNUCTRi(CR) BCCTRii( 4, ((CR)<<2)+3)
#define BLTCTRLi(CR) BCCTRLii(12, ((CR)<<2)+0) /* [1, Table F-10] */
#define BLECTRLi(CR) BCCTRLii( 4, ((CR)<<2)+1)
#define BEQCTRLi(CR) BCCTRLii(12, ((CR)<<2)+2)
#define BGECTRLi(CR) BCCTRLii( 4, ((CR)<<2)+0)
#define BGTCTRLi(CR) BCCTRLii(12, ((CR)<<2)+1)
#define BNLCTRLi(CR) BCCTRLii( 4, ((CR)<<2)+0)
#define BNECTRLi(CR) BCCTRLii( 4, ((CR)<<2)+2)
#define BNGCTRLi(CR) BCCTRLii( 4, ((CR)<<2)+1)
#define BSOCTRLi(CR) BCCTRLii(12, ((CR)<<2)+3)
#define BNSCTRLi(CR) BCCTRLii( 4, ((CR)<<2)+3)
#define BUNCTRLi(CR) BCCTRLii(12, ((CR)<<2)+3)
#define BNUCTRLi(CR) BCCTRLii( 4, ((CR)<<2)+3)
#define BLTLR() BLTLRi(0) /* with implicit _cr0 */
#define BLELR() BLELRi(0)
#define BEQLR() BEQLRi(0)
#define BGELR() BGELRi(0)
#define BGTLR() BGTLRi(0)
#define BNLLR() BNLLRi(0)
#define BNELR() BNELRi(0)
#define BNGLR() BNGLRi(0)
#define BSOLR() BSOLRi(0)
#define BNSLR() BNSLRi(0)
#define BUNLR() BUNLRi(0)
#define BNULR() BNULRi(0)
#define BLTLRL() BLTLRLi(0)
#define BLELRL() BLELRLi(0)
#define BEQLRL() BEQLRLi(0)
#define BGELRL() BGELRLi(0)
#define BGTLRL() BGTLRLi(0)
#define BNLLRL() BNLLRLi(0)
#define BNELRL() BNELRLi(0)
#define BNGLRL() BNGLRLi(0)
#define BSOLRL() BSOLRLi(0)
#define BNSLRL() BNSLRLi(0)
#define BUNLRL() BUNLRLi(0)
#define BNULRL() BNULRLi(0)
#define BLTCTR() BLTCTRi(0)
#define BLECTR() BLECTRi(0)
#define BEQCTR() BEQCTRi(0)
#define BGECTR() BGECTRi(0)
#define BGTCTR() BGTCTRi(0)
#define BNLCTR() BNLCTRi(0)
#define BNECTR() BNECTRi(0)
#define BNGCTR() BNGCTRi(0)
#define BSOCTR() BSOCTRi(0)
#define BNSCTR() BNSCTRi(0)
#define BUNCTR() BUNCTRi(0)
#define BNUCTR() BNUCTRi(0)
#define BLTCTRL() BLTCTRLi(0)
#define BLECTRL() BLECTRLi(0)
#define BEQCTRL() BEQCTRLi(0)
#define BGECTRL() BGECTRLi(0)
#define BGTCTRL() BGTCTRLi(0)
#define BNLCTRL() BNLCTRLi(0)
#define BNECTRL() BNECTRLi(0)
#define BNGCTRL() BNGCTRLi(0)
#define BSOCTRL() BSOCTRLi(0)
#define BNSCTRL() BNSCTRLi(0)
#define BUNCTRL() BUNCTRLi(0)
#define BNUCTRL() BNUCTRLi(0)
#define BLTii(C,D) BC_EXT(12, ((C)<<2)+0, D) /* [1, Table F-11] */
#define BNLii(C,D) BC_EXT( 4, ((C)<<2)+0, D)
#define BGEii(C,D) BC_EXT( 4, ((C)<<2)+0, D)
#define BGTii(C,D) BC_EXT(12, ((C)<<2)+1, D)
#define BNGii(C,D) BC_EXT( 4, ((C)<<2)+1, D)
#define BLEii(C,D) BC_EXT( 4, ((C)<<2)+1, D)
#define BEQii(C,D) BC_EXT(12, ((C)<<2)+2, D)
#define BNEii(C,D) BC_EXT( 4, ((C)<<2)+2, D)
#define BSOii(C,D) BC_EXT(12, ((C)<<2)+3, D)
#define BNSii(C,D) BC_EXT( 4, ((C)<<2)+3, D)
#define BUNii(C,D) BC_EXT(12, ((C)<<2)+3, D)
#define BNUii(C,D) BC_EXT( 4, ((C)<<2)+3, D)
#define BLTi(D) BLTii(0,D) /* with implicit _cr0 */
#define BLEi(D) BLEii(0,D)
#define BEQi(D) BEQii(0,D)
#define BGEi(D) BGEii(0,D)
#define BGTi(D) BGTii(0,D)
#define BNLi(D) BNLii(0,D)
#define BNEi(D) BNEii(0,D)
#define BNGi(D) BNGii(0,D)
#define BSOi(D) BSOii(0,D)
#define BNSi(D) BNSii(0,D)
#define BUNi(D) BUNii(0,D)
#define BNUi(D) BNUii(0,D)
#define BLTLii(C,D) BCLiii(12, ((C)<<2)+0, D) /* [1, Table F-??] */
#define BLELii(C,D) BCLiii( 4 ((C)<<2)+1, D)
#define BEQLii(C,D) BCLiii(12, ((C)<<2)+2, D)
#define BGELii(C,D) BCLiii( 4, ((C)<<2)+0, D)
#define BGTLii(C,D) BCLiii(12, ((C)<<2)+1, D)
#define BNLLii(C,D) BCLiii( 4, ((C)<<2)+0, D)
#define BNELii(C,D) BCLiii( 4, ((C)<<2)+2, D)
#define BNGLii(C,D) BCLiii( 4, ((C)<<2)+1, D)
#define BSOLii(C,D) BCLiii(12, ((C)<<2)+3, D)
#define BNSLii(C,D) BCLiii( 4, ((C)<<2)+3, D)
#define BUNLii(C,D) BCLiii(12, ((C)<<2)+3, D)
#define BNULii(C,D) BCLiii( 4, ((C)<<2)+3, D)
#define BLTLi(D) BLTLii(0,D) /* with implicit _cr0 */
#define BLELi(D) BLELii(0,D)
#define BEQLi(D) BEQLii(0,D)
#define BGELi(D) BGELii(0,D)
#define BGTLi(D) BGTLii(0,D)
#define BNLLi(D) BNLLii(0,D)
#define BNELi(D) BNELii(0,D)
#define BNGLi(D) BNGLii(0,D)
#define BSOLi(D) BSOLii(0,D)
#define BNSLi(D) BNSLii(0,D)
#define BUNLi(D) BUNLii(0,D)
#define BNULi(D) BNULii(0,D)
/* Note: there are many tens of other simplified branches that are not (yet?) defined here */
#define CRSETi(BX) CREQViii(BX, BX, BX) /* [1, Table F-15] */
#define CRCLRi(BX) CRXORiii(BX, BX, BX)
#define CRMOVEii(BX,BY) CRORiii(BX, BY, BY)
#define CRNOTii(BX,BY) CRNORiii(BX, BY, BY)
#define MTLRr(RS) MTSPRir(8, RS) /* [1, Table F-20] */
#define MFLRr(RD) MFSPRri(RD, 8)
#define MTCTRr(RS) MTSPRir(9, RS)
#define MFCTRr(RD) MFSPRri(RD, 9)
#define MTXERr(RS) MTSPRir(1, RS)
#define MFXERr(RD) MFSPRri(RD, 1)
#define NOP() ORIrri(0, 0, 0) /* [1, Section F.9] */
#define LIri(RD,IM) ADDIrri(RD, 0, IM)
#define LISri(RD,IM) ADDISrri(RD, 0, IM)
#define LArm(RD,D,RA) ADDIrri(RD, RA, D)
#define LArrr(RD,RB,RA) ADDIrrr(RD, RA, RB)
#define MRrr(RA,RS) ORrrr(RA, RS, RS)
#define NOTrr(RA,RS) NORrrr(RA, RS, RS)
/* alternative parenthesised forms of extended indexed load/store insns */
#define LBZUrx(RD,RA,RB) LBZUXrrr(RD,RA,RB)
#define LBZrx(RD,RA,RB) LBZXrrr(RD,RA,RB)
#define LHAUrx(RD,RA,RB) LHAUXrrr(RD,RA,RB)
#define LHArx(RD,RA,RB) LHAXrrr(RD,RA,RB)
#define LHBRrx(RD,RA,RB) LHBRXrrr(RD,RA,RB)
#define LHZUrx(RD,RA,RB) LHZUXrrr(RD,RA,RB)
#define LHZrx(RD,RA,RB) LHZXrrr(RD,RA,RB)
#define LWBRrx(RD,RA,RB) LWBRXrrr(RD,RA,RB)
#define LWZUrx(RD, RA, RB) LWZUXrrr(RD, RA, RB)
#define LWZrx(RD, RA, RB) LWZXrrr(RD, RA, RB)
#define STBUrx(RD,RA,RB) STBUXrrr(RD,RA,RB)
#define STBrx(RD,RA,RB) STBXrrr(RD,RA,RB)
#define STHBRrx(RS,RA,RB) STHBRXrrr(RS,RA,RB)
#define STHUrx(RS,RA,RB) STHUXrrr(RS,RA,RB)
#define STHrx(RS,RA,RB) STHXrrr(RS,RA,RB)
#define STWBRrx(RS,RA,RB) STWBRXrrr(RS,RA,RB)
#define STWCrx(RS,RA,RB) STWCXrrr(RS,RA,RB)
#define STWCX_rx(RS,RA,RB) STWCX_rrr(RS,RA,RB)
#define STWUrx(RS,RA,RB) STWUXrrr(RS,RA,RB)
#define STWrx(RS,RA,RB) STWXrrr(RS,RA,RB)
#define LArx(RD,RB,RA) LArrr(RD,RB,RA)
#define _LO(I) (_UL(I) & _MASK(16))
#define _HI(I) (_UL(I) >> (16))
/*** References:
*
* [1] "PowerPC Microprocessor Family: The Programming Environments For 32-Bit Microprocessors", Motorola, 1997.
*/
#endif /* __ccg_asm_ppc_h */

View file

@ -1,276 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer (PowerPC version)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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
struct jit_local_state {
int nextarg_put; /* Next r3-r8 reg. to be written */
int nextarg_putfp; /* Next r3-r8 reg. to be written */
int nextarg_get; /* Next r20-r25 reg. to be read */
};
#define JIT_SP 1
#define JIT_RET 3
#define JIT_R0 9
#define JIT_R1 10
#define JIT_R2 30 /* using r8 would limit argument passing */
#define JIT_V0 29
#define JIT_V1 28
#define JIT_V2 27
#define JIT_AUX 26 /* for 32-bit operands & shift counts */
/* If possible, use the `small' instruction (rd, rs, imm)
* else load imm into r26 and use the `big' instruction (rd, rs, r26)
*/
#define jit_chk_ims(imm, small, big) (_siP(16,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm), (big)) )
#define jit_chk_imu(imm, small, big) (_uiP(16,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm), (big)) )
#define jit_chk_imu15(imm, small, big) (_uiP(15,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm), (big)) )
/* Helper macros for branches */
#define jit_s_brai(rs, is, jmp) (jit_chk_ims (is, CMPWIri(rs, is), CMPWrr(rs, JIT_AUX)), jmp, _jit.pc)
#define jit_s_brar(s1, s2, jmp) ( CMPWrr(s1, s2), jmp, _jit.pc)
#define jit_u_brai(rs, is, jmp) (jit_chk_imu (is, CMPLWIri(rs, is), CMPLWrr(rs, JIT_AUX)), jmp, _jit.pc)
#define jit_u_brar(s1, s2, jmp) ( CMPLWrr(s1, s2), jmp, _jit.pc)
/* Helper macros for boolean tests. */
#define jit_sbooli(d, rs, is, jmp) (jit_chk_ims (is, CMPWIri (rs, is), CMPWrr(rs, JIT_AUX)), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
#define jit_sboolr(d, s1, s2, jmp) ( CMPWrr (s1, s2), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
#define jit_sbooli2(d, rs, is, jmp) (jit_chk_ims (is, CMPWIri (rs, is), CMPWrr(rs, JIT_AUX)), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
#define jit_sboolr2(d, s1, s2, jmp) ( CMPWrr (s1, s2), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
#define jit_ubooli(d, rs, is, jmp) (jit_chk_imu (is, CMPLWIri(rs, is), CMPLWrr(rs, JIT_AUX)), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
#define jit_uboolr(d, s1, s2, jmp) ( CMPLWrr (s1, s2), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
#define jit_ubooli2(d, rs, is, jmp) (jit_chk_imu (is, CMPLWIri(rs, is), CMPLWrr(rs, JIT_AUX)), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
#define jit_uboolr2(d, s1, s2, jmp) ( CMPLWrr (s1, s2), MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
/* modulus with immediate
* movei r26, imm
* mtlr r31
* divw r31, rs, r26 (or divwu)
* mullw r31, r31, r26
* sub rs, rs, r26
* mflr r31
*/
#define _jit_mod(div, rs, imm) (MOVEIri(JIT_AUX, (imm)), MTLRr(31), (div), \
MULLWrrr(31, 31, JIT_AUX), SUBrrr((rs), (rs), JIT_AUX), \
MFLRr(31))
/* Emit a 2-instruction MOVEI, even if a 1-instruction one is possible
* (it is a rare case for branches, and a fixed sequence of instructions
* is easier to patch). */
#define jit_movei(reg, imm) (LISri(reg,_HI(imm)), ORIrri((reg),(reg),_LO(imm)))
/* Patch a movei instruction made of a LIS at lis_pc and an ORI at ori_pc. */
#define jit_patch_movei(lis_pc, ori_pc) \
(*(lis_pc) &= ~_MASK(16), *lis_pc |= _HI(_jit.pc), \
*(ori_pc) &= ~_MASK(16), *ori_pc |= _LO(_jit.pc)) \
/* Patch a branch instruction */
#define jit_patch_branch(jump_pc) \
(*(jump_pc) &= ~_MASK(16) | 3, \
*(jump_pc) |= (_UL(_jit.pc) - _UL(jump_pc)) & _MASK(16))
#define _jit_blr_encoding ((19 << 26) | (20 << 21) | (00 << 16) | (00 << 11) | (16 << 1))
#define jit_patch(jump_pc) ( \
((*(jump_pc - 1) & ~1) == _jit_blr_encoding) \
? jit_patch_movei(((jump_pc) - 4), ((jump_pc) - 3)) \
: jit_patch_branch((jump_pc) - 1))
#define jit_arg_c() (_jitl.nextarg_get--)
#define jit_arg_i() (_jitl.nextarg_get--)
#define jit_arg_l() (_jitl.nextarg_get--)
#define jit_arg_p() (_jitl.nextarg_get--)
#define jit_arg_s() (_jitl.nextarg_get--)
#define jit_arg_uc() (_jitl.nextarg_get--)
#define jit_arg_ui() (_jitl.nextarg_get--)
#define jit_arg_ul() (_jitl.nextarg_get--)
#define jit_arg_us() (_jitl.nextarg_get--)
#define jit_addi_i(d, rs, is) jit_chk_ims((is), ADDICrri((d), (rs), (is)), ADDrrr((d), (rs), JIT_AUX))
#define jit_addr_i(d, s1, s2) ADDrrr((d), (s1), (s2))
#define jit_addci_i(d, rs, is) jit_chk_ims((is), ADDICrri((d), (rs), (is)), ADDCrrr((d), (rs), JIT_AUX))
#define jit_addcr_i(d, s1, s2) ADDCrrr((d), (s1), (s2))
#define jit_addxi_i(d, rs, is) (MOVEIri(JIT_AUX, (is)), ADDErrr((d), (rs), JIT_AUX))
#define jit_addxr_i(d, s1, s2) ADDErrr((d), (s1), (s2))
#define jit_andi_i(d, rs, is) jit_chk_imu((is), ANDI_rri((d), (rs), (is)), ANDrrr((d), (rs), JIT_AUX))
#define jit_andr_i(d, s1, s2) ANDrrr((d), (s1), (s2))
#define jit_bmsi_i(label, rs, is) (jit_chk_imu((is), ANDI_rri(JIT_AUX, (rs), (is)), AND_rrr(JIT_AUX, (rs), JIT_AUX)), BGTi((label)), _jit.pc)
#define jit_bmci_i(label, rs, is) (jit_chk_imu((is), ANDI_rri(JIT_AUX, (rs), (is)), AND_rrr(JIT_AUX, (rs), JIT_AUX)), BEQi((label)), _jit.pc)
#define jit_bmsr_i(label, s1, s2) ( AND_rrr(JIT_AUX, (s1), (s2)), BGTi((label)), _jit.pc)
#define jit_bmcr_i(label, s1, s2) ( AND_rrr(JIT_AUX, (s1), (s2)), BEQi((label)), _jit.pc)
#define jit_beqi_i(label, rs, is) jit_s_brai((rs), (is), BEQi((label)) )
#define jit_beqr_i(label, s1, s2) jit_s_brar((s1), (s2), BEQi((label)) )
#define jit_bgei_i(label, rs, is) jit_s_brai((rs), (is), BGEi((label)) )
#define jit_bgei_ui(label, rs, is) jit_u_brai((rs), (is), BGEi((label)) )
#define jit_bger_i(label, s1, s2) jit_s_brar((s1), (s2), BGEi((label)) )
#define jit_bger_ui(label, s1, s2) jit_u_brar((s1), (s2), BGEi((label)) )
#define jit_bgti_i(label, rs, is) jit_s_brai((rs), (is), BGTi((label)) )
#define jit_bgti_ui(label, rs, is) jit_u_brai((rs), (is), BGTi((label)) )
#define jit_bgtr_i(label, s1, s2) jit_s_brar((s1), (s2), BGTi((label)) )
#define jit_bgtr_ui(label, s1, s2) jit_u_brar((s1), (s2), BGTi((label)) )
#define jit_blei_i(label, rs, is) jit_s_brai((rs), (is), BLEi((label)) )
#define jit_blei_ui(label, rs, is) jit_u_brai((rs), (is), BLEi((label)) )
#define jit_bler_i(label, s1, s2) jit_s_brar((s1), (s2), BLEi((label)) )
#define jit_bler_ui(label, s1, s2) jit_u_brar((s1), (s2), BLEi((label)) )
#define jit_blti_i(label, rs, is) jit_s_brai((rs), (is), BLTi((label)) )
#define jit_blti_ui(label, rs, is) jit_u_brai((rs), (is), BLTi((label)) )
#define jit_bltr_i(label, s1, s2) jit_s_brar((s1), (s2), BLTi((label)) )
#define jit_bltr_ui(label, s1, s2) jit_u_brar((s1), (s2), BLTi((label)) )
#define jit_bnei_i(label, rs, is) jit_s_brai((rs), (is), BNEi((label)) )
#define jit_bner_i(label, s1, s2) jit_s_brar((s1), (s2), BNEi((label)) )
#define jit_boaddi_i(label, rs, is) (MOVEIri(JIT_AUX, (is)), ADDOrrr((rs), (rs), JIT_AUX), MCRXRi(0), BGTi((label)), _jit.pc) /* GT = bit 1 of XER = OV */
#define jit_bosubi_i(label, rs, is) (MOVEIri(JIT_AUX, (is)), SUBCOrrr((rs), (rs), JIT_AUX), MCRXRi(0), BGTi((label)), _jit.pc)
#define jit_boaddr_i(label, s1, s2) ( ADDOrrr((s1), (s1), (s2)), MCRXRi(0), BGTi((label)), _jit.pc)
#define jit_bosubr_i(label, s1, s2) ( SUBCOrrr((s1), (s1), (s2)), MCRXRi(0), BGTi((label)), _jit.pc)
#define jit_boaddi_ui(label, rs, is) (jit_chk_ims ((is), ADDICri((rs), (rs), is), ADDCrr((rs), JIT_AUX)), MCRXRi(0), BEQi((label)), _jit.pc) /* EQ = bit 2 of XER = CA */
#define jit_bosubi_ui(label, rs, is) (jit_chk_ims ((is), SUBICri((rs), (rs), is), SUBCrr((rs), JIT_AUX)), MCRXRi(0), BEQi((label)), _jit.pc)
#define jit_boaddr_ui(label, s1, s2) ( ADDCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.pc)
#define jit_bosubr_ui(label, s1, s2) ( SUBCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.pc)
#define jit_calli(label) (jit_movei(JIT_AUX, (label)), MTLRr(JIT_AUX), BLRL(), _jit.pc)
#define jit_divi_i(d, rs, is) jit_chk_ims(1111111, 0, DIVWrrr ((d), (rs), JIT_AUX))
#define jit_divi_ui(d, rs, is) jit_chk_imu(1111111, 0, DIVWUrrr((d), (rs), JIT_AUX))
#define jit_divr_i(d, s1, s2) DIVWrrr ((d), (s1), (s2))
#define jit_divr_ui(d, s1, s2) DIVWUrrr((d), (s1), (s2))
#define jit_eqi_i(d, rs, is) (jit_chk_ims((is), SUBIrri(JIT_AUX, (rs), (is)), SUBrrr(JIT_AUX, (rs), JIT_AUX)), SUBFICrri((d), JIT_AUX, 0), ADDErrr((d), (d), JIT_AUX))
#define jit_eqr_i(d, s1, s2) (SUBrrr(JIT_AUX, (s1), (s2)), SUBFICrri((d), JIT_AUX, 0), ADDErrr((d), (d), JIT_AUX))
#define jit_extr_c_i(d, rs) EXTSBrr((d), (rs))
#define jit_extr_s_i(d, rs) EXTSHrr((d), (rs))
#define jit_gei_i(d, rs, is) jit_sbooli2((d), (rs), (is), _lt)
#define jit_gei_ui(d, rs, is) jit_ubooli2((d), (rs), (is), _lt)
#define jit_ger_i(d, s1, s2) jit_sboolr2((d), (s1), (s2), _lt)
#define jit_ger_ui(d, s1, s2) jit_uboolr2((d), (s1), (s2), _lt)
#define jit_gti_i(d, rs, is) jit_sbooli ((d), (rs), (is), _gt)
#define jit_gti_ui(d, rs, is) jit_ubooli ((d), (rs), (is), _gt)
#define jit_gtr_i(d, s1, s2) jit_sboolr ((d), (s1), (s2), _gt)
#define jit_gtr_ui(d, s1, s2) jit_uboolr ((d), (s1), (s2), _gt)
#define jit_hmuli_i(d, rs, is) jit_chk_ims(1111111, 0, MULHWrrr ((d), (rs), JIT_AUX))
#define jit_hmuli_ui(d, rs, is) jit_chk_imu(1111111, 0, MULHWUrrr((d), (rs), JIT_AUX))
#define jit_hmulr_i(d, s1, s2) MULHWrrr ((d), (s1), (s2))
#define jit_hmulr_ui(d, s1, s2) MULHWUrrr((d), (s1), (s2))
#define jit_jmpi(label) (B_EXT((label)), _jit.pc)
#define jit_jmpr(reg) (MTLRr(reg), BLR())
#define jit_ldxi_c(d, rs, is) (jit_ldxi_uc((d), (rs), (is)), jit_extr_c_i((d), (d)))
#define jit_ldxr_c(d, s1, s2) (jit_ldxr_uc((d), (s1), (s2)), jit_extr_c_i((d), (d)))
#define jit_ldxi_i(d, rs, is) jit_chk_ims((d), LWZrm((d), (is), (rs)), LWZrx((d), JIT_AUX, (rs)))
#define jit_ldxi_s(d, rs, is) jit_chk_ims((d), LHArm((d), (is), (rs)), LHArx((d), JIT_AUX, (rs)))
#define jit_ldxi_uc(d, rs, is) jit_chk_ims((d), LBZrm((d), (is), (rs)), LBZrx((d), JIT_AUX, (rs)))
#define jit_ldxi_us(d, rs, is) jit_chk_ims((d), LHZrm((d), (is), (rs)), LHZrx((d), JIT_AUX, (rs)))
#define jit_ldxr_i(d, s1, s2) LWZrx((d), (s1), (s2))
#define jit_ldxr_s(d, s1, s2) LHArx((d), (s1), (s2))
#define jit_ldxr_uc(d, s1, s2) LBZrx((d), (s1), (s2))
#define jit_ldxr_us(d, s1, s2) LHZrx((d), (s1), (s2))
#define jit_lei_i(d, rs, is) jit_sbooli2((d), (rs), (is), _gt )
#define jit_lei_ui(d, rs, is) jit_ubooli2((d), (rs), (is), _gt )
#define jit_ler_i(d, s1, s2) jit_sboolr2((d), (s1), (s2), _gt )
#define jit_ler_ui(d, s1, s2) jit_uboolr2((d), (s1), (s2), _gt )
#define jit_lshi_i(d, rs, is) SLWIrri((d), (rs), (is))
#define jit_lshr_i(d, s1, s2) (ANDIrri(JIT_AUX, (s2), 31), SLWrrr ((d), (s1), JIT_AUX))
#define jit_lti_i(d, rs, is) jit_sbooli ((d), (rs), (is), _lt )
#define jit_lti_ui(d, rs, is) jit_ubooli ((d), (rs), (is), _lt )
#define jit_ltr_i(d, s1, s2) jit_sboolr ((d), (s1), (s2), _lt )
#define jit_ltr_ui(d, s1, s2) jit_uboolr ((d), (s1), (s2), _lt )
#define jit_modi_i(d, rs, is) _jit_mod(jit_divi_i (31, (rs), JIT_AUX), (is))
#define jit_modi_ui(d, rs, is) _jit_mod(jit_divi_ui(31, (rs), JIT_AUX), (irs))
#define jit_modr_i(d, s1, s2) (DIVWrrr(JIT_AUX, (s1), (s2)), MULLWrrr(JIT_AUX, JIT_AUX, (s2)), SUBrrr((d), (s1), JIT_AUX))
#define jit_modr_ui(d, s1, s2) (DIVWUrrr(JIT_AUX, (s1), (s2)), MULLWrrr(JIT_AUX, JIT_AUX, (s2)), SUBrrr((d), (s1), JIT_AUX))
#define jit_movi_i(d, is) MOVEIri((d), (is))
#define jit_movr_i(d, rs) MRrr((d), (rs))
#define jit_muli_i(d, rs, is) jit_chk_ims ((is), MULLIrri((d), (rs), (is)), MULLWrrr((d), (rs), JIT_AUX))
#define jit_muli_ui(d, rs, is) jit_chk_imu15((is), MULLIrri((d), (rs), (is)), MULLWrrr((d), (rs), JIT_AUX))
#define jit_mulr_i(d, s1, s2) MULLWrrr((d), (s1), (s2))
#define jit_mulr_ui(d, s1, s2) MULLWrrr((d), (s1), (s2))
#define jit_nei_i(d, rs, is) (jit_chk_ims((is), SUBIrri(JIT_AUX, (rs), (is)), SUBrrr(JIT_AUX, (rs), JIT_AUX)), ADDICrri((d), JIT_AUX, -1), SUBFErrr((d), (d), JIT_AUX))
#define jit_ner_i(d, s1, s2) (SUBrrr(JIT_AUX, (s1), (s2)), ADDICrri((d), JIT_AUX, -1), SUBFErrr((d), (d), JIT_AUX))
#define jit_nop() NOP()
#define jit_ori_i(d, rs, is) jit_chk_imu((is), ORIrri((d), (rs), (is)), ORrrr((d), (rs), JIT_AUX))
#define jit_orr_i(d, s1, s2) ORrrr((d), (s1), (s2))
#define jit_popr_i(rs) (LWZrm((rs), 0, 1), ADDIrri(1, 1, 4))
#define jitfp_prepare(numi, numf, numd) (_jitl.nextarg_put = 3 + (numi) + (numf) + 2*(numd))
#define jit_prolog(n) _jit_prolog(&_jit, (n))
#define jit_pushr_i(rs) STWUrm((rs), -4, 1)
#define jit_pusharg_i(rs) (--_jitl.nextarg_put, MRrr(_jitl.nextarg_put, (rs)))
#define jit_ret() jit_jmpr(31)
#define jit_retval(rd) MRrr((rd), 3)
#define jit_rsbi_i(d, rs, is) jit_chk_ims((is), SUBFICrri((d), (rs), (is)), SUBFCrrr((d), (rs), JIT_AUX))
#define jit_rshi_i(d, rs, is) SRAWIrri((d), (rs), (is))
#define jit_rshi_ui(d, rs, is) SRWIrri ((d), (rs), (is))
#define jit_rshr_i(d, s1, s2) (ANDIrrr(JIT_AUX, (s2), 31), SRAWrrr ((d), (s1), JIT_AUX))
#define jit_rshr_ui(d, s1, s2) (ANDIrrr(JIT_AUX, (s2), 31), SRWrrr ((d), (s1), JIT_AUX))
#define jit_stxi_c(id, rd, rs) jit_chk_ims((id), STBrm((rs), (id), (rd)), STBrx((rs), (rd), JIT_AUX))
#define jit_stxi_i(id, rd, rs) jit_chk_ims((id), STWrm((rs), (id), (rd)), STWrx((rs), (rd), JIT_AUX))
#define jit_stxi_s(id, rd, rs) jit_chk_ims((id), STHrm((rs), (id), (rd)), STHrx((rs), (rd), JIT_AUX))
#define jit_stxr_c(d1, d2, rs) STBrx((rs), (d1), (d2))
#define jit_stxr_i(d1, d2, rs) STWrx((rs), (d1), (d2))
#define jit_stxr_s(d1, d2, rs) STHrx((rs), (d1), (d2))
#define jit_subr_i(d, s1, s2) SUBrrr((d), (s1), (s2))
#define jit_subcr_i(d, s1, s2) SUBCrrr((d), (s1), (s2))
#define jit_subxi_i(d, rs, is) jit_chk_ims(111111111, 0, SUBErrr((d), (rs), JIT_AUX))
#define jit_subxr_i(d, s1, s2) SUBErrr((d), (s1), (s2))
#define jit_xori_i(d, rs, is) jit_chk_imu((is), XORIrri((d), (rs), (is)), XORrrr((d), (rs), JIT_AUX))
#define jit_xorr_i(d, s1, s2) XORrrr((d), (s1), (s2))
/* Cannot use JIT_RZERO because having 0 in a register field on the PowerPC
* does not mean `a register whose value is 0', but rather `no register at
* all' */
#define jit_negr_i(d, rs) jit_rsbi_i((d), (rs), 0)
#define jit_negr_l(d, rs) jit_rsbi_l((d), (rs), 0)
#define jit_ldr_c(rd, rs) jit_ldxr_c((rd), 0, (rs))
#define jit_str_c(rd, rs) jit_stxr_c(0, (rd), (rs))
#define jit_ldr_s(rd, rs) jit_ldxr_s((rd), 0, (rs))
#define jit_str_s(rd, rs) jit_stxr_s(0, (rd), (rs))
#define jit_ldr_i(rd, rs) jit_ldxr_i((rd), 0, (rs))
#define jit_str_i(rd, rs) jit_stxr_i(0, (rd), (rs))
#define jit_ldr_uc(rd, rs) jit_ldxr_uc((rd), 0, (rs))
#define jit_ldr_us(rd, rs) jit_ldxr_us((rd), 0, (rs))
/* e.g.
* 0x01234567 _HA << 16 = 0x01230000 _LA = 0x00004567 _HA << 16 + LA = 0x01234567
* 0x89abcdef _HA << 16 = 0x89ac0000 _LA = 0xffffcdef _HA << 16 + LA = 0x89abcdef
*/
#define _HA(addr) ((_UL(addr) >> 16) + (_US(_UL(addr)) >> 15))
#define _LA(addr) (_UL(addr) - (_HA(addr) << 16))
#define jit_ldi_c(rd, is) (LISri(JIT_AUX, _HA(is)), jit_ldxi_c((rd), JIT_AUX, _LA(is)))
#define jit_sti_c(id, rs) (LISri(JIT_AUX, _HA(id)), jit_stxi_c(_LA(id), JIT_AUX, (rs)))
#define jit_ldi_s(rd, is) (LISri(JIT_AUX, _HA(is)), jit_ldxi_s((rd), JIT_AUX, _LA(is)))
#define jit_sti_s(id, rs) (LISri(JIT_AUX, _HA(id)), jit_stxi_s(_LA(id), JIT_AUX, (rs)))
#define jit_ldi_i(rd, is) (LISri(JIT_AUX, _HA(is)), jit_ldxi_i((rd), JIT_AUX, _LA(is)))
#define jit_sti_i(id, rs) (LISri(JIT_AUX, _HA(id)), jit_stxi_i(_LA(id), JIT_AUX, (rs)))
#define jit_ldi_uc(rd, is) (LISri(JIT_AUX, _HA(is)), jit_ldxi_uc((rd), JIT_AUX, _LA(is)))
#define jit_ldi_us(rd, is) (LISri(JIT_AUX, _HA(is)), jit_ldxi_us((rd), JIT_AUX, _LA(is)))
#endif /* __lightning_core_h */

View file

@ -1,104 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler & support macros for the Sparc math unit
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_asm_fp_h
#define __lightning_asm_fp_h
#if 0
/* dummy for now */
#define jit_add_two(reg0) FADDrrr(13 - (reg0), 13 - (reg0), 12 - (reg0))
#define jit_sub_two(reg0) FSUBrrr(13 - (reg0), 13 - (reg0), 12 - (reg0))
#define jit_mul_two(reg0) FMULrrr(13 - (reg0), 13 - (reg0), 12 - (reg0))
#define jit_div_two(reg0) FDIVrrr(13 - (reg0), 13 - (reg0), 12 - (reg0))
#define jit_abs(reg0) FABSr(13 - (reg0))
#define jit_sqrt(reg0) FSQRTr(13 - (reg0))
#define jit_neg(reg0) FNEGr(13 - (reg0))
#define jit_ldxi_f(reg0, rs, is) 0
#define jit_ldxr_f(reg0, s1, s2) 0
#define jit_ldxi_d(reg0, rs, is) 0
#define jit_ldxr_d(reg0, s1, s2) 0
#define jit_ldi_f(reg0, is) 0
#define jit_ldr_f(reg0, rs) 0
#define jit_ldi_d(reg0, is) 0
#define jit_ldr_d(reg0, rs) 0
#define jit_stxi_f(id, rd, reg0) 0
#define jit_stxr_f(d1, d2, reg0) 0
#define jit_stxi_d(id, rd, reg0) 0
#define jit_stxr_d(d1, d2, reg0) 0
#define jit_sti_f(id, reg0) 0
#define jit_str_f(rd, reg0) 0
#define jit_sti_d(id, reg0) 0
#define jit_str_d(rd, reg0) 0
/* Make space for 1 or 2 words, store address in REG */
#define jit_data(REG, D1) (_FBA (18, 8, 0, 1), _L(D1), MFLRr(REG))
#define jit_data2(REG, D1, D2) (_FBA (18, 12, 0, 1), _L(D1), _L(D2), MFLRr(REG))
#define jit_fpimm(reg0, first, second) \
(jit_data2(JIT_AUX, (first), (second)), \
jit_ldxi_d((reg0), JIT_AUX, 0))
#define jit_floor(rd, reg0) jit_call_fp((rd), (reg0), floor)
#define jit_ceil(rd, reg0) jit_call_fp((rd), (reg0), ceil)
#define jit_call_fp(rd, reg0, fn) \
jit_fail(#fn " not supported", __FILE__, __LINE__, __FUNCTION__)
/* pass reg0 as first parameter of rd
bl fn
mr r3, rd */
#define jit_trunc(rd, reg0) (jit_data((rd), 0), \
FCTIWZrr(13 - (reg0), 13 - (reg0)), \
STFIWXrrr(13 - (reg0), 0, (rd)), \
LWZrm((rd), 0, (rd)))
#define jit_round(rd, reg0) (jit_data((rd), 0), \
FCTIWrr(13 - (reg0), 13 - (reg0)), \
STFIWXrrr(13 - (reg0), 0, (rd)), \
LWZrm((rd), 0, (rd)))
#define jit_cmp(le, ge, reg0) (FCMPOirr(7, 13 - (reg0), 0), \
CRORiii(28 + _gt, 28 + _gt, 28 + _eq), \
CRORiii(28 + _lt, 28 + _lt, 28 + _eq), \
MFCRr((ge)), \
EXTRWIrrii((le), (ge), 1, 28 + _lt), \
EXTRWIrrii((ge), (ge), 1, 28 + _gt))
#endif
#endif /* __lightning_asm_h */

View file

@ -1,169 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer inline functions (PowerPC)
*
***********************************************************************/
/***********************************************************************
*
* 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_funcs_h
#define __lightning_funcs_h
#if !defined(__GNUC__) && !defined(__GNUG__)
#error Go get GNU C, I do not know how to flush the cache
#error with this compiler.
#else
/* Why doesn't this compile?!?
* static void
* jit_flush_code(start, end)
* void *start;
* void *end;
*/
static void
jit_flush_code(void* start, void* end)
{
#ifndef LIGHTNING_CROSS
static int cache_line_size, cache_line_shift;
register char *ddest, *idest;
register int n, dcache_lines, icache_lines;
if (cache_line_size == 0) {
char buffer[8192];
int i, probe;
/* Find out the size of a cache line by zeroing one */
memset(buffer, 0xFF, 8192);
__asm__ __volatile__ ("dcbz 0,%0" : : "r"(buffer + 4096));
/* Probe for the beginning of the cache line. */
for(i = 0, probe = 4096; probe; probe >>= 1)
if (buffer[i | probe] != 0x00)
i |= probe;
/* i is now just before the start of the cache line */
i++;
for(cache_line_shift = 0, cache_line_size = 1;
i + cache_line_size < 8192; cache_line_shift++, cache_line_size <<= 1)
if (buffer[i + cache_line_size] != 0x00)
break;
}
n = ((char *) end) - ((char *)start);
dcache_lines = icache_lines = (n + cache_line_size - 1) >> cache_line_shift;
/* Force data cache write-backs */
for (ddest = start; dcache_lines--; ddest += cache_line_size) {
__asm__ __volatile__ ("dcbst 0,%0" : : "r"(ddest));
}
__asm__ __volatile__ ("sync" : : );
/* Now invalidate the instruction cache */
for (idest = start; icache_lines--; idest += cache_line_size) {
__asm__ __volatile__ ("icbi 0,%0; isync" : : "r"(idest));
}
__asm__ __volatile__ ("isync" : : );
#endif
}
#endif
#define _jit (*jit)
/* Emit a trampoline for a function.
* Upon entrance to the trampoline:
* - R0 = return address for the function
* - LR = address where the real code for the function lies
* - R3-R8 = parameters
* After jumping to the address pointed to by R10:
* - LR = address where the epilog lies (the function must return there)
* - R25-R20 = parameters (order is reversed, 1st argument is R25)
*/
static jit_insn *
_jit_trampoline(jit, n)
register jit_state *jit;
register int n;
{
static jit_insn trampolines[200];
static jit_insn *p_trampolines[6], *free = trampolines;
register int i, ofs, frame_size;
if (!p_trampolines[n]) {
_jit.pc = p_trampolines[n] = free;
frame_size = 24 + (6 + n) * 4; /* r26..r31 + args */
frame_size += 15; /* the stack must be quad-word */
frame_size &= ~15; /* aligned */
STWUrm(1, -frame_size, 1); /* stwu r1, -x(r1) */
for (ofs = frame_size - (6 + n) * 4, i = 26 - n; i <= 31; ofs += 4, i++) {
STWrm(i, ofs, 1); /* stw rI, ofs(r1) */
}
STWrm(0, ofs+4, 1); /* stw r0, x(r1) */
for (i = 0; i < n; i++) {
MRrr(25-i, 3+i); /* save parameters in r25..r20 */
}
BLRL(); /* blrl */
LWZrm(0, ofs+4, 1); /* lwz r0, x(r1) (ret.addr.) */
MTLRr(0); /* mtspr LR, r0 */
for (ofs = frame_size - (6 + n) * 4, i = 26 - n; i <= 31; ofs += 4, i++) {
LWZrm(i, ofs, 1); /* lwz rI, ofs(r1) */
}
ADDIrri(1, 1, frame_size); /* addi r1, r1, x */
BLR(); /* blr */
jit_flush_code(p_trampolines[n], _jit.pc);
free = _jit.pc;
}
return p_trampolines[n];
}
static void
_jit_prolog(jit, n)
register jit_state *jit;
register int n;
{
register jit_insn *save_pc, *trampo;
save_pc = _jit.pc;
trampo = _jit_trampoline(jit, n);
_jit.pc = save_pc;
_jitl.nextarg_get = 25;
MFLRr(0);
MOVEIri(10, trampo);
MTLRr(10);
BLRL(); /* blrl */
MFLRr(31); /* mflr r31 */
}
#undef _jit
#endif /* __lightning_funcs_h */

View file

@ -1,303 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler for the SPARC
*
***********************************************************************/
/***********************************************************************
*
* Copyright 1999, 2000, 2001, 2002 Ian Piumarta
*
* 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
/* <imm> = [0-9]+ -> add i, one parameter (imm)
* <reg> = %<imm> -> add r, one parameter (imm or _Rr(imm) )
* %g<imm> -> add r, one parameter (imm or _Rg(imm) )
* %o<imm> -> add r, one parameter (imm+8 or _Ro(imm) )
* %l<imm> -> add r, one parameter (imm+16 or _Rl(imm) )
* %i<imm> -> add r, one parameter (imm+24 or _Ri(imm) )
* <mem> = <imm>(<reg>) -> add m, two parameters (reg,imm)
* <idx> = <reg>(<reg>) -> add x, two parameters (reg,reg)
*/
typedef unsigned int jit_insn;
#define _d30(BD) ((_UL(BD) - _UL(_jit.pc))>>2)
#define _d22(BD) _ck_d(22, _d30(BD))
#define _HI(I) (_UL(I) >> (10))
#define _LO(I) (_UL(I) & _MASK(10))
/* register names */
#define _y 0
#define _psr 1
#define _Rr(N) ( 0+(N))
#define _Rg(N) ( 0+(N))
#define _Ro(N) ( 8+(N))
#define _Rl(N) (16+(N))
#define _Ri(N) (24+(N))
/* instruction formats -- Figure 5-1, page 44 in */
/* SPARC International, "The SPARC Architecture Manual, Version 8", Prentice-Hall, 1992. */
#define _0i(RD, OP2, IMM) _I((0<<30)| (_u5(RD)<<25)|(_u3(OP2)<<22)| _u22(IMM))
#define _0( A, CC, OP2, DSP) _I((0<<30)|(_u1(A)<<29)|(_u4(CC)<<25)|(_u3(OP2)<<22)| _d22(DSP))
#define _0d( A, CC, OP2, DSP) _I((0<<30)|(_u1(A)<<29)|(_u4(CC)<<25)|(_u3(OP2)<<22)| _u22(DSP))
#define _1( DSP) _I((1<<30)| _d30(DSP))
#define _2( RD, OP3, RS1, I, ASI, RS2) _I((2<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)|(_u8(ASI)<<5)|_u5 (RS2))
#define _2i(RD, OP3, RS1, I, IMM) _I((2<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)| _s13(IMM))
#define _2f(RD, OP3, RS1, OPF, RS2) _I((2<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)| (_u9(OPF)<<5)|_u5 (RS2))
#define _3( RD, OP3, RS1, I, ASI, RS2) _I((3<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)|(_u8(ASI)<<5)|_u5 (RS2))
#define _3i(RD, OP3, RS1, I, IMM) _I((3<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)| _s13(IMM))
/* basic instructions [Section B, page 87] */
#define ADDrrr(RS1, RS2, RD) _2 ((RD), 0, (RS1), 0, 0, (RS2))
#define ADDrir(RS1, IMM, RD) _2i ((RD), 0, (RS1), 1, (IMM))
#define ADDCCrrr(RS1, RS2, RD) _2 ((RD), 16, (RS1), 0, 0, (RS2))
#define ADDCCrir(RS1, IMM, RD) _2i ((RD), 16, (RS1), 1, (IMM))
#define ADDXrrr(RS1, RS2, RD) _2 ((RD), 8, (RS1), 0, 0, (RS2))
#define ADDXrir(RS1, IMM, RD) _2i ((RD), 8, (RS1), 1, (IMM))
#define ADDXCCrrr(RS1, RS2, RD) _2 ((RD), 24, (RS1), 0, 0, (RS2))
#define ADDXCCrir(RS1, IMM, RD) _2i ((RD), 24, (RS1), 1, (IMM))
#define ANDrrr(RS1, RS2, RD) _2 ((RD), 1, (RS1), 0, 0, (RS2))
#define ANDrir(RS1, IMM, RD) _2i ((RD), 1, (RS1), 1, (IMM))
#define ANDCCrrr(RS1, RS2, RD) _2 ((RD), 17, (RS1), 0, 0, (RS2))
#define ANDCCrir(RS1, IMM, RD) _2i ((RD), 17, (RS1), 1, (IMM))
#define BNi(DISP) _0 (0, 0, 2, (DISP))
#define BN_Ai(DISP) _0 (1, 0, 2, (DISP))
#define BEi(DISP) _0 (0, 1, 2, (DISP))
#define BE_Ai(DISP) _0 (1, 1, 2, (DISP))
#define BLEi(DISP) _0 (0, 2, 2, (DISP))
#define BLE_Ai(DISP) _0 (1, 2, 2, (DISP))
#define BLi(DISP) _0 (0, 3, 2, (DISP))
#define BL_Ai(DISP) _0 (1, 3, 2, (DISP))
#define BLEUi(DISP) _0 (0, 4, 2, (DISP))
#define BLEU_Ai(DISP) _0 (1, 4, 2, (DISP))
#define BCSi(DISP) _0 (0, 5, 2, (DISP))
#define BCS_Ai(DISP) _0 (1, 5, 2, (DISP))
#define BNEGi(DISP) _0 (0, 6, 2, (DISP))
#define BNEG_Ai(DISP) _0 (1, 6, 2, (DISP))
#define BVSi(DISP) _0 (0, 7, 2, (DISP))
#define BVS_Ai(DISP) _0 (1, 7, 2, (DISP))
#define BAi(DISP) _0 (0, 8, 2, (DISP))
#define BA_Ai(DISP) _0 (1, 8, 2, (DISP))
#define BNEi(DISP) _0 (0, 9, 2, (DISP))
#define BNE_Ai(DISP) _0 (1, 9, 2, (DISP))
#define BGi(DISP) _0 (0, 10, 2, (DISP))
#define BG_Ai(DISP) _0 (1, 10, 2, (DISP))
#define BGEi(DISP) _0 (0, 11, 2, (DISP))
#define BGE_Ai(DISP) _0 (1, 11, 2, (DISP))
#define BGUi(DISP) _0 (0, 12, 2, (DISP))
#define BGU_Ai(DISP) _0 (1, 12, 2, (DISP))
#define BCCi(DISP) _0 (0, 13, 2, (DISP))
#define BCC_Ai(DISP) _0 (1, 13, 2, (DISP))
#define BPOSi(DISP) _0 (0, 14, 2, (DISP))
#define BPOS_Ai(DISP) _0 (1, 14, 2, (DISP))
#define BVCi(DISP) _0 (0, 15, 2, (DISP))
#define BVC_Ai(DISP) _0 (1, 15, 2, (DISP))
#define CALLi(DISP) _1 ((DISP))
#define FLUSHrr(RS1, RS2) _2 (0, 0x3b, (RS1), 0, 0, (RS2))
#define FLUSHir(IMM, RS1) _2i (0, 0x3b, (RS1), 1, (IMM))
#define JMPLxr(RS1, RS2, RD) _2 ((RD), 56, (RS1), 0, 0, (RS2))
#define JMPLmr(RS1, IMM, RD) _2i ((RD), 56, (RS1), 1, (IMM))
#define LDxr(RS1, RS2, RD) _3 ((RD), 0, (RS1), 0, 0, (RS2))
#define LDmr(RS1, IMM, RD) _3i ((RD), 0, (RS1), 1, (IMM))
#define LDUBxr(RS1, RS2, RD) _3 ((RD), 1, (RS1), 0, 0, (RS2))
#define LDUBmr(RS1, IMM, RD) _3i ((RD), 1, (RS1), 1, (IMM))
#define LDUHxr(RS1, RS2, RD) _3 ((RD), 2, (RS1), 0, 0, (RS2))
#define LDUHmr(RS1, IMM, RD) _3i ((RD), 2, (RS1), 1, (IMM))
#define LDDxr(RS1, RS2, RD) _3 ((RD), 3, (RS1), 0, 0, (RS2))
#define LDDmr(RS1, IMM, RD) _3i ((RD), 3, (RS1), 1, (IMM))
#define LDSBxr(RS1, RS2, RD) _3 ((RD), 9, (RS1), 0, 0, (RS2))
#define LDSBmr(RS1, IMM, RD) _3i ((RD), 9, (RS1), 1, (IMM))
#define LDSHxr(RS1, RS2, RD) _3 ((RD), 10, (RS1), 0, 0, (RS2))
#define LDSHmr(RS1, IMM, RD) _3i ((RD), 10, (RS1), 1, (IMM))
#define ORrrr(RS1, RS2, RD) _2 ((RD), 2, (RS1), 0, 0, (RS2))
#define ORrir(RS1, IMM, RD) _2i ((RD), 2, (RS1), 1, (IMM))
#define ORCCrrr(RS1, RS2, RD) _2 ((RD), 18, (RS1), 0, 0, (RS2))
#define ORCCrir(RS1, IMM, RD) _2i ((RD), 18, (RS1), 1, (IMM))
#define RDir(RS, RD) _2 ((RD), (RS)|0x28, 0, 0, 0,0)
#define RESTORErrr(RS1, RS2, RD) _2 ((RD), 61, (RS1), 0, 0, (RS2))
#define RESTORErir(RS1, IMM, RD) _2i ((RD), 61, (RS1), 1, (IMM))
#define SAVErrr(RS1, RS2, RD) _2 ((RD), 60, (RS1), 0, 0, (RS2))
#define SAVErir(RS1, IMM, RD) _2i ((RD), 60, (RS1), 1, (IMM))
#define SDIVrrr(RS1, RS2, RD) _2 ((RD), 15, (RS1), 0, 0, (RS2))
#define SDIVrir(RS1, IMM, RD) _2i ((RD), 15, (RS1), 1, (IMM))
#define SDIVCCrrr(RS1, RS2, RD) _2 ((RD), 31, (RS1), 0, 0, (RS2))
#define SDIVCCrir(RS1, IMM, RD) _2i ((RD), 31, (RS1), 1, (IMM))
#define SETHIir(IMM, RD) _0i ((RD), 4, (IMM))
#define SLLrrr(RS1, RS2, RD) _2 ((RD), 37, (RS1), 0, 0, (RS2))
#define SLLrir(RS1, IMM, RD) _2i ((RD), 37, (RS1), 1, (IMM))
#define SMULrrr(RS1, RS2, RD) _2 ((RD), 11, (RS1), 0, 0, (RS2))
#define SMULrir(RS1, IMM, RD) _2i ((RD), 11, (RS1), 1, (IMM))
#define SMULCCrrr(RS1, RS2, RD) _2 ((RD), 27, (RS1), 0, 0, (RS2))
#define SMULCCrir(RS1, IMM, RD) _2i ((RD), 27, (RS1), 1, (IMM))
#define SRArrr(RS1, RS2, RD) _2 ((RD), 39, (RS1), 0, 0, (RS2))
#define SRArir(RS1, IMM, RD) _2i ((RD), 39, (RS1), 1, (IMM))
#define SRLrrr(RS1, RS2, RD) _2 ((RD), 38, (RS1), 0, 0, (RS2))
#define SRLrir(RS1, IMM, RD) _2i ((RD), 38, (RS1), 1, (IMM))
#define STrx(RS, RD1, RD2) _3 ((RS), 4, (RD1), 0, 0, (RD2))
#define STrm(RS, RD, IMM) _3i ((RS), 4, (RD), 1, (IMM))
#define STBrx(RS, RD1, RD2) _3 ((RS), 5, (RD1), 0, 0, (RD2))
#define STBrm(RS, RD, IMM) _3i ((RS), 5, (RD), 1, (IMM))
#define STBAR() _0i (0, 0x28, 15, 0, 0)
#define STHrx(RS, RD1, RD2) _3 ((RS), 6, (RD1), 0, 0, (RD2))
#define STHrm(RS, RD, IMM) _3i ((RS), 6, (RD), 1, (IMM))
#define STDrx(RS, RD1, RD2) _3 ((RS), 7, (RD1), 0, 0, (RD2))
#define STDrm(RS, RD, IMM) _3i ((RS), 7, (RD), 1, (IMM))
#define SUBrrr(RS1, RS2, RD) _2 ((RD), 4, (RS1), 0, 0, (RS2))
#define SUBrir(RS1, IMM, RD) _2i ((RD), 4, (RS1), 1, (IMM))
#define SUBCCrrr(RS1, RS2, RD) _2 ((RD), 20, (RS1), 0, 0, (RS2))
#define SUBCCrir(RS1, IMM, RD) _2i ((RD), 20, (RS1), 1, (IMM))
#define SUBXrrr(RS1, RS2, RD) _2 ((RD), 12, (RS1), 0, 0, (RS2))
#define SUBXrir(RS1, IMM, RD) _2i ((RD), 12, (RS1), 1, (IMM))
#define SUBXCCrrr(RS1, RS2, RD) _2 ((RD), 28, (RS1), 0, 0, (RS2))
#define SUBXCCrir(RS1, IMM, RD) _2i ((RD), 28, (RS1), 1, (IMM))
#define UDIVrrr(RS1, RS2, RD) _2 ((RD), 14, (RS1), 0, 0, (RS2))
#define UDIVrir(RS1, IMM, RD) _2i ((RD), 14, (RS1), 1, (IMM))
#define UDIVCCrrr(RS1, RS2, RD) _2 ((RD), 30, (RS1), 0, 0, (RS2))
#define UDIVCCrir(RS1, IMM, RD) _2i ((RD), 30, (RS1), 1, (IMM))
#define UMULrrr(RS1, RS2, RD) _2 ((RD), 10, (RS1), 0, 0, (RS2))
#define UMULrir(RS1, IMM, RD) _2i ((RD), 10, (RS1), 1, (IMM))
#define UMULCCrrr(RS1, RS2, RD) _2 ((RD), 26, (RS1), 0, 0, (RS2))
#define UMULCCrir(RS1, IMM, RD) _2i ((RD), 26, (RS1), 1, (IMM))
#define WRrri(RS1, RS2, RD) _2 (0, (RD)|0x30, RS1, 0, 0, (RS2))
#define WRrii(RS1, IMM, RD) _2i (0, (RD)|0x30, RS1, 1, (IMM))
#define XORrrr(RS1, RS2, RD) _2 ((RD), 3, (RS1), 0, 0, (RS2))
#define XORrir(RS1, IMM, RD) _2i ((RD), 3, (RS1), 1, (IMM))
#define XORCCrrr(RS1, RS2, RD) _2 ((RD), 19, (RS1), 0, 0, (RS2))
#define XORCCrir(RS1, IMM, RD) _2i ((RD), 19, (RS1), 1, (IMM))
/* synonyms */
#define Bi(DISP) BAi((DISP))
#define B_Ai(DISP) BA_Ai((DISP))
#define BNZi(DISP) BNEi((DISP))
#define BNZ_Ai(DISP) BNE_Ai((DISP))
#define BZi(DISP) BEi((DISP))
#define BZ_Ai(DISP) BE_Ai((DISP))
#define BGEUi(DISP) BCCi((DISP))
#define BGEU_Ai(DISP) BCC_Ai((DISP))
#define BLUi(DISP) BCSi((DISP))
#define BLU_Ai(DISP) BCS_Ai((DISP))
#define LDUWxr(RS1, RS2, RD) LDxr((RS1), (RS2), (RD))
#define LDUWmr(RS1, IMM, RD) LDmr((RS1), (IMM), (RD))
#define LDSWxr(RS1, RS2, RD) LDxr((RS1), (RS2), (RD))
#define LDSWmr(RS1, IMM, RD) LDmr((RS1), (IMM), (RD))
#define STWrx(RS, RD1, RD2) STrx((RS), (RD1), (RD2))
#define STWrm(RS, RD, IMM) STrm((RS), (RD), (IMM))
/* synthetic instructions [Table A-1, page 85] */
#define BCLRrr(R,S) ANDNrrr((R), (S), (S))
#define BCLRir(I,R) ANDNrir((R), (I), (R))
#define BSETrr(R,S) ORrrr((R), (S), (S))
#define BSETir(I,R) ORrir((R), (I), (R))
#define BTOGrr(R,S) XORrrr((R), (S), (S))
#define BTOGir(I,R) XORrir((R), (I), (R))
#define BTSTrr(R,S) ANDCCrrr((R), (S), 0)
#define BTSTir(I,R) ANDCCrir((R), (I), 0)
#define CALLm(R,I) JMPLmr((R), (I), _Ro(7))
#define CALLx(R,S) JMPLxr((R), (S), _Ro(7))
#define CLRr(R) ORrrr(0, 0, (R))
#define CLRBm(R,I) STBrm(0, (R), (I))
#define CLRBx(R,S) STBrm(0, (R), (S))
#define CLRHm(R,I) STHrm(0, (R), (I))
#define CLRHx(R,S) STHrm(0, (R), (S))
#define CLRm(R,I) STrm(0, (R), (I))
#define CLRx(R,S) STrm(0, (R), (S))
#define CMPrr(RS1, RS2) SUBCCrrr((RS1), (RS2), 0)
#define CMPri(RS1, IMM) SUBCCrir((RS1), (IMM), 0)
#define DECr(R) SUBrir((R), 1, (R))
#define DECir(I,R) SUBrir((R), (I), (R))
#define DECCCr(R) SUBCCrir((R), 1, (R))
#define DECCCir(I,R) SUBCCrir((R), (I), (R))
#define INCr(R) ADDrir((R), 1, (R))
#define INCir(I,R) ADDrir((R), (I), (R))
#define INCCCr(R) ADDCCrir((R), 1, (R))
#define INCCCir(I,R) ADDCCrir((R), (I), (R))
#define JMPm(R,I) JMPLmr((R), (I), 0)
#define JMPx(R,S) JMPLxr((R), (S), 0)
#define MOVrr(R,S) ORrrr(0, (R), (S))
#define MOVir(I, R) ORrir(0, (I), (R))
#define NEGrr(R,S) SUBrrr(0, (R), (S))
#define NEGr(R) SUBrrr(0, (R), (R))
#define NOP() SETHIir(0, 0)
#define NOTrr(R,S) XNORrrr((R), 0, (S))
#define NOTr(R) XNORrrr((R), 0, (R))
#define RESTORE() RESTORErrr(0, 0, 0)
#define RET() JMPLmr(_Ri(7),8 ,0)
#define RETL() JMPLmr(_Ro(7),8 ,0)
#define SAVE() SAVErrr(0, 0, 0)
#define SETir(I,R) (_siP(13,(I)) ? MOVir((I),(R)) : SETir2(_HI(I), _LO(I), (R)))
#define SETir2(H,L,R) (SETHIir(H,R), (L ? ORrir(R,L,R) : 0))
/* BNZ,a executes the delay instruction if NZ (so skips if Z)
* BZ,a executes the delay instruction if Z (so skips if NZ). */
#define SKIPZ() _0d (1, 9, 2, 2) /* BNZ,a .+8 */
#define SKIPNZ() _0d (1, 1, 2, 2) /* BZ,a .+8 */
#define SKIP() _0d (1, 0, 2, 0) /* BN,a . */
#define TSTr(R) ORCCrrr(0, (R), 0)
#define WRii(IMM, RD) WRrii(0, (IMM), (RD))
#define WRri(RS2, RD) WRrri(0, (RS2), (RD))
#endif /* __ccg_asm_sparc_h */

View file

@ -1,283 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer (Sparc version)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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
#define JIT_R0 _Rl(0)
#define JIT_R1 _Rl(1)
#define JIT_R2 _Rl(2)
#define JIT_V0 _Rl(3)
#define JIT_V1 _Rl(4)
#define JIT_V2 _Rl(5)
#define JIT_BIG _Rg(1) /* %g1 used to make 32-bit operands */
#define JIT_BIG2 _Rg(2) /* %g2 used to make 32-bit compare operands */
#define JIT_SP _Ro(6)
#define JIT_RZERO _Rg(0)
#define JIT_RET _Ri(0)
/* Delay slot scheduling: jmp generates branches with annulled delay
* slots; we toggle the annul bit if we can fill the slot. CALLs and
* cond. branches have a different meaning for the annul bit, so we
* automatically generate a NOP and eventually copy the delay insn onto
* it. Delay slots in RET are already used for RESTORE, so we don't
* schedule them.
*
* ,--- _jit.pc
* insn X X before
* cmp branch insn X X after (branch)
* `--- _jit.pc
* call insn insn X after (call)
* `--- _jit.pc
*/
struct jit_local_state {
int nextarg_put; /* Next %o reg. to be written */
int nextarg_get; /* Next %i reg. to be read */
jit_insn delay;
};
#define jit_fill_delay_after(branch) (_jitl.delay = *--_jit.pc, \
((branch) == _jit.pc /* check if NOP was inserted */ \
? (_jit.pc[-1] ^= 1<<29) /* no if branch, toggle annul bit */ \
: (_jit.pc[-1] = _jitl.delay)), /* yes if call, replace NOP with delay insn */ \
*_jit.pc = _jitl.delay, _jit.pc - 1) /* return addr of delay insn */
/* If possible, use the `small' instruction (rs, imm, rd)
* else load imm into %l6 and use the `big' instruction (rs, %l6, rd)
* jit_chk_imm2 uses %l7 instead of %l6 to avoid conflicts when using delay slots
*/
#define jit_chk_imm(imm, small, big) (_siP(13,(imm)) ? (small) : (SETir((imm), JIT_BIG), (big)) )
#define jit_chk_imm2(imm, small, big) (_siP(13,(imm)) ? (small) : (SETir((imm), JIT_BIG2), (big)) )
/* Helper macros for branches */
#define jit_branchi(rs, is, jmp, nop) (jit_chk_imm2(is, CMPri(rs, is), CMPrr(rs, JIT_BIG2)), jmp, nop, _jit.pc - 1)
#define jit_branchr(s1, s2, jmp, nop) ( CMPrr(s1, s2), jmp, nop, _jit.pc - 1)
/* Helper macros for boolean tests -- delay slot sets d to 1;
* taken branch leaves it to 1, not-taken branch resets it to 0 */
#define jit_booli(d, rs, is, jmp) (jit_chk_imm (is, CMPri(rs, is), CMPrr(rs, JIT_BIG)), jmp, MOVir(1, (d)), MOVir(0, (d)))
#define jit_boolr(d, s1, s2, jmp) ( CMPrr(s1, s2), jmp, MOVir(1, (d)), MOVir(0, (d)))
/* Helper macros for division
* The architecture specifies that there must be 3 instructions between *
* a y register write and a use of it for correct results. */
#define jit_prepare_y(rs, is) (SRArir(rs, 31, JIT_BIG), WRri(JIT_BIG, _y), NOP(), NOP(), NOP(), _jit.pc -= jit_immsize(is))
#define jit_clr_y(rs, is) ( WRri(0, _y), NOP(), NOP(), NOP(), _jit.pc -= jit_immsize(is))
/* How many instruction are needed by `set imm, %l6' */
#define jit_immsize(imm) (_siP(13, (imm)) ? 0 : \
((imm) & 0x3ff ? 2 : 1))
/* branch instructions return the address of the *delay* instruction -- this
* is just a helper macro that makes jit_patch more readable.
*/
#define jit_patch_(jump_pc) \
(*jump_pc &= ~_MASK(22), \
*jump_pc |= ((_UL(_jit.pc) - _UL(jump_pc)) >> 2) & _MASK(22))
/* helper macros for remainder -- it is said that _rem and _urem
* trash the output registers
*
* jit_modr jit_modi
*-----------------------------------------------------------------------------
* mov %o0, %l7 mov %o0, %l7 ! save o0
* mov s1, %o0 mov rs, %o0
* mov %o1, %l6 ! save o1
* mov s2, %o1
* save %sp, -96, %sp save %sp, -96, %sp ! switch window
* mov %i1, %o1 set is, %o1 ! transfer/set divisor
* call f ! call the function
* mov %i0, %o0 mov %i0, %o0 ! transfer dividend
* mov %o0, %i0 mov %o0, %i0 ! transfer result
* restore restore ! switch to old window
* mov %o0, d mov %o0, d ! store result
* mov %l7, %o0 mov %o0, %l7 ! restore o0
* mov %l6, %o1 ! restore o1
*/
#define jit_mod(d, rs, f, before_save, set_o1, at_end) ( \
MOVrr(_Ro(0), _Rl(7)), \
MOVrr(rs, _Ro(0)), \
before_save, \
SAVErir(JIT_SP, -96, JIT_SP), \
set_o1, \
CALLi( (unsigned long) f), \
MOVrr(_Ri(0), _Ro(0)), \
MOVrr(_Ro(0), _Ri(0)), \
RESTORE(), \
MOVrr(_Ro(0), d), \
MOVrr(_Rl(7), _Ro(0)), \
at_end) \
#define jit_modi(d, rs, is, f) jit_mod(d, s1, f, 0, SETir((is), _Ro(1)), 0)
#define jit_modr(d, s1, s2, f) jit_mod(d, s1, f, (MOVrr(_Ro(1), _Rl(6)), MOVrr(s2, _Ro(1)), MOVrr(_Ri(1), _Ro(1)), MOVrr(_Rl(6), _Ro(1)) ))
#define jit_arg_c() (_jitl.nextarg_get++)
#define jit_arg_i() (_jitl.nextarg_get++)
#define jit_arg_l() (_jitl.nextarg_get++)
#define jit_arg_p() (_jitl.nextarg_get++)
#define jit_arg_s() (_jitl.nextarg_get++)
#define jit_arg_uc() (_jitl.nextarg_get++)
#define jit_arg_ui() (_jitl.nextarg_get++)
#define jit_arg_ul() (_jitl.nextarg_get++)
#define jit_arg_us() (_jitl.nextarg_get++)
#define jit_addi_i(d, rs, is) jit_chk_imm((is), ADDrir((rs), (is), (d)), ADDrrr((rs), JIT_BIG, (d)))
#define jit_addr_i(d, s1, s2) ADDrrr((s1), (s2), (d))
#define jit_addci_i(d, rs, is) jit_chk_imm((is), ADDCCrir((rs), (is), (d)), ADDCCrrr((rs), JIT_BIG, (d)))
#define jit_addcr_i(d, s1, s2) ADDCCrrr((s1), (s2), (d))
#define jit_addxi_i(d, rs, is) jit_chk_imm((is), ADDXCCrir((rs), (is), (d)), ADDXCCrrr((rs), JIT_BIG, (d)))
#define jit_addxr_i(d, s1, s2) ADDXCCrrr((s1), (s2), (d))
#define jit_andi_i(d, rs, is) jit_chk_imm((is), ANDrir((rs), (is), (d)), ANDrrr((rs), JIT_BIG, (d)))
#define jit_andr_i(d, s1, s2) ANDrrr((s1), (s2), (d))
#define jit_beqi_i(label, rs, is) jit_branchi((rs), (is), BEi((label)), NOP() )
#define jit_beqr_i(label, s1, s2) jit_branchr((s1), (s2), BEi((label)), NOP() )
#define jit_bgei_i(label, rs, is) jit_branchi((rs), (is), BGEi((label)), NOP() )
#define jit_bgei_ui(label, rs, is) jit_branchi((rs), (is), BGEUi((label)), NOP() )
#define jit_bger_i(label, s1, s2) jit_branchr((s1), (s2), BGEi((label)), NOP() )
#define jit_bger_ui(label, s1, s2) jit_branchr((s1), (s2), BGEUi((label)), NOP() )
#define jit_bgti_i(label, rs, is) jit_branchi((rs), (is), BGi((label)), NOP() )
#define jit_bgti_ui(label, rs, is) jit_branchi((rs), (is), BGUi((label)), NOP() )
#define jit_bgtr_i(label, s1, s2) jit_branchr((s1), (s2), BGi((label)), NOP() )
#define jit_bgtr_ui(label, s1, s2) jit_branchr((s1), (s2), BGUi((label)), NOP() )
#define jit_blei_i(label, rs, is) jit_branchi((rs), (is), BLEi((label)), NOP() )
#define jit_blei_ui(label, rs, is) jit_branchi((rs), (is), BLEUi((label)), NOP() )
#define jit_bler_i(label, s1, s2) jit_branchr((s1), (s2), BLEi((label)), NOP() )
#define jit_bler_ui(label, s1, s2) jit_branchr((s1), (s2), BLEUi((label)), NOP() )
#define jit_blti_i(label, rs, is) jit_branchi((rs), (is), BLi((label)), NOP() )
#define jit_blti_ui(label, rs, is) jit_branchi((rs), (is), BLUi((label)), NOP() )
#define jit_bltr_i(label, s1, s2) jit_branchr((s1), (s2), BLi((label)), NOP() )
#define jit_bltr_ui(label, s1, s2) jit_branchr((s1), (s2), BLUi((label)), NOP() )
#define jit_bnei_i(label, rs, is) jit_branchi((rs), (is), BNEi((label)), NOP() )
#define jit_bner_i(label, s1, s2) jit_branchr((s1), (s2), BNEi((label)), NOP() )
#define jit_bmsi_i(label, rs, is) (jit_chk_imm((is), BTSTir((is), (rs)), BTSTrr((rs), JIT_BIG)), BNEi((label)), NOP(), _jit.pc - 1)
#define jit_bmci_i(label, rs, is) (jit_chk_imm((is), BTSTir((is), (rs)), BTSTrr((rs), JIT_BIG)), BEi((label)), NOP(), _jit.pc - 1)
#define jit_bmsr_i(label, s1, s2) ( BTSTrr((s1), (s2)), BNEi((label)), NOP(), _jit.pc - 1)
#define jit_bmcr_i(label, s1, s2) ( BTSTrr((s1), (s2)), BEi((label)), NOP(), _jit.pc - 1)
#define jit_boaddi_i(label, rs, is) (jit_chk_imm((is), ADDCCrir((rs), (is), (rs)), ADDCCrrr((rs), JIT_BIG, (rs))), BVSi((label)), NOP(), _jit.pc - 1)
#define jit_bosubi_i(label, rs, is) (jit_chk_imm((is), SUBCCrir((rs), (is), (rs)), SUBCCrrr((rs), JIT_BIG, (rs))), BVSi((label)), NOP(), _jit.pc - 1)
#define jit_boaddr_i(label, s1, s2) ( ADDCCrrr((s1), (s2), (s1)), BVSi((label)), NOP(), _jit.pc - 1)
#define jit_bosubr_i(label, s1, s2) ( SUBCCrrr((s1), (s2), (s1)), BVSi((label)), NOP(), _jit.pc - 1)
#define jit_boaddi_ui(label, rs, is) (jit_chk_imm((is), ADDCCrir((rs), (is), (rs)), ADDCCrrr((rs), JIT_BIG, (rs))), BCSi((label)), NOP(), _jit.pc - 1)
#define jit_bosubi_ui(label, rs, is) (jit_chk_imm((is), SUBCCrir((rs), (is), (rs)), SUBCCrrr((rs), JIT_BIG, (rs))), BCSi((label)), NOP(), _jit.pc - 1)
#define jit_boaddr_ui(label, s1, s2) ( ADDCCrrr((s1), (s2), (s1)), BCSi((label)), NOP(), _jit.pc - 1)
#define jit_bosubr_ui(label, s1, s2) ( SUBCCrrr((s1), (s2), (s1)), BCSi((label)), NOP(), _jit.pc - 1)
#define jit_calli(label) (CALLi(label), NOP(), _jit.pc - 1)
#define jit_divi_i(d, rs, is) (jit_prepare_y((rs), (is)), jit_chk_imm((is), SDIVrir((rs), (is), (d)), SDIVrrr((rs), JIT_BIG, (d))) )
#define jit_divi_ui(d, rs, is) (jit_clr_y((rs)), (is)), jit_chk_imm((is), UDIVrir((rs), (is), (d)), UDIVrrr((rs), JIT_BIG, (d))) )
#define jit_divr_i(d, s1, s2) (jit_prepare_y((s1), 3), SDIVrrr((s1), (s2), (d)))
#define jit_divr_ui(d, s1, s2) (jit_clr_y((s1), 3), UDIVrrr((s1), (s2), (d)))
#define jit_eqi_i(d, rs, is) jit_chk_imm((is), \
(SUBCCrir((rs), (is), (d)), ADDXCCrir((d), -1, JIT_BIG), SUBXrir(0,-1,(d))),\
jit_eqr_i(d, rs, JIT_BIG))
#define jit_eqr_i(d, s1, s2) (SUBCCrrr((s1), (s2), (d)), ADDXCCrir((d), -1, JIT_BIG), SUBXrir(0,-1,(d)))
#define jit_nei_i(d, rs, is) jit_chk_imm((is), \
(SUBCCrir((rs), (is), (d)), ADDXCCrir((d), -1, JIT_BIG), ADDXrrr(0,0,(d))),\
jit_ner_i(d, rs, JIT_BIG))
#define jit_ner_i(d, s1, s2) (SUBCCrrr((s1), (s2), (d)), ADDXCCrir((d), -1, JIT_BIG), ADDXrrr(0,0,(d)))
#define jit_gei_i(d, rs, is) jit_booli ((d), (rs), (is), BGEi(_jit.pc + 3) )
#define jit_gei_ui(d, rs, is) jit_booli ((d), (rs), (is), BGEUi(_jit.pc + 3))
#define jit_ger_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BGEi(_jit.pc + 3) )
#define jit_ger_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BGEUi(_jit.pc + 3))
#define jit_gti_i(d, rs, is) jit_booli ((d), (rs), (is), BGi(_jit.pc + 3) )
#define jit_gti_ui(d, rs, is) jit_booli ((d), (rs), (is), BGUi(_jit.pc + 3) )
#define jit_gtr_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BGi(_jit.pc + 3) )
#define jit_gtr_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BGUi(_jit.pc + 3) )
#define jit_hmuli_i(d, rs, is) (jit_muli_i (JIT_BIG, (rs), (is)), RDir (_y, (d)))
#define jit_hmuli_ui(d, rs, is) (jit_muli_ui(JIT_BIG, (rs), (is)), RDir (_y, (d)))
#define jit_hmulr_i(d, s1, s2) (jit_mulr_i (JIT_BIG, (s1), (s2)), RDir (_y, (d)))
#define jit_hmulr_ui(d, s1, s2) (jit_mulr_ui(JIT_BIG, (s1), (s2)), RDir (_y, (d)))
#define jit_jmpi(label) (BA_Ai((label)), _jit.pc)
#define jit_jmpr(reg) (JMPx(JIT_RZERO, (reg)), NOP(), _jit.pc - 1)
#define jit_ldxi_c(d, rs, is) jit_chk_imm((is), LDSBmr((rs), (is), (d)), LDSBxr((rs), JIT_BIG, (d)))
#define jit_ldxi_i(d, rs, is) jit_chk_imm((is), LDSWmr((rs), (is), (d)), LDSWxr((rs), JIT_BIG, (d)))
#define jit_ldxi_s(d, rs, is) jit_chk_imm((is), LDSHmr((rs), (is), (d)), LDSHxr((rs), JIT_BIG, (d)))
#define jit_ldxi_uc(d, rs, is) jit_chk_imm((is), LDUBmr((rs), (is), (d)), LDUBxr((rs), JIT_BIG, (d)))
#define jit_ldxi_us(d, rs, is) jit_chk_imm((is), LDUHmr((rs), (is), (d)), LDUHxr((rs), JIT_BIG, (d)))
#define jit_ldxr_c(d, s1, s2) LDSBxr((s1), (s2), (d))
#define jit_ldxr_i(d, s1, s2) LDSWxr((s1), (s2), (d))
#define jit_ldxr_s(d, s1, s2) LDSHxr((s1), (s2), (d))
#define jit_ldxr_uc(d, s1, s2) LDUBxr((s1), (s2), (d))
#define jit_ldxr_us(d, s1, s2) LDUHxr((s1), (s2), (d))
#define jit_lei_i(d, rs, is) jit_booli ((d), (rs), (is), BLEi(_jit.pc + 3) )
#define jit_lei_ui(d, rs, is) jit_booli ((d), (rs), (is), BLEUi(_jit.pc + 3))
#define jit_ler_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BLEi(_jit.pc + 3) )
#define jit_ler_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BLEUi(_jit.pc + 3))
#define jit_lshi_i(d, rs, is) SLLrir((rs), (is), (d))
#define jit_lshr_i(d, r1, r2) SLLrrr((r1), (r2), (d))
#define jit_lti_i(d, rs, is) jit_booli ((d), (rs), (is), BLi(_jit.pc + 3) )
#define jit_lti_ui(d, rs, is) jit_booli ((d), (rs), (is), BLUi(_jit.pc + 3) )
#define jit_ltr_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BLi(_jit.pc + 3) )
#define jit_ltr_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BLUi(_jit.pc + 3) )
#define jit_modi_i(d, rs, is) jit_modi((d), (rs), (is), _rem)
#define jit_modi_ui(d, rs, is) jit_modi((d), (rs), (is), _urem)
#define jit_modr_i(d, s1, s2) jit_modr((d), (s1), (s2), _rem)
#define jit_modr_ui(d, s1, s2) jit_modr((d), (s1), (s2), _urem)
#define jit_movi_i(d, is) SETir((is), (d))
#define jit_movr_i(d, rs) MOVrr((rs), (d))
#define jit_muli_i(d, rs, is) jit_chk_imm((is), SMULrir((rs), (is), (d)), SMULrrr((rs), JIT_BIG, (d)))
#define jit_muli_ui(d, rs, is) jit_chk_imm((is), UMULrir((rs), (is), (d)), UMULrrr((rs), JIT_BIG, (d)))
#define jit_mulr_i(d, s1, s2) SMULrrr((s1), (s2), (d))
#define jit_mulr_ui(d, s1, s2) UMULrrr((s1), (s2), (d))
#define jit_nop() NOP()
#define jit_ori_i(d, rs, is) jit_chk_imm((is), ORrir((rs), (is), (d)), ORrrr((rs), JIT_BIG, (d)))
#define jit_orr_i(d, s1, s2) ORrrr((s1), (s2), (d))
#define jit_patch(delay_pc) jit_patch_ ( ((delay_pc) - 1) )
#define jit_popr_i(rs) (LDmr(JIT_SP, 0, (rs)), ADDrir(JIT_SP, 8, JIT_SP))
#define jitfp_prepare(numargs, nf, nd) (_jitl.nextarg_put = (numargs))
#define jit_prolog(numargs) (SAVErir(JIT_SP, -96, JIT_SP), _jitl.nextarg_get = _Ri(0))
#define jit_pushr_i(rs) (STrm((rs), JIT_SP, -8), SUBrir(JIT_SP, 8, JIT_SP))
#define jit_pusharg_i(rs) (--_jitl.nextarg_put, MOVrr((rs), _Ro(_jitl.nextarg_put)))
#define jit_ret() (RET(), RESTORE())
#define jit_retval(rd) MOVrr(_Ro(0), (rd))
#define jit_rshi_i(d, rs, is) SRArir((rs), (is), (d))
#define jit_rshi_ui(d, rs, is) SRLrir((rs), (is), (d))
#define jit_rshr_i(d, r1, r2) SRArrr((r1), (r2), (d))
#define jit_rshr_ui(d, r1, r2) SRLrrr((r1), (r2), (d))
#define jit_stxi_c(id, rd, rs) jit_chk_imm((id), STBrm((rs), (rd), (id)), STBrx((rs), (rd), JIT_BIG))
#define jit_stxi_i(id, rd, rs) jit_chk_imm((id), STWrm((rs), (rd), (id)), STWrx((rs), (rd), JIT_BIG))
#define jit_stxi_s(id, rd, rs) jit_chk_imm((id), STHrm((rs), (rd), (id)), STHrx((rs), (rd), JIT_BIG))
#define jit_stxr_c(d1, d2, rs) STBrx((rs), (d1), (d2))
#define jit_stxr_i(d1, d2, rs) STWrx((rs), (d1), (d2))
#define jit_stxr_s(d1, d2, rs) STHrx((rs), (d1), (d2))
#define jit_subr_i(d, s1, s2) SUBrrr((s1), (s2), (d))
#define jit_subcr_i(d, s1, s2) SUBCCrrr((s1), (s2), (d))
#define jit_subxi_i(d, rs, is) jit_chk_imm((is), SUBXCCrir((rs), (is), (d)), SUBXCCrrr((rs), JIT_BIG, (d)))
#define jit_subxr_i(d, s1, s2) SUBXCCrrr((s1), (s2), (d))
#define jit_xori_i(d, rs, is) jit_chk_imm((is), XORrir((rs), (is), (d)), XORrrr((rs), JIT_BIG, (d)))
#define jit_xorr_i(d, s1, s2) XORrrr((s1), (s2), (d))
#endif /* __lightning_core_h */

View file

@ -1,163 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Run-time assembler & support macros for the PowerPC math unit
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_asm_fp_h
#define __lightning_asm_fp_h
#if 0
/* dummy for now */
#define _FP1(RD, RS1, OPF, RS2) _2f((RD), 52, (RS1), (OPF), (RS2))
#define _FP2(RD, RS1, OPF, RS2) _2f((RD), 53, (RS1), (OPF), (RS2))
#define FITODrr(FRS, FRD) _FP1((FRD), 0, 200, (FRS))
#define FDTOIrr(FRS, FRD) _FP1((FRD), 0, 210, (FRS))
#define FSTODrr(FRS, FRD) _FP1((FRD), 0, 201, (FRS))
#define FDTOSrr(FRS, FRD) _FP1((FRD), 0, 198, (FRS))
#define FMOVSrr(FRS, FRD) _FP1((FRD), 0, 1, (FRS))
#define FNEGSrr(FRS, FRD) _FP1((FRD), 0, 5, (FRS))
#define FABSSrr(FRS, FRD) _FP1((FRD), 0, 9, (FRS))
#define FSQRTDrr(FRS, FRD) _FP1((FRD), 0, 74, (FRS))
#define FADDDrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 66, (FRS2))
#define FSUBDrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 70, (FRS2))
#define FMULDrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 82, (FRS2))
#define FDIVDrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 86, (FRS2))
#define FCMPDrr(FRS1, FRS2) _FP2(0, (FRS1), 82, (FRS2))
#define LDFxr(RS1, RS2, RD) _3 ((RD), 32, (RS1), 0, 0, (RS2))
#define LDFmr(RS1, IMM, RD) _3i ((RD), 32, (RS1), 1, (IMM))
#define LDDFxr(RS1, RS2, RD) _3 ((RD), 35, (RS1), 0, 0, (RS2))
#define LDDFmr(RS1, IMM, RD) _3i ((RD), 35, (RS1), 1, (IMM))
#define STFrx(RS, RD1, RD2) _3 ((RS), 36, (RD1), 0, 0, (RD2))
#define STFrm(RS, RD1, IMM) _3i ((RS), 36, (RD1), 1, (IMM))
#define STDFrx(RS, RD1, RD2) _3 ((RS), 39, (RD1), 0, 0, (RD2))
#define STDFrm(RS, RD1, IMM) _3i ((RS), 39, (RD1), 1, (IMM))
#define FBNi(DISP) _0 (0, 0, 6, (DISP))
#define FBN_Ai(DISP) _0 (1, 0, 6, (DISP))
#define FBNEi(DISP) _0 (0, 1, 6, (DISP))
#define FBNE_Ai(DISP) _0 (1, 1, 6, (DISP))
#define FBLGi(DISP) _0 (0, 2, 6, (DISP))
#define FBLG_Ai(DISP) _0 (1, 2, 6, (DISP))
#define FBULi(DISP) _0 (0, 3, 6, (DISP))
#define FBUL_Ai(DISP) _0 (1, 3, 6, (DISP))
#define FBLi(DISP) _0 (0, 4, 6, (DISP))
#define FBL_Ai(DISP) _0 (1, 4, 6, (DISP))
#define FBUGi(DISP) _0 (0, 5, 6, (DISP))
#define FBUG_Ai(DISP) _0 (1, 5, 6, (DISP))
#define FBGi(DISP) _0 (0, 6, 6, (DISP))
#define FBG_Ai(DISP) _0 (1, 6, 6, (DISP))
#define FBUi(DISP) _0 (0, 7, 6, (DISP))
#define FBU_Ai(DISP) _0 (1, 7, 6, (DISP))
#define FBAi(DISP) _0 (0, 8, 6, (DISP))
#define FBA_Ai(DISP) _0 (1, 8, 6, (DISP))
#define FBEi(DISP) _0 (0, 9, 6, (DISP))
#define FBE_Ai(DISP) _0 (1, 9, 6, (DISP))
#define FBUEi(DISP) _0 (0, 10, 6, (DISP))
#define FBUE_Ai(DISP) _0 (1, 10, 6, (DISP))
#define FBGEi(DISP) _0 (0, 11, 6, (DISP))
#define FBGE_Ai(DISP) _0 (1, 11, 6, (DISP))
#define FBUGEi(DISP) _0 (0, 12, 6, (DISP))
#define FBUGE_Ai(DISP) _0 (1, 12, 6, (DISP))
#define FBLEi(DISP) _0 (0, 13, 6, (DISP))
#define FBLE_Ai(DISP) _0 (1, 13, 6, (DISP))
#define FBULEi(DISP) _0 (0, 14, 6, (DISP))
#define FBULE_Ai(DISP) _0 (1, 14, 6, (DISP))
#define FBOi(DISP) _0 (0, 15, 6, (DISP))
#define FBO_Ai(DISP) _0 (1, 15, 6, (DISP))
#define FSKIPUG() _0d (1, 13, 6, 2) /* fble,a .+8 */
#define FSKIPUL() _0d (1, 11, 6, 2) /* fbge,a .+8 */
#define jit_add_two(reg0) FADDDrrr(30 - (reg0) * 2, 28 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_sub_two(reg0) FSUBDrrr(30 - (reg0) * 2, 28 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_mul_two(reg0) FMULDrrr(30 - (reg0) * 2, 28 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_div_two(reg0) FDIVDrrr(30 - (reg0) * 2, 28 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_abs(reg0) FABSSrr(30 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_neg(reg0) FNEGSrr(30 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_sqrt(reg0) FSQRTDrr(30 - (reg0) * 2, 30 - (reg0) * 2)
#define jit_fpimm(reg0, first, second) \
(_1(4), NOP(), _L(first), _L(second), \
jit_ldxi_d((reg0), _Ro(7), 8))
#define jit_ldxi_f(reg0, rs, is) (jit_chk_imm((is), LDFmr((rs), (is), 30 - (reg0) * 2), LDFxr((rs), JIT_BIG, 30 - (reg0) * 2)), FSTODrr(30 - (reg0) * 2, 30 - (reg0) * 2))
#define jit_ldxi_d(reg0, rs, is) jit_chk_imm((is), LDDFmr((rs), (is), 30 - (reg0) * 2), LDDFxr((rs), JIT_BIG, 30 - (reg0) * 2))
#define jit_ldxr_f(reg0, s1, s2) (LDFxr((s1), (s2), 30 - (reg0) * 2), FSTODrr(30 - (reg0) * 2, 30 - (reg0) * 2))
#define jit_ldxr_d(reg0, s1, s2) LDDFxr((s1), (s2), 30 - (reg0) * 2)
#define jit_stxi_f(id, rd, reg0) (FDTOSrr(30 - (reg0) * 2, 30 - (reg0) * 2), jit_chk_imm((id), STFrm(30 - (reg0) * 2, (rd), (id)), STFrx(30 - (reg0) * 2, (rd), JIT_BIG)))
#define jit_stxi_d(id, rd, reg0) jit_chk_imm((id), STDFrm(30 - (reg0) * 2, (rd), (id)), STDFrx(30 - (reg0) * 2, (rd), JIT_BIG))
#define jit_stxr_f(d1, d2, reg0) (FDTOSrr(30 - (reg0) * 2, 30 - (reg0) * 2), STFrx (30 - (reg0) * 2, (d1), (d2)))
#define jit_stxr_d(d1, d2, reg0) STDFrx(30 - (reg0) * 2, (d1), (d2))
#define jit_do_round(mode, rd, freg) ( \
_1(3), \
SETHIir(_HI(mode << 29), JIT_BIG), \
NOP(), \
STFSRm(_Ro(7), 8), /* store fsr */ \
LDmr(_Ro(7), 8, rd), \
XORrrr(rd, JIT_BIG, JIT_BIG), /* adjust mode */ \
STrm(JIT_BIG, _Ro(7), 8), \
LDFSRm(_Ro(7), 8), /* load fsr */ \
FDTOIrr(freg, freg), /* truncate */ \
STrm(rd, _Ro(7), 8), /* load old fsr */ \
LDFSRm(_Ro(7), 8), \
STFrm(freg, _Ro(7), 8), /* store truncated value */ \
LDmr(_Ro(7), 8, rd)) /* load it into rd */
/* call delay slot data ,--- call lands here */
#define jit_exti_d(reg0, rs) (_1(3), NOP(), NOP(), STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, 30 - (reg0) * 2), FITODrr(30 - (reg0) * 2, 30 - (reg0) * 2))
#define jit_round(rd, reg0) (_1(3), FDTOIrr(30 - (reg0) * 2, 30 - (reg0) * 2), NOP(), STFrm(30 - (reg0) * 2, _Ro(7), 8), LDmr(_Ro(7), 8, (rd)))
#define jit_floor(rd, reg0) jit_do_round(3, (rd), (30 - (reg0) * 2))
#define jit_ceil(rd, reg0) jit_do_round(2, (rd), (30 - (reg0) * 2))
#define jit_trunc(rd, reg0) jit_do_round(1, (rd), (30 - (reg0) * 2))
static double jit_zero = 0.0;
#define jit_cmp(le, ge, reg0) (SETHIir(_HI(_UL(&jit_zero)), (le)), \
LDDFmr((le), _LO(_UL(&jit_zero)), 28 - (reg0) * 2), \
FCMPDrr(30 - (reg0) * 2, 28 - (reg0) * 2), \
MOVir(0, (le)), MOVir(0, (ge)), \
FSKIPUL(), MOVir(1, (ge)), \
FSKIPUG(), MOVir(1, (le)))
#endif
#endif /* __lightning_asm_fp_h */

View file

@ -1,65 +0,0 @@
/******************************** -*- C -*- ****************************
*
* Platform-independent layer inline functions (Sparc)
*
***********************************************************************/
/***********************************************************************
*
* Copyright 2000, 2001, 2002 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_funcs_h
#define __lightning_funcs_h
#if !defined(__GNUC__) && !defined(__GNUG__)
#error Go get GNU C, I do not know how to flush the cache
#error with this compiler.
#else
/* Why doesn't this compile?!?
* static void
* jit_flush_code(start, end)
* void *start;
* void *end;
*/
static void
jit_flush_code(void* start, void* end)
{
#ifndef LIGHTNING_CROSS
register char *dest;
__asm__ __volatile__ ("stbar");
for (dest = (char *)start; dest <= (char *)end; dest += 4) {
__asm__ __volatile__ ("flush %0"::"r"(dest));
}
/* [SPARC Architecture Manual v8, page 139, implementation note #5] */
__asm__ __volatile__ ("nop; nop; nop; nop; nop");
#endif
}
#endif
#endif /* __lightning_core_h */

View file

@ -194,7 +194,7 @@ void *create_closure(void *func, size_t *argsizes, unsigned int *mapping, ...)
}
jit_finish(func);
jit_ret();
jit_flush_code(codeBuf, jit_get_ip().ptr);
jit_flush_code(codeBuffer, jit_get_ip().ptr);
return closure;
}