diff --git a/ChangeLog b/ChangeLog index 6acdb0b4a..71653dc90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2012-12-02 Paulo Andrade + + * lightning/Makefile.am, lightning/asm-common.h, + lightning/core-common.h, lightning/fp-common.h, + lightning/funcs-common.h, lightning/i386/Makefile.frag, + lightning/i386/asm-32.h, lightning/i386/asm-64.h, + lightning/i386/asm.h, lightning/i386/core-32.h, + lightning/i386/core-64.h, lightning/i386/core.h, + lightning/i386/fp-32.h, lightning/i386/fp-64.h, + lightning/i386/fp.h, lightning/i386/funcs.h, + lightning/ppc/asm.h, lightning/ppc/core.h, + lightning/ppc/fp.h, lightning/ppc/funcs.h, + lightning/sparc/asm.h, lightning/sparc/core.h, + lightning/sparc/fp.h, lightning/sparc/funcs.h: + Removed. The core logic is used in the new code, and new mips + and arm ports will be added. At first, sparc will not be + supported as it has not yet been ported to the new engine. + 2012-12-02 Paulo Andrade * tests/Makefile.am, tests/3to2.c, tests/3to2.ok, tests/add.c, diff --git a/lightning/Makefile.am b/lightning/Makefile.am deleted file mode 100644 index e133d8590..000000000 --- a/lightning/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -DISTCLEANFILES = asm.h core.h funcs.h fp.h - -EXTRA_DIST = i386/Makefile.frag \ - i386/asm-32.h i386/asm-64.h i386/asm.h \ - i386/core-32.h i386/core-64.h i386/core.h \ - i386/fp-32.h i386/fp-64.h i386/fp.h \ - i386/funcs.h \ - sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \ - ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h - -@lightning_frag@ - -LIGHTNING_COMMON_FILES = funcs-common.h core-common.h fp-common.h asm-common.h - -if LIGHTNING_MAIN - -lightningdir = $(includedir)/lightning -dist_pkgdata_DATA = Makefile.am -dist_lightning_HEADERS = $(LIGHTNING_COMMON_FILES) -nodist_lightning_HEADERS = asm.h core.h funcs.h fp.h $(LIGHTNING_TARGET_FILES) - -else -all-am: - @set frob $(LIGHTNING_TARGET_FILES); shift; \ - for i; \ - do \ - echo $(LN_S) -f $(srcdir)/$$i `basename $$i`; \ - $(LN_S) -f $(srcdir)/$$i `basename $$i`; \ - done - -clean-local: - @set frob $(LIGHTNING_TARGET_FILES); shift; \ - for i; \ - do \ - echo rm -f `basename $$i`; \ - rm -f `basename $$i`; \ - done - -dist-hook: - cp -p $(srcdir)/lightning.h $(distdir) -endif diff --git a/lightning/asm-common.h b/lightning/asm-common.h deleted file mode 100644 index bdaa6c2ea..000000000 --- a/lightning/asm-common.h +++ /dev/null @@ -1,205 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - -#ifndef __lightning_asm_common_h -#define __lightning_asm_common_h_ - - -#ifndef _ASM_SAFETY -#define JITFAIL(MSG) 0 -#else -#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || (defined __GNUC__ && (__GNUC__ == 3 ? __GNUC_MINOR__ >= 2 : __GNUC__ > 3)) -#define JITFAIL(MSG) jit_fail(MSG, __FILE__, __LINE__, __func__) -#elif defined __GNUC__ -#define JITFAIL(MSG) jit_fail(MSG, __FILE__, __LINE__, __FUNCTION__) -#else -#define JITFAIL(MSG) jit_fail(MSG, __FILE__, __LINE__, "(unknown)") -#endif -#endif - -#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || (defined __GNUC__ && (__GNUC__ == 3 ? __GNUC_MINOR__ >= 2 : __GNUC__ > 3)) -#define JITSORRY(MSG) jit_fail("sorry, unimplemented: " MSG, __FILE__, __LINE__, __func__) -#elif defined __GNUC__ -#define JITSORRY(MSG) jit_fail("sorry, unimplemented: " MSG, __FILE__, __LINE__, __FUNCTION__) -#else -#define JITSORRY(MSG) jit_fail("sorry, unimplemented: " MSG, __FILE__, __LINE__, "(unknown)") -#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 _jit_UC(X) ((_uc )(X)) -#define _jit_US(X) ((_us )(X)) -#define _jit_UI(X) ((_ui )(X)) -#define _jit_SI(X) ((int )(X)) -#define _jit_SL(X) ((_sl )(X)) -#define _jit_UL(X) ((_ul )(X)) -# define _PUC(X) ((_uc *)(X)) -# define _PUS(X) ((_us *)(X)) -# define _PUI(X) ((_ui *)(X)) -# define _PSI(X) ((int *)(X)) -# define _PSL(X) ((_sl *)(X)) -# define _PUL(X) ((_ul *)(X)) - -#define _jit_B(B) _jit_UL(((*_jit.x.uc_pc++)= _jit_UC((B)& 0xff))) -#define _jit_W(W) _jit_UL(((*_jit.x.us_pc++)= _jit_US((W)&0xffff))) -#define _jit_I(I) _jit_UL(((*_jit.x.ui_pc++)= _jit_UI((I) ))) -#define _jit_L(L) _jit_UL(((*_jit.x.ul_pc++)= _jit_UL((L) ))) -#define _jit_I_noinc(I) _jit_UL(((*_jit.x.ui_pc)= _jit_UI((I) ))) - -#define _MASK(N) ((unsigned long)((1L<<(N)))-1L) -#define _siP(N,I) (!((((unsigned long)(I))^(((unsigned long)(I))<<1))&~_MASK(N))) -#define _uiP(N,I) (!(((unsigned long)(I))&~_MASK(N))) -#define _suiP(N,I) (_siP(N,I) | _uiP(N,I)) - -#ifndef _ASM_SAFETY -#define _ck_s(W,I) (_jit_UL(I) & _MASK(W)) -#define _ck_u(W,I) (_jit_UL(I) & _MASK(W)) -#define _ck_su(W,I) (_jit_UL(I) & _MASK(W)) -#define _ck_d(W,I) (_jit_UL(I) & _MASK(W)) -#else -#define _ck_s(W,I) (_siP(W,I) ? (_jit_UL(I) & _MASK(W)) : JITFAIL( "signed integer `"#I"' too large for "#W"-bit field")) -#define _ck_u(W,I) (_uiP(W,I) ? (_jit_UL(I) & _MASK(W)) : JITFAIL("unsigned integer `"#I"' too large for "#W"-bit field")) -#define _ck_su(W,I) (_suiP(W,I) ? (_jit_UL(I) & _MASK(W)) : JITFAIL( "integer `"#I"' too large for "#W"-bit field")) -#define _ck_d(W,I) (_siP(W,I) ? (_jit_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 _s32P(I) _siP(32,I) -#define _u8P(I) _uiP(8,I) -#define _u16P(I) _uiP(16,I) -#define _u32P(I) _uiP(32,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 */ diff --git a/lightning/core-common.h b/lightning/core-common.h deleted file mode 100644 index 4182b7d89..000000000 --- a/lightning/core-common.h +++ /dev/null @@ -1,634 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - -#ifndef __lightning_core_common_h -#define __lightning_core_common_h_ - -typedef struct { - union { - jit_insn *pc; - _uc *uc_pc; - _us *us_pc; - _ui *ui_pc; - _ul *ul_pc; - } x; - struct jit_fp *fp; - struct jit_local_state jitl; -} jit_state; - -#ifdef jit_init -static jit_state _jit = jit_init (); -#else -static jit_state _jit; -#endif - -#define JIT_NOREG (-1) -#define JIT_R0 JIT_R(0) -#define JIT_R1 JIT_R(1) -#define JIT_R2 JIT_R(2) -#define JIT_V0 JIT_V(0) -#define JIT_V1 JIT_V(1) -#define JIT_V2 JIT_V(2) - -#define _jitl _jit.jitl - -#define jit_get_ip() (*(jit_code *) &_jit.x.pc) -#define jit_set_ip(ptr) (_jit.x.pc = (ptr), jit_get_ip ()) -#define jit_get_label() (_jit.x.pc) -#define jit_forward() (_jit.x.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)(void); - char (*cptr)(void); - unsigned char (*ucptr)(void); - short (*sptr)(void); - unsigned short (*usptr)(void); - int (*iptr)(void); - unsigned int (*uiptr)(void); - long (*lptr)(void); - unsigned long (*ulptr)(void); - void * (*pptr)(void); - float (*fptr)(void); - double (*dptr)(void); -} 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_subxi_ul(d, rs, is) jit_subxi_l((d), (rs), (is)) -#define jit_subxr_ui(d, s1, s2) jit_subxr_i((d), (s1), (s2)) -#define jit_subxr_ul(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_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)) -#define jit_rsbi_p(d, rs, is) jit_rsbi_ul((d), (rs), (long) (is)) - -#ifndef jit_movi_p -#define jit_movi_p(d, is) (jit_movi_ul((d), (long) (is)), _jit.x.pc) -#endif - -#define jit_patch(pv) jit_patch_at ((pv), (_jit.x.pc)) - -#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_f(d, s1, s2) jit_subr_f((d), (s2), (s1)) -#define jit_rsbr_d(d, s1, s2) jit_subr_d((d), (s2), (s1)) -#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)) -#define jit_rsbr_p(d, s1, s2) jit_subr_p((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) -#define jit_notr_i(d, rs) jit_xori_i((d), (rs), ~0) -#define jit_notr_ui(d, rs) jit_xori_i((d), (rs), ~0) -#define jit_notr_l(d, rs) jit_xori_l((d), (rs), ~0L) -#define jit_notr_ul(d, rs) jit_xori_l((d), (rs), ~0L) - -#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 - -#ifdef jit_addi_l /* sizeof(long) != sizeof(int) */ -#ifndef jit_extr_c_l -#define jit_extr_c_l(d, rs) (jit_lshi_l((d), (rs), 56), jit_rshi_l((d), (d), 56)) -#endif -#ifndef jit_extr_s_l -#define jit_extr_s_l(d, rs) (jit_lshi_l((d), (rs), 48), jit_rshi_l((d), (d), 48)) -#endif -#ifndef jit_extr_i_l -#define jit_extr_i_l(d, rs) (jit_lshi_l((d), (rs), 32), jit_rshi_l((d), (d), 32)) -#endif -#ifndef jit_extr_c_ul -#define jit_extr_c_ul(d, rs) jit_andi_l((d), (rs), 0xFF) -#endif -#ifndef jit_extr_s_ul -#define jit_extr_s_ul(d, rs) jit_andi_l((d), (rs), 0xFFFF) -#endif -#ifndef jit_extr_i_ul -#define jit_extr_i_ul(d, rs) jit_andi_l((d), (rs), 0xFFFFFFFFUL) -#endif -#endif - -#define jit_extr_c_s(d, rs) jit_extr_c_i((d), (rs)) -#define jit_extr_c_us(d, rs) jit_extr_c_ui((d), (rs)) -#define jit_extr_uc_s(d, rs) jit_extr_uc_i((d), (rs)) -#define jit_extr_uc_us(d, rs) jit_extr_uc_ui((d), (rs)) -#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)) -#define jit_extr_uc_l(d, rs) jit_extr_c_ul((d), (rs)) -#define jit_extr_uc_ul(d, rs) jit_extr_c_ul((d), (rs)) -#define jit_extr_us_l(d, rs) jit_extr_s_ul((d), (rs)) -#define jit_extr_us_ul(d, rs) jit_extr_s_ul((d), (rs)) -#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) jit_prepare_i((nint)) -#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)) - -#define jit_ldr_ul(d, rs) jit_ldr_l((d), (rs)) -#define jit_ldi_ul(d, is) jit_ldi_l((d), (is)) -#define jit_ldxr_ul(d, s1, s2) jit_ldxr_l((d), (s1), (s2)) -#define jit_ldxi_ul(d, rs, is) jit_ldxi_l((d), (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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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), (long)(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)) - -/* This was a bug, but we keep it. */ -#define jit_retval(rd) jit_retval_i ((rd)) - -#ifndef jit_finish -#define jit_finish(sub) jit_calli(sub) -#endif - -#ifndef jit_finishr -#define jit_finishr(reg) jit_callr(reg) -#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_AP -#define jit_getarg_c(reg, ofs) jit_extr_c_l ((reg), (ofs)) -#define jit_getarg_i(reg, ofs) jit_extr_i_l ((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_l ((reg), (ofs)) -#define jit_getarg_uc(reg, ofs) jit_extr_uc_ul((reg), (ofs)) -#define jit_getarg_ui(reg, ofs) jit_extr_ui_ul((reg), (ofs)) -#define jit_getarg_ul(reg, ofs) jit_movr_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_AP, (ofs)); -#define jit_getarg_uc(reg, ofs) jit_ldxi_uc((reg), JIT_AP, (ofs)); -#define jit_getarg_s(reg, ofs) jit_ldxi_s((reg), JIT_AP, (ofs)); -#define jit_getarg_us(reg, ofs) jit_ldxi_us((reg), JIT_AP, (ofs)); -#define jit_getarg_i(reg, ofs) jit_ldxi_i((reg), JIT_AP, (ofs)); -#define jit_getarg_ui(reg, ofs) jit_ldxi_ui((reg), JIT_AP, (ofs)); -#define jit_getarg_l(reg, ofs) jit_ldxi_l((reg), JIT_AP, (ofs)); -#define jit_getarg_ul(reg, ofs) jit_ldxi_ul((reg), JIT_AP, (ofs)); -#define jit_getarg_p(reg, ofs) jit_ldxi_p((reg), JIT_AP, (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)) -#ifndef jit_addci_l -#define jit_addci_l(d, rs, is) jit_addci_i((d), (rs), (is)) -#endif -#ifndef jit_addcr_l -#define jit_addcr_l(d, s1, s2) jit_addcr_i((d), (s1), (s2)) -#endif -#define jit_addxi_l(d, rs, is) jit_addxi_i((d), (rs), (is)) -#define jit_addxr_l(d, s1, s2) jit_addxr_i((d), (s1), (s2)) -#define jit_andi_l(d, rs, is) jit_andi_i((d), (rs), (is)) -#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)) -#ifndef jit_negr_l -#define jit_negr_l(d, s1) jit_negr_i((d), (s1)) -#endif -#define jit_ori_l(d, rs, is) jit_ori_i((d), (rs), (is)) -#define jit_orr_l(d, s1, s2) jit_orr_i((d), (s1), (s2)) -#define jit_rshi_l(d, rs, is) jit_rshi_i((d), (rs), (is)) -#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)) - -/* Sign/Zero extension */ -#define jit_extr_c_l(d, rs) jit_extr_c_i(d, rs) -#define jit_extr_c_ul(d, rs) jit_extr_c_ui(d, rs) -#define jit_extr_s_l(d, rs) jit_extr_s_i(d, rs) -#define jit_extr_s_ul(d, rs) jit_extr_s_ui(d, rs) -#define jit_extr_i_l(d, rs) jit_movr_i(d, rs) -#define jit_extr_i_ul(d, rs) jit_movr_i(d, rs) - -/* Unary */ -#ifndef jit_movi_l -#define jit_movi_l(d, rs) jit_movi_i((d), (rs)) -#define jit_movr_l(d, rs) jit_movr_i((d), (rs)) -#endif - -/* 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)) -#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)) - - -/* 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_ */ diff --git a/lightning/fp-common.h b/lightning/fp-common.h deleted file mode 100644 index 0d76f4240..000000000 --- a/lightning/fp-common.h +++ /dev/null @@ -1,149 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - -#define JIT_FPR0 JIT_FPR(0) -#define JIT_FPR1 JIT_FPR(1) -#define JIT_FPR2 JIT_FPR(2) -#define JIT_FPR3 JIT_FPR(3) -#define JIT_FPR4 JIT_FPR(4) -#define JIT_FPR5 JIT_FPR(5) - -#ifdef JIT_RZERO -#ifndef jit_ldi_f -#define jit_ldi_f(rd, is) jit_ldxi_f((rd), JIT_RZERO, (is)) -#define jit_sti_f(id, rs) jit_stxi_f((id), JIT_RZERO, (rs)) -#define jit_ldi_d(rd, is) jit_ldxi_d((rd), JIT_RZERO, (is)) -#define jit_sti_d(id, rs) jit_stxi_d((id), JIT_RZERO, (rs)) -#endif - -#ifndef jit_ldr_f -#define jit_ldr_f(rd, rs) jit_ldxr_f((rd), JIT_RZERO, (rs)) -#define jit_str_f(rd, rs) jit_stxr_f((rd), JIT_RZERO, (rs)) -#define jit_ldr_d(rd, rs) jit_ldxr_d((rd), JIT_RZERO, (rs)) -#define jit_str_d(rd, rs) jit_stxr_d((rd), JIT_RZERO, (rs)) -#endif -#endif - -#ifndef jit_addr_f -#define jit_addr_f(rd,s1,s2) jit_addr_d(rd,s1,s2) -#define jit_subr_f(rd,s1,s2) jit_subr_d(rd,s1,s2) -#define jit_mulr_f(rd,s1,s2) jit_mulr_d(rd,s1,s2) -#define jit_divr_f(rd,s1,s2) jit_divr_d(rd,s1,s2) -#define jit_movr_f(rd,rs) jit_movr_d(rd,rs) -#define jit_abs_f(rd,rs) jit_abs_d(rd,rs) -#define jit_negr_f(rd,rs) jit_negr_d(rd,rs) -#define jit_sqrt_f(rd,rs) jit_sqrt_d(rd,rs) -#define jit_extr_i_f(rd, rs) jit_extr_i_d(rd, rs) -#define jit_roundr_f_i(rd, rs) jit_roundr_d_i(rd, rs) -#define jit_floorr_f_i(rd, rs) jit_floorr_d_i(rd, rs) -#define jit_ceilr_f_i(rd, rs) jit_ceilr_d_i(rd, rs) -#define jit_truncr_f_i(rd, rs) jit_truncr_d_i(rd, rs) -#define jit_ltr_f(d, s1, s2) jit_ltr_d(d, s1, s2) -#define jit_ler_f(d, s1, s2) jit_ler_d(d, s1, s2) -#define jit_eqr_f(d, s1, s2) jit_eqr_d(d, s1, s2) -#define jit_ner_f(d, s1, s2) jit_ner_d(d, s1, s2) -#define jit_ger_f(d, s1, s2) jit_ger_d(d, s1, s2) -#define jit_gtr_f(d, s1, s2) jit_gtr_d(d, s1, s2) -#define jit_unltr_f(d, s1, s2) jit_unltr_d(d, s1, s2) -#define jit_unler_f(d, s1, s2) jit_unler_d(d, s1, s2) -#define jit_uneqr_f(d, s1, s2) jit_uneqr_d(d, s1, s2) -#define jit_ltgtr_f(d, s1, s2) jit_ltgtr_d(d, s1, s2) -#define jit_unger_f(d, s1, s2) jit_unger_d(d, s1, s2) -#define jit_ungtr_f(d, s1, s2) jit_ungtr_d(d, s1, s2) -#define jit_ordr_f(d, s1, s2) jit_ordr_d(d, s1, s2) -#define jit_unordr_f(d, s1, s2) jit_unordr_d(d, s1, s2) -#define jit_retval_f(rs) jit_retval_d(rs) -#endif - -#ifndef jit_extr_f_d -#define jit_extr_f_d(rd, rs) jit_movr_d(rd, rs) -#endif - -#ifndef jit_extr_d_f -#define jit_extr_d_f(rd, rs) jit_movr_d(rd, rs) -#endif - -#if !defined(__WORDSIZE) || __WORDSIZE == 32 -# if !defined(jit_extr_l_f) -# define jit_extr_l_f(rd, rs) jit_extr_i_f(rd, rs) -# endif -# if !defined(jit_extr_l_d) -# define jit_extr_l_d(rd, rs) jit_extr_i_d(rd, rs) -# endif -# if !defined(jit_roundr_f_l) -# define jit_roundr_f_l(rd, rs) jit_roundr_f_i(rd, rs) -# define jit_truncr_f_l(rd, rs) jit_truncr_f_i(rd, rs) -# define jit_floorr_f_l(rd, rs) jit_floorr_f_i(rd, rs) -# define jit_ceilr_f_l(rd, rs) jit_ceilr_f_i(rd, rs) -# endif -# if !defined(jit_roundr_d_l) -# define jit_roundr_d_l(rd, rs) jit_roundr_d_i(rd, rs) -# define jit_truncr_d_l(rd, rs) jit_truncr_d_i(rd, rs) -# define jit_floorr_d_l(rd, rs) jit_floorr_d_i(rd, rs) -# define jit_ceilr_d_l(rd, rs) jit_ceilr_d_i(rd, rs) -# endif -#endif - -#ifndef jit_beqr_f -#define jit_beqr_f(lab, a, b) jit_beqr_d(lab, a, b) -#define jit_bner_f(lab, a, b) jit_bner_d(lab, a, b) -#define jit_bgtr_f(lab, a, b) jit_bgtr_d(lab, a, b) -#define jit_bger_f(lab, a, b) jit_bger_d(lab, a, b) -#define jit_bltr_f(lab, a, b) jit_bltr_d(lab, a, b) -#define jit_bler_f(lab, a, b) jit_bler_d(lab, a, b) -#define jit_buneqr_f(lab, a, b) jit_buneqr_d(lab, a, b) -#define jit_bltgtr_f(lab, a, b) jit_bltgtr_d(lab, a, b) -#define jit_bungtr_f(lab, a, b) jit_bungtr_d(lab, a, b) -#define jit_bunger_f(lab, a, b) jit_bunger_d(lab, a, b) -#define jit_bunltr_f(lab, a, b) jit_bunltr_d(lab, a, b) -#define jit_bunler_f(lab, a, b) jit_bunler_d(lab, a, b) -#define jit_bordr_f(lab, a, b) jit_bordr_d(lab, a, b) -#define jit_bunordr_f(lab, a, b) jit_bunordr_d(lab, a, b) -#endif - -#ifndef jit_retval_f -#define jit_retval_f(op1) jit_movr_f((op1), JIT_FPRET) -#endif - -#ifndef jit_retval_d -#define jit_retval_d(op1) jit_movr_d((op1), JIT_FPRET) -#endif - -#ifndef jit_getarg_f -#ifndef JIT_AP -#define jit_getarg_f(reg, ofs) jit_movr_f ((reg), (ofs)) -#define jit_getarg_d(reg, ofs) jit_movr_d ((reg), (ofs)) -#else -#define jit_getarg_f(reg, ofs) jit_ldxi_f((reg), JIT_AP, (ofs)); -#define jit_getarg_d(reg, ofs) jit_ldxi_d((reg), JIT_AP, (ofs)); -#endif -#endif - diff --git a/lightning/funcs-common.h b/lightning/funcs-common.h deleted file mode 100644 index b9e400cef..000000000 --- a/lightning/funcs-common.h +++ /dev/null @@ -1,49 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - -#ifndef __lightning_funcs_common_h -#define __lightning_funcs_common_h - -#include -#include - -static int jit_fail(const char *, const char*, int, const char *) JIT_UNUSED; - -int -jit_fail(const char *msg, const char *file, int line, const char *function) -{ - fprintf(stderr, "%s: In function `%s':\n", file, function); - fprintf(stderr, "%s:%d: %s\n", file, line, msg); - abort(); -} - - -#endif /* __lightning_funcs_common_h */ diff --git a/lightning/i386/Makefile.frag b/lightning/i386/Makefile.frag deleted file mode 100644 index c61495a4d..000000000 --- a/lightning/i386/Makefile.frag +++ /dev/null @@ -1,2 +0,0 @@ -LIGHTNING_TARGET_FILES += i386/asm-32.h i386/core-32.h \ - i386/asm-64.h i386/core-64.h i386/fp-32.h i386/fp-64.h diff --git a/lightning/i386/asm-32.h b/lightning/i386/asm-32.h deleted file mode 100644 index c5c0f802d..000000000 --- a/lightning/i386/asm-32.h +++ /dev/null @@ -1,125 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Run-time assembler for the i386 - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2003 Gwenole Beauchesne - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_asm_h -#define __lightning_asm_h - -#ifndef LIGHTNING_DEBUG - -/* OPCODE + i = immediate operand - * + r = register operand - * + m = memory operand (disp,base,index,scale) - * + sr/sm = a star preceding a register or memory - */ - -#if !_ASM_SAFETY -# define _r1(R) _rN(R) -# define _r2(R) _rN(R) -# define _r4(R) _rN(R) -# define _r8(R) _rN(R) -# define _rM(R) _rN(R) -# define _rX(R) _rN(R) -#else -/* _r1() used to check only for _AL and _AH but there is - * usage of _CL and _DL when _*AX is already an operand */ -# define _r1(R) \ - /* Valid 32 bit register? */ \ - ((!((R) & ~0x77) \ - /* 32, 16 or 8 bit register? */ \ - && (((_rC(R) == 0x40 || _rC(R) == 0x30 || _rC(R) == 0x10) \ - /* Yes. Register is _AL, _CL or _DL? */ \ - && ( (_rN(R) | 0x10) == _AL \ - || (_rN(R) | 0x10) == _CL \ - || (_rN(R) | 0x10) == _DL)) \ - /* No. Register is _AH? */ \ - || ((_rC(R) == 0x20 && (_rN(R) | 0x20) == _AH)))) \ - ? _rN(R) : JITFAIL("bad 8-bit register " #R)) -# define _r2(R) \ - /* Valid 32 bit register? */ \ - ((!((R) & ~0x77) \ - /* 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x40 || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 16-bit register " #R)) -# define _r4(R) \ - /* Valid 32 bit register? */ \ - ((!((R) & ~0x77) \ - /* 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x40 || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 32-bit register " #R)) -# define _r8(R) \ - JITFAIL("bad 64-bit register " #R) -# define _rM(R) \ - /* Valid MMX register? */ \ - ((!((R) & ~0x67) && _rC(R) == 0x60) \ - ? _rN(R) : JITFAIL("bad MMX register " #R)) -# define _rX(R) \ - /* Valid SSE register? */ \ - ((!((R) & ~0x77) && _rC(R) == 0x70) \ - ? _rN(R) : JITFAIL("bad SSE register " #R)) -#endif - -#define _rA(R) _r4(R) - -#define jit_check8(rs) ((_rN(rs) | _AL) == _AL) -#define jit_reg8(rs) \ - ((jit_reg16(rs) == _SI || jit_reg16(rs) == _DI) \ - ? _AL : (_rN(rs) | _AL)) -#define jit_reg16(rs) (_rN(rs) | _AX) - -/* Use RIP-addressing in 64-bit mode, if possible */ -#define _r_X( R, D,B,I,S,O) (_r0P(I) ? (_r0P(B) ? _r_D (R,D ) : \ - (_rsp12P(B) ? _r_DBIS(R,D,_ESP,_ESP,1) : \ - _r_DB (R,D, B ))) : \ - (_r0P(B) ? _r_4IS (R,D, I,S) : \ - (!_rspP(I) ? _r_DBIS(R,D, B, I,S) : \ - JITFAIL("illegal index register: %esp")))) -#define _m32only(X) (X) -#define _m64only(X) JITFAIL("invalid instruction in 32-bit mode") -#define _m64(X) ((void)0) - -#define _AH 0x24 -#define _CH 0x25 -#define _DH 0x26 -#define _BH 0x27 - -#define CALLsr(R) CALLLsr(R) -#define JMPsr(R) JMPLsr(R) - -#define DECWr(RD) (_d16(), _Or (0x48,_r2(RD) )) -#define DECLr(RD) _Or (0x48,_r4(RD) ) -#define INCWr(RD) (_d16(), _Or (0x40,_r2(RD) )) -#define INCLr(RD) _Or (0x40,_r4(RD) ) - -#endif -#endif /* __lightning_asm_h */ diff --git a/lightning/i386/asm-64.h b/lightning/i386/asm-64.h deleted file mode 100644 index 66680f486..000000000 --- a/lightning/i386/asm-64.h +++ /dev/null @@ -1,431 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Run-time assembler for the x86-64 - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2003 Gwenole Beauchesne - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_asm_h -#define __lightning_asm_h - -#ifndef LIGHTNING_DEBUG - -/* OPCODE + i = immediate operand - * + r = register operand - * + m = memory operand (disp,base,index,scale) - * + sr/sm = a star preceding a register or memory - */ - -#if !_ASM_SAFETY -# define _r1(R) _rN(R) -# define _r2(R) _rN(R) -# define _r4(R) _rN(R) -# define _r8(R) _rN(R) -# define _rM(R) _rN(R) -# define _rX(R) _rN(R) -#else -# define _r1(R) \ - /* Valid 64 bit register? */ \ - ((!((R) & ~0xff) \ - /* 64, 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x50 || _rC(R) == 0x40 \ - || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 8-bit register " #R)) -# define _r2(R) \ - /* Valid 64 bit register? */ \ - ((!((R) & ~0xff) \ - /* 64, 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x50 || _rC(R) == 0x40 \ - || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 16-bit register " #R)) -# define _r4(R) \ - /* Valid 64 bit register? */ \ - ((!((R) & ~0xff) \ - /* 64, 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x50 || _rC(R) == 0x40 \ - || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 32-bit register " #R)) -# define _r8(R) \ - /* Valid 64 bit register? */ \ - ((!((R) & ~0xff) \ - /* 64, 32, 16 or 8 bit register? */ \ - && (_rC(R) == 0x50 || _rC(R) == 0x40 \ - || _rC(R) == 0x30 || _rC(R) == 0x10)) \ - ? _rN(R) : JITFAIL("bad 64-bit register " #R)) -# define _rM(R) \ - /* Valid MMX* register? */ \ - ((!((R) & ~0x6f) && _rC(R) == 0x60) \ - ? _rN(R) : JITFAIL("bad MMX register " #R)) -# define _rX(R) \ - /* Valid SSE2 register? */ \ - ((!((R) & ~0x7f) && _rC(R) == 0x70) \ - ? _rN(R) : JITFAIL("bad SSE2 register " #R)) -#endif - -#define _rA(R) _r8(R) - -#define jit_check8(rs) 1 -#define jit_reg8(rs) (_rR(rs) | _AL) -#define jit_reg16(rs) (_rR(rs) | _AX) - -/* Use RIP-addressing in 64-bit mode, if possible */ -#if 0 -#define _x86_RIP_addressing_possible(D,O) (X86_RIP_RELATIVE_ADDR && \ - ((unsigned long)x86_get_target() + 4 + (O) - (D) <= 0xffffffff)) - -#define _r_X( R, D,B,I,S,O) (_r0P(I) ? (_r0P(B) ? (!X86_TARGET_64BIT ? _r_D(R,D) : \ - (_x86_RIP_addressing_possible(D, O) ? \ - _r_D(R, (D) - ((unsigned long)x86_get_target() + 4 + (O))) : \ - _r_DSIB(R,D))) : \ - _r_DSIB(R,D )) : \ - (_rIP(B) ? _r_D (R,D ) : \ - (_rsp12P(B) ? _r_DBIS(R,D,_RSP,_RSP,1) : \ - _r_DB (R,D, B )))) : \ - (_r0P(B) ? _r_4IS (R,D, I,S) : \ - (!_rspP(I) ? _r_DBIS(R,D, B, I,S) : \ - JITFAIL("illegal index register: %esp")))) -#else -#define _r_X( R, D,B,I,S,O) (_r0P(I) ? (_r0P(B) ? _r_DSIB(R,D ) : \ - (_rIP(B) ? _r_D (R,D ) : \ - (_rsp12P(B) ? _r_DBIS(R,D,_RSP,_RSP,1) : \ - _r_DB (R,D, B )))) : \ - (_r0P(B) ? _r_4IS (R,D, I,S) : \ - (!_rspP(I) ? _r_DBIS(R,D, B, I,S) : \ - JITFAIL("illegal index register: %esp")))) -#endif - - -#define _m32only(X) (JITFAIL("invalid instruction in 64-bit mode")) -#define _m64only(X) (X) -#define _m64(X) (X) - -#define _SPL 0x14 -#define _BPL 0x15 -#define _SIL 0x16 -#define _DIL 0x17 -#define _R8B 0x18 -#define _R9B 0x19 -#define _R10B 0x1A -#define _R11B 0x1B -#define _R12B 0x1C -#define _R13B 0x1D -#define _R14B 0x1E -#define _R15B 0x1F - -#define _R8W 0x38 -#define _R9W 0x39 -#define _R10W 0x3A -#define _R11W 0x3B -#define _R12W 0x3C -#define _R13W 0x3D -#define _R14W 0x3E -#define _R15W 0x3F -#define _R8D 0x48 -#define _R9D 0x49 -#define _R10D 0x4A -#define _R11D 0x4B -#define _R12D 0x4C -#define _R13D 0x4D -#define _R14D 0x4E -#define _R15D 0x4F - -#define _RAX 0x50 -#define _RCX 0x51 -#define _RDX 0x52 -#define _RBX 0x53 -#define _RSP 0x54 -#define _RBP 0x55 -#define _RSI 0x56 -#define _RDI 0x57 -#define _R8 0x58 -#define _R9 0x59 -#define _R10 0x5A -#define _R11 0x5B -#define _R12 0x5C -#define _R13 0x5D -#define _R14 0x5E -#define _R15 0x5F -#define _RIP -2 - -#define _r1e8lP(R) ((int)(R) >= _SPL && (int)(R) <= _DIL) - -#define DECWr(RD) (_d16(), _REXLrr(0, RD), _O_Mrm (0xff ,_b11,_b001 ,_r2(RD) )) -#define DECLr(RD) (_REXLrr(0, RD), _O_Mrm (0xff ,_b11,_b001 ,_r4(RD) )) -#define INCWr(RD) (_d16(), _REXLrr(0, RD), _O_Mrm (0xff ,_b11,_b000 ,_r2(RD) )) -#define INCLr(RD) (_REXLrr(0, RD), _O_Mrm (0xff ,_b11,_b000 ,_r4(RD) )) - -#define ADCQrr(RS, RD) _ALUQrr(X86_ADC, RS, RD) -#define ADCQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_ADC, MD, MB, MI, MS, RD) -#define ADCQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_ADC, RS, MD, MB, MI, MS) -#define ADCQir(IM, RD) _ALUQir(X86_ADC, IM, RD) -#define ADCQim(IM, MD, MB, MI, MS) _ALUQim(X86_ADC, IM, MD, MB, MI, MS) - -#define ADDQrr(RS, RD) _ALUQrr(X86_ADD, RS, RD) -#define ADDQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_ADD, MD, MB, MI, MS, RD) -#define ADDQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_ADD, RS, MD, MB, MI, MS) -#define ADDQir(IM, RD) _ALUQir(X86_ADD, IM, RD) -#define ADDQim(IM, MD, MB, MI, MS) _ALUQim(X86_ADD, IM, MD, MB, MI, MS) - -#define ANDQrr(RS, RD) _ALUQrr(X86_AND, RS, RD) -#define ANDQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_AND, MD, MB, MI, MS, RD) -#define ANDQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_AND, RS, MD, MB, MI, MS) -#define ANDQir(IM, RD) _ALUQir(X86_AND, IM, RD) -#define ANDQim(IM, MD, MB, MI, MS) _ALUQim(X86_AND, IM, MD, MB, MI, MS) - -#define CMPQrr(RS, RD) _ALUQrr(X86_CMP, RS, RD) -#define CMPQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_CMP, MD, MB, MI, MS, RD) -#define CMPQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_CMP, RS, MD, MB, MI, MS) -#define CMPQir(IM, RD) _ALUQir(X86_CMP, IM, RD) -#define CMPQim(IM, MD, MB, MI, MS) _ALUQim(X86_CMP, IM, MD, MB, MI, MS) - -#define ORQrr(RS, RD) _ALUQrr(X86_OR, RS, RD) -#define ORQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_OR, MD, MB, MI, MS, RD) -#define ORQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_OR, RS, MD, MB, MI, MS) -#define ORQir(IM, RD) _ALUQir(X86_OR, IM, RD) -#define ORQim(IM, MD, MB, MI, MS) _ALUQim(X86_OR, IM, MD, MB, MI, MS) - -#define SBBQrr(RS, RD) _ALUQrr(X86_SBB, RS, RD) -#define SBBQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_SBB, MD, MB, MI, MS, RD) -#define SBBQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_SBB, RS, MD, MB, MI, MS) -#define SBBQir(IM, RD) _ALUQir(X86_SBB, IM, RD) -#define SBBQim(IM, MD, MB, MI, MS) _ALUQim(X86_SBB, IM, MD, MB, MI, MS) - -#define SUBQrr(RS, RD) _ALUQrr(X86_SUB, RS, RD) -#define SUBQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_SUB, MD, MB, MI, MS, RD) -#define SUBQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_SUB, RS, MD, MB, MI, MS) -#define SUBQir(IM, RD) _ALUQir(X86_SUB, IM, RD) -#define SUBQim(IM, MD, MB, MI, MS) _ALUQim(X86_SUB, IM, MD, MB, MI, MS) - -#define XORQrr(RS, RD) _ALUQrr(X86_XOR, RS, RD) -#define XORQmr(MD, MB, MI, MS, RD) _ALUQmr(X86_XOR, MD, MB, MI, MS, RD) -#define XORQrm(RS, MD, MB, MI, MS) _ALUQrm(X86_XOR, RS, MD, MB, MI, MS) -#define XORQir(IM, RD) _ALUQir(X86_XOR, IM, RD) -#define XORQim(IM, MD, MB, MI, MS) _ALUQim(X86_XOR, IM, MD, MB, MI, MS) - -#define ROLQir(IM, RD) _ROTSHIQir(X86_ROL, IM, RD) -#define ROLQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_ROL, IM, MD, MB, MI, MS) -#define ROLQrr(RS, RD) _ROTSHIQrr(X86_ROL, RS, RD) -#define ROLQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_ROL, RS, MD, MB, MI, MS) - -#define RORQir(IM, RD) _ROTSHIQir(X86_ROR, IM, RD) -#define RORQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_ROR, IM, MD, MB, MI, MS) -#define RORQrr(RS, RD) _ROTSHIQrr(X86_ROR, RS, RD) -#define RORQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_ROR, RS, MD, MB, MI, MS) - -#define RCLQir(IM, RD) _ROTSHIQir(X86_RCL, IM, RD) -#define RCLQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_RCL, IM, MD, MB, MI, MS) -#define RCLQrr(RS, RD) _ROTSHIQrr(X86_RCL, RS, RD) -#define RCLQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_RCL, RS, MD, MB, MI, MS) - -#define RCRQir(IM, RD) _ROTSHIQir(X86_RCR, IM, RD) -#define RCRQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_RCR, IM, MD, MB, MI, MS) -#define RCRQrr(RS, RD) _ROTSHIQrr(X86_RCR, RS, RD) -#define RCRQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_RCR, RS, MD, MB, MI, MS) - -#define SHLQir(IM, RD) _ROTSHIQir(X86_SHL, IM, RD) -#define SHLQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_SHL, IM, MD, MB, MI, MS) -#define SHLQrr(RS, RD) _ROTSHIQrr(X86_SHL, RS, RD) -#define SHLQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_SHL, RS, MD, MB, MI, MS) - -#define SHRQir(IM, RD) _ROTSHIQir(X86_SHR, IM, RD) -#define SHRQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_SHR, IM, MD, MB, MI, MS) -#define SHRQrr(RS, RD) _ROTSHIQrr(X86_SHR, RS, RD) -#define SHRQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_SHR, RS, MD, MB, MI, MS) - -#define SALQir SHLQir -#define SALQim SHLQim -#define SALQrr SHLQrr -#define SALQrm SHLQrm - -#define SARQir(IM, RD) _ROTSHIQir(X86_SAR, IM, RD) -#define SARQim(IM, MD, MB, MI, MS) _ROTSHIQim(X86_SAR, IM, MD, MB, MI, MS) -#define SARQrr(RS, RD) _ROTSHIQrr(X86_SAR, RS, RD) -#define SARQrm(RS, MD, MB, MI, MS) _ROTSHIQrm(X86_SAR, RS, MD, MB, MI, MS) - -#define BTQir(IM, RD) _BTQir(X86_BT, IM, RD) -#define BTQim(IM, MD, MB, MI, MS) _BTQim(X86_BT, IM, MD, MB, MI, MS) -#define BTQrr(RS, RD) _BTQrr(X86_BT, RS, RD) -#define BTQrm(RS, MD, MB, MI, MS) _BTQrm(X86_BT, RS, MD, MB, MI, MS) - -#define BTCQir(IM, RD) _BTQir(X86_BTC, IM, RD) -#define BTCQim(IM, MD, MB, MI, MS) _BTQim(X86_BTC, IM, MD, MB, MI, MS) -#define BTCQrr(RS, RD) _BTQrr(X86_BTC, RS, RD) -#define BTCQrm(RS, MD, MB, MI, MS) _BTQrm(X86_BTC, RS, MD, MB, MI, MS) - -#define BTRQir(IM, RD) _BTQir(X86_BTR, IM, RD) -#define BTRQim(IM, MD, MB, MI, MS) _BTQim(X86_BTR, IM, MD, MB, MI, MS) -#define BTRQrr(RS, RD) _BTQrr(X86_BTR, RS, RD) -#define BTRQrm(RS, MD, MB, MI, MS) _BTQrm(X86_BTR, RS, MD, MB, MI, MS) - -#define BTSQir(IM, RD) _BTQir(X86_BTS, IM, RD) -#define BTSQim(IM, MD, MB, MI, MS) _BTQim(X86_BTS, IM, MD, MB, MI, MS) -#define BTSQrr(RS, RD) _BTQrr(X86_BTS, RS, RD) -#define BTSQrm(RS, MD, MB, MI, MS) _BTQrm(X86_BTS, RS, MD, MB, MI, MS) - -#define LEAQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _O_r_X (0x8d ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVQrr(RS, RD) (_REXQrr(RS, RD), _O_Mrm (0x89 ,_b11,_r8(RS),_r8(RD) )) -#define MOVQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _O_r_X (0x8b ,_r8(RD) ,MD,MB,MI,MS )) -#define MOVQrm(RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _O_r_X (0x89 ,_r8(RS) ,MD,MB,MI,MS )) -#define MOVQir(IM, R) (_REXQrr(0, R), _Or_Q (0xb8,_r8(R) ,IM )) -#define MOVQim(IM, MD, MB, MI, MS) (_REXQrm(0, MB, MI), _O_X_L (0xc7 ,MD,MB,MI,MS ,IM )) - -#define NOTQr(RS) _UNARYQr(X86_NOT, RS) -#define NOTQm(MD, MB, MI, MS) _UNARYQm(X86_NOT, MD, MB, MI, MS) - -#define NEGQr(RS) _UNARYQr(X86_NEG, RS) -#define NEGQm(MD, MB, MI, MS) _UNARYQm(X86_NEG, MD, MB, MI, MS) - -#define MULQr(RS) _UNARYQr(X86_MUL, RS) -#define MULQm(MD, MB, MI, MS) _UNARYQm(X86_MUL, MD, MB, MI, MS) - -#define IMULQr(RS) _UNARYQr(X86_IMUL, RS) -#define IMULQm(MD, MB, MI, MS) _UNARYQm(X86_IMUL, MD, MB, MI, MS) - -#define DIVQr(RS) _UNARYQr(X86_DIV, RS) -#define DIVQm(MD, MB, MI, MS) _UNARYQm(X86_DIV, MD, MB, MI, MS) - -#define IDIVQr(RS) _UNARYQr(X86_IDIV, RS) -#define IDIVQm(MD, MB, MI, MS) _UNARYQm(X86_IDIV, MD, MB, MI, MS) - -#define IMULQir(IM, RD) IMULQirr(IM, RD, RD) -#define IMULQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0faf ,_b11,_r8(RD),_r8(RS) )) -#define IMULQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0faf ,_r8(RD) ,MD,MB,MI,MS )) -#define IMULQirr(IM,RS,RD) (_REXQrr(RD, RS), _Os_Mrm_sL (0x69 ,_b11,_r8(RS),_r8(RD) ,IM )) -#define IMULQimr(IM,MD,MB,MI,MS,RD) (_REXQmr(MB, MI, RD), _Os_r_X_sL (0x69 ,_r8(RD) ,MD,MB,MI,MS ,IM )) - -#define CALLQsr(R) (_REXQrr(0, R), _O_Mrm (0xff ,_b11,_b010,_r8(R) )) -#define JMPQsr(R) (_REXQrr(0, R), _O_Mrm (0xff ,_b11,_b100,_r8(R) )) - -#define CMOVQrr(CC,RS,RD) (_REXQrr(RD, RS), _OO_Mrm (0x0f40|(CC) ,_b11,_r8(RD),_r8(RS) )) -#define CMOVQmr(CC,MD,MB,MI,MS,RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0f40|(CC) ,_r8(RD) ,MD,MB,MI,MS )) - -#define POPQr(RD) _m64only((_REXQr(RD), _Or (0x58,_r8(RD) ))) -#define POPQm(MD, MB, MI, MS) _m64only((_REXQm(MB, MI), _O_r_X (0x8f ,_b000 ,MD,MB,MI,MS ))) - -#define PUSHQr(RS) _m64only((_REXQr(RS), _Or (0x50,_r8(RS) ))) -#define PUSHQm(MD, MB, MI, MS) _m64only((_REXQm(MB, MI), _O_r_X (0xff ,_b110 ,MD,MB,MI,MS ))) -#define PUSHQi(IM) _m64only( _Os_sL (0x68 ,IM )) - -#define TESTQrr(RS, RD) (_REXQrr(RS, RD), _O_Mrm (0x85 ,_b11,_r8(RS),_r8(RD) )) -#define TESTQrm(RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _O_r_X (0x85 ,_r8(RS) ,MD,MB,MI,MS )) -#define TESTQir(IM, RD) \ - /* Immediate fits in 32 bits? */ \ - (_s32P((long)(IM)) \ - /* Yes. Immediate does not fit in 8 bits and reg is %rax? */ \ - ? (!_s8P(IM) && (RD) == _RAX \ - ? (_REXQrr(0, RD), _O_L(0xa9, IM)) \ - : (_REXQrr(0, RD), _O_Mrm_L(0xf7, _b11, _b000, _r8(RD), IM))) \ - /* No. Need immediate in a register */ \ - : (MOVQir(IM, JIT_REXTMP), TESTQrr(JIT_REXTMP, RD))) -#define TESTQim(IM, MD, MB, MI, MS) (_REXQrm(0, MB, MI), _O_r_X_L (0xf7 ,_b000 ,MD,MB,MI,MS ,IM )) - -#define CMPXCHGQrr(RS, RD) (_REXQrr(RS, RD), _OO_Mrm (0x0fb1 ,_b11,_r8(RS),_r8(RD) )) -#define CMPXCHGQrm(RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _OO_r_X (0x0fb1 ,_r8(RS) ,MD,MB,MI,MS )) - -#define XADDQrr(RS, RD) (_REXQrr(RS, RD), _OO_Mrm (0x0fc1 ,_b11,_r8(RS),_r8(RD) )) -#define XADDQrm(RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _OO_r_X (0x0fc1 ,_r8(RS) ,MD,MB,MI,MS )) - -#define XCHGQrr(RS, RD) (_REXQrr(RS, RD), _O_Mrm (0x87 ,_b11,_r8(RS),_r8(RD) )) -#define XCHGQrm(RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _O_r_X (0x87 ,_r8(RS) ,MD,MB,MI,MS )) - -#define DECQm(MD, MB, MI, MS) (_REXQrm(0, MB, MI), _O_r_X (0xff ,_b001 ,MD,MB,MI,MS )) -#define DECQr(RD) (_REXQrr(0, RD), _O_Mrm (0xff ,_b11,_b001 ,_r8(RD) )) -#define INCQm(MD, MB, MI, MS) (_REXQrm(0, MB, MI), _O_r_X (0xff ,_b000 ,MD,MB,MI,MS )) -#define INCQr(RD) (_REXQrr(0, RD), _O_Mrm (0xff ,_b11,_b000 ,_r8(RD) )) - -#define BSFQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fbc ,_b11,_r8(RD),_r8(RS) )) -#define BSFQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fbc ,_r8(RD) ,MD,MB,MI,MS )) - -#define BSRQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fbd ,_b11,_r8(RD),_r8(RS) )) -#define BSRQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fbd ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVSBQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fbe ,_b11,_r8(RD),_r1(RS) )) -#define MOVSBQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fbe ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVZBQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fb6 ,_b11,_r8(RD),_r1(RS) )) -#define MOVZBQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fb6 ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVSWQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fbf ,_b11,_r8(RD),_r2(RS) )) -#define MOVSWQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fbf ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVZWQrr(RS, RD) (_REXQrr(RD, RS), _OO_Mrm (0x0fb7 ,_b11,_r8(RD),_r2(RS) )) -#define MOVZWQmr(MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _OO_r_X (0x0fb7 ,_r8(RD) ,MD,MB,MI,MS )) - -#define MOVSLQrr(RS, RD) _m64only((_REXQrr(RD, RS), _O_Mrm (0x63 ,_b11,_r8(RD),_r4(RS) ))) -#define MOVSLQmr(MD, MB, MI, MS, RD) _m64only((_REXQmr(MB, MI, RD), _O_r_X (0x63 ,_r8(RD) ,MD,MB,MI,MS ))) - -#define BSWAPQr(R) (_REXQrr(0, R), _OOr (0x0fc8,_r8(R) )) - - - -#define __SSEQrr(OP,RS,RSA,RD,RDA) (_REXQrr(RD, RS), _OO_Mrm (0x0f00|(OP) ,_b11,RDA(RD),RSA(RS) )) -#define __SSEQmr(OP,MD,MB,MI,MS,RD,RDA) (_REXQmr(MB, MI, RD), _OO_r_X (0x0f00|(OP) ,RDA(RD) ,MD,MB,MI,MS )) -#define __SSEQrm(OP,RS,RSA,MD,MB,MI,MS) (_REXQrm(RS, MB, MI), _OO_r_X (0x0f00|(OP) ,RSA(RS) ,MD,MB,MI,MS )) -#define __SSEQ1rm(OP,RS,RSA,MD,MB,MI,MS) (_REXQrm(RS, MB, MI), _OO_r_X (0x0f01|(OP) ,RSA(RS) ,MD,MB,MI,MS )) - -#define _SSEQrr(PX,OP,RS,RSA,RD,RDA) (_jit_B(PX), __SSEQrr(OP, RS, RSA, RD, RDA)) -#define _SSEQmr(PX,OP,MD,MB,MI,MS,RD,RDA) (_jit_B(PX), __SSEQmr(OP, MD, MB, MI, MS, RD, RDA)) -#define _SSEQrm(PX,OP,RS,RSA,MD,MB,MI,MS) (_jit_B(PX), __SSEQrm(OP, RS, RSA, MD, MB, MI, MS)) -#define _SSEQ1rm(PX,OP,RS,RSA,MD,MB,MI,MS) (_jit_B(PX), __SSEQ1rm(OP, RS, RSA, MD, MB, MI, MS)) - -#define CVTTSS2SIQrr(RS, RD) _SSEQrr(0xf3, X86_SSE_CVTTSI, RS,_rX, RD,_r8) -#define CVTTSS2SIQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf3, X86_SSE_CVTTSI, MD, MB, MI, MS, RD,_r8) -#define CVTTSD2SIQrr(RS, RD) _SSEQrr(0xf2, X86_SSE_CVTTSI, RS,_rX, RD,_r8) -#define CVTTSD2SIQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf2, X86_SSE_CVTTSI, MD, MB, MI, MS, RD,_r8) - -#define CVTSS2SIQrr(RS, RD) _SSEQrr(0xf3, X86_SSE_CVTSI, RS,_rX, RD,_r8) -#define CVTSS2SIQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf3, X86_SSE_CVTSI, MD, MB, MI, MS, RD,_r8) -#define CVTSD2SIQrr(RS, RD) _SSEQrr(0xf2, X86_SSE_CVTSI, RS,_rX, RD,_r8) -#define CVTSD2SIQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf2, X86_SSE_CVTSI, MD, MB, MI, MS, RD,_r8) - -#define CVTSI2SSQrr(RS, RD) _SSEQrr(0xf3, X86_SSE_CVTIS, RS,_r8, RD,_rX) -#define CVTSI2SSQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf3, X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) -#define CVTSI2SDQrr(RS, RD) _SSEQrr(0xf2, X86_SSE_CVTIS, RS,_r8, RD,_rX) -#define CVTSI2SDQmr(MD, MB, MI, MS, RD) _SSEQmr(0xf2, X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) - -#define MOVDQXrr(RS, RD) _SSEQrr(0x66, 0x6e, RS,_r8, RD,_rX) -#define MOVDQXmr(MD, MB, MI, MS, RD) _SSEQmr(0x66, 0x6e, MD, MB, MI, MS, RD,_rX) - -#define MOVDXQrr(RS, RD) _SSEQrr(0x66, 0x7e, RS,_rX, RD,_r8) -#define MOVDXQrm(RS, MD, MB, MI, MS) _SSEQrm(0x66, 0x7e, RS,_rX, MD, MB, MI, MS) -#define MOVDQMrr(RS, RD) __SSEQrr( 0x6e, RS,_r8, RD,_rM) -#define MOVDQMmr(MD, MB, MI, MS, RD) __SSEQmr( 0x6e, MD, MB, MI, MS, RD,_rM) -#define MOVDMQrr(RS, RD) __SSEQrr( 0x7e, RS,_rM, RD,_r8) -#define MOVDMQrm(RS, MD, MB, MI, MS) __SSEQrm( 0x7e, RS,_rM, MD, MB, MI, MS) - - - -#define CALLsr(R) CALLQsr(R) -#define JMPsr(R) JMPQsr(R) - -#endif -#endif /* __lightning_asm_h */ - diff --git a/lightning/i386/asm.h b/lightning/i386/asm.h deleted file mode 100644 index 14d9eecbb..000000000 --- a/lightning/i386/asm.h +++ /dev/null @@ -1,1605 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Run-time assembler for the i386 - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 1999, 2000, 2001, 2002 Ian Piumarta - * Copyright 2003 Gwenole Beauchesne - * Copyright 2006 Free Software Foundation - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_asm_i386_h -#define __lightning_asm_i386_h - -/* OPCODE + i = immediate operand - * + r = register operand - * + m = memory operand (disp,base,index,scale) - * + sr/sm = a star preceding a register or memory - */ - -typedef _uc jit_insn; - -#ifndef LIGHTNING_DEBUG -#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 _NOREG 0 - -#define _AL 0x10 -#define _CL 0x11 -#define _DL 0x12 -#define _BL 0x13 - -#define _AX 0x30 -#define _CX 0x31 -#define _DX 0x32 -#define _BX 0x33 -#define _SP 0x34 -#define _BP 0x35 -#define _SI 0x36 -#define _DI 0x37 - -#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 _MM0 0x60 -#define _MM1 0x61 -#define _MM2 0x62 -#define _MM3 0x63 -#define _MM4 0x64 -#define _MM5 0x65 -#define _MM6 0x66 -#define _MM7 0x67 - -#define _XMM0 0x70 -#define _XMM1 0x71 -#define _XMM2 0x72 -#define _XMM3 0x73 -#define _XMM4 0x74 -#define _XMM5 0x75 -#define _XMM6 0x76 -#define _XMM7 0x77 -#define _XMM8 0x78 -#define _XMM9 0x79 -#define _XMM10 0x7a -#define _XMM11 0x7b -#define _XMM12 0x7c -#define _XMM13 0x7d -#define _XMM14 0x7e -#define _XMM15 0x7f - -#define _ST0 0 -#define _ST1 1 -#define _ST2 2 -#define _ST3 3 -#define _ST4 4 -#define _ST5 5 -#define _ST6 6 -#define _ST7 7 - -#define _r0P(R) ((int)(R) == (int)_NOREG) -#define _rIP(R) ((int)(R) == (int)_RIP) - -#define _rC(R) ((R) & 0xf0) -#define _rR(R) ((R) & 0x0f) -#define _rN(R) ((R) & 0x07) -#define _rXP(R) ((R) > 0 && _rR(R) > 7) - -#define _rbpP(R) (_rR(R) == _rR(_EBP)) -#define _rspP(R) (_rR(R) == _rR(_ESP)) -#define _rbp13P(R) (_rN(R) == _rN(_EBP)) -#define _rsp12P(R) (_rN(R) == _rN(_ESP)) - -/*** ASSEMBLER ***/ - -#define _OFF4(D) (_jit_UL(D) - _jit_UL(_jit.x.pc)) -#define _CKD8(D) _ck_d(8, ((_uc) _OFF4(D)) ) - -#define _D8(D) (_jit_B(0), ((*(_PUC(_jit.x.pc)-1))= _CKD8(D))) -#define _D32(D) (_jit_I(0), ((*(_PUI(_jit.x.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) _jit_B((_M(Md)<<6)|(_r(R)<<3)|_m(M)) -#define _SIB(Sc,I, B) _jit_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! */ - -/* _r_D() is RIP addressing mode if X86_TARGET_64BIT, use _r_DSIB() instead */ -#define _r_D( R, D ) (_Mrm(_b00,_rN(R),_b101 ) ,_jit_I((long)(D))) -#define _r_DSIB(R, D ) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(1),_b100 ,_b101 ),_jit_I((long)(D))) -#define _r_0B( R, B ) (_Mrm(_b00,_rN(R),_rA(B)) ) -#define _r_0BIS(R, B,I,S) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_rA(I),_rA(B)) ) -#define _r_1B( R, D,B ) (_Mrm(_b01,_rN(R),_rA(B)) ,_jit_B((long)(D))) -#define _r_1BIS(R, D,B,I,S) (_Mrm(_b01,_rN(R),_b100 ),_SIB(_SCL(S),_rA(I),_rA(B)),_jit_B((long)(D))) -#define _r_4B( R, D,B ) (_Mrm(_b10,_rN(R),_rA(B)) ,_jit_I((long)(D))) -#define _r_4IS( R, D,I,S) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_rA(I),_b101 ),_jit_I((long)(D))) -#define _r_4BIS(R, D,B,I,S) (_Mrm(_b10,_rN(R),_b100 ),_SIB(_SCL(S),_rA(I),_rA(B)),_jit_I((long)(D))) - -#define _r_DB( R, D,B ) ((_s0P(D) && (!_rbp13P(B)) ? _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) && (!_rbp13P(B)) ? _r_0BIS(R, B,I,S) : (_s8P(D) ? _r_1BIS(R,D,B,I,S) : _r_4BIS(R,D,B,I,S)))) - - - -/* --- Instruction formats ------------------------------------------------- */ - -/* _format Opcd ModR/M dN(rB,rI,Sc) imm... */ - -#define _d16() ( _jit_B(0x66 ) ) -#define _O( OP ) ( _jit_B( OP ) ) -#define _Or( OP,R ) ( _jit_B( (OP)|_r(R)) ) -#define _OO( OP ) ( _jit_B((OP)>>8), _jit_B( (OP) ) ) -#define _OOr( OP,R ) ( _jit_B((OP)>>8), _jit_B( (OP)|_r(R)) ) -#define _Os( OP,B ) ( _s8P(B) ? _jit_B(((OP)|_b10)) : _jit_B(OP) ) -#define _sW( W ) ( _s8P(W) ? _jit_B(W):_jit_W(W) ) -#define _sL( L ) ( _s8P(L) ? _jit_B(L):_jit_I(L) ) -#define _sWO( W ) ( _s8P(W) ? 1 : 2 ) -#define _sLO( L ) ( _s8P(L) ? 1 : 4 ) -#define _O_B( OP ,B ) ( _O ( OP ) ,_jit_B(B) ) -#define _O_W( OP ,W ) ( _O ( OP ) ,_jit_W(W) ) -#define _O_L( OP ,L ) ( _O ( OP ) ,_jit_I(L) ) -#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 ) ,_jit_W(W),_jit_B(B)) -#define _Or_B( OP,R ,B ) ( _Or ( OP,R) ,_jit_B(B) ) -#define _Or_W( OP,R ,W ) ( _Or ( OP,R) ,_jit_W(W) ) -#define _Or_L( OP,R ,L ) ( _Or ( OP,R) ,_jit_I(L) ) -#define _Or_Q( OP,R ,Q ) ( _Or ( OP,R) ,_jit_L(Q) ) -#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 ) ,_jit_B(B) ) -#define _O_Mrm_W( OP ,MO,R,M ,W ) ( _O ( OP ),_Mrm(MO,R,M ) ,_jit_W(W) ) -#define _O_Mrm_L( OP ,MO,R,M ,L ) ( _O ( OP ),_Mrm(MO,R,M ) ,_jit_I(L) ) -#define _OO_Mrm_B( OP ,MO,R,M ,B ) ( _OO ( OP ),_Mrm(MO,R,M ) ,_jit_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,0) ) -#define _OO_r_X( OP ,R ,MD,MB,MI,MS ) ( _OO ( OP ),_r_X( R ,MD,MB,MI,MS,0) ) -#define _O_r_X_B( OP ,R ,MD,MB,MI,MS,B ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS,1) ,_jit_B(B) ) -#define _O_r_X_W( OP ,R ,MD,MB,MI,MS,W ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS,2) ,_jit_W(W) ) -#define _O_r_X_L( OP ,R ,MD,MB,MI,MS,L ) ( _O ( OP ),_r_X( R ,MD,MB,MI,MS,4) ,_jit_I(L) ) -#define _OO_r_X_B( OP ,R ,MD,MB,MI,MS,B ) ( _OO ( OP ),_r_X( R ,MD,MB,MI,MS,1) ,_jit_B(B) ) -#define _Os_r_X_sW(OP ,R ,MD,MB,MI,MS,W ) ( _Os ( OP,W),_r_X( R ,MD,MB,MI,MS,_sWO(W)),_sW(W)) -#define _Os_r_X_sL(OP ,R ,MD,MB,MI,MS,L ) ( _Os ( OP,L),_r_X( R ,MD,MB,MI,MS,_sLO(L)),_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) ) - - -/* --- REX prefixes -------------------------------------------------------- */ - - -#define _BIT(X) (!!(X)) -#define _d64(W,R,X,B) (_jit_B(0x40|(W)<<3|(R)<<2|(X)<<1|(B))) - -#define __REXwrxb(L,W,R,X,B) ((W|R|X|B) || (L) ? (void)_d64(W,R,X,B) : ((void)0)) -#define __REXwrx_(L,W,R,X,MR) (__REXwrxb(L,W,R,X,_BIT(_rIP(MR)?0:_rXP(MR)))) -#define __REXw_x_(L,W,R,X,MR) (__REXwrx_(L,W,_BIT(_rXP(R)),X,MR)) -#define __REX_reg(RR) (__REXwrxb(0,0,0,00,_BIT(_rXP(RR)))) -#define __REX_mem(MB,MI) (__REXwrxb(0,0,0,_BIT(_rXP(MI)),_BIT(_rXP(MB)))) - -/* FIXME: can't mix new (SPL,BPL,SIL,DIL) with (AH,BH,CH,DH) */ -#define _REXBrr(RR,MR) _m64(__REXw_x_(_r1e8lP(RR)||_r1e8lP(MR),0,RR,0,MR)) -#define _REXBmr(MB,MI,RD) _m64(__REXw_x_(_r1e8lP(RD)||_r1e8lP(MB),0,RD,_BIT(_rXP(MI)),MB)) -#define _REXBrm(RS,MB,MI) _REXBmr(MB,MI,RS) - -#define _REXBLrr(RR,MR) _m64(__REXw_x_(_r1e8lP(MR),0,RR,0,MR)) -#define _REXLrr(RR,MR) _m64(__REXw_x_(0,0,RR,0,MR)) -#define _REXLmr(MB,MI,RD) _m64(__REXw_x_(0,0,RD,_BIT(_rXP(MI)),MB)) -#define _REXLrm(RS,MB,MI) _REXLmr(MB,MI,RS) -#define _REXLr(RR) _m64(__REX_reg(RR)) -#define _REXLm(MB,MI) _m64(__REX_mem(MB,MI)) - -#define _REXQrr(RR,MR) _m64only(__REXw_x_(0,1,RR,0,MR)) -#define _REXQmr(MB,MI,RD) _m64only(__REXw_x_(0,1,RD,_BIT(_rXP(MI)),MB)) -#define _REXQrm(RS,MB,MI) _REXQmr(MB,MI,RS) -#define _REXQr(RR) _m64only(__REX_reg(RR)) -#define _REXQm(MB,MI) _m64only(__REX_mem(MB,MI)) - - -/* ========================================================================= */ -/* --- Fully-qualified intrinsic instructions ------------------------------ */ -/* ========================================================================= */ - -/* OPCODE + i = immediate operand - * + r = register operand - * + m = memory operand (disp,base,index,scale) - * + sr/sm = a star preceding a register or memory - * + 0 = top of stack register (for FPU instructions) - * - * NOTE in x86-64 mode: a memory operand with only a valid - * displacement value will lead to the expect absolute mode. If - * RIP addressing is necessary, X86_RIP shall be used as the base - * register argument. - */ - -/* --- ALU instructions ---------------------------------------------------- */ - -enum { - X86_ADD = 0, - X86_OR = 1, - X86_ADC = 2, - X86_SBB = 3, - X86_AND = 4, - X86_SUB = 5, - X86_XOR = 6, - X86_CMP = 7, -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define _ALUBrr(OP,RS, RD) (_REXBrr(RS, RD), _O_Mrm (((OP) << 3) ,_b11,_r1(RS),_r1(RD) )) -#define _ALUBmr(OP, MD, MB, MI, MS, RD) (_REXBmr(MB, MI, RD), _O_r_X (((OP) << 3) + 2,_r1(RD) ,MD,MB,MI,MS )) -#define _ALUBrm(OP, RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _O_r_X (((OP) << 3) , ,_r1(RS) ,MD,MB,MI,MS )) -#define _ALUBir(OP, IM, RD) ((RD) == _AL ? \ - (_REXBrr(0, RD), _O_B (((OP) << 3) + 4 ,_su8(IM))) : \ - (_REXBrr(0, RD), _O_Mrm_B (0x80 ,_b11,OP ,_r1(RD) ,_su8(IM))) ) -#define _ALUBim(OP, IM, MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_r_X_B (0x80 ,OP ,MD,MB,MI,MS ,_su8(IM))) - -#define _ALUWrr(OP, RS, RD) (_d16(), _REXLrr(RS, RD), _O_Mrm (((OP) << 3) + 1,_b11,_r2(RS),_r2(RD) )) -#define _ALUWmr(OP, MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _O_r_X (((OP) << 3) + 3 ,_r2(RD) ,MD,MB,MI,MS )) -#define _ALUWrm(OP, RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _O_r_X (((OP) << 3) + 1 ,_r2(RS) ,MD,MB,MI,MS )) -#define _ALUWir(OP, IM, RD) ((RD) == _AX ? \ - (_d16(), _REXLrr(0, RD), _O_W (((OP) << 3) + 5 ,_su16(IM))) : \ - (_d16(), _REXLrr(0, RD), _Os_Mrm_sW (0x81 ,_b11,OP ,_r2(RD) ,_su16(IM))) ) -#define _ALUWim(OP, IM, MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _Os_r_X_sW (0x81 ,OP ,MD,MB,MI,MS ,_su16(IM))) - -#define _ALULrr(OP, RS, RD) (_REXLrr(RS, RD), _O_Mrm (((OP) << 3) + 1,_b11,_r4(RS),_r4(RD) )) -#define _ALULmr(OP, MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _O_r_X (((OP) << 3) + 3 ,_r4(RD) ,MD,MB,MI,MS )) -#define _ALULrm(OP, RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _O_r_X (((OP) << 3) + 1 ,_r4(RS) ,MD,MB,MI,MS )) -#define _ALULir(OP, IM, RD) (!_s8P(IM) && (RD) == _EAX ? \ - (_REXLrr(0, RD), _O_L (((OP) << 3) + 5 ,IM )) : \ - (_REXLrr(0, RD), _Os_Mrm_sL (0x81 ,_b11,OP ,_r4(RD) ,IM )) ) -#define _ALULim(OP, IM, MD, MB, MI, MS) (_REXLrm(0, MB, MI), _Os_r_X_sL (0x81 ,OP ,MD,MB,MI,MS ,IM )) - -#define _ALUQrr(OP, RS, RD) (_REXQrr(RS, RD), _O_Mrm (((OP) << 3) + 1,_b11,_r8(RS),_r8(RD) )) -#define _ALUQmr(OP, MD, MB, MI, MS, RD) (_REXQmr(MB, MI, RD), _O_r_X (((OP) << 3) + 3 ,_r8(RD) ,MD,MB,MI,MS )) -#define _ALUQrm(OP, RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _O_r_X (((OP) << 3) + 1 ,_r8(RS) ,MD,MB,MI,MS )) -#define _ALUQir(OP, IM, RD) \ - /* Immediate fits in 32 bits? */ \ - (_s32P((long)(IM)) \ - /* Yes. Immediate does not fit in 8 bits and reg is %rax? */ \ - ? (!_s8P(IM) && (RD) == _RAX \ - ? (_REXQrr(0, RD), _O_L(((OP) << 3) + 5, IM)) \ - : (_REXQrr(0, RD), _Os_Mrm_sL(0x81, _b11, OP, _r8(RD), IM))) \ - /* No. Need immediate in a register */ \ - : (MOVQir(IM, JIT_REXTMP), _ALUQrr(OP, JIT_REXTMP, RD))) -#define _ALUQim(OP, IM, MD, MB, MI, MS) (_REXQrm(0, MB, MI), _Os_r_X_sL (0x81 ,OP ,MD,MB,MI,MS ,IM )) - -#define ADCBrr(RS, RD) _ALUBrr(X86_ADC, RS, RD) -#define ADCBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_ADC, MD, MB, MI, MS, RD) -#define ADCBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_ADC, RS, MD, MB, MI, MS) -#define ADCBir(IM, RD) _ALUBir(X86_ADC, IM, RD) -#define ADCBim(IM, MD, MB, MI, MS) _ALUBim(X86_ADC, IM, MD, MB, MI, MS) - -#define ADCWrr(RS, RD) _ALUWrr(X86_ADC, RS, RD) -#define ADCWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_ADC, MD, MB, MI, MS, RD) -#define ADCWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_ADC, RS, MD, MB, MI, MS) -#define ADCWir(IM, RD) _ALUWir(X86_ADC, IM, RD) -#define ADCWim(IM, MD, MB, MI, MS) _ALUWim(X86_ADC, IM, MD, MB, MI, MS) - -#define ADCLrr(RS, RD) _ALULrr(X86_ADC, RS, RD) -#define ADCLmr(MD, MB, MI, MS, RD) _ALULmr(X86_ADC, MD, MB, MI, MS, RD) -#define ADCLrm(RS, MD, MB, MI, MS) _ALULrm(X86_ADC, RS, MD, MB, MI, MS) -#define ADCLir(IM, RD) _ALULir(X86_ADC, IM, RD) -#define ADCLim(IM, MD, MB, MI, MS) _ALULim(X86_ADC, IM, MD, MB, MI, MS) - - -#define ADDBrr(RS, RD) _ALUBrr(X86_ADD, RS, RD) -#define ADDBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_ADD, MD, MB, MI, MS, RD) -#define ADDBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_ADD, RS, MD, MB, MI, MS) -#define ADDBir(IM, RD) _ALUBir(X86_ADD, IM, RD) -#define ADDBim(IM, MD, MB, MI, MS) _ALUBim(X86_ADD, IM, MD, MB, MI, MS) - -#define ADDWrr(RS, RD) _ALUWrr(X86_ADD, RS, RD) -#define ADDWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_ADD, MD, MB, MI, MS, RD) -#define ADDWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_ADD, RS, MD, MB, MI, MS) -#define ADDWir(IM, RD) _ALUWir(X86_ADD, IM, RD) -#define ADDWim(IM, MD, MB, MI, MS) _ALUWim(X86_ADD, IM, MD, MB, MI, MS) - -#define ADDLrr(RS, RD) _ALULrr(X86_ADD, RS, RD) -#define ADDLmr(MD, MB, MI, MS, RD) _ALULmr(X86_ADD, MD, MB, MI, MS, RD) -#define ADDLrm(RS, MD, MB, MI, MS) _ALULrm(X86_ADD, RS, MD, MB, MI, MS) -#define ADDLir(IM, RD) _ALULir(X86_ADD, IM, RD) -#define ADDLim(IM, MD, MB, MI, MS) _ALULim(X86_ADD, IM, MD, MB, MI, MS) - - -#define ANDBrr(RS, RD) _ALUBrr(X86_AND, RS, RD) -#define ANDBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_AND, MD, MB, MI, MS, RD) -#define ANDBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_AND, RS, MD, MB, MI, MS) -#define ANDBir(IM, RD) _ALUBir(X86_AND, IM, RD) -#define ANDBim(IM, MD, MB, MI, MS) _ALUBim(X86_AND, IM, MD, MB, MI, MS) - -#define ANDWrr(RS, RD) _ALUWrr(X86_AND, RS, RD) -#define ANDWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_AND, MD, MB, MI, MS, RD) -#define ANDWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_AND, RS, MD, MB, MI, MS) -#define ANDWir(IM, RD) _ALUWir(X86_AND, IM, RD) -#define ANDWim(IM, MD, MB, MI, MS) _ALUWim(X86_AND, IM, MD, MB, MI, MS) - -#define ANDLrr(RS, RD) _ALULrr(X86_AND, RS, RD) -#define ANDLmr(MD, MB, MI, MS, RD) _ALULmr(X86_AND, MD, MB, MI, MS, RD) -#define ANDLrm(RS, MD, MB, MI, MS) _ALULrm(X86_AND, RS, MD, MB, MI, MS) -#define ANDLir(IM, RD) _ALULir(X86_AND, IM, RD) -#define ANDLim(IM, MD, MB, MI, MS) _ALULim(X86_AND, IM, MD, MB, MI, MS) - - -#define CMPBrr(RS, RD) _ALUBrr(X86_CMP, RS, RD) -#define CMPBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_CMP, MD, MB, MI, MS, RD) -#define CMPBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_CMP, RS, MD, MB, MI, MS) -#define CMPBir(IM, RD) _ALUBir(X86_CMP, IM, RD) -#define CMPBim(IM, MD, MB, MI, MS) _ALUBim(X86_CMP, IM, MD, MB, MI, MS) - -#define CMPWrr(RS, RD) _ALUWrr(X86_CMP, RS, RD) -#define CMPWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_CMP, MD, MB, MI, MS, RD) -#define CMPWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_CMP, RS, MD, MB, MI, MS) -#define CMPWir(IM, RD) _ALUWir(X86_CMP, IM, RD) -#define CMPWim(IM, MD, MB, MI, MS) _ALUWim(X86_CMP, IM, MD, MB, MI, MS) - -#define CMPLrr(RS, RD) _ALULrr(X86_CMP, RS, RD) -#define CMPLmr(MD, MB, MI, MS, RD) _ALULmr(X86_CMP, MD, MB, MI, MS, RD) -#define CMPLrm(RS, MD, MB, MI, MS) _ALULrm(X86_CMP, RS, MD, MB, MI, MS) -#define CMPLir(IM, RD) _ALULir(X86_CMP, IM, RD) -#define CMPLim(IM, MD, MB, MI, MS) _ALULim(X86_CMP, IM, MD, MB, MI, MS) - - -#define ORBrr(RS, RD) _ALUBrr(X86_OR, RS, RD) -#define ORBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_OR, MD, MB, MI, MS, RD) -#define ORBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_OR, RS, MD, MB, MI, MS) -#define ORBir(IM, RD) _ALUBir(X86_OR, IM, RD) -#define ORBim(IM, MD, MB, MI, MS) _ALUBim(X86_OR, IM, MD, MB, MI, MS) - -#define ORWrr(RS, RD) _ALUWrr(X86_OR, RS, RD) -#define ORWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_OR, MD, MB, MI, MS, RD) -#define ORWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_OR, RS, MD, MB, MI, MS) -#define ORWir(IM, RD) _ALUWir(X86_OR, IM, RD) -#define ORWim(IM, MD, MB, MI, MS) _ALUWim(X86_OR, IM, MD, MB, MI, MS) - -#define ORLrr(RS, RD) _ALULrr(X86_OR, RS, RD) -#define ORLmr(MD, MB, MI, MS, RD) _ALULmr(X86_OR, MD, MB, MI, MS, RD) -#define ORLrm(RS, MD, MB, MI, MS) _ALULrm(X86_OR, RS, MD, MB, MI, MS) -#define ORLir(IM, RD) _ALULir(X86_OR, IM, RD) -#define ORLim(IM, MD, MB, MI, MS) _ALULim(X86_OR, IM, MD, MB, MI, MS) - - -#define SBBBrr(RS, RD) _ALUBrr(X86_SBB, RS, RD) -#define SBBBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_SBB, MD, MB, MI, MS, RD) -#define SBBBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_SBB, RS, MD, MB, MI, MS) -#define SBBBir(IM, RD) _ALUBir(X86_SBB, IM, RD) -#define SBBBim(IM, MD, MB, MI, MS) _ALUBim(X86_SBB, IM, MD, MB, MI, MS) - -#define SBBWrr(RS, RD) _ALUWrr(X86_SBB, RS, RD) -#define SBBWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_SBB, MD, MB, MI, MS, RD) -#define SBBWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_SBB, RS, MD, MB, MI, MS) -#define SBBWir(IM, RD) _ALUWir(X86_SBB, IM, RD) -#define SBBWim(IM, MD, MB, MI, MS) _ALUWim(X86_SBB, IM, MD, MB, MI, MS) - -#define SBBLrr(RS, RD) _ALULrr(X86_SBB, RS, RD) -#define SBBLmr(MD, MB, MI, MS, RD) _ALULmr(X86_SBB, MD, MB, MI, MS, RD) -#define SBBLrm(RS, MD, MB, MI, MS) _ALULrm(X86_SBB, RS, MD, MB, MI, MS) -#define SBBLir(IM, RD) _ALULir(X86_SBB, IM, RD) -#define SBBLim(IM, MD, MB, MI, MS) _ALULim(X86_SBB, IM, MD, MB, MI, MS) - - -#define SUBBrr(RS, RD) _ALUBrr(X86_SUB, RS, RD) -#define SUBBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_SUB, MD, MB, MI, MS, RD) -#define SUBBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_SUB, RS, MD, MB, MI, MS) -#define SUBBir(IM, RD) _ALUBir(X86_SUB, IM, RD) -#define SUBBim(IM, MD, MB, MI, MS) _ALUBim(X86_SUB, IM, MD, MB, MI, MS) - -#define SUBWrr(RS, RD) _ALUWrr(X86_SUB, RS, RD) -#define SUBWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_SUB, MD, MB, MI, MS, RD) -#define SUBWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_SUB, RS, MD, MB, MI, MS) -#define SUBWir(IM, RD) _ALUWir(X86_SUB, IM, RD) -#define SUBWim(IM, MD, MB, MI, MS) _ALUWim(X86_SUB, IM, MD, MB, MI, MS) - -#define SUBLrr(RS, RD) _ALULrr(X86_SUB, RS, RD) -#define SUBLmr(MD, MB, MI, MS, RD) _ALULmr(X86_SUB, MD, MB, MI, MS, RD) -#define SUBLrm(RS, MD, MB, MI, MS) _ALULrm(X86_SUB, RS, MD, MB, MI, MS) -#define SUBLir(IM, RD) _ALULir(X86_SUB, IM, RD) -#define SUBLim(IM, MD, MB, MI, MS) _ALULim(X86_SUB, IM, MD, MB, MI, MS) - - -#define XORBrr(RS, RD) _ALUBrr(X86_XOR, RS, RD) -#define XORBmr(MD, MB, MI, MS, RD) _ALUBmr(X86_XOR, MD, MB, MI, MS, RD) -#define XORBrm(RS, MD, MB, MI, MS) _ALUBrm(X86_XOR, RS, MD, MB, MI, MS) -#define XORBir(IM, RD) _ALUBir(X86_XOR, IM, RD) -#define XORBim(IM, MD, MB, MI, MS) _ALUBim(X86_XOR, IM, MD, MB, MI, MS) - -#define XORWrr(RS, RD) _ALUWrr(X86_XOR, RS, RD) -#define XORWmr(MD, MB, MI, MS, RD) _ALUWmr(X86_XOR, MD, MB, MI, MS, RD) -#define XORWrm(RS, MD, MB, MI, MS) _ALUWrm(X86_XOR, RS, MD, MB, MI, MS) -#define XORWir(IM, RD) _ALUWir(X86_XOR, IM, RD) -#define XORWim(IM, MD, MB, MI, MS) _ALUWim(X86_XOR, IM, MD, MB, MI, MS) - -#define XORLrr(RS, RD) _ALULrr(X86_XOR, RS, RD) -#define XORLmr(MD, MB, MI, MS, RD) _ALULmr(X86_XOR, MD, MB, MI, MS, RD) -#define XORLrm(RS, MD, MB, MI, MS) _ALULrm(X86_XOR, RS, MD, MB, MI, MS) -#define XORLir(IM, RD) _ALULir(X86_XOR, IM, RD) -#define XORLim(IM, MD, MB, MI, MS) _ALULim(X86_XOR, IM, MD, MB, MI, MS) - - - -/* --- Shift/Rotate instructions ------------------------------------------- */ - -enum { - X86_ROL = 0, - X86_ROR = 1, - X86_RCL = 2, - X86_RCR = 3, - X86_SHL = 4, - X86_SHR = 5, - X86_SAR = 7, -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define _ROTSHIBir(OP,IM,RD) ((IM) == 1 ? \ - (_REXBrr(0, RD), _O_Mrm (0xd0 ,_b11,OP,_r1(RD) )) : \ - (_REXBrr(0, RD), _O_Mrm_B (0xc0 ,_b11,OP,_r1(RD) ,_u8(IM))) ) -#define _ROTSHIBim(OP,IM,MD,MB,MI,MS) ((IM) == 1 ? \ - (_REXBrm(0, MB, MI), _O_r_X (0xd0 ,OP ,MD,MB,MI,MS )) : \ - (_REXBrm(0, MB, MI), _O_r_X_B (0xc0 ,OP ,MD,MB,MI,MS ,_u8(IM))) ) -#define _ROTSHIBrr(OP,RS,RD) (((RS) == _CL) ? \ - (_REXBrr(RS, RD), _O_Mrm (0xd2 ,_b11,OP,_r1(RD) )) : \ - JITFAIL("source register must be CL" ) ) -#define _ROTSHIBrm(OP,RS,MD,MB,MI,MS) (((RS) == _CL) ? \ - (_REXBrm(RS, MB, MI), _O_r_X (0xd2 ,OP ,MD,MB,MI,MS )) : \ - JITFAIL("source register must be CL" ) ) - -#define _ROTSHIWir(OP,IM,RD) ((IM) == 1 ? \ - (_d16(), _REXLrr(0, RD), _O_Mrm (0xd1 ,_b11,OP,_r2(RD) )) : \ - (_d16(), _REXLrr(0, RD), _O_Mrm_B (0xc1 ,_b11,OP,_r2(RD) ,_u8(IM))) ) -#define _ROTSHIWim(OP,IM,MD,MB,MI,MS) ((IM) == 1 ? \ - (_d16(), _REXLrm(0, MB, MI), _O_r_X (0xd1 ,OP ,MD,MB,MI,MS )) : \ - (_d16(), _REXLrm(0, MB, MI), _O_r_X_B (0xc1 ,OP ,MD,MB,MI,MS ,_u8(IM))) ) -#define _ROTSHIWrr(OP,RS,RD) (((RS) == _CL) ? \ - (_d16(), _REXLrr(RS, RD), _O_Mrm (0xd3 ,_b11,OP,_r2(RD) )) : \ - JITFAIL("source register must be CL" ) ) -#define _ROTSHIWrm(OP,RS,MD,MB,MI,MS) (((RS) == _CL) ? \ - (_d16(), _REXLrm(RS, MB, MI), _O_r_X (0xd3 ,OP ,MD,MB,MI,MS )) : \ - JITFAIL("source register must be CL" ) ) - -#define _ROTSHILir(OP,IM,RD) ((IM) == 1 ? \ - (_REXLrr(0, RD), _O_Mrm (0xd1 ,_b11,OP,_r4(RD) )) : \ - (_REXLrr(0, RD), _O_Mrm_B (0xc1 ,_b11,OP,_r4(RD) ,_u8(IM))) ) -#define _ROTSHILim(OP,IM,MD,MB,MI,MS) ((IM) == 1 ? \ - (_REXLrm(0, MB, MI), _O_r_X (0xd1 ,OP ,MD,MB,MI,MS )) : \ - (_REXLrm(0, MB, MI), _O_r_X_B (0xc1 ,OP ,MD,MB,MI,MS ,_u8(IM))) ) -#define _ROTSHILrr(OP,RS,RD) (((RS) == _CL) ? \ - (_REXLrr(RS, RD), _O_Mrm (0xd3 ,_b11,OP,_r4(RD) )) : \ - JITFAIL("source register must be CL" ) ) -#define _ROTSHILrm(OP,RS,MD,MB,MI,MS) (((RS) == _CL) ? \ - (_REXLrm(RS, MB, MI), _O_r_X (0xd3 ,OP ,MD,MB,MI,MS )) : \ - JITFAIL("source register must be CL" ) ) - -#define _ROTSHIQir(OP,IM,RD) ((IM) == 1 ? \ - (_REXQrr(0, RD), _O_Mrm (0xd1 ,_b11,OP,_r8(RD) )) : \ - (_REXQrr(0, RD), _O_Mrm_B (0xc1 ,_b11,OP,_r8(RD) ,_u8(IM))) ) -#define _ROTSHIQim(OP,IM,MD,MB,MI,MS) ((IM) == 1 ? \ - (_REXQrm(0, MB, MI), _O_r_X (0xd1 ,OP ,MD,MB,MI,MS )) : \ - (_REXQrm(0, MB, MI), _O_r_X_B (0xc1 ,OP ,MD,MB,MI,MS ,_u8(IM))) ) -#define _ROTSHIQrr(OP,RS,RD) (((RS) == _CL) ? \ - (_REXQrr(RS, RD), _O_Mrm (0xd3 ,_b11,OP,_r8(RD) )) : \ - JITFAIL("source register must be CL" ) ) -#define _ROTSHIQrm(OP,RS,MD,MB,MI,MS) (((RS) == _CL) ? \ - (_REXQrm(RS, MB, MI), _O_r_X (0xd3 ,OP ,MD,MB,MI,MS )) : \ - JITFAIL("source register must be CL" ) ) - -#define ROLBir(IM, RD) _ROTSHIBir(X86_ROL, IM, RD) -#define ROLBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_ROL, IM, MD, MB, MI, MS) -#define ROLBrr(RS, RD) _ROTSHIBrr(X86_ROL, RS, RD) -#define ROLBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_ROL, RS, MD, MB, MI, MS) - -#define ROLWir(IM, RD) _ROTSHIWir(X86_ROL, IM, RD) -#define ROLWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_ROL, IM, MD, MB, MI, MS) -#define ROLWrr(RS, RD) _ROTSHIWrr(X86_ROL, RS, RD) -#define ROLWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_ROL, RS, MD, MB, MI, MS) - -#define ROLLir(IM, RD) _ROTSHILir(X86_ROL, IM, RD) -#define ROLLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_ROL, IM, MD, MB, MI, MS) -#define ROLLrr(RS, RD) _ROTSHILrr(X86_ROL, RS, RD) -#define ROLLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_ROL, RS, MD, MB, MI, MS) - - -#define RORBir(IM, RD) _ROTSHIBir(X86_ROR, IM, RD) -#define RORBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_ROR, IM, MD, MB, MI, MS) -#define RORBrr(RS, RD) _ROTSHIBrr(X86_ROR, RS, RD) -#define RORBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_ROR, RS, MD, MB, MI, MS) - -#define RORWir(IM, RD) _ROTSHIWir(X86_ROR, IM, RD) -#define RORWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_ROR, IM, MD, MB, MI, MS) -#define RORWrr(RS, RD) _ROTSHIWrr(X86_ROR, RS, RD) -#define RORWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_ROR, RS, MD, MB, MI, MS) - -#define RORLir(IM, RD) _ROTSHILir(X86_ROR, IM, RD) -#define RORLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_ROR, IM, MD, MB, MI, MS) -#define RORLrr(RS, RD) _ROTSHILrr(X86_ROR, RS, RD) -#define RORLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_ROR, RS, MD, MB, MI, MS) - - -#define RCLBir(IM, RD) _ROTSHIBir(X86_RCL, IM, RD) -#define RCLBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_RCL, IM, MD, MB, MI, MS) -#define RCLBrr(RS, RD) _ROTSHIBrr(X86_RCL, RS, RD) -#define RCLBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_RCL, RS, MD, MB, MI, MS) - -#define RCLWir(IM, RD) _ROTSHIWir(X86_RCL, IM, RD) -#define RCLWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_RCL, IM, MD, MB, MI, MS) -#define RCLWrr(RS, RD) _ROTSHIWrr(X86_RCL, RS, RD) -#define RCLWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_RCL, RS, MD, MB, MI, MS) - -#define RCLLir(IM, RD) _ROTSHILir(X86_RCL, IM, RD) -#define RCLLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_RCL, IM, MD, MB, MI, MS) -#define RCLLrr(RS, RD) _ROTSHILrr(X86_RCL, RS, RD) -#define RCLLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_RCL, RS, MD, MB, MI, MS) - - -#define RCRBir(IM, RD) _ROTSHIBir(X86_RCR, IM, RD) -#define RCRBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_RCR, IM, MD, MB, MI, MS) -#define RCRBrr(RS, RD) _ROTSHIBrr(X86_RCR, RS, RD) -#define RCRBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_RCR, RS, MD, MB, MI, MS) - -#define RCRWir(IM, RD) _ROTSHIWir(X86_RCR, IM, RD) -#define RCRWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_RCR, IM, MD, MB, MI, MS) -#define RCRWrr(RS, RD) _ROTSHIWrr(X86_RCR, RS, RD) -#define RCRWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_RCR, RS, MD, MB, MI, MS) - -#define RCRLir(IM, RD) _ROTSHILir(X86_RCR, IM, RD) -#define RCRLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_RCR, IM, MD, MB, MI, MS) -#define RCRLrr(RS, RD) _ROTSHILrr(X86_RCR, RS, RD) -#define RCRLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_RCR, RS, MD, MB, MI, MS) - - -#define SHLBir(IM, RD) _ROTSHIBir(X86_SHL, IM, RD) -#define SHLBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_SHL, IM, MD, MB, MI, MS) -#define SHLBrr(RS, RD) _ROTSHIBrr(X86_SHL, RS, RD) -#define SHLBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_SHL, RS, MD, MB, MI, MS) - -#define SHLWir(IM, RD) _ROTSHIWir(X86_SHL, IM, RD) -#define SHLWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_SHL, IM, MD, MB, MI, MS) -#define SHLWrr(RS, RD) _ROTSHIWrr(X86_SHL, RS, RD) -#define SHLWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_SHL, RS, MD, MB, MI, MS) - -#define SHLLir(IM, RD) _ROTSHILir(X86_SHL, IM, RD) -#define SHLLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_SHL, IM, MD, MB, MI, MS) -#define SHLLrr(RS, RD) _ROTSHILrr(X86_SHL, RS, RD) -#define SHLLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_SHL, RS, MD, MB, MI, MS) - - -#define SHRBir(IM, RD) _ROTSHIBir(X86_SHR, IM, RD) -#define SHRBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_SHR, IM, MD, MB, MI, MS) -#define SHRBrr(RS, RD) _ROTSHIBrr(X86_SHR, RS, RD) -#define SHRBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_SHR, RS, MD, MB, MI, MS) - -#define SHRWir(IM, RD) _ROTSHIWir(X86_SHR, IM, RD) -#define SHRWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_SHR, IM, MD, MB, MI, MS) -#define SHRWrr(RS, RD) _ROTSHIWrr(X86_SHR, RS, RD) -#define SHRWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_SHR, RS, MD, MB, MI, MS) - -#define SHRLir(IM, RD) _ROTSHILir(X86_SHR, IM, RD) -#define SHRLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_SHR, IM, MD, MB, MI, MS) -#define SHRLrr(RS, RD) _ROTSHILrr(X86_SHR, RS, RD) -#define SHRLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_SHR, RS, MD, MB, MI, MS) - - -#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) _ROTSHIBir(X86_SAR, IM, RD) -#define SARBim(IM, MD, MB, MI, MS) _ROTSHIBim(X86_SAR, IM, MD, MB, MI, MS) -#define SARBrr(RS, RD) _ROTSHIBrr(X86_SAR, RS, RD) -#define SARBrm(RS, MD, MB, MI, MS) _ROTSHIBrm(X86_SAR, RS, MD, MB, MI, MS) - -#define SARWir(IM, RD) _ROTSHIWir(X86_SAR, IM, RD) -#define SARWim(IM, MD, MB, MI, MS) _ROTSHIWim(X86_SAR, IM, MD, MB, MI, MS) -#define SARWrr(RS, RD) _ROTSHIWrr(X86_SAR, RS, RD) -#define SARWrm(RS, MD, MB, MI, MS) _ROTSHIWrm(X86_SAR, RS, MD, MB, MI, MS) - -#define SARLir(IM, RD) _ROTSHILir(X86_SAR, IM, RD) -#define SARLim(IM, MD, MB, MI, MS) _ROTSHILim(X86_SAR, IM, MD, MB, MI, MS) -#define SARLrr(RS, RD) _ROTSHILrr(X86_SAR, RS, RD) -#define SARLrm(RS, MD, MB, MI, MS) _ROTSHILrm(X86_SAR, RS, MD, MB, MI, MS) - - - -/* --- Bit test instructions ----------------------------------------------- */ - -enum { - X86_BT = 4, - X86_BTS = 5, - X86_BTR = 6, - X86_BTC = 7, -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define _BTWir(OP, IM, RD) (_d16(), _REXLrr(0, RD), _OO_Mrm_B (0x0fba ,_b11,OP ,_r2(RD) ,_u8(IM))) -#define _BTWim(OP, IM, MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _OO_r_X_B (0x0fba ,OP ,MD,MB,MI,MS ,_u8(IM))) -#define _BTWrr(OP, RS, RD) (_d16(), _REXLrr(RS, RD), _OO_Mrm (0x0f83|((OP)<<3),_b11,_r2(RS),_r2(RD) )) -#define _BTWrm(OP, RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _OO_r_X (0x0f83|((OP)<<3) ,_r2(RS) ,MD,MB,MI,MS )) - -#define _BTLir(OP, IM, RD) (_REXLrr(0, RD), _OO_Mrm_B (0x0fba ,_b11,OP ,_r4(RD) ,_u8(IM))) -#define _BTLim(OP, IM, MD, MB, MI, MS) (_REXLrm(0, MB, MI), _OO_r_X_B (0x0fba ,OP ,MD,MB,MI,MS ,_u8(IM))) -#define _BTLrr(OP, RS, RD) (_REXLrr(RS, RD), _OO_Mrm (0x0f83|((OP)<<3),_b11,_r4(RS),_r4(RD) )) -#define _BTLrm(OP, RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _OO_r_X (0x0f83|((OP)<<3) ,_r4(RS) ,MD,MB,MI,MS )) - -#define _BTQir(OP, IM, RD) (_REXQrr(0, RD), _OO_Mrm_B (0x0fba ,_b11,OP ,_r8(RD) ,_u8(IM))) -#define _BTQim(OP, IM, MD, MB, MI, MS) (_REXQrm(0, MB, MI), _OO_r_X_B (0x0fba ,OP ,MD,MB,MI,MS ,_u8(IM))) -#define _BTQrr(OP, RS, RD) (_REXQrr(RS, RD), _OO_Mrm (0x0f83|((OP)<<3),_b11,_r8(RS),_r8(RD) )) -#define _BTQrm(OP, RS, MD, MB, MI, MS) (_REXQrm(RS, MB, MI), _OO_r_X (0x0f83|((OP)<<3) ,_r8(RS) ,MD,MB,MI,MS )) - -#define BTWir(IM, RD) _BTWir(X86_BT, IM, RD) -#define BTWim(IM, MD, MB, MI, MS) _BTWim(X86_BT, IM, MD, MI, MS) -#define BTWrr(RS, RD) _BTWrr(X86_BT, RS, RD) -#define BTWrm(RS, MD, MB, MI, MS) _BTWrm(X86_BT, RS, MD, MB, MI, MS) - -#define BTLir(IM, RD) _BTLir(X86_BT, IM, RD) -#define BTLim(IM, MD, MB, MI, MS) _BTLim(X86_BT, IM, MD, MB, MI, MS) -#define BTLrr(RS, RD) _BTLrr(X86_BT, RS, RD) -#define BTLrm(RS, MD, MB, MI, MS) _BTLrm(X86_BT, RS, MD, MB, MI, MS) - - -#define BTCWir(IM, RD) _BTWir(X86_BTC, IM, RD) -#define BTCWim(IM, MD, MB, MI, MS) _BTWim(X86_BTC, IM, MD, MI, MS) -#define BTCWrr(RS, RD) _BTWrr(X86_BTC, RS, RD) -#define BTCWrm(RS, MD, MB, MI, MS) _BTWrm(X86_BTC, RS, MD, MB, MI, MS) - -#define BTCLir(IM, RD) _BTLir(X86_BTC, IM, RD) -#define BTCLim(IM, MD, MB, MI, MS) _BTLim(X86_BTC, IM, MD, MB, MI, MS) -#define BTCLrr(RS, RD) _BTLrr(X86_BTC, RS, RD) -#define BTCLrm(RS, MD, MB, MI, MS) _BTLrm(X86_BTC, RS, MD, MB, MI, MS) - - -#define BTRWir(IM, RD) _BTWir(X86_BTR, IM, RD) -#define BTRWim(IM, MD, MB, MI, MS) _BTWim(X86_BTR, IM, MD, MI, MS) -#define BTRWrr(RS, RD) _BTWrr(X86_BTR, RS, RD) -#define BTRWrm(RS, MD, MB, MI, MS) _BTWrm(X86_BTR, RS, MD, MB, MI, MS) - -#define BTRLir(IM, RD) _BTLir(X86_BTR, IM, RD) -#define BTRLim(IM, MD, MB, MI, MS) _BTLim(X86_BTR, IM, MD, MB, MI, MS) -#define BTRLrr(RS, RD) _BTLrr(X86_BTR, RS, RD) -#define BTRLrm(RS, MD, MB, MI, MS) _BTLrm(X86_BTR, RS, MD, MB, MI, MS) - - -#define BTSWir(IM, RD) _BTWir(X86_BTS, IM, RD) -#define BTSWim(IM, MD, MB, MI, MS) _BTWim(X86_BTS, IM, MD, MI, MS) -#define BTSWrr(RS, RD) _BTWrr(X86_BTS, RS, RD) -#define BTSWrm(RS, MD, MB, MI, MS) _BTWrm(X86_BTS, RS, MD, MB, MI, MS) - -#define BTSLir(IM, RD) _BTLir(X86_BTS, IM, RD) -#define BTSLim(IM, MD, MB, MI, MS) _BTLim(X86_BTS, IM, MD, MB, MI, MS) -#define BTSLrr(RS, RD) _BTLrr(X86_BTS, RS, RD) -#define BTSLrm(RS, MD, MB, MI, MS) _BTLrm(X86_BTS, RS, MD, MB, MI, MS) - - - -/* --- Move instructions --------------------------------------------------- */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define MOVBrr(RS, RD) (_REXBrr(RS, RD), _O_Mrm (0x88 ,_b11,_r1(RS),_r1(RD) )) -#define MOVBmr(MD, MB, MI, MS, RD) (_REXBmr(MB, MI, RD), _O_r_X (0x8a ,_r1(RD) ,MD,MB,MI,MS )) -#define MOVBrm(RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _O_r_X (0x88 ,_r1(RS) ,MD,MB,MI,MS )) -#define MOVBir(IM, R) (_REXBrr(0, R), _Or_B (0xb0,_r1(R) ,_su8(IM))) -#define MOVBim(IM, MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_X_B (0xc6 ,MD,MB,MI,MS ,_su8(IM))) - -#define MOVWrr(RS, RD) (_d16(), _REXLrr(RS, RD), _O_Mrm (0x89 ,_b11,_r2(RS),_r2(RD) )) -#define MOVWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _O_r_X (0x8b ,_r2(RD) ,MD,MB,MI,MS )) -#define MOVWrm(RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _O_r_X (0x89 ,_r2(RS) ,MD,MB,MI,MS )) -#define MOVWir(IM, R) (_d16(), _REXLrr(0, R), _Or_W (0xb8,_r2(R) ,_su16(IM))) -#define MOVWim(IM, MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _O_X_W (0xc7 ,MD,MB,MI,MS ,_su16(IM))) - -#define MOVLrr(RS, RD) (_REXLrr(RS, RD), _O_Mrm (0x89 ,_b11,_r4(RS),_r4(RD) )) -#define MOVLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _O_r_X (0x8b ,_r4(RD) ,MD,MB,MI,MS )) -#define MOVLrm(RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _O_r_X (0x89 ,_r4(RS) ,MD,MB,MI,MS )) -#define MOVLir(IM, R) (_REXLrr(0, R), _Or_L (0xb8,_r4(R) ,IM )) -#define MOVLim(IM, MD, MB, MI, MS) (_REXLrm(0, MB, MI), _O_X_L (0xc7 ,MD,MB,MI,MS ,IM )) - - - -/* --- Unary and Multiply/Divide instructions ------------------------------ */ - -enum { - X86_NOT = 2, - X86_NEG = 3, - X86_MUL = 4, - X86_IMUL = 5, - X86_DIV = 6, - X86_IDIV = 7, -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define _UNARYBr(OP, RS) (_REXBrr(0, RS), _O_Mrm (0xf6 ,_b11,OP ,_r1(RS) )) -#define _UNARYBm(OP, MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_r_X (0xf6 ,OP ,MD,MB,MI,MS )) -#define _UNARYWr(OP, RS) (_d16(), _REXLrr(0, RS), _O_Mrm (0xf7 ,_b11,OP ,_r2(RS) )) -#define _UNARYWm(OP, MD, MB, MI, MS) (_d16(), _REXLmr(MB, MI, 0), _O_r_X (0xf7 ,OP ,MD,MB,MI,MS )) -#define _UNARYLr(OP, RS) (_REXLrr(0, RS), _O_Mrm (0xf7 ,_b11,OP ,_r4(RS) )) -#define _UNARYLm(OP, MD, MB, MI, MS) (_REXLmr(MB, MI, 0), _O_r_X (0xf7 ,OP ,MD,MB,MI,MS )) -#define _UNARYQr(OP, RS) (_REXQrr(0, RS), _O_Mrm (0xf7 ,_b11,OP ,_r8(RS) )) -#define _UNARYQm(OP, MD, MB, MI, MS) (_REXQmr(MB, MI, 0), _O_r_X (0xf7 ,OP ,MD,MB,MI,MS )) - -#define NOTBr(RS) _UNARYBr(X86_NOT, RS) -#define NOTBm(MD, MB, MI, MS) _UNARYBm(X86_NOT, MD, MB, MI, MS) -#define NOTWr(RS) _UNARYWr(X86_NOT, RS) -#define NOTWm(MD, MB, MI, MS) _UNARYWm(X86_NOT, MD, MB, MI, MS) -#define NOTLr(RS) _UNARYLr(X86_NOT, RS) -#define NOTLm(MD, MB, MI, MS) _UNARYLm(X86_NOT, MD, MB, MI, MS) - -#define NEGBr(RS) _UNARYBr(X86_NEG, RS) -#define NEGBm(MD, MB, MI, MS) _UNARYBm(X86_NEG, MD, MB, MI, MS) -#define NEGWr(RS) _UNARYWr(X86_NEG, RS) -#define NEGWm(MD, MB, MI, MS) _UNARYWm(X86_NEG, MD, MB, MI, MS) -#define NEGLr(RS) _UNARYLr(X86_NEG, RS) -#define NEGLm(MD, MB, MI, MS) _UNARYLm(X86_NEG, MD, MB, MI, MS) - -#define MULBr(RS) _UNARYBr(X86_MUL, RS) -#define MULBm(MD, MB, MI, MS) _UNARYBm(X86_MUL, MD, MB, MI, MS) -#define MULWr(RS) _UNARYWr(X86_MUL, RS) -#define MULWm(MD, MB, MI, MS) _UNARYWm(X86_MUL, MD, MB, MI, MS) -#define MULLr(RS) _UNARYLr(X86_MUL, RS) -#define MULLm(MD, MB, MI, MS) _UNARYLm(X86_MUL, MD, MB, MI, MS) - -#define IMULBr(RS) _UNARYBr(X86_IMUL, RS) -#define IMULBm(MD, MB, MI, MS) _UNARYBm(X86_IMUL, MD, MB, MI, MS) -#define IMULWr(RS) _UNARYWr(X86_IMUL, RS) -#define IMULWm(MD, MB, MI, MS) _UNARYWm(X86_IMUL, MD, MB, MI, MS) -#define IMULLr(RS) _UNARYLr(X86_IMUL, RS) -#define IMULLm(MD, MB, MI, MS) _UNARYLm(X86_IMUL, MD, MB, MI, MS) - -#define DIVBr(RS) _UNARYBr(X86_DIV, RS) -#define DIVBm(MD, MB, MI, MS) _UNARYBm(X86_DIV, MD, MB, MI, MS) -#define DIVWr(RS) _UNARYWr(X86_DIV, RS) -#define DIVWm(MD, MB, MI, MS) _UNARYWm(X86_DIV, MD, MB, MI, MS) -#define DIVLr(RS) _UNARYLr(X86_DIV, RS) -#define DIVLm(MD, MB, MI, MS) _UNARYLm(X86_DIV, MD, MB, MI, MS) - -#define IDIVBr(RS) _UNARYBr(X86_IDIV, RS) -#define IDIVBm(MD, MB, MI, MS) _UNARYBm(X86_IDIV, MD, MB, MI, MS) -#define IDIVWr(RS) _UNARYWr(X86_IDIV, RS) -#define IDIVWm(MD, MB, MI, MS) _UNARYWm(X86_IDIV, MD, MB, MI, MS) -#define IDIVLr(RS) _UNARYLr(X86_IDIV, RS) -#define IDIVLm(MD, MB, MI, MS) _UNARYLm(X86_IDIV, MD, MB, MI, MS) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define IMULWrr(RS, RD) (_d16(), _REXLrr(RD, RS), _OO_Mrm (0x0faf ,_b11,_r2(RD),_r2(RS) )) -#define IMULWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0faf ,_r2(RD) ,MD,MB,MI,MS )) - -#define IMULWirr(IM,RS,RD) (_d16(), _REXLrr(RS, RD), _Os_Mrm_sW (0x69 ,_b11,_r2(RS),_r2(RD) ,_su16(IM) )) -#define IMULWimr(IM,MD,MB,MI,MS,RD) (_d16(), _REXLmr(MB, MI, RD), _Os_r_X_sW (0x69 ,_r2(RD) ,MD,MB,MI,MS ,_su16(IM) )) - -#define IMULLir(IM, RD) (_REXLrr(0, RD), _Os_Mrm_sL (0x69 ,_b11,_r4(RD),_r4(RD) ,IM )) -#define IMULLrr(RS, RD) (_REXLrr(RD, RS), _OO_Mrm (0x0faf ,_b11,_r4(RD),_r4(RS) )) -#define IMULLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0faf ,_r4(RD) ,MD,MB,MI,MS )) - - -#define IMULLirr(IM,RS,RD) (_REXLrr(RS, RD), _Os_Mrm_sL (0x69 ,_b11,_r4(RS),_r4(RD) ,IM )) -#define IMULLimr(IM,MD,MB,MI,MS,RD) (_REXLmr(MB, MI, RD), _Os_r_X_sL (0x69 ,_r4(RD) ,MD,MB,MI,MS ,IM )) - - - -/* --- Control Flow related instructions ----------------------------------- */ - -enum { - X86_CC_O = 0x0, - X86_CC_NO = 0x1, - X86_CC_NAE = 0x2, - X86_CC_B = 0x2, - X86_CC_C = 0x2, - X86_CC_AE = 0x3, - X86_CC_NB = 0x3, - X86_CC_NC = 0x3, - X86_CC_E = 0x4, - X86_CC_Z = 0x4, - X86_CC_NE = 0x5, - X86_CC_NZ = 0x5, - X86_CC_BE = 0x6, - X86_CC_NA = 0x6, - X86_CC_A = 0x7, - X86_CC_NBE = 0x7, - X86_CC_S = 0x8, - X86_CC_NS = 0x9, - X86_CC_P = 0xa, - X86_CC_PE = 0xa, - X86_CC_NP = 0xb, - X86_CC_PO = 0xb, - X86_CC_L = 0xc, - X86_CC_NGE = 0xc, - X86_CC_GE = 0xd, - X86_CC_NL = 0xd, - X86_CC_LE = 0xe, - X86_CC_NG = 0xe, - X86_CC_G = 0xf, - X86_CC_NLE = 0xf, -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -/* FIXME: no prefix is availble to encode a 32-bit operand size in 64-bit - mode */ -#define CALLm(M) _O_D32 (0xe8 ,(int)(M) ) -#define CALLLsr(R) (_REXLrr(0, R), _O_Mrm (0xff ,_b11,_b010,_r4(R) )) -#define CALLsm(D,B,I,S) (_REXLrm(0, B, I), _O_r_X (0xff ,_b010 ,(int)(D),B,I,S )) - -/* FIXME: no prefix is availble to encode a 32-bit operand size in 64-bit - mode */ -#define JMPSm(M) _O_D8 (0xeb ,(int)(M) ) -#define JMPm(M) _O_D32 (0xe9 ,(int)(M) ) -#define JMPLsr(R) (_REXLrr(0, R), _O_Mrm (0xff ,_b11,_b100,_r4(R) )) -#define JMPsm(D,B,I,S) (_REXLrm(0, B, I), _O_r_X (0xff ,_b100 ,(int)(D),B,I,S )) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ -#define JCCSii(CC, D) _O_B (0x70|(CC) ,(_sc)(int)(D) ) -#define JCCSim(CC, D) _O_D8 (0x70|(CC) ,(int)(D) ) -#define JOSm(D) JCCSim(0x0, D) -#define JNOSm(D) JCCSim(0x1, D) -#define JBSm(D) JCCSim(0x2, D) -#define JCSm(D) JCCSim(0x2, D) -#define JNAESm(D) JCCSim(0x2, D) -#define JNBSm(D) JCCSim(0x3, D) -#define JNCSm(D) JCCSim(0x3, D) -#define JAESm(D) JCCSim(0x3, D) -#define JESm(D) JCCSim(0x4, D) -#define JZSm(D) JCCSim(0x4, D) -#define JNESm(D) JCCSim(0x5, D) -#define JNZSm(D) JCCSim(0x5, D) -#define JBESm(D) JCCSim(0x6, D) -#define JNASm(D) JCCSim(0x6, D) -#define JNBESm(D) JCCSim(0x7, D) -#define JASm(D) JCCSim(0x7, D) -#define JSSm(D) JCCSim(0x8, D) -#define JNSSm(D) JCCSim(0x9, D) -#define JPSm(D) JCCSim(0xa, D) -#define JPESm(D) JCCSim(0xa, D) -#define JNPSm(D) JCCSim(0xb, D) -#define JPOSm(D) JCCSim(0xb, D) -#define JLSm(D) JCCSim(0xc, D) -#define JNGESm(D) JCCSim(0xc, D) -#define JNLSm(D) JCCSim(0xd, D) -#define JGESm(D) JCCSim(0xd, D) -#define JLESm(D) JCCSim(0xe, D) -#define JNGSm(D) JCCSim(0xe, D) -#define JNLESm(D) JCCSim(0xf, D) -#define JGSm(D) JCCSim(0xf, D) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ -#define JCCim(CC, D) _OO_D32 (0x0f80|(CC) ,(long)(D) ) -#define JOm(D) JCCim(0x0, D) -#define JNOm(D) JCCim(0x1, D) -#define JBm(D) JCCim(0x2, D) -#define JCm(D) JCCim(0x2, D) -#define JNAEm(D) JCCim(0x2, D) -#define JNBm(D) JCCim(0x3, D) -#define JNCm(D) JCCim(0x3, D) -#define JAEm(D) JCCim(0x3, D) -#define JEm(D) JCCim(0x4, D) -#define JZm(D) JCCim(0x4, D) -#define JNEm(D) JCCim(0x5, D) -#define JNZm(D) JCCim(0x5, D) -#define JBEm(D) JCCim(0x6, D) -#define JNAm(D) JCCim(0x6, D) -#define JNBEm(D) JCCim(0x7, D) -#define JAm(D) JCCim(0x7, D) -#define JSm(D) JCCim(0x8, D) -#define JNSm(D) JCCim(0x9, D) -#define JPm(D) JCCim(0xa, D) -#define JPEm(D) JCCim(0xa, D) -#define JNPm(D) JCCim(0xb, D) -#define JPOm(D) JCCim(0xb, D) -#define JLm(D) JCCim(0xc, D) -#define JNGEm(D) JCCim(0xc, D) -#define JNLm(D) JCCim(0xd, D) -#define JGEm(D) JCCim(0xd, D) -#define JLEm(D) JCCim(0xe, D) -#define JNGm(D) JCCim(0xe, D) -#define JNLEm(D) JCCim(0xf, D) -#define JGm(D) JCCim(0xf, D) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ -#define SETCCir(CC, RD) (_REXBrr(0, 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) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ -#define SETCCim(CC,MD,MB,MI,MS) (_REXBrm(0, MB, MI), _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) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ -#define CMOVWrr(CC,RS,RD) (_d16(), _REXLrr(RD, RS), _OO_Mrm (0x0f40|(CC) ,_b11,_r2(RD),_r2(RS) )) -#define CMOVWmr(CC,MD,MB,MI,MS,RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0f40|(CC) ,_r2(RD) ,MD,MB,MI,MS )) -#define CMOVLrr(CC,RS,RD) (_REXLrr(RD, RS), _OO_Mrm (0x0f40|(CC) ,_b11,_r4(RD),_r4(RS) )) -#define CMOVLmr(CC,MD,MB,MI,MS,RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0f40|(CC) ,_r4(RD) ,MD,MB,MI,MS )) - - -/* --- Push/Pop instructions ----------------------------------------------- */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define POPWr(RD) _m32only((_d16(), _Or (0x58,_r2(RD) ))) -#define POPWm(MD, MB, MI, MS) _m32only((_d16(), _O_r_X (0x8f ,_b000 ,MD,MB,MI,MS ))) - -#define POPLr(RD) _m32only( _Or (0x58,_r4(RD) )) -#define POPLm(MD, MB, MI, MS) _m32only( _O_r_X (0x8f ,_b000 ,MD,MB,MI,MS )) - - -#define PUSHWr(RS) _m32only((_d16(), _Or (0x50,_r2(RS) ))) -#define PUSHWm(MD, MB, MI, MS) _m32only((_d16(), _O_r_X (0xff, ,_b110 ,MD,MB,MI,MS ))) -#define PUSHWi(IM) _m32only((_d16(), _Os_sW (0x68 ,IM ))) - -#define PUSHLr(RS) _m32only( _Or (0x50,_r4(RS) )) -#define PUSHLm(MD, MB, MI, MS) _m32only( _O_r_X (0xff ,_b110 ,MD,MB,MI,MS )) -#define PUSHLi(IM) _m32only( _Os_sL (0x68 ,IM )) - - -#define POPA_() (_d16(), _O (0x61 )) -#define POPAD_() _O (0x61 ) - -#define PUSHA_() (_d16(), _O (0x60 )) -#define PUSHAD_() _O (0x60 ) - -#define POPF_() _O (0x9d ) -#define PUSHF_() _O (0x9c ) - - -/* --- Test instructions --------------------------------------------------- */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define TESTBrr(RS, RD) (_REXBrr(RS, RD), _O_Mrm (0x84 ,_b11,_r1(RS),_r1(RD) )) -#define TESTBrm(RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _O_r_X (0x84 ,_r1(RS) ,MD,MB,MI,MS )) -#define TESTBir(IM, RD) ((RD) == _AL ? \ - (_REXBrr(0, RD), _O_B (0xa8 ,_u8(IM))) : \ - (_REXBrr(0, RD), _O_Mrm_B (0xf6 ,_b11,_b000 ,_r1(RD) ,_u8(IM))) ) -#define TESTBim(IM, MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_r_X_B (0xf6 ,_b000 ,MD,MB,MI,MS ,_u8(IM))) - -#define TESTWrr(RS, RD) (_d16(), _REXLrr(RS, RD), _O_Mrm (0x85 ,_b11,_r2(RS),_r2(RD) )) -#define TESTWrm(RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _O_r_X (0x85 ,_r2(RS) ,MD,MB,MI,MS )) -#define TESTWir(IM, RD) ((RD) == _AX ? \ - (_d16(), _REXLrr(0, RD), _O_W (0xa9 ,_u16(IM))) : \ - (_d16(), _REXLrr(0, RD), _O_Mrm_W (0xf7 ,_b11,_b000 ,_r2(RD) ,_u16(IM))) ) -#define TESTWim(IM, MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _O_r_X_W (0xf7 ,_b000 ,MD,MB,MI,MS ,_u16(IM))) - -#define TESTLrr(RS, RD) (_REXLrr(RS, RD), _O_Mrm (0x85 ,_b11,_r4(RS),_r4(RD) )) -#define TESTLrm(RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _O_r_X (0x85 ,_r4(RS) ,MD,MB,MI,MS )) -#define TESTLir(IM, RD) (!_s8P(IM) && (RD) == _EAX ? \ - (_REXLrr(0, RD), _O_L (0xa9 ,IM )) : \ - (_REXLrr(0, RD), _O_Mrm_L (0xf7 ,_b11,_b000 ,_r4(RD) ,IM )) ) -#define TESTLim(IM, MD, MB, MI, MS) (_REXLrm(0, MB, MI), _O_r_X_L (0xf7 ,_b000 ,MD,MB,MI,MS ,IM )) - - - -/* --- Exchange instructions ----------------------------------------------- */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define CMPXCHGBrr(RS, RD) (_REXBrr(RS, RD), _OO_Mrm (0x0fb0 ,_b11,_r1(RS),_r1(RD) )) -#define CMPXCHGBrm(RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _OO_r_X (0x0fb0 ,_r1(RS) ,MD,MB,MI,MS )) - -#define CMPXCHGWrr(RS, RD) (_d16(), _REXLrr(RS, RD), _OO_Mrm (0x0fb1 ,_b11,_r2(RS),_r2(RD) )) -#define CMPXCHGWrm(RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _OO_r_X (0x0fb1 ,_r2(RS) ,MD,MB,MI,MS )) - -#define CMPXCHGLrr(RS, RD) (_REXLrr(RS, RD), _OO_Mrm (0x0fb1 ,_b11,_r4(RS),_r4(RD) )) -#define CMPXCHGLrm(RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _OO_r_X (0x0fb1 ,_r4(RS) ,MD,MB,MI,MS )) - - -#define XADDBrr(RS, RD) (_REXBrr(RS, RD), _OO_Mrm (0x0fc0 ,_b11,_r1(RS),_r1(RD) )) -#define XADDBrm(RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _OO_r_X (0x0fc0 ,_r1(RS) ,MD,MB,MI,MS )) - -#define XADDWrr(RS, RD) (_d16(), _REXLrr(RS, RD), _OO_Mrm (0x0fc1 ,_b11,_r2(RS),_r2(RD) )) -#define XADDWrm(RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _OO_r_X (0x0fc1 ,_r2(RS) ,MD,MB,MI,MS )) - -#define XADDLrr(RS, RD) (_REXLrr(RS, RD), _OO_Mrm (0x0fc1 ,_b11,_r4(RS),_r4(RD) )) -#define XADDLrm(RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _OO_r_X (0x0fc1 ,_r4(RS) ,MD,MB,MI,MS )) - - -#define XCHGBrr(RS, RD) (_REXBrr(RS, RD), _O_Mrm (0x86 ,_b11,_r1(RS),_r1(RD) )) -#define XCHGBrm(RS, MD, MB, MI, MS) (_REXBrm(RS, MB, MI), _O_r_X (0x86 ,_r1(RS) ,MD,MB,MI,MS )) - -#define XCHGWrr(RS, RD) (_d16(), _REXLrr(RS, RD), _O_Mrm (0x87 ,_b11,_r2(RS),_r2(RD) )) -#define XCHGWrm(RS, MD, MB, MI, MS) (_d16(), _REXLrm(RS, MB, MI), _O_r_X (0x87 ,_r2(RS) ,MD,MB,MI,MS )) - -#define XCHGLrr(RS, RD) (_REXLrr(RS, RD), _O_Mrm (0x87 ,_b11,_r4(RS),_r4(RD) )) -#define XCHGLrm(RS, MD, MB, MI, MS) (_REXLrm(RS, MB, MI), _O_r_X (0x87 ,_r4(RS) ,MD,MB,MI,MS )) - - - -/* --- Increment/Decrement instructions ------------------------------------ */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define DECBm(MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_r_X (0xfe ,_b001 ,MD,MB,MI,MS )) -#define DECBr(RD) (_REXBrr(0, RD), _O_Mrm (0xfe ,_b11,_b001 ,_r1(RD) )) - -#define DECWm(MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _O_r_X (0xff ,_b001 ,MD,MB,MI,MS )) - -#define DECLm(MD, MB, MI, MS) (_REXLrm(0, MB, MI), _O_r_X (0xff ,_b001 ,MD,MB,MI,MS )) - - -#define INCBm(MD, MB, MI, MS) (_REXBrm(0, MB, MI), _O_r_X (0xfe ,_b000 ,MD,MB,MI,MS )) -#define INCBr(RD) (_REXBrr(0, RD), _O_Mrm (0xfe ,_b11,_b000 ,_r1(RD) )) - -#define INCWm(MD, MB, MI, MS) (_d16(), _REXLrm(0, MB, MI), _O_r_X (0xff ,_b000 ,MD,MB,MI,MS )) - -#define INCLm(MD, MB, MI, MS) (_REXLrm(0, MB, MI), _O_r_X (0xff ,_b000 ,MD,MB,MI,MS )) - - - -/* --- Misc instructions --------------------------------------------------- */ - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define BSFWrr(RS, RD) (_d16(), _REXLrr(RD, RS), _OO_Mrm (0x0fbc ,_b11,_r2(RD),_r2(RS) )) -#define BSFWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0fbc ,_r2(RD) ,MD,MB,MI,MS )) -#define BSRWrr(RS, RD) (_d16(), _REXLrr(RD, RS), _OO_Mrm (0x0fbd ,_b11,_r2(RD),_r2(RS) )) -#define BSRWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0fbd ,_r2(RD) ,MD,MB,MI,MS )) - -#define BSFLrr(RS, RD) (_REXLrr(RD, RS), _OO_Mrm (0x0fbc ,_b11,_r4(RD),_r4(RS) )) -#define BSFLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fbc ,_r4(RD) ,MD,MB,MI,MS )) -#define BSRLrr(RS, RD) (_REXLrr(RD, RS), _OO_Mrm (0x0fbd ,_b11,_r4(RD),_r4(RS) )) -#define BSRLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fbd ,_r4(RD) ,MD,MB,MI,MS )) - - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define MOVSBWrr(RS, RD) (_d16(), _REXBLrr(RD, RS), _OO_Mrm (0x0fbe ,_b11,_r2(RD),_r1(RS) )) -#define MOVSBWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0fbe ,_r2(RD) ,MD,MB,MI,MS )) -#define MOVZBWrr(RS, RD) (_d16(), _REXBLrr(RD, RS), _OO_Mrm (0x0fb6 ,_b11,_r2(RD),_r1(RS) )) -#define MOVZBWmr(MD, MB, MI, MS, RD) (_d16(), _REXLmr(MB, MI, RD), _OO_r_X (0x0fb6 ,_r2(RD) ,MD,MB,MI,MS )) - -#define MOVSBLrr(RS, RD) (_REXBLrr(RD, RS), _OO_Mrm (0x0fbe ,_b11,_r4(RD),_r1(RS) )) -#define MOVSBLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fbe ,_r4(RD) ,MD,MB,MI,MS )) -#define MOVZBLrr(RS, RD) (_REXBLrr(RD, RS), _OO_Mrm (0x0fb6 ,_b11,_r4(RD),_r1(RS) )) -#define MOVZBLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fb6 ,_r4(RD) ,MD,MB,MI,MS )) - - -#define MOVSWLrr(RS, RD) (_REXLrr(RD, RS), _OO_Mrm (0x0fbf ,_b11,_r4(RD),_r2(RS) )) -#define MOVSWLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fbf ,_r4(RD) ,MD,MB,MI,MS )) -#define MOVZWLrr(RS, RD) (_REXLrr(RD, RS), _OO_Mrm (0x0fb7 ,_b11,_r4(RD),_r2(RS) )) -#define MOVZWLmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _OO_r_X (0x0fb7 ,_r4(RD) ,MD,MB,MI,MS )) - - - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define LEALmr(MD, MB, MI, MS, RD) (_REXLmr(MB, MI, RD), _O_r_X (0x8d ,_r4(RD) ,MD,MB,MI,MS )) - -#define BSWAPLr(R) (_REXLrr(0, R), _OOr (0x0fc8,_r4(R) )) - -#define CLC_() _O (0xf8 ) -#define STC_() _O (0xf9 ) - -#define CMC_() _O (0xf5 ) -#define CLD_() _O (0xfc ) -#define STD_() _O (0xfd ) - -#define CBTW_() (_d16(), _O (0x98 )) -#define CWTL_() _O (0x98 ) -#define CLTQ_() _m64only(_REXQrr(0, 0), _O (0x98 )) - -#define CBW_() CBTW_() -#define CWDE_() CWTL_() -#define CDQE_() CLTQ_() - -#define CWTD_() (_d16(), _O (0x99 )) -#define CLTD_() _O (0x99 ) -#define CQTO_() _m64only(_REXQrr(0, 0), _O (0x99 )) - -#define CWD_() CWTD_() -#define CDQ_() CLTD_() -#define CQO_() CQTO_() - -#define LAHF_() _m32only( _O (0x9f )) -#define SAHF_() _m32only( _O (0x9e )) - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define CPUID_() _OO (0x0fa2 ) -#define RDTSC_() _OO (0xff31 ) - -#define ENTERii(W, B) _O_W_B (0xc8 ,_su16(W),_su8(B)) - -#define LEAVE_() _O (0xc9 ) -#define RET_() _O (0xc3 ) -#define RETi(IM) _O_W (0xc2 ,_su16(IM)) - -#define NOP_() _O (0x90 ) - -/* x87 instructions -- yay, we found a use for octal constants :-) */ - -#define ESCmi(D,B,I,S,OP) (_REXLrm(0,B,I), _O_r_X(0xd8|(OP >> 3), (OP & 7), D,B,I,S)) -#define ESCri(RD,OP) _O_Mrm(0xd8|(OP >> 3), _b11, (OP & 7), RD) - -#define ESCrri(RS,RD,OP) ((RS) == _ST0 ? ESCri(RD,(OP|040)) \ - : (RD) == _ST0 ? ESCri(RS,OP) \ - : JITFAIL ("coprocessor instruction without st0")) - -#define FLDSm(D,B,I,S) ESCmi(D,B,I,S,010) /* fld m32real */ -#define FILDLm(D,B,I,S) ESCmi(D,B,I,S,030) /* fild m32int */ -#define FLDLm(D,B,I,S) ESCmi(D,B,I,S,050) /* fld m64real */ -#define FILDWm(D,B,I,S) ESCmi(D,B,I,S,070) /* fild m16int */ -#define FSTSm(D,B,I,S) ESCmi(D,B,I,S,012) /* fst m32real */ -#define FISTLm(D,B,I,S) ESCmi(D,B,I,S,032) /* fist m32int */ -#define FSTLm(D,B,I,S) ESCmi(D,B,I,S,052) /* fst m64real */ -#define FISTWm(D,B,I,S) ESCmi(D,B,I,S,072) /* fist m16int */ -#define FSTPSm(D,B,I,S) ESCmi(D,B,I,S,013) /* 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,053) /* fstp m64real */ -#define FISTPWm(D,B,I,S) ESCmi(D,B,I,S,073) /* fistp m16int */ -#define FLDTm(D,B,I,S) ESCmi(D,B,I,S,035) /* fld m80real */ -#define FILDQm(D,B,I,S) ESCmi(D,B,I,S,075) /* fild m64int */ -#define FSTPTm(D,B,I,S) ESCmi(D,B,I,S,037) /* fstp m80real */ -#define FISTPQm(D,B,I,S) ESCmi(D,B,I,S,077) /* fistp m64int */ - -#define FADDrr(RS,RD) ESCrri(RS,RD,000) -#define FMULrr(RS,RD) ESCrri(RS,RD,001) -#define FSUBrr(RS,RD) ESCrri(RS,RD,004) -#define FSUBRrr(RS,RD) ESCrri(RS,RD,005) -#define FDIVrr(RS,RD) ESCrri(RS,RD,006) -#define FDIVRrr(RS,RD) ESCrri(RS,RD,007) - -#define FLDr(RD) ESCri(RD,010) -#define FXCHr(RD) ESCri(RD,011) -#define FFREEr(RD) ESCri(RD,050) -#define FSTr(RD) ESCri(RD,052) -#define FSTPr(RD) ESCri(RD,053) -#define FCOMr(RD) ESCri(RD,002) -#define FCOMPr(RD) ESCri(RD,003) -#define FCOMIr(RD) ESCri(RD,036) -#define FCOMIPr(RD) ESCri(RD,076) -#define FUCOMr(RD) ESCri(RD,054) -#define FUCOMPr(RD) ESCri(RD,055) -#define FUCOMIr(RD) ESCri(RD,035) -#define FUCOMIPr(RD) ESCri(RD,075) -#define FADDPr(RD) ESCri(RD,060) -#define FMULPr(RD) ESCri(RD,061) -#define FSUBPr(RD) ESCri(RD,064) -#define FSUBRPr(RD) ESCri(RD,065) -#define FDIVPr(RD) ESCri(RD,066) -#define FDIVRPr(RD) ESCri(RD,067) - -#define FNSTSWr(RD) ((RD == _AX || RD == _EAX) ? _OO (0xdfe0) \ - : JITFAIL ("AX or EAX expected")) -/* N byte NOPs */ -#define NOPi(N) ((( (N) >= 8) ? (_jit_B(0x8d),_jit_B(0xb4),_jit_B(0x26),_jit_I(0x00),_jit_B(0x90)) : (void) 0), \ - (( ((N)&7) == 7) ? (_jit_B(0x8d),_jit_B(0xb4),_jit_B(0x26),_jit_I(0x00)) : \ - ( ((N)&7) == 6) ? (_jit_B(0x8d),_jit_B(0xb6),_jit_I(0x00)) : \ - ( ((N)&7) == 5) ? (_jit_B(0x90),_jit_B(0x8d),_jit_B(0x74),_jit_B(0x26),_jit_B(0x00)) : \ -/* leal 0(,%esi), %esi */ ( ((N)&7) == 4) ? (_jit_B(0x8d),_jit_B(0x74),_jit_B(0x26),_jit_B(0x00)) : \ -/* leal (,%esi), %esi */ ( ((N)&7) == 3) ? (_jit_B(0x8d),_jit_B(0x76),_jit_B(0x00)) : \ -/* movl %esi, %esi */ ( ((N)&7) == 2) ? (_jit_B(0x89),_jit_B(0xf6)) : \ - ( ((N)&7) == 1) ? (_jit_B(0x90)) : \ - ( ((N)&7) == 0) ? 0 : \ - JITFAIL(".align argument too large"))) - - -/* --- Media 128-bit instructions ------------------------------------------ */ - -enum { - X86_SSE_MOV = 0x10, - X86_SSE_MOVLP = 0x12, - X86_SSE_MOVHP = 0x16, - X86_SSE_MOVA = 0x28, - X86_SSE_CVTIS = 0x2a, - X86_SSE_CVTTSI = 0x2c, - X86_SSE_CVTSI = 0x2d, - X86_SSE_UCOMI = 0x2e, - X86_SSE_COMI = 0x2f, - X86_SSE_SQRT = 0x51, - X86_SSE_RSQRT = 0x52, - X86_SSE_RCP = 0x53, - X86_SSE_AND = 0x54, - X86_SSE_ANDN = 0x55, - X86_SSE_OR = 0x56, - X86_SSE_XOR = 0x57, - X86_SSE_ADD = 0x58, - X86_SSE_MUL = 0x59, - X86_SSE_CVTSD = 0x5a, - X86_SSE_CVTDT = 0x5b, - X86_SSE_SUB = 0x5c, - X86_SSE_MIN = 0x5d, - X86_SSE_DIV = 0x5e, - X86_SSE_MAX = 0x5f, - X86_SSE_MOV2 = 0xd6 -}; - -/* _format Opcd ,Mod ,r ,m ,mem=dsp+sib ,imm... */ - -#define __SSELrr(OP,RS,RSA,RD,RDA) (_REXLrr(RD, RS), _OO_Mrm (0x0f00|(OP) ,_b11,RDA(RD),RSA(RS) )) -#define __SSELmr(OP,MD,MB,MI,MS,RD,RDA) (_REXLmr(MB, MI, RD), _OO_r_X (0x0f00|(OP) ,RDA(RD) ,MD,MB,MI,MS )) -#define __SSELrm(OP,RS,RSA,MD,MB,MI,MS) (_REXLrm(RS, MB, MI), _OO_r_X (0x0f00|(OP) ,RSA(RS) ,MD,MB,MI,MS )) -#define __SSEL1rm(OP,RS,RSA,MD,MB,MI,MS) (_REXLrm(RS, MB, MI), _OO_r_X (0x0f01|(OP) ,RSA(RS) ,MD,MB,MI,MS )) - -#define _SSELrr(PX,OP,RS,RSA,RD,RDA) (_jit_B(PX), __SSELrr(OP, RS, RSA, RD, RDA)) -#define _SSELmr(PX,OP,MD,MB,MI,MS,RD,RDA) (_jit_B(PX), __SSELmr(OP, MD, MB, MI, MS, RD, RDA)) -#define _SSELrm(PX,OP,RS,RSA,MD,MB,MI,MS) (_jit_B(PX), __SSELrm(OP, RS, RSA, MD, MB, MI, MS)) -#define _SSEL1rm(PX,OP,RS,RSA,MD,MB,MI,MS) (_jit_B(PX), __SSEL1rm(OP, RS, RSA, MD, MB, MI, MS)) - -#define _SSEPSrr(OP,RS,RD) __SSELrr ( OP, RS,_rX, RD,_rX) -#define _SSEPSmr(OP,MD,MB,MI,MS,RD) __SSELmr ( OP, MD, MB, MI, MS, RD,_rX) -#define _SSEPSrm(OP,RS,MD,MB,MI,MS) __SSELrm ( OP, RS,_rX, MD, MB, MI, MS) -#define _SSEPS1rm(OP,RS,MD,MB,MI,MS) __SSEL1rm( OP, RS,_rX, MD, MB, MI, MS) - -#define _SSEPDrr(OP,RS,RD) _SSELrr (0x66, OP, RS,_rX, RD,_rX) -#define _SSEPDmr(OP,MD,MB,MI,MS,RD) _SSELmr (0x66, OP, MD, MB, MI, MS, RD,_rX) -#define _SSEPDrm(OP,RS,MD,MB,MI,MS) _SSELrm (0x66, OP, RS,_rX, MD, MB, MI, MS) -#define _SSEPD1rm(OP,RS,MD,MB,MI,MS) _SSEL1rm(0x66, OP, RS,_rX, MD, MB, MI, MS) - -#define _SSESSrr(OP,RS,RD) _SSELrr (0xf3, OP, RS,_rX, RD,_rX) -#define _SSESSmr(OP,MD,MB,MI,MS,RD) _SSELmr (0xf3, OP, MD, MB, MI, MS, RD,_rX) -#define _SSESSrm(OP,RS,MD,MB,MI,MS) _SSELrm (0xf3, OP, RS,_rX, MD, MB, MI, MS) -#define _SSESS1rm(OP,RS,MD,MB,MI,MS) _SSEL1rm(0xf3, OP, RS,_rX, MD, MB, MI, MS) - -#define _SSESDrr(OP,RS,RD) _SSELrr (0xf2, OP, RS,_rX, RD,_rX) -#define _SSESDmr(OP,MD,MB,MI,MS,RD) _SSELmr (0xf2, OP, MD, MB, MI, MS, RD,_rX) -#define _SSESDrm(OP,RS,MD,MB,MI,MS) _SSELrm (0xf2, OP, RS,_rX, MD, MB, MI, MS) -#define _SSESD1rm(OP,RS,MD,MB,MI,MS) _SSEL1rm(0xf2, OP, RS,_rX, MD, MB, MI, MS) - -#define ADDPSrr(RS, RD) _SSEPSrr(X86_SSE_ADD, RS, RD) -#define ADDPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_ADD, MD, MB, MI, MS, RD) -#define ADDPDrr(RS, RD) _SSEPDrr(X86_SSE_ADD, RS, RD) -#define ADDPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_ADD, MD, MB, MI, MS, RD) - -#define ADDSSrr(RS, RD) _SSESSrr(X86_SSE_ADD, RS, RD) -#define ADDSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_ADD, MD, MB, MI, MS, RD) -#define ADDSDrr(RS, RD) _SSESDrr(X86_SSE_ADD, RS, RD) -#define ADDSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_ADD, MD, MB, MI, MS, RD) - -#define ANDNPSrr(RS, RD) _SSEPSrr(X86_SSE_ANDN, RS, RD) -#define ANDNPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_ANDN, MD, MB, MI, MS, RD) -#define ANDNPDrr(RS, RD) _SSEPDrr(X86_SSE_ANDN, RS, RD) -#define ANDNPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_ANDN, MD, MB, MI, MS, RD) - -#define ANDNSSrr ANDNPSrr -#define ANDNSSmr ANDNPSrr -#define ANDNSDrr ANDNPDrr -#define ANDNSDmr ANDNPDrr - -#define ANDPSrr(RS, RD) _SSEPSrr(X86_SSE_AND, RS, RD) -#define ANDPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_AND, MD, MB, MI, MS, RD) -#define ANDPDrr(RS, RD) _SSEPDrr(X86_SSE_AND, RS, RD) -#define ANDPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_AND, MD, MB, MI, MS, RD) - -#define ANDSSrr ANDPSrr -#define ANDSSmr ANDPSrr -#define ANDSDrr ANDPDrr -#define ANDSDmr ANDPDrr - -#define DIVPSrr(RS, RD) _SSEPSrr(X86_SSE_DIV, RS, RD) -#define DIVPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_DIV, MD, MB, MI, MS, RD) -#define DIVPDrr(RS, RD) _SSEPDrr(X86_SSE_DIV, RS, RD) -#define DIVPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_DIV, MD, MB, MI, MS, RD) - -#define DIVSSrr(RS, RD) _SSESSrr(X86_SSE_DIV, RS, RD) -#define DIVSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_DIV, MD, MB, MI, MS, RD) -#define DIVSDrr(RS, RD) _SSESDrr(X86_SSE_DIV, RS, RD) -#define DIVSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_DIV, MD, MB, MI, MS, RD) - -#define MAXPSrr(RS, RD) _SSEPSrr(X86_SSE_MAX, RS, RD) -#define MAXPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_MAX, MD, MB, MI, MS, RD) -#define MAXPDrr(RS, RD) _SSEPDrr(X86_SSE_MAX, RS, RD) -#define MAXPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_MAX, MD, MB, MI, MS, RD) - -#define MAXSSrr(RS, RD) _SSESSrr(X86_SSE_MAX, RS, RD) -#define MAXSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_MAX, MD, MB, MI, MS, RD) -#define MAXSDrr(RS, RD) _SSESDrr(X86_SSE_MAX, RS, RD) -#define MAXSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_MAX, MD, MB, MI, MS, RD) - -#define MINPSrr(RS, RD) _SSEPSrr(X86_SSE_MIN, RS, RD) -#define MINPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_MIN, MD, MB, MI, MS, RD) -#define MINPDrr(RS, RD) _SSEPDrr(X86_SSE_MIN, RS, RD) -#define MINPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_MIN, MD, MB, MI, MS, RD) - -#define MINSSrr(RS, RD) _SSESSrr(X86_SSE_MIN, RS, RD) -#define MINSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_MIN, MD, MB, MI, MS, RD) -#define MINSDrr(RS, RD) _SSESDrr(X86_SSE_MIN, RS, RD) -#define MINSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_MIN, MD, MB, MI, MS, RD) - -#define MULPSrr(RS, RD) _SSEPSrr(X86_SSE_MUL, RS, RD) -#define MULPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_MUL, MD, MB, MI, MS, RD) -#define MULPDrr(RS, RD) _SSEPDrr(X86_SSE_MUL, RS, RD) -#define MULPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_MUL, MD, MB, MI, MS, RD) - -#define MULSSrr(RS, RD) _SSESSrr(X86_SSE_MUL, RS, RD) -#define MULSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_MUL, MD, MB, MI, MS, RD) -#define MULSDrr(RS, RD) _SSESDrr(X86_SSE_MUL, RS, RD) -#define MULSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_MUL, MD, MB, MI, MS, RD) - -#define ORPSrr(RS, RD) _SSEPSrr(X86_SSE_OR, RS, RD) -#define ORPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_OR, MD, MB, MI, MS, RD) -#define ORPDrr(RS, RD) _SSEPDrr(X86_SSE_OR, RS, RD) -#define ORPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_OR, MD, MB, MI, MS, RD) - -#define ORSSrr ORPSrr -#define ORSSmr ORPSrr -#define ORSDrr ORPDrr -#define ORSDmr ORPDrr - -#define RCPPSrr(RS, RD) _SSEPSrr(X86_SSE_RCP, RS, RD) -#define RCPPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_RCP, MD, MB, MI, MS, RD) -#define RCPSSrr(RS, RD) _SSESSrr(X86_SSE_RCP, RS, RD) -#define RCPSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_RCP, MD, MB, MI, MS, RD) - -#define RSQRTPSrr(RS, RD) _SSEPSrr(X86_SSE_RSQRT, RS, RD) -#define RSQRTPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_RSQRT, MD, MB, MI, MS, RD) -#define RSQRTSSrr(RS, RD) _SSESSrr(X86_SSE_RSQRT, RS, RD) -#define RSQRTSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_RSQRT, MD, MB, MI, MS, RD) - -#define SQRTPSrr(RS, RD) _SSEPSrr(X86_SSE_SQRT, RS, RD) -#define SQRTPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_SQRT, MD, MB, MI, MS, RD) -#define SQRTPDrr(RS, RD) _SSEPDrr(X86_SSE_SQRT, RS, RD) -#define SQRTPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_SQRT, MD, MB, MI, MS, RD) - -#define SQRTSSrr(RS, RD) _SSESSrr(X86_SSE_SQRT, RS, RD) -#define SQRTSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_SQRT, MD, MB, MI, MS, RD) -#define SQRTSDrr(RS, RD) _SSESDrr(X86_SSE_SQRT, RS, RD) -#define SQRTSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_SQRT, MD, MB, MI, MS, RD) - -#define SUBPSrr(RS, RD) _SSEPSrr(X86_SSE_SUB, RS, RD) -#define SUBPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_SUB, MD, MB, MI, MS, RD) -#define SUBPDrr(RS, RD) _SSEPDrr(X86_SSE_SUB, RS, RD) -#define SUBPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_SUB, MD, MB, MI, MS, RD) - -#define SUBSSrr(RS, RD) _SSESSrr(X86_SSE_SUB, RS, RD) -#define SUBSSmr(MD, MB, MI, MS, RD) _SSESSmr(X86_SSE_SUB, MD, MB, MI, MS, RD) -#define SUBSDrr(RS, RD) _SSESDrr(X86_SSE_SUB, RS, RD) -#define SUBSDmr(MD, MB, MI, MS, RD) _SSESDmr(X86_SSE_SUB, MD, MB, MI, MS, RD) - -#define XORPSrr(RS, RD) _SSEPSrr(X86_SSE_XOR, RS, RD) -#define XORPSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_XOR, MD, MB, MI, MS, RD) -#define XORPDrr(RS, RD) _SSEPDrr(X86_SSE_XOR, RS, RD) -#define XORPDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_XOR, MD, MB, MI, MS, RD) - -#define XORSSrr XORPSrr -#define XORSSmr XORPSrr -#define XORSDrr XORPDrr -#define XORSDmr XORPDrr - -/* No prefixes here. */ -#define COMISSrr(RS, RD) _SSEPSrr(X86_SSE_COMI, RS, RD) -#define COMISSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_COMI, MD, MB, MI, MS, RD) -#define COMISDrr(RS, RD) _SSEPDrr(X86_SSE_COMI, RS, RD) -#define COMISDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_COMI, MD, MB, MI, MS, RD) - -/* No prefixes here. */ -#define UCOMISSrr(RS, RD) _SSEPSrr(X86_SSE_UCOMI, RS, RD) -#define UCOMISSmr(MD, MB, MI, MS, RD) _SSEPSmr(X86_SSE_UCOMI, MD, MB, MI, MS, RD) -#define UCOMISDrr(RS, RD) _SSEPDrr(X86_SSE_UCOMI, RS, RD) -#define UCOMISDmr(MD, MB, MI, MS, RD) _SSEPDmr(X86_SSE_UCOMI, MD, MB, MI, MS, RD) - -#define MOVSSrr(RS, RD) _SSESSrr (X86_SSE_MOV, RS, RD) -#define MOVSSmr(MD, MB, MI, MS, RD) _SSESSmr (X86_SSE_MOV, MD, MB, MI, MS, RD) -#define MOVSSrm(RS, MD, MB, MI, MS) _SSESS1rm(X86_SSE_MOV, RS, MD, MB, MI, MS) - -#define MOVSDrr(RS, RD) _SSESDrr (X86_SSE_MOV, RS, RD) -#define MOVSDmr(MD, MB, MI, MS, RD) _SSESDmr (X86_SSE_MOV, MD, MB, MI, MS, RD) -#define MOVSDrm(RS, MD, MB, MI, MS) _SSESD1rm(X86_SSE_MOV, RS, MD, MB, MI, MS) - -#define MOVAPSrr(RS, RD) _SSEPSrr (X86_SSE_MOVA, RS, RD) -#define MOVAPSmr(MD, MB, MI, MS, RD) _SSEPSmr (X86_SSE_MOVA, MD, MB, MI, MS, RD) -#define MOVAPSrm(RS, MD, MB, MI, MS) _SSEPS1rm(X86_SSE_MOVA, RS, MD, MB, MI, MS) - -#define MOVAPDrr(RS, RD) _SSEPDrr (X86_SSE_MOVA, RS, RD) -#define MOVAPDmr(MD, MB, MI, MS, RD) _SSEPDmr (X86_SSE_MOVA, MD, MB, MI, MS, RD) -#define MOVAPDrm(RS, MD, MB, MI, MS) _SSEPD1rm(X86_SSE_MOVA, RS, MD, MB, MI, MS) - -#define CVTPS2PIrr(RS, RD) __SSELrr( X86_SSE_CVTSI, RS,_rX, RD,_rM) -#define CVTPS2PImr(MD, MB, MI, MS, RD) __SSELmr( X86_SSE_CVTSI, MD, MB, MI, MS, RD,_rM) -#define CVTPD2PIrr(RS, RD) _SSELrr(0x66, X86_SSE_CVTSI, RS,_rX, RD,_rM) -#define CVTPD2PImr(MD, MB, MI, MS, RD) _SSELmr(0x66, X86_SSE_CVTSI, MD, MB, MI, MS, RD,_rM) - -#define CVTPI2PSrr(RS, RD) __SSELrr( X86_SSE_CVTIS, RS,_rM, RD,_rX) -#define CVTPI2PSmr(MD, MB, MI, MS, RD) __SSELmr( X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) -#define CVTPI2PDrr(RS, RD) _SSELrr(0x66, X86_SSE_CVTIS, RS,_rM, RD,_rX) -#define CVTPI2PDmr(MD, MB, MI, MS, RD) _SSELmr(0x66, X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) - -#define CVTPS2PDrr(RS, RD) __SSELrr( X86_SSE_CVTSD, RS,_rX, RD,_rX) -#define CVTPS2PDmr(MD, MB, MI, MS, RD) __SSELmr( X86_SSE_CVTSD, MD, MB, MI, MS, RD,_rX) -#define CVTPD2PSrr(RS, RD) _SSELrr(0x66, X86_SSE_CVTSD, RS,_rX, RD,_rX) -#define CVTPD2PSmr(MD, MB, MI, MS, RD) _SSELmr(0x66, X86_SSE_CVTSD, MD, MB, MI, MS, RD,_rX) - -#define CVTSS2SDrr(RS, RD) _SSELrr(0xf3, X86_SSE_CVTSD, RS,_rX, RD,_rX) -#define CVTSS2SDmr(MD, MB, MI, MS, RD) _SSELmr(0xf3, X86_SSE_CVTSD, MD, MB, MI, MS, RD,_rX) -#define CVTSD2SSrr(RS, RD) _SSELrr(0xf2, X86_SSE_CVTSD, RS,_rX, RD,_rX) -#define CVTSD2SSmr(MD, MB, MI, MS, RD) _SSELmr(0xf2, X86_SSE_CVTSD, MD, MB, MI, MS, RD,_rX) - -#define CVTTSS2SILrr(RS, RD) _SSELrr(0xf3, X86_SSE_CVTTSI, RS,_rX, RD,_r4) -#define CVTTSS2SILmr(MD, MB, MI, MS, RD) _SSELmr(0xf3, X86_SSE_CVTTSI, MD, MB, MI, MS, RD,_r4) -#define CVTTSD2SILrr(RS, RD) _SSELrr(0xf2, X86_SSE_CVTTSI, RS,_rX, RD,_r4) -#define CVTTSD2SILmr(MD, MB, MI, MS, RD) _SSELmr(0xf2, X86_SSE_CVTTSI, MD, MB, MI, MS, RD,_r4) - -#define CVTSS2SILrr(RS, RD) _SSELrr(0xf3, X86_SSE_CVTSI, RS,_rX, RD,_r4) -#define CVTSS2SILmr(MD, MB, MI, MS, RD) _SSELmr(0xf3, X86_SSE_CVTSI, MD, MB, MI, MS, RD,_r4) -#define CVTSD2SILrr(RS, RD) _SSELrr(0xf2, X86_SSE_CVTSI, RS,_rX, RD,_r4) -#define CVTSD2SILmr(MD, MB, MI, MS, RD) _SSELmr(0xf2, X86_SSE_CVTSI, MD, MB, MI, MS, RD,_r4) - -#define CVTSI2SSLrr(RS, RD) _SSELrr(0xf3, X86_SSE_CVTIS, RS,_r4, RD,_rX) -#define CVTSI2SSLmr(MD, MB, MI, MS, RD) _SSELmr(0xf3, X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) -#define CVTSI2SDLrr(RS, RD) _SSELrr(0xf2, X86_SSE_CVTIS, RS,_r4, RD,_rX) -#define CVTSI2SDLmr(MD, MB, MI, MS, RD) _SSELmr(0xf2, X86_SSE_CVTIS, MD, MB, MI, MS, RD,_rX) - -#define MOVDLXrr(RS, RD) _SSELrr(0x66, 0x6e, RS,_r4, RD,_rX) -#define MOVDLXmr(MD, MB, MI, MS, RD) _SSELmr(0x66, 0x6e, MD, MB, MI, MS, RD,_rX) - -#define MOVDXLrr(RS, RD) _SSELrr(0x66, 0x7e, RS,_rX, RD,_r4) -#define MOVDXLrm(RS, MD, MB, MI, MS) _SSELrm(0x66, 0x7e, RS,_rX, MD, MB, MI, MS) - -#define MOVDLMrr(RS, RD) __SSELrr( 0x6e, RS,_r4, RD,_rM) -#define MOVDLMmr(MD, MB, MI, MS, RD) __SSELmr( 0x6e, MD, MB, MI, MS, RD,_rM) - -#define MOVDMLrr(RS, RD) __SSELrr( 0x7e, RS,_rM, RD,_r4) -#define MOVDMLrm(RS, MD, MB, MI, MS) __SSELrm( 0x7e, RS,_rM, MD, MB, MI, MS) - -#define MOVDQ2Qrr(RS, RD) _SSELrr(0xf2, X86_SSE_MOV2, RS,_rX, RD,_rM) -#define MOVQ2DQrr(RS, RD) _SSELrr(0xf3, X86_SSE_MOV2, RS,_rM, RD,_rX) -#define MOVHLPSrr(RS, RD) __SSELrr( X86_SSE_MOVLP, RS,_rX, RD,_rX) -#define MOVLHPSrr(RS, RD) __SSELrr( X86_SSE_MOVHP, RS,_rX, RD,_rX) - -#define MOVDQArr(RS, RD) _SSELrr(0x66, 0x6f, RS,_rX, RD,_rX) -#define MOVDQAmr(MD, MB, MI, MS, RD) _SSELmr(0x66, 0x6f, MD, MB, MI, MS, RD,_rX) -#define MOVDQArm(RS, MD, MB, MI, MS) _SSELrm(0x66, 0x7f, RS,_rX, MD, MB, MI, MS) - -#define MOVDQUrr(RS, RD) _SSELrr(0xf3, 0x6f, RS,_rX, RD,_rX) -#define MOVDQUmr(MD, MB, MI, MS, RD) _SSELmr(0xf3, 0x6f, MD, MB, MI, MS, RD,_rX) -#define MOVDQUrm(RS, MD, MB, MI, MS) _SSELrm(0xf3, 0x7f, RS,_rX, MD, MB, MI, MS) - -#define MOVHPDmr(MD, MB, MI, MS, RD) _SSELmr (0x66, X86_SSE_MOVHP, MD, MB, MI, MS, RD,_rX) -#define MOVHPDrm(RS, MD, MB, MI, MS) _SSEL1rm(0x66, X86_SSE_MOVHP, RS,_rX, MD, MB, MI, MS) -#define MOVHPSmr(MD, MB, MI, MS, RD) __SSELmr ( X86_SSE_MOVHP, MD, MB, MI, MS, RD,_rX) -#define MOVHPSrm(RS, MD, MB, MI, MS) __SSEL1rm( X86_SSE_MOVHP, RS,_rX, MD, MB, MI, MS) - -#define MOVLPDmr(MD, MB, MI, MS, RD) _SSELmr (0x66, X86_SSE_MOVLP, MD, MB, MI, MS, RD,_rX) -#define MOVLPDrm(RS, MD, MB, MI, MS) _SSEL1rm(0x66, X86_SSE_MOVLP, RS,_rX, MD, MB, MI, MS) -#define MOVLPSmr(MD, MB, MI, MS, RD) __SSELmr ( X86_SSE_MOVLP, MD, MB, MI, MS, RD,_rX) -#define MOVLPSrm(RS, MD, MB, MI, MS) __SSEL1rm( X86_SSE_MOVLP, RS,_rX, MD, MB, MI, MS) - -/*** 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. */ - -#if defined (__x86_64__) -#include "asm-64.h" -#else -#include "asm-32.h" -#endif - -#endif -#endif /* __lightning_asm_i386_h */ - diff --git a/lightning/i386/core-32.h b/lightning/i386/core-32.h deleted file mode 100644 index 9c0710429..000000000 --- a/lightning/i386/core-32.h +++ /dev/null @@ -1,174 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer (i386 version) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini and Matthew Flatt. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_core_h -#define __lightning_core_h - -#define JIT_CAN_16 1 -#define JIT_AP _EBP - -#define JIT_R_NUM 3 -#define JIT_R(i) (_EAX + (i)) -#define JIT_V_NUM 3 -#define JIT_V(i) ((i) == 0 ? _EBX : _ESI + (i) - 1) - -struct jit_local_state { - int framesize; - int argssize; - int alloca_offset; - int alloca_slack; -}; - -/* Whether a register is used for the user-accessible registers. */ -#define jit_save(reg) 1 - -#define jit_base_prolog() (_jitl.framesize = 20, _jitl.alloca_offset = _jitl.alloca_slack = 0, \ - PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI), PUSHLr(_EBP), MOVLrr(_ESP, _EBP)) -#define jit_base_ret(ofs) \ - (((ofs) < 0 ? LEAVE_() : POPLr(_EBP)), \ - POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), RET_()) - -/* Used internally. SLACK is used by the Darwin ABI which keeps the stack - aligned to 16-bytes. */ - -#define jit_allocai_internal(amount, slack) \ - (((amount) < _jitl.alloca_slack \ - ? (void)0 \ - : (void)(_jitl.alloca_slack += (amount) + (slack), \ - ((amount) + (slack) == sizeof (int) \ - ? PUSHLr(_EAX) \ - : SUBLir((amount) + (slack), _ESP)))), \ - _jitl.alloca_slack -= (amount), \ - _jitl.alloca_offset -= (amount)) - -/* Stack */ -#define jit_pushr_i(rs) PUSHLr(rs) -#define jit_popr_i(rs) POPLr(rs) - -/* The += in argssize allows for stack pollution */ - -#ifdef __APPLE__ -/* Stack must stay 16-byte aligned: */ -# define jit_prepare_i(ni) (((ni & 0x3) \ - ? (void)SUBLir(4 * ((((ni) + 3) & ~(0x3)) - (ni)), JIT_SP) \ - : (void)0), \ - _jitl.argssize += (((ni) + 3) & ~(0x3))) - -#define jit_allocai(n) \ - jit_allocai_internal ((n), (_jitl.alloca_slack - (n)) & 15) - -#define jit_prolog(n) (jit_base_prolog(), jit_subi_i (JIT_SP, JIT_SP, 12)) -#define jit_ret() jit_base_ret (-12) - -#else -# define jit_prepare_i(ni) (_jitl.argssize += (ni)) - -#define jit_allocai(n) \ - jit_allocai_internal ((n), 0) - -#define jit_prolog(n) jit_base_prolog() -#define jit_ret() jit_base_ret (_jitl.alloca_offset) -#endif - -#define jit_calli(label) (CALLm( ((unsigned long) (label))), _jit.x.pc) -#define jit_callr(reg) CALLsr(reg) - -#define jit_pusharg_i(rs) PUSHLr(rs) -#define jit_finish(sub) ((void)jit_calli((sub)), ADDLir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0) -#define jit_finishr(reg) (jit_callr((reg)), ADDLir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0) - -#define jit_arg_c() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_uc() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_s() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_us() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_i() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_ui() ((_jitl.framesize += sizeof(int)) - sizeof(int)) -#define jit_arg_l() ((_jitl.framesize += sizeof(long)) - sizeof(long)) -#define jit_arg_ul() ((_jitl.framesize += sizeof(long)) - sizeof(long)) -#define jit_arg_p() ((_jitl.framesize += sizeof(long)) - sizeof(long)) - -#define jit_movi_p(d, is) (MOVLir (((long)(is)), (d)), _jit.x.pc) -#define jit_patch_long_at(jump_pc,v) (*_PSL((jump_pc) - sizeof(long)) = _jit_SL((jit_insn *)(v) - (jump_pc))) -#define jit_patch_at(jump_pc,v) jit_patch_long_at(jump_pc, v) - -/* Memory */ -#define jit_replace(s, rep, op) \ - (jit_pushr_i(rep), \ - MOVLrr((s), (rep)), \ - op, jit_popr_i(rep)) - -#define jit_movbrm(rs, dd, db, di, ds) \ - (jit_check8(rs) \ - ? MOVBrm(jit_reg8(rs), dd, db, di, ds) \ - : jit_replace(rs, \ - ((dd != _EAX && db != _EAX && di != _EAX) ? _EAX : \ - ((dd != _ECX && db != _ECX && di != _ECX) ? _ECX : _EDX)), \ - MOVBrm(((dd != _EAX && db != _EAX && di != _EAX) ? _AL : \ - ((dd != _ECX && db != _ECX && di != _ECX) ? _CL : _DL)), \ - dd, db, di, ds))) - -#define jit_ldr_c(d, rs) MOVSBLmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_c(d, s1, s2) MOVSBLmr(0, (s1), (s2), 1, (d)) - -#define jit_ldr_s(d, rs) MOVSWLmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_s(d, s1, s2) MOVSWLmr(0, (s1), (s2), 1, (d)) - -#define jit_ldi_c(d, is) MOVSBLmr((is), 0, 0, 0, (d)) -#define jit_ldxi_c(d, rs, is) MOVSBLmr((is), (rs), 0, 0, (d)) - -#define jit_ldi_uc(d, is) MOVZBLmr((is), 0, 0, 0, (d)) -#define jit_ldxi_uc(d, rs, is) MOVZBLmr((is), (rs), 0, 0, (d)) - -#define jit_sti_c(id, rs) jit_movbrm((rs), (id), 0, 0, 0) -#define jit_stxi_c(id, rd, rs) jit_movbrm((rs), (id), (rd), 0, 0) - -#define jit_ldi_s(d, is) MOVSWLmr((is), 0, 0, 0, (d)) -#define jit_ldxi_s(d, rs, is) MOVSWLmr((is), (rs), 0, 0, (d)) - -#define jit_ldi_us(d, is) MOVZWLmr((is), 0, 0, 0, (d)) -#define jit_ldxi_us(d, rs, is) MOVZWLmr((is), (rs), 0, 0, (d)) - -#define jit_sti_s(id, rs) MOVWrm(jit_reg16(rs), (id), 0, 0, 0) -#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_ldxi_i(d, rs, is) MOVLmr((is), (rs), 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_sti_i(id, rs) MOVLrm((rs), (id), 0, 0, 0) -#define jit_stxi_i(id, rd, rs) MOVLrm((rs), (id), (rd), 0, 0) - -#endif /* __lightning_core_h */ - diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h deleted file mode 100644 index fadeff581..000000000 --- a/lightning/i386/core-64.h +++ /dev/null @@ -1,497 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer (i386 version) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini and Matthew Flatt. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_core_h -#define __lightning_core_h - -/* Used to implement ldc, stc, ... */ -#define JIT_CAN_16 0 -#define JIT_REXTMP _R12 - -/* Number or integer argument registers */ -#define JIT_ARG_MAX 6 - -/* Number of float argument registers */ -#define JIT_FP_ARG_MAX 8 - -#define JIT_R_NUM 3 -#define JIT_R(i) ((i) == 0 ? _EAX : _R9 + (i)) -#define JIT_V_NUM 3 -#define JIT_V(i) ((i) == 0 ? _EBX : _R12 + (i)) - -struct jit_local_state { - int long_jumps; - int nextarg_getfp; - int nextarg_putfp; - int nextarg_geti; - int nextarg_puti; - int framesize; - int argssize; - int fprssize; - int alloca_offset; - int alloca_slack; -}; - -/* Whether a register in the "low" bank is used for the user-accessible - registers. */ -#define jit_save(reg) ((reg) == _EAX || (reg) == _EBX) - -/* Keep the stack 16-byte aligned, the SSE hardware prefers it this way. */ -#define jit_allocai_internal(amount, slack) \ - (((amount) < _jitl.alloca_slack \ - ? 0 \ - : (_jitl.alloca_slack += (amount) + (slack), \ - SUBQir((amount) + (slack), _ESP))), \ - _jitl.alloca_slack -= (amount), \ - _jitl.alloca_offset -= (amount)) - -#define jit_allocai(n) \ - jit_allocai_internal ((n), (_jitl.alloca_slack - (n)) & 15) - -/* 3-parameter operation */ -#define jit_qopr_(d, s1, s2, op1d, op2d) \ - ( ((s2) == (d)) ? op1d : \ - ( (((s1) == (d)) ? (void)0 : (void)MOVQrr((s1), (d))), op2d ) \ - ) - -/* 3-parameter operation, with immediate. TODO: fix the case where mmediate - does not fit! */ -#define jit_qop_small(d, s1, op2d) \ - (((s1) == (d)) ? op2d : (MOVQrr((s1), (d)), op2d)) -#define jit_qop_(d, s1, is, op2d, op2i) \ - (_s32P((long)(is)) \ - ? jit_qop_small ((d), (s1), (op2d)) \ - : (MOVQir ((is), JIT_REXTMP), jit_qop_small ((d), (s1), (op2i)))) - -#define jit_bra_qr(s1, s2, op) (CMPQrr(s2, s1), op, _jit.x.pc) -#define _jit_bra_l(rs, is, op) (CMPQir(is, rs), op, _jit.x.pc) - -#define jit_bra_l(rs, is, op) (_s32P((long)(is)) \ - ? _jit_bra_l(rs, is, op) \ - : (MOVQir(is, JIT_REXTMP), jit_bra_qr(rs, JIT_REXTMP, op))) - -/* When CMP with 0 can be replaced with TEST */ -#define jit_bra_l0(rs, is, op, op0) \ - ( (is) == 0 ? (TESTQrr(rs, rs), op0, _jit.x.pc) : jit_bra_l(rs, is, op)) - -#define jit_reduceQ(op, is, rs) \ - (_u8P(is) ? jit_reduce_(op##Bir(is, jit_reg8(rs))) : \ - jit_reduce_(op##Qir(is, rs)) ) - -#define jit_addi_l(d, rs, is) \ - /* Value is not zero? */ \ - ((is) \ - /* Yes. Value is unsigned and fits in signed 32 bits? */ \ - ? (_uiP(31, is) \ - /* Yes. d == rs? */ \ - ? jit_opi_((d), (rs), \ - /* Yes. Use add opcode */ \ - ADDQir((is), (d)), \ - /* No. Use lea opcode */ \ - LEAQmr((is), (rs), 0, 0, (d))) \ - /* No. Need value in a register */ \ - : (jit_movi_l(JIT_REXTMP, is), \ - jit_addr_l(d, rs, JIT_REXTMP))) \ - /* No. Do nothing. */ \ - : 0) -#define jit_addr_l(d, s1, s2) jit_opo_((d), (s1), (s2), ADDQrr((s2), (d)), ADDQrr((s1), (d)), LEAQmr(0, (s1), (s2), 1, (d)) ) -#define jit_addci_l(d, rs, is) jit_qop_ ((d), (rs), (is), ADCQir((is), (d)), ADCQrr(JIT_REXTMP, (d))) -#define jit_addcr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ADCQrr((s1), (d)), ADCQrr((s2), (d)) ) -#define jit_addxi_l(d, rs, is) jit_qop_ ((d), (rs), (is), ADDQir((is), (d)), ADDQrr(JIT_REXTMP, (d))) -#define jit_addxr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ADDQrr((s1), (d)), ADDQrr((s2), (d)) ) -#define jit_andi_l(d, rs, is) jit_qop_ ((d), (rs), (is), ANDQir((is), (d)), ANDQrr(JIT_REXTMP, (d))) -#define jit_andr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ANDQrr((s1), (d)), ANDQrr((s2), (d)) ) -#define jit_orr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ORQrr((s1), (d)), ORQrr((s2), (d)) ) -#define jit_subr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), (SUBQrr((s1), (d)), NEGQr(d)), SUBQrr((s2), (d)) ) -#define jit_xorr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), XORQrr((s1), (d)), XORQrr((s2), (d)) ) - -/* These can sometimes use byte or word versions! */ -#define jit_ori_l(d, rs, is) jit_qop_ ((d), (rs), (is), jit_reduceQ(OR, (is), (d)), ORQrr(JIT_REXTMP, (d)) ) -#define jit_xori_l(d, rs, is) jit_qop_ ((d), (rs), (is), jit_reduceQ(XOR, (is), (d)), XORQrr(JIT_REXTMP, (d)) ) - -#define jit_lshi_l(d, rs, is) ((is) <= 3 ? LEAQmr(0, 0, (rs), 1 << (is), (d)) : jit_qop_small ((d), (rs), SHLQir((is), (d)) )) -#define jit_rshi_l(d, rs, is) jit_qop_small ((d), (rs), SARQir((is), (d)) ) -#define jit_rshi_ul(d, rs, is) jit_qop_small ((d), (rs), SHRQir((is), (d)) ) -#define jit_lshr_l(d, r1, r2) jit_shift((d), (r1), (r2), SHLQrr) -#define jit_rshr_l(d, r1, r2) jit_shift((d), (r1), (r2), SARQrr) -#define jit_rshr_ul(d, r1, r2) jit_shift((d), (r1), (r2), SHRQrr) - - -/* Stack */ -#define jit_pushr_i(rs) PUSHQr(rs) -#define jit_popr_i(rs) POPQr(rs) - -/* A return address is 8 bytes, plus 5 registers = 40 bytes, total = 48 bytes. */ -#define jit_prolog(n) (_jitl.framesize = ((n) & 1) ? 56 : 48, _jitl.nextarg_getfp = _jitl.nextarg_geti = 0, _jitl.alloca_offset = 0, \ - PUSHQr(_EBX), PUSHQr(_R12), PUSHQr(_R13), PUSHQr(_R14), PUSHQr(_EBP), MOVQrr(_ESP, _EBP)) - -#define jit_calli(sub) (MOVQir((long) (sub), JIT_REXTMP), CALLsr(JIT_REXTMP)) -#define jit_callr(reg) CALLsr((reg)) - -#define jit_prepare_i(ni) (_jitl.nextarg_puti = (ni), \ - _jitl.argssize = _jitl.nextarg_puti > JIT_ARG_MAX \ - ? _jitl.nextarg_puti - JIT_ARG_MAX : 0) -#define jit_pusharg_i(rs) (--_jitl.nextarg_puti >= JIT_ARG_MAX \ - ? PUSHQr(rs) : MOVQrr(rs, jit_arg_reg_order[_jitl.nextarg_puti])) - -#define jit_finish(sub) (_jitl.fprssize \ - ? (MOVBir(_jitl.fprssize, _AL), _jitl.fprssize = 0) \ - : MOVBir(0, _AL), \ - ((_jitl.argssize & 1) \ - ? (PUSHQr(_EAX), ++_jitl.argssize) : 0), \ - jit_calli(sub), \ - (_jitl.argssize \ - ? (ADDQir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0) \ - : 0)) -#define jit_reg_is_arg(reg) ((reg) == _ECX || (reg) == _EDX) - -#define jit_finishr(reg) (_jitl.fprssize \ - ? (MOVBir(_jitl.fprssize, _AL), _jitl.fprssize = 0) \ - : MOVBir(0, _AL), \ - ((_jitl.argssize & 1) \ - ? (PUSHQr(_EAX), ++_jitl.argssize) : 0), \ - (jit_reg_is_arg((reg)) \ - ? (MOVQrr(reg, JIT_REXTMP), \ - jit_callr(JIT_REXTMP)) \ - : jit_callr(reg)), \ - (_jitl.argssize \ - ? (ADDQir(sizeof(long) * _jitl.argssize, JIT_SP), _jitl.argssize = 0) \ - : 0)) - -#define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX)) -#define jit_arg_i() (_jitl.nextarg_geti < JIT_ARG_MAX \ - ? _jitl.nextarg_geti++ \ - : ((_jitl.framesize += sizeof(long)) - sizeof(long))) -#define jit_arg_c() jit_arg_i() -#define jit_arg_uc() jit_arg_i() -#define jit_arg_s() jit_arg_i() -#define jit_arg_us() jit_arg_i() -#define jit_arg_ui() jit_arg_i() -#define jit_arg_l() jit_arg_i() -#define jit_arg_ul() jit_arg_i() -#define jit_arg_p() jit_arg_i() - -#define jit_getarg_c(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_extr_c_l((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_c((reg), JIT_FP, (ofs))) -#define jit_getarg_uc(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_extr_uc_ul((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_uc((reg), JIT_FP, (ofs))) -#define jit_getarg_s(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_extr_s_l((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_s((reg), JIT_FP, (ofs))) -#define jit_getarg_us(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_extr_us_ul((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_us((reg), JIT_FP, (ofs))) -#define jit_getarg_i(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_movr_l((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_i((reg), JIT_FP, (ofs))) -#define jit_getarg_ui(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_movr_ul((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_ui((reg), JIT_FP, (ofs))) -#define jit_getarg_l(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_movr_l((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_l((reg), JIT_FP, (ofs))) -#define jit_getarg_ul(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_movr_ul((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_ul((reg), JIT_FP, ofs)) -#define jit_getarg_p(reg, ofs) ((ofs) < JIT_ARG_MAX \ - ? jit_movr_p((reg), jit_arg_reg_order[(ofs)]) \ - : jit_ldxi_p((reg), JIT_FP, (ofs))) - -static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX, _R8D, _R9D }; - -#define jit_negr_l(d, rs) jit_opi_((d), (rs), NEGQr(d), (XORQrr((d), (d)), SUBQrr((rs), (d))) ) -#define jit_movr_l(d, rs) ((void)((rs) == (d) ? 0 : MOVQrr((rs), (d)))) -#define jit_movi_p(d, is) (MOVQir(((long)(is)), (d)), _jit.x.pc) -#define jit_movi_l(d, is) \ - /* Value is not zero? */ \ - ((is) \ - /* Yes. Value is unsigned and fits in signed 32 bits? */ \ - ? (_uiP(31, is) \ - /* Yes. Use 32 bits opcode */ \ - ? MOVLir(is, (d)) \ - /* No. Use 64 bits opcode */ \ - : MOVQir(is, (d))) \ - /* No. Set register to zero. */ \ - : XORQrr ((d), (d))) - -#define jit_bmsr_l(label, s1, s2) (TESTQrr((s1), (s2)), JNZm(label), _jit.x.pc) -#define jit_bmcr_l(label, s1, s2) (TESTQrr((s1), (s2)), JZm(label), _jit.x.pc) -#define jit_boaddr_l(label, s1, s2) (ADDQrr((s2), (s1)), JOm(label), _jit.x.pc) -#define jit_bosubr_l(label, s1, s2) (SUBQrr((s2), (s1)), JOm(label), _jit.x.pc) -#define jit_boaddr_ul(label, s1, s2) (ADDQrr((s2), (s1)), JCm(label), _jit.x.pc) -#define jit_bosubr_ul(label, s1, s2) (SUBQrr((s2), (s1)), JCm(label), _jit.x.pc) - -#define jit_boaddi_l(label, rs, is) (ADDQir((is), (rs)), JOm(label), _jit.x.pc) -#define jit_bosubi_l(label, rs, is) (SUBQir((is), (rs)), JOm(label), _jit.x.pc) -#define jit_boaddi_ul(label, rs, is) (ADDQir((is), (rs)), JCm(label), _jit.x.pc) -#define jit_bosubi_ul(label, rs, is) (SUBQir((is), (rs)), JCm(label), _jit.x.pc) - -#define jit_patch_long_at(jump_pc,v) (*_PSL((jump_pc) - sizeof(long)) = _jit_SL((jit_insn *)(v))) -#define jit_patch_short_at(jump_pc,v) (*_PSI((jump_pc) - sizeof(int)) = _jit_SI((jit_insn *)(v) - (jump_pc))) -#define jit_patch_at(jump_pc,v) (_jitl.long_jumps ? jit_patch_long_at((jump_pc)-3, v) : jit_patch_short_at(jump_pc, v)) -#define jit_ret() (LEAVE_(), POPQr(_R14), POPQr(_R13), POPQr(_R12), POPQr(_EBX), RET_()) - -/* Memory */ - -/* Used to implement ldc, stc, ... We have SIL and friends which simplify it all. */ -#define jit_movbrm(rs, dd, db, di, ds) MOVBrm(jit_reg8(rs), dd, db, di, ds) - -#define jit_ldr_c(d, rs) MOVSBQmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_c(d, s1, s2) MOVSBQmr(0, (s1), (s2), 1, (d)) - -#define jit_ldr_s(d, rs) MOVSWQmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_s(d, s1, s2) MOVSWQmr(0, (s1), (s2), 1, (d)) - -#define jit_ldi_c(d, is) (_u32P((long)(is)) ? MOVSBQmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_c(d, JIT_REXTMP))) -#define jit_ldxi_c(d, rs, is) (_u32P((long)(is)) ? MOVSBQmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_c(d, rs, JIT_REXTMP))) - -#define jit_ldi_uc(d, is) (_u32P((long)(is)) ? MOVZBLmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_uc(d, JIT_REXTMP))) -#define jit_ldxi_uc(d, rs, is) (_u32P((long)(is)) ? MOVZBLmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_uc(d, rs, JIT_REXTMP))) - -#define jit_sti_c(id, rs) (_u32P((long)(id)) ? MOVBrm(jit_reg8(rs), (id), 0, 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_str_c(JIT_REXTMP, rs))) -#define jit_stxi_c(id, rd, rs) (_u32P((long)(id)) ? MOVBrm(jit_reg8(rs), (id), (rd), 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_stxr_c(JIT_REXTMP, rd, rs))) - -#define jit_ldi_s(d, is) (_u32P((long)(is)) ? MOVSWQmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_s(d, JIT_REXTMP))) -#define jit_ldxi_s(d, rs, is) (_u32P((long)(is)) ? MOVSWQmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_s(d, rs, JIT_REXTMP))) - -#define jit_ldi_us(d, is) (_u32P((long)(is)) ? MOVZWLmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_us(d, JIT_REXTMP))) -#define jit_ldxi_us(d, rs, is) (_u32P((long)(is)) ? MOVZWLmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_us(d, rs, JIT_REXTMP))) - -#define jit_sti_s(id, rs) (_u32P((long)(id)) ? MOVWrm(jit_reg16(rs), (id), 0, 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_str_s(JIT_REXTMP, rs))) -#define jit_stxi_s(id, rd, rs) (_u32P((long)(id)) ? MOVWrm(jit_reg16(rs), (id), (rd), 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_stxr_s(JIT_REXTMP, rd, rs))) - -#define jit_ldi_ui(d, is) (_u32P((long)(is)) ? MOVLmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_ui(d, JIT_REXTMP))) -#define jit_ldxi_ui(d, rs, is) (_u32P((long)(is)) ? MOVLmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_ui(d, rs, JIT_REXTMP))) - -#define jit_ldi_i(d, is) (_u32P((long)(is)) ? MOVSLQmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_i(d, JIT_REXTMP))) -#define jit_ldxi_i(d, rs, is) (_u32P((long)(is)) ? MOVSLQmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_i(d, rs, JIT_REXTMP))) - -#define jit_sti_i(id, rs) (_u32P((long)(id)) ? MOVLrm((rs), (id), 0, 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_str_i(JIT_REXTMP, rs))) -#define jit_stxi_i(id, rd, rs) (_u32P((long)(id)) ? MOVLrm((rs), (id), (rd), 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_stxr_i(JIT_REXTMP, rd, rs))) - -#define jit_ldi_l(d, is) (_u32P((long)(is)) ? MOVQmr((is), 0, 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_l(d, JIT_REXTMP))) -#define jit_ldxi_l(d, rs, is) (_u32P((long)(is)) ? MOVQmr((is), (rs), 0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldxr_l(d, rs, JIT_REXTMP))) - -#define jit_sti_l(id, rs) (_u32P((long)(id)) ? MOVQrm((rs), (id), 0, 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_str_l(JIT_REXTMP, rs))) -#define jit_stxi_l(id, rd, rs) (_u32P((long)(id)) ? MOVQrm((rs), (id), (rd), 0, 0) : (jit_movi_l(JIT_REXTMP, id), jit_stxr_l(JIT_REXTMP, rd, rs))) - -#define jit_ldr_ui(d, rs) MOVLmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_ui(d, s1, s2) MOVLmr(0, (s1), (s2), 1, (d)) - -#define jit_ldr_i(d, rs) MOVSLQmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_i(d, s1, s2) MOVSLQmr(0, (s1), (s2), 1, (d)) - -#define jit_ldr_l(d, rs) MOVQmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_l(d, s1, s2) MOVQmr(0, (s1), (s2), 1, (d)) - -#define jit_str_l(rd, rs) MOVQrm((rs), 0, (rd), 0, 0) -#define jit_stxr_l(d1, d2, rs) MOVQrm((rs), 0, (d1), (d2), 1) - -#define jit_blti_l(label, rs, is) jit_bra_l0((rs), (is), JLm(label), JSm(label) ) -#define jit_blei_l(label, rs, is) jit_bra_l ((rs), (is), JLEm(label) ) -#define jit_bgti_l(label, rs, is) jit_bra_l ((rs), (is), JGm(label) ) -#define jit_bgei_l(label, rs, is) jit_bra_l0((rs), (is), JGEm(label), JNSm(label) ) -#define jit_beqi_l(label, rs, is) jit_bra_l0((rs), (is), JEm(label), JEm(label) ) -#define jit_bnei_l(label, rs, is) jit_bra_l0((rs), (is), JNEm(label), JNEm(label) ) -#define jit_blti_ul(label, rs, is) jit_bra_l ((rs), (is), JBm(label) ) -#define jit_blei_ul(label, rs, is) jit_bra_l0((rs), (is), JBEm(label), JEm(label) ) -#define jit_bgti_ul(label, rs, is) jit_bra_l0((rs), (is), JAm(label), JNEm(label) ) -#define jit_bgei_ul(label, rs, is) jit_bra_l ((rs), (is), JAEm(label) ) -#define jit_bmsi_l(label, rs, is) (jit_reduceQ(TEST, (is), (rs)), JNZm(label), _jit.x.pc) -#define jit_bmci_l(label, rs, is) (jit_reduceQ(TEST, (is), (rs)), JZm(label), _jit.x.pc) - -#define jit_pushr_l(rs) jit_pushr_i(rs) -#define jit_popr_l(rs) jit_popr_i(rs) - -#define jit_pusharg_l(rs) jit_pusharg_i(rs) -#define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX)) -#define jit_bltr_l(label, s1, s2) jit_bra_qr((s1), (s2), JLm(label) ) -#define jit_bler_l(label, s1, s2) jit_bra_qr((s1), (s2), JLEm(label) ) -#define jit_bgtr_l(label, s1, s2) jit_bra_qr((s1), (s2), JGm(label) ) -#define jit_bger_l(label, s1, s2) jit_bra_qr((s1), (s2), JGEm(label) ) -#define jit_beqr_l(label, s1, s2) jit_bra_qr((s1), (s2), JEm(label) ) -#define jit_bner_l(label, s1, s2) jit_bra_qr((s1), (s2), JNEm(label) ) -#define jit_bltr_ul(label, s1, s2) jit_bra_qr((s1), (s2), JBm(label) ) -#define jit_bler_ul(label, s1, s2) jit_bra_qr((s1), (s2), JBEm(label) ) -#define jit_bgtr_ul(label, s1, s2) jit_bra_qr((s1), (s2), JAm(label) ) -#define jit_bger_ul(label, s1, s2) jit_bra_qr((s1), (s2), JAEm(label) ) - -/* Bool operations. */ -#define jit_bool_qr(d, s1, s2, op) \ - (jit_replace8(d, CMPQrr(s2, s1), op)) - -#define jit_bool_qi(d, rs, is, op) \ - (jit_replace8(d, CMPQir(is, rs), op)) - -/* When CMP with 0 can be replaced with TEST */ -#define jit_bool_qi0(d, rs, is, op, op0) \ - ((is) != 0 \ - ? (jit_replace8(d, CMPQir(is, rs), op)) \ - : (jit_replace8(d, TESTQrr(rs, rs), op0))) - -#define jit_ltr_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETLr ) -#define jit_ler_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETLEr ) -#define jit_gtr_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETGr ) -#define jit_ger_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETGEr ) -#define jit_eqr_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETEr ) -#define jit_ner_l(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETNEr ) -#define jit_ltr_ul(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETBr ) -#define jit_ler_ul(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETBEr ) -#define jit_gtr_ul(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETAr ) -#define jit_ger_ul(d, s1, s2) jit_bool_qr((d), (s1), (s2), SETAEr ) - -#define jit_lti_l(d, rs, is) jit_bool_qi0((d), (rs), (is), SETLr, SETSr ) -#define jit_lei_l(d, rs, is) jit_bool_qi ((d), (rs), (is), SETLEr ) -#define jit_gti_l(d, rs, is) jit_bool_qi ((d), (rs), (is), SETGr ) -#define jit_gei_l(d, rs, is) jit_bool_qi0((d), (rs), (is), SETGEr, SETNSr ) -#define jit_eqi_l(d, rs, is) jit_bool_qi0((d), (rs), (is), SETEr, SETEr ) -#define jit_nei_l(d, rs, is) jit_bool_qi0((d), (rs), (is), SETNEr, SETNEr ) -#define jit_lti_ul(d, rs, is) jit_bool_qi ((d), (rs), (is), SETBr ) -#define jit_lei_ul(d, rs, is) jit_bool_qi0((d), (rs), (is), SETBEr, SETEr ) -#define jit_gti_ul(d, rs, is) jit_bool_qi0((d), (rs), (is), SETAr, SETNEr ) -#define jit_gei_ul(d, rs, is) jit_bool_qi0((d), (rs), (is), SETAEr, INCLr ) - -/* Multiplication/division. */ -#define jit_mulr_ul_(s1, s2) \ - jit_qopr_(_RAX, s1, s2, MULQr(s1), MULQr(s2)) - -#define jit_mulr_l_(s1, s2) \ - jit_qopr_(_RAX, s1, s2, IMULQr(s1), IMULQr(s2)) - -#define jit_muli_l_(is, rs) \ - (MOVQir(is, rs == _RAX ? _RDX : _RAX), \ - IMULQr(rs == _RAX ? _RDX : rs)) - -#define jit_muli_ul_(is, rs) \ - (MOVQir(is, rs == _RAX ? _RDX : _RAX), \ - IMULQr(rs == _RAX ? _RDX : rs)) - -#define jit_divi_l_(result, d, rs, is) \ - (jit_might (d, _RAX, jit_pushr_l(_RAX)), \ - jit_might (d, _RCX, jit_pushr_l(_RCX)), \ - jit_might (d, _RDX, jit_pushr_l(_RDX)), \ - jit_might (rs, _RAX, MOVQrr(rs, _RAX)), \ - jit_might (rs, _RDX, MOVQrr(rs, _RDX)), \ - MOVQir(is, _RCX), \ - SARQir(63, _RDX), \ - IDIVQr(_RCX), \ - jit_might(d, result, MOVQrr(result, d)), \ - jit_might(d, _RDX, jit_popr_l(_RDX)), \ - jit_might(d, _RCX, jit_popr_l(_RCX)), \ - jit_might(d, _RAX, jit_popr_l(_RAX))) - -#define jit_divr_l_(result, d, s1, s2) \ - (jit_might (d, _RAX, jit_pushr_l(_RAX)), \ - jit_might (d, _RCX, jit_pushr_l(_RCX)), \ - jit_might (d, _RDX, jit_pushr_l(_RDX)), \ - ((s1 == _RCX) ? jit_pushr_l(_RCX) : 0), \ - jit_might (s2, _RCX, MOVQrr(s2, _RCX)), \ - ((s1 == _RCX) ? jit_popr_l(_RDX) : \ - jit_might (s1, _RDX, MOVQrr(s1, _RDX))), \ - MOVQrr(_RDX, _RAX), \ - SARQir(63, _RDX), \ - IDIVQr(_RCX), \ - jit_might(d, result, MOVQrr(result, d)), \ - jit_might(d, _RDX, jit_popr_l(_RDX)), \ - jit_might(d, _RCX, jit_popr_l(_RCX)), \ - jit_might(d, _RAX, jit_popr_l(_RAX))) - -#define jit_divi_ul_(result, d, rs, is) \ - (jit_might (d, _RAX, jit_pushr_l(_RAX)), \ - jit_might (d, _RCX, jit_pushr_l(_RCX)), \ - jit_might (d, _RDX, jit_pushr_l(_RDX)), \ - jit_might (rs, _RAX, MOVQrr(rs, _RAX)), \ - MOVQir(is, _RCX), \ - XORQrr(_RDX, _RDX), \ - DIVQr(_RCX), \ - jit_might(d, result, MOVQrr(result, d)), \ - jit_might(d, _RDX, jit_popr_l(_RDX)), \ - jit_might(d, _RCX, jit_popr_l(_RCX)), \ - jit_might(d, _RAX, jit_popr_l(_RAX))) - -#define jit_divr_ul_(result, d, s1, s2) \ - (jit_might (d, _RAX, jit_pushr_l(_RAX)), \ - jit_might (d, _RCX, jit_pushr_l(_RCX)), \ - jit_might (d, _RDX, jit_pushr_l(_RDX)), \ - ((s1 == _RCX) ? jit_pushr_l(_RCX) : 0), \ - jit_might (s2, _RCX, MOVQrr(s2, _RCX)), \ - ((s1 == _RCX) ? jit_popr_l(_RAX) : \ - jit_might (s1, _RAX, MOVQrr(s1, _RAX))), \ - XORQrr(_RDX, _RDX), \ - DIVQr(_RCX), \ - jit_might(d, result, MOVQrr(result, d)), \ - jit_might(d, _RDX, jit_popr_l(_RDX)), \ - jit_might(d, _RCX, jit_popr_l(_RCX)), \ - jit_might(d, _RAX, jit_popr_l(_RAX))) - -#define jit_muli_l(d, rs, is) jit_qop_ ((d), (rs), (is), IMULQir((is), (d)), IMULQrr(JIT_REXTMP, (d)) ) -#define jit_mulr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), IMULQrr((s1), (d)), IMULQrr((s2), (d)) ) - -/* As far as low bits are concerned, signed and unsigned multiplies are - exactly the same. */ -#define jit_muli_ul(d, rs, is) jit_qop_ ((d), (rs), (is), IMULQir((is), (d)), IMULQrr(JIT_REXTMP, (d)) ) -#define jit_mulr_ul(d, s1, s2) jit_qopr_((d), (s1), (s2), IMULQrr((s1), (d)), IMULQrr((s2), (d)) ) - -#define jit_hmuli_l(d, rs, is) \ - ((d) == _RDX ? ( jit_pushr_l(_RAX), jit_muli_l_((is), (rs)), jit_popr_l(_RAX) ) : \ - ((d) == _RAX ? (jit_pushr_l(_RDX), jit_muli_l_((is), (rs)), MOVQrr(_RDX, _RAX), jit_popr_l(_RDX) ) : \ - (jit_pushr_l(_RDX), jit_pushr_l(_RAX), jit_muli_l_((is), (rs)), MOVQrr(_RDX, (d)), jit_popr_l(_RAX), jit_popr_l(_RDX) ))) - -#define jit_hmulr_l(d, s1, s2) \ - ((d) == _RDX ? ( jit_pushr_l(_RAX), jit_mulr_l_((s1), (s2)), jit_popr_l(_RAX) ) : \ - ((d) == _RAX ? (jit_pushr_l(_RDX), jit_mulr_l_((s1), (s2)), MOVQrr(_RDX, _RAX), jit_popr_l(_RDX) ) : \ - (jit_pushr_l(_RDX), jit_pushr_l(_RAX), jit_mulr_l_((s1), (s2)), MOVQrr(_RDX, (d)), jit_popr_l(_RAX), jit_popr_l(_RDX) ))) - -#define jit_hmuli_ul(d, rs, is) \ - ((d) == _RDX ? ( jit_pushr_l(_RAX), jit_muli_ul_((is), (rs)), jit_popr_l(_RAX) ) : \ - ((d) == _RAX ? (jit_pushr_l(_RDX), jit_muli_ul_((is), (rs)), MOVQrr(_RDX, _RAX), jit_popr_l(_RDX) ) : \ - (jit_pushr_l(_RDX), jit_pushr_l(_RAX), jit_muli_ul_((is), (rs)), MOVQrr(_RDX, (d)), jit_popr_l(_RAX), jit_popr_l(_RDX) ))) - -#define jit_hmulr_ul(d, s1, s2) \ - ((d) == _RDX ? ( jit_pushr_l(_RAX), jit_mulr_ul_((s1), (s2)), jit_popr_l(_RAX) ) : \ - ((d) == _RAX ? (jit_pushr_l(_RDX), jit_mulr_ul_((s1), (s2)), MOVQrr(_RDX, _RAX), jit_popr_l(_RDX) ) : \ - (jit_pushr_l(_RDX), jit_pushr_l(_RAX), jit_mulr_ul_((s1), (s2)), MOVQrr(_RDX, (d)), jit_popr_l(_RAX), jit_popr_l(_RDX) ))) - -#define jit_divi_l(d, rs, is) jit_divi_l_(_RAX, (d), (rs), (is)) -#define jit_divi_ul(d, rs, is) jit_divi_ul_(_RAX, (d), (rs), (is)) -#define jit_modi_l(d, rs, is) jit_divi_l_(_RDX, (d), (rs), (is)) -#define jit_modi_ul(d, rs, is) jit_divi_ul_(_RDX, (d), (rs), (is)) -#define jit_divr_l(d, s1, s2) jit_divr_l_(_RAX, (d), (s1), (s2)) -#define jit_divr_ul(d, s1, s2) jit_divr_ul_(_RAX, (d), (s1), (s2)) -#define jit_modr_l(d, s1, s2) jit_divr_l_(_RDX, (d), (s1), (s2)) -#define jit_modr_ul(d, s1, s2) jit_divr_ul_(_RDX, (d), (s1), (s2)) - -#endif /* __lightning_core_h */ - diff --git a/lightning/i386/core.h b/lightning/i386/core.h deleted file mode 100644 index df42caf67..000000000 --- a/lightning/i386/core.h +++ /dev/null @@ -1,365 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer (i386 version) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini and Matthew Flatt. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_core_i386_h -#define __lightning_core_i386_h - -#define JIT_FP _EBP -#define JIT_SP _ESP -#define JIT_RET _EAX - - -/* 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) - -/* For LT, LE, ... */ -#define jit_replace8(d, cmp, op) \ - (jit_check8(d) \ - ? ((cmp), \ - MOVLir(0, (d)), \ - op(_rR(d) | _AL)) \ - : (jit_pushr_i(_EAX), (cmp), \ - MOVLir(0, _EAX), \ - op(_AL), MOVLrr(_EAX, (d)), jit_popr_i(_EAX))) - -#define jit_bool_r(d, s1, s2, op) \ - (jit_replace8(d, CMPLrr(s2, s1), op)) - -#define jit_bool_i(d, rs, is, op) \ - (jit_replace8(d, CMPLir(is, rs), op)) - -/* When CMP with 0 can be replaced with TEST */ -#define jit_bool_i0(d, rs, is, op, op0) \ - ((is) != 0 \ - ? (jit_replace8(d, CMPLir(is, rs), op)) \ - : (jit_replace8(d, TESTLrr(rs, rs), op0))) - -/* For BLT, BLE, ... */ -#define jit_bra_r(s1, s2, op) (CMPLrr(s2, s1), op, _jit.x.pc) -#define jit_bra_i(rs, is, op) (CMPLir(is, rs), op, _jit.x.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.x.pc) : (CMPLir(is, rs), op, _jit.x.pc)) - -/* 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_CAN_16 ? 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) ? 0 : 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, jit_pushr_i(_EAX)), \ - jit_might (d, _ECX, jit_pushr_i(_ECX)), \ - jit_might (d, _EDX, jit_pushr_i(_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, jit_popr_i(_EDX)), \ - jit_might(d, _ECX, jit_popr_i(_ECX)), \ - jit_might(d, _EAX, jit_popr_i(_EAX))) - -#define jit_divr_i_(result, d, s1, s2) \ - (jit_might (d, _EAX, jit_pushr_i(_EAX)), \ - jit_might (d, _ECX, jit_pushr_i(_ECX)), \ - jit_might (d, _EDX, jit_pushr_i(_EDX)), \ - ((s1 == _ECX) ? jit_pushr_i(_ECX) : 0), \ - jit_might (s2, _ECX, MOVLrr(s2, _ECX)), \ - ((s1 == _ECX) ? jit_popr_i(_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, jit_popr_i(_EDX)), \ - jit_might(d, _ECX, jit_popr_i(_ECX)), \ - jit_might(d, _EAX, jit_popr_i(_EAX))) - -#define jit_divi_ui_(result, d, rs, is) \ - (jit_might (d, _EAX, jit_pushr_i(_EAX)), \ - jit_might (d, _ECX, jit_pushr_i(_ECX)), \ - jit_might (d, _EDX, jit_pushr_i(_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, jit_popr_i(_EDX)), \ - jit_might(d, _ECX, jit_popr_i(_ECX)), \ - jit_might(d, _EAX, jit_popr_i(_EAX))) - -#define jit_divr_ui_(result, d, s1, s2) \ - (jit_might (d, _EAX, jit_pushr_i(_EAX)), \ - jit_might (d, _ECX, jit_pushr_i(_ECX)), \ - jit_might (d, _EDX, jit_pushr_i(_EDX)), \ - ((s1 == _ECX) ? jit_pushr_i(_ECX) : 0), \ - jit_might (s2, _ECX, MOVLrr(s2, _ECX)), \ - ((s1 == _ECX) ? jit_popr_i(_EAX) : \ - jit_might (s1, _EAX, MOVLrr(s1, _EAX))), \ - XORLrr(_EDX, _EDX), \ - DIVLr(_ECX), \ - jit_might(d, result, MOVLrr(result, d)), \ - jit_might(d, _EDX, jit_popr_i(_EDX)), \ - jit_might(d, _ECX, jit_popr_i(_ECX)), \ - jit_might(d, _EAX, jit_popr_i(_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)) ) - -/* As far as low bits are concerned, signed and unsigned multiplies are - exactly the same. */ -#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)) ) - -#define jit_hmuli_i(d, rs, is) \ - ((d) == _EDX ? ( jit_pushr_i(_EAX), jit_muli_i_((is), (rs)), jit_popr_i(_EAX) ) : \ - ((d) == _EAX ? (jit_pushr_i(_EDX), jit_muli_i_((is), (rs)), MOVLrr(_EDX, _EAX), jit_popr_i(_EDX) ) : \ - (jit_pushr_i(_EDX), jit_pushr_i(_EAX), jit_muli_i_((is), (rs)), MOVLrr(_EDX, (d)), jit_popr_i(_EAX), jit_popr_i(_EDX) ))) - -#define jit_hmulr_i(d, s1, s2) \ - ((d) == _EDX ? ( jit_pushr_i(_EAX), jit_mulr_i_((s1), (s2)), jit_popr_i(_EAX) ) : \ - ((d) == _EAX ? (jit_pushr_i(_EDX), jit_mulr_i_((s1), (s2)), MOVLrr(_EDX, _EAX), jit_popr_i(_EDX) ) : \ - (jit_pushr_i(_EDX), jit_pushr_i(_EAX), jit_mulr_i_((s1), (s2)), MOVLrr(_EDX, (d)), jit_popr_i(_EAX), jit_popr_i(_EDX) ))) - -#define jit_hmuli_ui(d, rs, is) \ - ((d) == _EDX ? ( jit_pushr_i(_EAX), jit_muli_ui_((is), (rs)), jit_popr_i(_EAX) ) : \ - ((d) == _EAX ? (jit_pushr_i(_EDX), jit_muli_ui_((is), (rs)), MOVLrr(_EDX, _EAX), jit_popr_i(_EDX) ) : \ - (jit_pushr_i(_EDX), jit_pushr_i(_EAX), jit_muli_ui_((is), (rs)), MOVLrr(_EDX, (d)), jit_popr_i(_EAX), jit_popr_i(_EDX) ))) - -#define jit_hmulr_ui(d, s1, s2) \ - ((d) == _EDX ? ( jit_pushr_i(_EAX), jit_mulr_ui_((s1), (s2)), jit_popr_i(_EAX) ) : \ - ((d) == _EAX ? (jit_pushr_i(_EDX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EDX, _EAX), jit_popr_i(_EDX) ) : \ - (jit_pushr_i(_EDX), jit_pushr_i(_EAX), jit_mulr_ui_((s1), (s2)), MOVLrr(_EDX, (d)), jit_popr_i(_EAX), jit_popr_i(_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_shift(d, s1, s2, m) \ - ((d) == _ECX || (d) == (s2) \ - ? ((s2) == _EAX \ - ? jit_fixd(d, _EDX, jit_shift2(_EDX, s1, s2, m)) \ - : jit_fixd(d, _EAX, jit_shift2(_EAX, s1, s2, m))) \ - : jit_shift2(d, s1, s2, m)) - -/* Shift operation, assuming d != s2 or ECX */ -#define jit_shift2(d, s1, s2, m) \ - jit_op_(d, s1, jit_cfixs(s2, _ECX, m(_CL, d))) - -/* Substitute x for destination register d */ -#define jit_fixd(d, x, op) \ - (jit_pushr_i(x), op, jit_movr_i(d, x), jit_popr_i(x)) - -/* Conditionally substitute y for source register s */ -#define jit_cfixs(s, y, op) \ - ((s) == (y) ? op : \ - (jit_pushr_i(y), jit_movr_i(y, s), op, jit_popr_i(y))) - -#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_shift((d), (r1), (r2), SHLLrr) -#define jit_rshr_i(d, r1, r2) jit_shift((d), (r1), (r2), SARLrr) -#define jit_rshr_ui(d, r1, r2) jit_shift((d), (r1), (r2), SHRLrr) - -/* Stack */ -#define jit_retval_i(rd) ((void)jit_movr_i ((rd), _EAX)) - -/* Unary */ -#define jit_negr_i(d, rs) jit_opi_((d), (rs), NEGLr(d), (XORLrr((d), (d)), SUBLrr((rs), (d))) ) - -#define jit_movr_i(d, rs) ((void)((rs) == (d) ? 0 : MOVLrr((rs), (d)))) -#define jit_movi_i(d, is) ((is) ? MOVLir((is), (d)) : XORLrr ((d), (d)) ) -#define jit_patch_movi(pa,pv) (*_PSL((pa) - sizeof(long)) = _jit_SL((pv))) - -#define jit_ntoh_ui(d, rs) jit_op_((d), (rs), BSWAPLr(d)) -#define jit_ntoh_us(d, rs) jit_op_((d), (rs), RORWir(8, d)) - -/* Boolean */ -#define jit_ltr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETLr ) -#define jit_ler_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETLEr ) -#define jit_gtr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETGr ) -#define jit_ger_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETGEr ) -#define jit_eqr_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETEr ) -#define jit_ner_i(d, s1, s2) jit_bool_r((d), (s1), (s2), SETNEr ) -#define jit_ltr_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETBr ) -#define jit_ler_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETBEr ) -#define jit_gtr_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETAr ) -#define jit_ger_ui(d, s1, s2) jit_bool_r((d), (s1), (s2), SETAEr ) - -#define jit_lti_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETLr, SETSr ) -#define jit_lei_i(d, rs, is) jit_bool_i ((d), (rs), (is), SETLEr ) -#define jit_gti_i(d, rs, is) jit_bool_i ((d), (rs), (is), SETGr ) -#define jit_gei_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETGEr, SETNSr ) -#define jit_eqi_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETEr, SETEr ) -#define jit_nei_i(d, rs, is) jit_bool_i0((d), (rs), (is), SETNEr, SETNEr ) -#define jit_lti_ui(d, rs, is) jit_bool_i ((d), (rs), (is), SETBr ) -#define jit_lei_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETBEr, SETEr ) -#define jit_gti_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETAr, SETNEr ) -#define jit_gei_ui(d, rs, is) jit_bool_i0((d), (rs), (is), SETAEr, INCLr ) - -/* Jump */ -#define jit_bltr_i(label, s1, s2) jit_bra_r((s1), (s2), JLm(label) ) -#define jit_bler_i(label, s1, s2) jit_bra_r((s1), (s2), JLEm(label) ) -#define jit_bgtr_i(label, s1, s2) jit_bra_r((s1), (s2), JGm(label) ) -#define jit_bger_i(label, s1, s2) jit_bra_r((s1), (s2), JGEm(label) ) -#define jit_beqr_i(label, s1, s2) jit_bra_r((s1), (s2), JEm(label) ) -#define jit_bner_i(label, s1, s2) jit_bra_r((s1), (s2), JNEm(label) ) -#define jit_bltr_ui(label, s1, s2) jit_bra_r((s1), (s2), JBm(label) ) -#define jit_bler_ui(label, s1, s2) jit_bra_r((s1), (s2), JBEm(label) ) -#define jit_bgtr_ui(label, s1, s2) jit_bra_r((s1), (s2), JAm(label) ) -#define jit_bger_ui(label, s1, s2) jit_bra_r((s1), (s2), JAEm(label) ) -#define jit_bmsr_i(label, s1, s2) (TESTLrr((s1), (s2)), JNZm(label), _jit.x.pc) -#define jit_bmcr_i(label, s1, s2) (TESTLrr((s1), (s2)), JZm(label), _jit.x.pc) -#define jit_boaddr_i(label, s1, s2) (ADDLrr((s2), (s1)), JOm(label), _jit.x.pc) -#define jit_bosubr_i(label, s1, s2) (SUBLrr((s2), (s1)), JOm(label), _jit.x.pc) -#define jit_boaddr_ui(label, s1, s2) (ADDLrr((s2), (s1)), JCm(label), _jit.x.pc) -#define jit_bosubr_ui(label, s1, s2) (SUBLrr((s2), (s1)), JCm(label), _jit.x.pc) - -#define jit_blti_i(label, rs, is) jit_bra_i0((rs), (is), JLm(label), JSm(label) ) -#define jit_blei_i(label, rs, is) jit_bra_i ((rs), (is), JLEm(label) ) -#define jit_bgti_i(label, rs, is) jit_bra_i ((rs), (is), JGm(label) ) -#define jit_bgei_i(label, rs, is) jit_bra_i0((rs), (is), JGEm(label), JNSm(label) ) -#define jit_beqi_i(label, rs, is) jit_bra_i0((rs), (is), JEm(label), JEm(label) ) -#define jit_bnei_i(label, rs, is) jit_bra_i0((rs), (is), JNEm(label), JNEm(label) ) -#define jit_blti_ui(label, rs, is) jit_bra_i ((rs), (is), JBm(label) ) -#define jit_blei_ui(label, rs, is) jit_bra_i0((rs), (is), JBEm(label), JEm(label) ) -#define jit_bgti_ui(label, rs, is) jit_bra_i0((rs), (is), JAm(label), JNEm(label) ) -#define jit_bgei_ui(label, rs, is) jit_bra_i ((rs), (is), JAEm(label) ) -#define jit_boaddi_i(label, rs, is) (ADDLir((is), (rs)), JOm(label), _jit.x.pc) -#define jit_bosubi_i(label, rs, is) (SUBLir((is), (rs)), JOm(label), _jit.x.pc) -#define jit_boaddi_ui(label, rs, is) (ADDLir((is), (rs)), JCm(label), _jit.x.pc) -#define jit_bosubi_ui(label, rs, is) (SUBLir((is), (rs)), JCm(label), _jit.x.pc) - -#define jit_bmsi_i(label, rs, is) (jit_reduce(TEST, (is), (rs)), JNZm(label), _jit.x.pc) -#define jit_bmci_i(label, rs, is) (jit_reduce(TEST, (is), (rs)), JZm(label), _jit.x.pc) - -#define jit_jmpi(label) (JMPm( ((unsigned long) (label))), _jit.x.pc) -#define jit_jmpr(reg) JMPsr(reg) - -/* Memory */ -#define jit_ldr_uc(d, rs) MOVZBLmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_uc(d, s1, s2) MOVZBLmr(0, (s1), (s2), 1, (d)) - -#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_ldr_us(d, rs) MOVZWLmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_us(d, s1, s2) MOVZWLmr(0, (s1), (s2), 1, (d)) - -#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_str_i(rd, rs) MOVLrm((rs), 0, (rd), 0, 0) -#define jit_stxr_i(d1, d2, rs) MOVLrm((rs), 0, (d1), (d2), 1) - -/* Extra */ -#define jit_nop() NOP_() - -#define _jit_alignment(pc, n) (((pc ^ _MASK(4)) + 1) & _MASK(n)) -#define jit_align(n) NOPi(_jit_alignment(_jit_UL(_jit.x.pc), (n))) - - -#if defined (__x86_64__) -#include "core-64.h" -#else -#include "core-32.h" -#endif - -#endif /* __lightning_core_i386_h */ - diff --git a/lightning/i386/fp-32.h b/lightning/i386/fp-32.h deleted file mode 100644 index 009afc649..000000000 --- a/lightning/i386/fp-32.h +++ /dev/null @@ -1,356 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Support macros for the i386 math coprocessor - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2004, 2008 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - -#ifndef __lightning_fp_h -#define __lightning_fp_h - -/* We really must map the x87 stack onto a flat register file. In practice, - we can provide something sensible and make it work on the x86 using the - stack like a file of eight registers. - - We use six or seven registers so as to have some freedom - for floor, ceil, round, (and log, tan, atn and exp). - - Not hard at all, basically play with FXCH. FXCH is mostly free, - so the generated code is not bad. Of course we special case when one - of the operands turns out to be ST0. - - Here are the macros that actually do the trick. */ - -#define JIT_FPR_NUM 6 -#define JIT_FPRET 0 -#define JIT_FPR(i) (i) - -#define jit_fxch(rs, op) (((rs) != 0 ? FXCHr(rs) : 0), \ - op, ((rs) != 0 ? FXCHr(rs) : 0)) - -#define jit_fp_unary(rd, s1, op) \ - ((rd) == (s1) ? jit_fxch ((rd), op) \ - : (rd) == 0 ? (FSTPr (0), FLDr ((s1)-1), op) \ - : (FLDr ((s1)), op, FSTPr ((rd) + 1))) - -#define jit_fp_binary(rd, s1, s2, op, opr) \ - ((rd) == (s1) ? \ - ((s2) == 0 ? opr(0, (rd)) \ - : (s2) == (s1) ? jit_fxch((rd), op(0, 0)) \ - : jit_fxch((rd), op((s2), 0))) \ - : (rd) == (s2) ? \ - ((s1) == 0 ? op(0, (rd)) \ - : jit_fxch((rd), opr((s1), 0))) \ - : (FLDr (s1), op((s2)+1, 0), FSTPr((rd)+1))) - -#define jit_addr_d(rd,s1,s2) jit_fp_binary((rd),(s1),(s2),FADDrr,FADDrr) -#define jit_subr_d(rd,s1,s2) jit_fp_binary((rd),(s1),(s2),FSUBrr,FSUBRrr) -#define jit_mulr_d(rd,s1,s2) jit_fp_binary((rd),(s1),(s2),FMULrr,FMULrr) -#define jit_divr_d(rd,s1,s2) jit_fp_binary((rd),(s1),(s2),FDIVrr,FDIVRrr) - -#define jit_abs_d(rd,rs) jit_fp_unary ((rd), (rs), _OO (0xd9e1)) -#define jit_negr_d(rd,rs) jit_fp_unary ((rd), (rs), _OO (0xd9e0)) -#define jit_sqrt_d(rd,rs) jit_fp_unary ((rd), (rs), _OO (0xd9fa)) - -/* - moves: - - move FPR0 to FPR3 - FST ST3 - - move FPR3 to FPR0 - FXCH ST3 - FST ST3 - - move FPR3 to FPR1 - FLD ST3 - FSTP ST2 Stack is rotated, so FPRn becomes STn+1 */ - -#define jit_movr_d(rd,s1) \ - ((s1) == (rd) ? 0 \ - : (s1) == 0 ? FSTr ((rd)) \ - : (rd) == 0 ? (FXCHr ((s1)), FSTr ((s1))) \ - : (FLDr ((s1)), FSTPr ((rd)+1))) - -/* - loads: - - load into FPR0 - FSTP ST0 - FLD [FUBAR] - - load into FPR3 - FSTP ST3 Save old st0 into destination register - FLD [FUBAR] - FXCH ST3 Get back old st0 - - (and similarly for immediates, using the stack) */ - -#define jit_movi_f(rd,immf) \ - (_O (0x68), \ - *((float *) _jit.x.pc) = (float) immf, \ - _jit.x.uc_pc += sizeof (float), \ - jit_ldr_f((rd), _ESP), \ - ADDLir(4, _ESP)) - -union jit_double_imm { - double d; - int i[2]; -}; - -#define jit_movi_d(rd,immd) \ - (_O (0x68), \ - _jit.x.uc_pc[4] = 0x68, \ - ((union jit_double_imm *) (_jit.x.uc_pc + 5))->d = (double) immd, \ - *((int *) _jit.x.uc_pc) = ((union jit_double_imm *) (_jit.x.uc_pc + 5))->i[1], \ - _jit.x.uc_pc += 9, \ - jit_ldr_d((rd), _ESP), \ - ADDLir(8, _ESP)) - -#define jit_ldi_f(rd, is) \ - ((rd) == 0 ? (FSTPr (0), FLDSm((is), 0, 0, 0)) \ - : (FLDSm((is), 0, 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldi_d(rd, is) \ - ((rd) == 0 ? (FSTPr (0), FLDLm((is), 0, 0, 0)) \ - : (FLDLm((is), 0, 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldr_f(rd, rs) \ - ((rd) == 0 ? (FSTPr (0), FLDSm(0, (rs), 0, 0)) \ - : (FLDSm(0, (rs), 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldr_d(rd, rs) \ - ((rd) == 0 ? (FSTPr (0), FLDLm(0, (rs), 0, 0)) \ - : (FLDLm(0, (rs), 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldxi_f(rd, rs, is) \ - ((rd) == 0 ? (FSTPr (0), FLDSm((is), (rs), 0, 0)) \ - : (FLDSm((is), (rs), 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldxi_d(rd, rs, is) \ - ((rd) == 0 ? (FSTPr (0), FLDLm((is), (rs), 0, 0)) \ - : (FLDLm((is), (rs), 0, 0), FSTPr ((rd) + 1))) - -#define jit_ldxr_f(rd, s1, s2) \ - ((rd) == 0 ? (FSTPr (0), FLDSm(0, (s1), (s2), 1)) \ - : (FLDSm(0, (s1), (s2), 1), FSTPr ((rd) + 1))) - -#define jit_ldxr_d(rd, s1, s2) \ - ((rd) == 0 ? (FSTPr (0), FLDLm(0, (s1), (s2), 1)) \ - : (FLDLm(0, (s1), (s2), 1), FSTPr ((rd) + 1))) - -#define jit_extr_i_d(rd, rs) (PUSHLr((rs)), \ - ((rd) == 0 ? (FSTPr (0), FILDLm(0, _ESP, 0, 0)) \ - : (FILDLm(0, _ESP, 0, 0), FSTPr ((rd) + 1))), \ - POPLr((rs))) - -#define jit_stxi_f(id, rd, rs) jit_fxch ((rs), FSTSm((id), (rd), 0, 0)) -#define jit_stxr_f(d1, d2, rs) jit_fxch ((rs), FSTSm(0, (d1), (d2), 1)) -#define jit_stxi_d(id, rd, rs) jit_fxch ((rs), FSTLm((id), (rd), 0, 0)) -#define jit_stxr_d(d1, d2, rs) jit_fxch ((rs), FSTLm(0, (d1), (d2), 1)) -#define jit_sti_f(id, rs) jit_fxch ((rs), FSTSm((id), 0, 0, 0)) -#define jit_str_f(rd, rs) jit_fxch ((rs), FSTSm(0, (rd), 0, 0)) -#define jit_sti_d(id, rs) jit_fxch ((rs), FSTLm((id), 0, 0, 0)) -#define jit_str_d(rd, rs) jit_fxch ((rs), FSTLm(0, (rd), 0, 0)) - -/* ABI */ -#define jit_retval_d(rd) FSTPr((rd) + 1) - -/* Assume round to near mode */ -#define jit_floorr_d_i(rd, rs) \ - (FLDr (rs), jit_floor2((rd), ((rd) == _EDX ? _EAX : _EDX))) - -#define jit_ceilr_d_i(rd, rs) \ - (FLDr (rs), jit_ceil2((rd), ((rd) == _EDX ? _EAX : _EDX))) - -#define jit_truncr_d_i(rd, rs) \ - (FLDr (rs), jit_trunc2((rd), ((rd) == _EDX ? _EAX : _EDX))) - -#define jit_calc_diff(ofs) \ - FISTLm(ofs, _ESP, 0, 0), \ - FILDLm(ofs, _ESP, 0, 0), \ - FSUBRPr(1), \ - 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.x.pc + 11), \ - ADDLir(0x7FFFFFFF, aux), /* 6 */ \ - SBBLir(0, rd), /* 3 */ \ - JMPSm(_jit.x.pc + 10), /* 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_roundr_d_i(rd, rs) \ - (PUSHLr(_EAX), \ - jit_fxch ((rs), FISTLm(0, _ESP, 0, 0)), \ - POPLr((rd))) - -#define jit_fp_test(d, s1, s2, n, _and, res) \ - (((s1) == 0 ? FUCOMr((s2)) : (FLDr((s1)), FUCOMPr((s2) + 1))), \ - ((d) != _EAX ? MOVLrr(_EAX, (d)) : 0), \ - FNSTSWr(_EAX), \ - SHRLir(n, _EAX), \ - ((_and) ? ANDLir((_and), _EAX) : MOVLir(0, _EAX)), \ - res, \ - ((d) != _EAX ? _O (0x90 + ((d) & 7)) : 0)) /* xchg */ - -#define jit_fp_btest(d, s1, s2, n, _and, cmp, res) \ - (((s1) == 0 ? FUCOMr((s2)) : (FLDr((s1)), FUCOMPr((s2) + 1))), \ - PUSHLr(_EAX), \ - FNSTSWr(_EAX), \ - SHRLir(n, _EAX), \ - ((_and) ? ANDLir ((_and), _EAX) : 0), \ - ((cmp) ? CMPLir ((cmp), _EAX) : 0), \ - POPLr(_EAX), \ - res ((d)), \ - _jit.x.pc) - -#define jit_nothing_needed(x) - -/* After FNSTSW we have 1 if <, 40 if =, 0 if >, 45 if unordered. Here - is how to map the values of the status word's high byte to the - conditions. - - < = > unord valid values condition - gt no no yes no 0 STSW & 45 == 0 - lt yes no no no 1 STSW & 45 == 1 - eq no yes no no 40 STSW & 45 == 40 - unord no no no yes 45 bit 2 == 1 - - ge no yes no no 0, 40 bit 0 == 0 - unlt yes no no yes 1, 45 bit 0 == 1 - ltgt yes no yes no 0, 1 bit 6 == 0 - uneq no yes no yes 40, 45 bit 6 == 1 - le yes yes no no 1, 40 odd parity for STSW & 41 - ungt no no yes yes 0, 45 even parity for STSW & 41 - - unle yes yes no yes 1, 40, 45 STSW & 45 != 0 - unge no yes yes yes 0, 40, 45 STSW & 45 != 1 - ne yes no yes yes 0, 1, 45 STSW & 45 != 40 - ord yes yes yes no 0, 1, 40 bit 2 == 0 - - lt, le, ungt, unge are actually computed as gt, ge, unlt, unle with - the operands swapped; it is more efficient this way. */ - -#define jit_gtr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 8, 0x45, SETZr (_AL)) -#define jit_ger_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 9, 0, SBBBir (-1, _AL)) -#define jit_unler_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 8, 0x45, SETNZr (_AL)) -#define jit_unltr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 9, 0, ADCBir (0, _AL)) -#define jit_ltr_d(d, s1, s2) jit_fp_test((d), (s2), (s1), 8, 0x45, SETZr (_AL)) -#define jit_ler_d(d, s1, s2) jit_fp_test((d), (s2), (s1), 9, 0, SBBBir (-1, _AL)) -#define jit_unger_d(d, s1, s2) jit_fp_test((d), (s2), (s1), 8, 0x45, SETNZr (_AL)) -#define jit_ungtr_d(d, s1, s2) jit_fp_test((d), (s2), (s1), 9, 0, ADCBir (0, _AL)) -#define jit_eqr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 8, 0x45, (CMPBir (0x40, _AL), SETEr (_AL))) -#define jit_ner_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 8, 0x45, (CMPBir (0x40, _AL), SETNEr (_AL))) -#define jit_ltgtr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 15, 0, SBBBir (-1, _AL)) -#define jit_uneqr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 15, 0, ADCBir (0, _AL)) -#define jit_ordr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 11, 0, SBBBir (-1, _AL)) -#define jit_unordr_d(d, s1, s2) jit_fp_test((d), (s1), (s2), 11, 0, ADCBir (0, _AL)) - -#define jit_bgtr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 8, 0x45, 0, JZm) -#define jit_bger_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 9, 0, 0, JNCm) -#define jit_bunler_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 8, 0x45, 0, JNZm) -#define jit_bunltr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 9, 0, 0, JCm) -#define jit_bltr_d(d, s1, s2) jit_fp_btest((d), (s2), (s1), 8, 0x45, 0, JZm) -#define jit_bler_d(d, s1, s2) jit_fp_btest((d), (s2), (s1), 9, 0, 0, JNCm) -#define jit_bunger_d(d, s1, s2) jit_fp_btest((d), (s2), (s1), 8, 0x45, 0, JNZm) -#define jit_bungtr_d(d, s1, s2) jit_fp_btest((d), (s2), (s1), 9, 0, 0, JCm) -#define jit_beqr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 8, 0x45, 0x40, JZm) -#define jit_bner_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 8, 0x45, 0x40, JNZm) -#define jit_bltgtr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 15, 0, 0, JNCm) -#define jit_buneqr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 15, 0, 0, JCm) -#define jit_bordr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 11, 0, 0, JNCm) -#define jit_bunordr_d(d, s1, s2) jit_fp_btest((d), (s1), (s2), 11, 0, 0, JCm) - -#define jit_pusharg_d(rs) (jit_subi_i(JIT_SP,JIT_SP,sizeof(double)), jit_str_d(JIT_SP,(rs))) -#define jit_pusharg_f(rs) (jit_subi_i(JIT_SP,JIT_SP,sizeof(float)), jit_str_f(JIT_SP,(rs))) - - -#if 0 -#define jit_sin() _OO(0xd9fe) /* fsin */ -#define jit_cos() _OO(0xd9ff) /* fcos */ -#define jit_tan() (_OO(0xd9f2), /* fptan */ \ - FSTPr(0)) /* fstp st */ -#define jit_atn() (_OO(0xd9e8), /* fld1 */ \ - _OO(0xd9f3)) /* fpatan */ -#define jit_exp() (_OO(0xd9ea), /* fldl2e */ \ - FMULPr(1), /* fmulp */ \ - _OO(0xd9c0), /* fld st */ \ - _OO(0xd9fc), /* frndint */ \ - _OO(0xdce9), /* fsubr */ \ - FXCHr(1), /* fxch st(1) */ \ - _OO(0xd9f0), /* f2xm1 */ \ - _OO(0xd9e8), /* fld1 */ \ - _OO(0xdec1), /* faddp */ \ - _OO(0xd9fd), /* fscale */ \ - FSTPr(1)) /* fstp st(1) */ -#define jit_log() (_OO(0xd9ed), /* fldln2 */ \ - FXCHr(1), /* fxch st(1) */ \ - _OO(0xd9f1)) /* fyl2x */ -#endif - -#define jit_prepare_f(nf) (_jitl.argssize += (nf)) -#define jit_prepare_d(nd) (_jitl.argssize += 2 * (nd)) -#define jit_arg_f() ((_jitl.framesize += sizeof(float)) - sizeof(float)) -#define jit_arg_d() ((_jitl.framesize += sizeof(double)) - sizeof(double)) - -#endif /* __lightning_fp_h */ diff --git a/lightning/i386/fp-64.h b/lightning/i386/fp-64.h deleted file mode 100644 index 22308a7f1..000000000 --- a/lightning/i386/fp-64.h +++ /dev/null @@ -1,325 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Support macros for SSE floating-point math - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - -#ifndef __lightning_fp_h -#define __lightning_fp_h - -#include - -#define JIT_FPR_NUM 7 -#define JIT_FPRET _XMM0 -#define JIT_FPR(i) (_XMM8 + (i)) -#define JIT_FPTMP _XMM15 - -/* Either use a temporary register that is finally AND/OR/XORed with RS = RD, - or use RD as the temporary register and to the AND/OR/XOR with RS. */ -#define jit_unop_tmp(rd, rs, op) \ - ( (rs) == (rd) \ - ? op((rd), JIT_FPTMP, JIT_FPTMP)) \ - : op((rd), (rd), (rs))) - -#define jit_unop_f(rd, rs, op) \ - ((rs) == (rd) ? op((rd)) : (MOVSSrr ((rs), (rd)), op((rd)))) - -#define jit_unop_d(rd, rs, op) \ - ((rs) == (rd) ? op((rd)) : (MOVSDrr ((rs), (rd)), op((rd)))) - -#define jit_3opc_f(rd, s1, s2, op) \ - ( (s1) == (rd) ? op((s2), (rd)) \ - : ((s2) == (rd) ? op((s1), (rd)) \ - : (MOVSSrr ((s1), (rd)), op((s2), (rd))))) - -#define jit_3opc_d(rd, s1, s2, op) \ - ( (s1) == (rd) ? op((s2), (rd)) \ - : ((s2) == (rd) ? op((s1), (rd)) \ - : (MOVSDrr ((s1), (rd)), op((s2), (rd))))) - -#define jit_3op_f(rd, s1, s2, op) \ - ( (s1) == (rd) ? op((s2), (rd)) \ - : ((s2) == (rd) \ - ? (MOVSSrr ((rd), JIT_FPTMP), MOVSSrr ((s1), (rd)), op(JIT_FPTMP, (rd))) \ - : (MOVSSrr ((s1), (rd)), op((s2), (rd))))) - -#define jit_3op_d(rd, s1, s2, op) \ - ( (s1) == (rd) ? op((s2), (rd)) \ - : ((s2) == (rd) \ - ? (MOVSDrr ((rd), JIT_FPTMP), MOVSDrr ((s1), (rd)), op(JIT_FPTMP, (rd))) \ - : (MOVSDrr ((s1), (rd)), op((s2), (rd))))) - -#define jit_addr_f(rd,s1,s2) jit_3opc_f((rd), (s1), (s2), ADDSSrr) -#define jit_subr_f(rd,s1,s2) jit_3op_f((rd), (s1), (s2), SUBSSrr) -#define jit_mulr_f(rd,s1,s2) jit_3opc_f((rd), (s1), (s2), MULSSrr) -#define jit_divr_f(rd,s1,s2) jit_3op_f((rd), (s1), (s2), DIVSSrr) - -#define jit_addr_d(rd,s1,s2) jit_3opc_d((rd), (s1), (s2), ADDSDrr) -#define jit_subr_d(rd,s1,s2) jit_3op_d((rd), (s1), (s2), SUBSDrr) -#define jit_mulr_d(rd,s1,s2) jit_3opc_d((rd), (s1), (s2), MULSDrr) -#define jit_divr_d(rd,s1,s2) jit_3op_d((rd), (s1), (s2), DIVSDrr) - -#define jit_movr_f(rd,rs) MOVSSrr((rs), (rd)) -#define jit_movr_d(rd,rs) MOVSDrr((rs), (rd)) - -/* either pcmpeqd %xmm7, %xmm7 / psrld $1, %xmm7 / andps %xmm7, %RD (if RS = RD) - or pcmpeqd %RD, %RD / psrld $1, %RD / andps %RS, %RD (if RS != RD) */ -#define _jit_abs_f(rd,cnst,rs) \ - (PCMPEQDrr((cnst), (cnst)), PSRLDir (1, (cnst)), ANDPSrr ((rs), (rd))) -#define _jit_neg_f(rd,cnst,rs) \ - (PCMPEQDrr((cnst), (cnst)), PSLLDir (31, (cnst)), XORPSrr ((rs), (rd))) -#define jit_abs_f(rd,rs) jit_unop_tmp ((rd), (rs), _jit_abs_f) -#define jit_neg_f(rd,rs) jit_unop_tmp ((rd), (rs), _jit_neg_f) - -#define _jit_abs_d(rd,cnst,rs) \ - (PCMPEQDrr((cnst), (cnst)), PSRLQir (1, (cnst)), ANDPDrr ((rs), (rd))) -#define _jit_neg_d(rd,cnst,rs) \ - (PCMPEQDrr((cnst), (cnst)), PSLLQir (63, (cnst)), XORPDrr ((rs), (rd))) -#define jit_abs_d(rd,rs) jit_unop_tmp ((rd), (rs), _jit_abs_d) -#define jit_neg_d(rd,rs) jit_unop_tmp ((rd), (rs), _jit_neg_d) - -#define jit_sqrt_d(rd,rs) SQRTSSrr((rs), (rd)) -#define jit_sqrt_f(rd,rs) SQRTSDrr((rs), (rd)) - -#define _jit_ldi_f(d, is) MOVSSmr((is), 0, 0, 0, (d)) -#define _jit_ldxi_f(d, rs, is) MOVSSmr((is), (rs), 0, 0, (d)) -#define jit_ldr_f(d, rs) MOVSSmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_f(d, s1, s2) MOVSSmr(0, (s1), (s2), 1, (d)) - -#define _jit_sti_f(id, rs) MOVSSrm((rs), (id), 0, 0, 0) -#define _jit_stxi_f(id, rd, rs) MOVSSrm((rs), (id), (rd), 0, 0) -#define jit_str_f(rd, rs) MOVSSrm((rs), 0, (rd), 0, 0) -#define jit_stxr_f(d1, d2, rs) MOVSSrm((rs), 0, (d1), (d2), 1) - -#define jit_ldi_f(d, is) (_u32P((long)(is)) ? _jit_ldi_f((d), (is)) : (jit_movi_l(JIT_REXTMP, (is)), jit_ldr_f((d), JIT_REXTMP))) -#define jit_sti_f(id, rs) (_u32P((long)(id)) ? _jit_sti_f((id), (rs)) : (jit_movi_l(JIT_REXTMP, (id)), jit_str_f (JIT_REXTMP, (rs)))) -#define jit_ldxi_f(d, rs, is) (_u32P((long)(is)) ? _jit_ldxi_f((d), (rs), (is)) : (jit_movi_l(JIT_REXTMP, (is)), jit_ldxr_f((d), (rs), JIT_REXTMP))) -#define jit_stxi_f(id, rd, rs) (_u32P((long)(id)) ? _jit_stxi_f((id), (rd), (rs)) : (jit_movi_l(JIT_REXTMP, (id)), jit_stxr_f (JIT_REXTMP, (rd), (rs)))) - -#define _jit_ldi_d(d, is) MOVSDmr((is), 0, 0, 0, (d)) -#define _jit_ldxi_d(d, rs, is) MOVSDmr((is), (rs), 0, 0, (d)) -#define jit_ldr_d(d, rs) MOVSDmr(0, (rs), 0, 0, (d)) -#define jit_ldxr_d(d, s1, s2) MOVSDmr(0, (s1), (s2), 1, (d)) - -#define _jit_sti_d(id, rs) MOVSDrm((rs), (id), 0, 0, 0) -#define _jit_stxi_d(id, rd, rs) MOVSDrm((rs), (id), (rd), 0, 0) -#define jit_str_d(rd, rs) MOVSDrm((rs), 0, (rd), 0, 0) -#define jit_stxr_d(d1, d2, rs) MOVSDrm((rs), 0, (d1), (d2), 1) - -#define jit_ldi_d(d, is) (_u32P((long)(is)) ? _jit_ldi_d((d), (is)) : (jit_movi_l(JIT_REXTMP, (is)), jit_ldr_d((d), JIT_REXTMP))) -#define jit_sti_d(id, rs) (_u32P((long)(id)) ? _jit_sti_d((id), (rs)) : (jit_movi_l(JIT_REXTMP, (id)), jit_str_d (JIT_REXTMP, (rs)))) -#define jit_ldxi_d(d, rs, is) (_u32P((long)(is)) ? _jit_ldxi_d((d), (rs), (is)) : (jit_movi_l(JIT_REXTMP, (is)), jit_ldxr_d((d), (rs), JIT_REXTMP))) -#define jit_stxi_d(id, rd, rs) (_u32P((long)(id)) ? _jit_stxi_d((id), (rd), (rs)) : (jit_movi_l(JIT_REXTMP, (id)), jit_stxr_d (JIT_REXTMP, (rd), (rs)))) - - -#define jit_movi_f(rd,immf) \ - ((immf) == 0.0 ? XORSSrr ((rd), (rd)) : \ - (PUSHQi (0x12345678L), \ - *((float *) (_jit.x.uc_pc - 4)) = (float) immf, \ - jit_ldr_f((rd), _ESP), \ - ADDQir(8, _ESP))) - -union jit_double_imm { - double d; - long l; -}; - -#define jit_movi_d(rd,immd) \ - ((immd) == 0.0 ? XORSDrr ((rd), (rd)) : \ - (_O (0x50), \ - MOVQir (0x123456789abcdef0L, _EAX), \ - ((union jit_double_imm *) (_jit.x.uc_pc - 8))->d = (double) immd, \ - _O (0x50), jit_ldr_d((rd), _ESP), \ - _O (0x58), _O (0x58))) - -#define jit_extr_i_d(rd, rs) CVTSI2SDLrr((rs), (rd)) -#define jit_extr_i_f(rd, rs) CVTSI2SSLrr((rs), (rd)) -#define jit_extr_l_d(rd, rs) CVTSI2SDQrr((rs), (rd)) -#define jit_extr_l_f(rd, rs) CVTSI2SSQrr((rs), (rd)) -#define jit_extr_f_d(rd, rs) CVTSS2SDrr((rs), (rd)) -#define jit_extr_d_f(rd, rs) CVTSD2SSrr((rs), (rd)) -#define jit_roundr_d_i(rd, rs) CVTSD2SILrr((rs), (rd)) -#define jit_roundr_f_i(rd, rs) CVTSS2SILrr((rs), (rd)) -#define jit_roundr_d_l(rd, rs) CVTSD2SIQrr((rs), (rd)) -#define jit_roundr_f_l(rd, rs) CVTSS2SIQrr((rs), (rd)) -#define jit_truncr_d_i(rd, rs) CVTTSD2SILrr((rs), (rd)) -#define jit_truncr_f_i(rd, rs) CVTTSS2SILrr((rs), (rd)) -#define jit_truncr_d_l(rd, rs) CVTTSD2SIQrr((rs), (rd)) -#define jit_truncr_f_l(rd, rs) CVTTSS2SIQrr((rs), (rd)) - - -#define jit_ceilr_f_i(rd, rs) do { \ - jit_roundr_f_i ((rd), (rs)); \ - jit_extr_i_f (JIT_FPTMP, (rd)); \ - UCOMISSrr ((rs), JIT_FPTMP); \ - ADCLir (0, (rd)); \ - } while (0) - -#define jit_ceilr_d_i(rd, rs) do { \ - jit_roundr_d_i ((rd), (rs)); \ - jit_extr_i_d (JIT_FPTMP, (rd)); \ - UCOMISDrr ((rs), JIT_FPTMP); \ - ADCLir (0, (rd)); \ - } while (0) - -#define jit_ceilr_f_l(rd, rs) do { \ - jit_roundr_f_l ((rd), (rs)); \ - jit_extr_l_f (JIT_FPTMP, (rd)); \ - UCOMISSrr ((rs), JIT_FPTMP); \ - ADCLir (0, (rd)); \ - } while (0) - -#define jit_ceilr_d_l(rd, rs) do { \ - jit_roundr_d_l ((rd), (rs)); \ - jit_extr_l_d (JIT_FPTMP, (rd)); \ - UCOMISDrr ((rs), JIT_FPTMP); \ - ADCLir (0, (rd)); \ - } while (0) - -#define jit_floorr_f_i(rd, rs) do { \ - jit_roundr_f_i ((rd), (rs)); \ - jit_extr_i_f (JIT_FPTMP, (rd)); \ - UCOMISSrr (JIT_FPTMP, (rs)); \ - SBBLir (0, (rd)); \ - } while (0) - -#define jit_floorr_d_i(rd, rs) do { \ - jit_roundr_d_i ((rd), (rs)); \ - jit_extr_i_d (JIT_FPTMP, (rd)); \ - UCOMISDrr (JIT_FPTMP, (rs)); \ - SBBLir (0, (rd)); \ - } while (0) - -#define jit_floorr_f_l(rd, rs) do { \ - jit_roundr_f_l ((rd), (rs)); \ - jit_extr_l_f (JIT_FPTMP, (rd)); \ - UCOMISSrr (JIT_FPTMP, (rs)); \ - SBBLir (0, (rd)); \ - } while (0) - -#define jit_floorr_d_l(rd, rs) do { \ - jit_roundr_d_l ((rd), (rs)); \ - jit_extr_l_d (JIT_FPTMP, (rd)); \ - UCOMISDrr (JIT_FPTMP, (rs)); \ - SBBLir (0, (rd)); \ - } while (0) - -#define jit_bltr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JAm ((d)), _jit.x.pc) -#define jit_bler_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JAEm ((d)), _jit.x.pc) -#define jit_beqr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), _OO (0x7a06), JEm ((d)), _jit.x.pc) -#define jit_bner_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), _OO (0x7a02), _OO (0x7405), JMPm (((d))), _jit.x.pc) /* JP to JMP, JZ past JMP */ -#define jit_bger_f(d, s1, s2) (UCOMISSrr ((s2), (s1)), JAEm ((d)), _jit.x.pc) -#define jit_bgtr_f(d, s1, s2) (UCOMISSrr ((s2), (s1)), JAm ((d)), _jit.x.pc) -#define jit_bunltr_f(d, s1, s2) (UCOMISSrr ((s2), (s1)), JNAEm ((d)), _jit.x.pc) -#define jit_bunler_f(d, s1, s2) (UCOMISSrr ((s2), (s1)), JNAm ((d)), _jit.x.pc) -#define jit_buneqr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JEm ((d)), _jit.x.pc) -#define jit_bltgtr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JNEm ((d)), _jit.x.pc) -#define jit_bunger_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JNAm ((d)), _jit.x.pc) -#define jit_bungtr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JNAEm ((d)), _jit.x.pc) -#define jit_bordr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JNPm ((d)), _jit.x.pc) -#define jit_bunordr_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), JPm ((d)), _jit.x.pc) - -#define jit_bltr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JAm ((d)), _jit.x.pc) -#define jit_bler_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JAEm ((d)), _jit.x.pc) -#define jit_beqr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), _OO (0x7a06), JEm ((d)), _jit.x.pc) -#define jit_bner_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), _OO (0x7a02), _OO (0x7405), JMPm (((d))), _jit.x.pc) /* JP to JMP, JZ past JMP */ -#define jit_bger_d(d, s1, s2) (UCOMISDrr ((s2), (s1)), JAEm ((d)), _jit.x.pc) -#define jit_bgtr_d(d, s1, s2) (UCOMISDrr ((s2), (s1)), JAm ((d)), _jit.x.pc) -#define jit_bunltr_d(d, s1, s2) (UCOMISDrr ((s2), (s1)), JNAEm ((d)), _jit.x.pc, _jit.x.pc) -#define jit_bunler_d(d, s1, s2) (UCOMISDrr ((s2), (s1)), JNAm ((d)), _jit.x.pc) -#define jit_buneqr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JEm ((d)), _jit.x.pc) -#define jit_bltgtr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JNEm ((d)), _jit.x.pc) -#define jit_bunger_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JNAm ((d)), _jit.x.pc) -#define jit_bungtr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JNAEm ((d)), _jit.x.pc) -#define jit_bordr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JNPm ((d)), _jit.x.pc) -#define jit_bunordr_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), JPm ((d)), _jit.x.pc) - -#define jit_ltr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETAr (jit_reg8((d)))) -#define jit_ler_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETAEr (jit_reg8((d)))) -#define jit_eqr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), _OO(0x7a03), SETEr (jit_reg8((d)))) -#define jit_ner_f(d, s1, s2) (UCOMISSrr ((s1), (s2)), MOVLir (1, (d)), _OO(0x7a03), SETNEr (jit_reg8((d)))) -#define jit_ger_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s2), (s1)), SETAEr (jit_reg8((d)))) -#define jit_gtr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s2), (s1)), SETAr (jit_reg8((d)))) -#define jit_unltr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s2), (s1)), SETNAEr (jit_reg8((d)))) -#define jit_unler_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s2), (s1)), SETNAr (jit_reg8((d)))) -#define jit_uneqr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETEr (jit_reg8((d)))) -#define jit_ltgtr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETNEr (jit_reg8((d)))) -#define jit_unger_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETNAr (jit_reg8((d)))) -#define jit_ungtr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETNAEr (jit_reg8((d)))) -#define jit_ordr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETNPr (jit_reg8((d)))) -#define jit_unordr_f(d, s1, s2) (XORLrr ((d), (d)), UCOMISSrr ((s1), (s2)), SETPr (jit_reg8((d)))) - -#define jit_ltr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETAr (jit_reg8((d)))) -#define jit_ler_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETAEr (jit_reg8((d)))) -#define jit_eqr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), _OO(0x7a03), SETEr (jit_reg8((d)))) -#define jit_ner_d(d, s1, s2) (UCOMISDrr ((s1), (s2)), MOVLir (1, (d)), _OO(0x7a03), SETNEr (jit_reg8((d)))) -#define jit_ger_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s2), (s1)), SETAEr (jit_reg8((d)))) -#define jit_gtr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s2), (s1)), SETAr (jit_reg8((d)))) -#define jit_unltr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s2), (s1)), SETNAEr (jit_reg8((d)))) -#define jit_unler_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s2), (s1)), SETNAr (jit_reg8((d)))) -#define jit_uneqr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETEr (jit_reg8((d)))) -#define jit_ltgtr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETNEr (jit_reg8((d)))) -#define jit_unger_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETNAr (jit_reg8((d)))) -#define jit_ungtr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETNAEr (jit_reg8((d)))) -#define jit_ordr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETNPr (jit_reg8((d)))) -#define jit_unordr_d(d, s1, s2) (XORLrr ((d), (d)), UCOMISDrr ((s1), (s2)), SETPr (jit_reg8((d)))) - -#define jit_prepare_f(num) ((_jitl.nextarg_putfp + (num) > JIT_FP_ARG_MAX \ - ? (_jitl.argssize += _jitl.nextarg_putfp + (num) - JIT_FP_ARG_MAX, \ - _jitl.fprssize = JIT_FP_ARG_MAX) \ - : (_jitl.fprssize += (num))), \ - _jitl.nextarg_putfp += (num)) -#define jit_prepare_d(num) ((_jitl.nextarg_putfp + (num) > JIT_FP_ARG_MAX \ - ? (_jitl.argssize += _jitl.nextarg_putfp + (num) - JIT_FP_ARG_MAX, \ - _jitl.fprssize = JIT_FP_ARG_MAX) \ - : (_jitl.fprssize += (num))), \ - _jitl.nextarg_putfp += (num)) - -#define jit_arg_f() (_jitl.nextarg_getfp < JIT_FP_ARG_MAX \ - ? _jitl.nextarg_getfp++ \ - : ((_jitl.framesize += sizeof(double)) - sizeof(double))) -#define jit_arg_d() (_jitl.nextarg_getfp < JIT_FP_ARG_MAX \ - ? _jitl.nextarg_getfp++ \ - : ((_jitl.framesize += sizeof(double)) - sizeof(double))) - -#define jit_getarg_f(reg, ofs) ((ofs) < JIT_FP_ARG_MAX \ - ? jit_movr_f((reg), _XMM0 + (ofs)) \ - : jit_ldxi_f((reg), JIT_FP, (ofs))) -#define jit_getarg_d(reg, ofs) ((ofs) < JIT_FP_ARG_MAX \ - ? jit_movr_d((reg), _XMM0 + (ofs)) \ - : jit_ldxi_d((reg), JIT_FP, (ofs))) - -#define jit_pusharg_f(rs) (--_jitl.nextarg_putfp >= JIT_FP_ARG_MAX \ - ? (SUBQir(sizeof(double), JIT_SP), jit_str_f(JIT_SP,(rs))) \ - : jit_movr_f(_XMM0 + _jitl.nextarg_putfp, (rs))) -#define jit_pusharg_d(rs) (--_jitl.nextarg_putfp >= JIT_FP_ARG_MAX \ - ? (SUBQir(sizeof(double), JIT_SP), jit_str_d(JIT_SP,(rs))) \ - : jit_movr_d(_XMM0 + _jitl.nextarg_putfp, (rs))) - -#endif /* __lightning_fp_h */ diff --git a/lightning/i386/fp.h b/lightning/i386/fp.h deleted file mode 100644 index 7aade65da..000000000 --- a/lightning/i386/fp.h +++ /dev/null @@ -1,43 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Floating-point support (i386) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2008 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_fp_i386_h -#define __lightning_fp_i386_h - -#if defined (__x86_64__) -#include "fp-64.h" -#else -#include "fp-32.h" -#endif - -#endif /* __lightning_fp_i386_h */ diff --git a/lightning/i386/funcs.h b/lightning/i386/funcs.h deleted file mode 100644 index 9e401adff..000000000 --- a/lightning/i386/funcs.h +++ /dev/null @@ -1,92 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer inline functions (i386) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_funcs_h -#define __lightning_funcs_h - -#ifdef __linux__ -#include -#include -#endif - -static void -jit_flush_code(void *dest, void *end) -{ - /* On the x86, the PROT_EXEC bits are not handled by the MMU. - However, the kernel can emulate this by setting the code - segment's limit to the end address of the highest page - whose PROT_EXEC bit is set. - - Linux kernels that do so and that disable by default the - execution of the data and stack segment are becoming more - and more common (Fedora, for example), so we implement our - jit_flush_code as an mprotect. */ -#ifdef __linux__ - static unsigned long prev_page = 0, prev_length = 0; - long page, length; -#ifdef PAGESIZE - const int page_size = PAGESIZE; -#else - static int page_size = -1; - if (page_size == -1) - page_size = sysconf (_SC_PAGESIZE); -#endif - - page = (long) dest & ~(page_size - 1); - length = ((char *) end - (char *) page + page_size - 1) & ~(page_size - 1); - - /* Simple-minded attempt at optimizing the common case where a single - chunk of memory is used to compile multiple functions. */ - if (page >= prev_page && page + length <= prev_page + prev_length) - return; - - mprotect ((void *) page, length, PROT_READ | PROT_WRITE | PROT_EXEC); - - /* See if we can extend the previously mprotect'ed memory area towards - higher addresses: the starting address remains the same as before. */ - if (page >= prev_page && page <= prev_page + prev_length) - prev_length = page + length - prev_page; - - /* See if we can extend the previously mprotect'ed memory area towards - lower addresses: the highest address remains the same as before. */ - else if (page < prev_page && page + length >= prev_page - && page + length <= prev_page + prev_length) - prev_length += prev_page - page, prev_page = page; - - /* Nothing to do, replace the area. */ - else - prev_page = page, prev_length = length; -#endif -} - -#endif /* __lightning_funcs_h */ diff --git a/lightning/ppc/asm.h b/lightning/ppc/asm.h deleted file mode 100644 index 71825bdc6..000000000 --- a/lightning/ppc/asm.h +++ /dev/null @@ -1,647 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - -#ifndef __lightning_asm_h -#define __lightning_asm_h - -/* = [0-9]+ | (.+) -> add i, one parameter (imm) - * = r -> add r, one parameter (imm) - * = () -> add m, two parameters (imm,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; - -#ifndef LIGHTNING_DEBUG -#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,(_jit_UL(D)-_jit_UL(_jit.x.pc))) & ~3) -#define _d26(D) (_ck_d(26,(_jit_UL(D)-_jit_UL(_jit.x.pc))) & ~3) - -/* primitive instruction forms [1, Section A.4] */ - -#define _FB( OP, BD,AA,LK ) (_jit_I_noinc((_u6(OP)<<26)| _d26(BD)| (_u1(AA)<<1)|_u1(LK)), _jit.x.pc++, 0) -#define _FBA( OP, BD,AA,LK ) _jit_I((_u6(OP)<<26)| (_u26(BD)&~3)| (_u1(AA)<<1)|_u1(LK)) -#define _BB( OP,BO,BI, BD,AA,LK ) (_jit_I_noinc((_u6(OP)<<26)|(_u5(BO)<<21)|(_u5(BI)<<16)| _d16(BD)| (_u1(AA)<<1)|_u1(LK)), _jit.x.pc++, 0) -#define _D( OP,RD,RA, DD ) _jit_I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _s16(DD) ) -#define _Du( OP,RD,RA, DD ) _jit_I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _u16(DD) ) -#define _Ds( OP,RD,RA, DD ) _jit_I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)| _su16(DD) ) -#define _X( OP,RD,RA,RB, XO,RC ) _jit_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 ) _jit_I((_u6(OP)<<26)|(_u5(BO)<<21)|(_u5(BI)<<16)|( _u5(00)<<11)| (_u10(XO)<<1)|_u1(LK)) -#define _XFX( OP,RD, SR,XO ) _jit_I((_u6(OP)<<26)|(_u5(RD)<<21)| (_u10(SR)<<11)| (_u10(XO)<<1)|_u1(00)) -#define _XO( OP,RD,RA,RB,OE,XO,RC ) _jit_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 ) _jit_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,-_LO((IM))) /* [1, Section F.2.1] */ -#define SUBISrri(RD,RA,IM) ADDISrri(RD,RA,-_LO((IM))) -#define SUBICrri(RD,RA,IM) ADDICrri(RD,RA,-_LO((IM))) -#define SUBIC_rri(RD,RA,IM) ADDIC_rri(RD,RA,-_LO((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 JIT_AUX */ -#define BC_EXT(A, C, D) (_siP(16, _jit_UL(D)-_jit_UL(_jit.x.pc)) \ - ? BCiii((A), (C), (D)) \ - : (BCiii((A)^9, (C), _jit.x.pc+5), \ - LISri(JIT_AUX,_HI(D)), \ - ORIrri(JIT_AUX,JIT_AUX,_LO(D)), \ - MTLRr(JIT_AUX), BLR() )) - -#define B_EXT(D) (_siP(16, _jit_UL(D)-_jit_UL(_jit.x.pc)) \ - ? Bi((D)) \ - : (LISri(JIT_AUX,_HI(D)), \ - ORIrri(JIT_AUX,JIT_AUX,_LO(D)), \ - MTLRr(JIT_AUX), 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) (_jit_UL(I) & _MASK(16)) -#define _HI(I) (_jit_UL(I) >> (16)) - -#define _A(OP,RD,RA,RB,RC,XO,RCx) _jit_I((_u6(OP)<<26)|(_u5(RD)<<21)|(_u5(RA)<<16)|( _u5(RB)<<11)|_u5(RC)<<6|(_u5(XO)<<1)|_u1(RCx)) - -#define LFDrri(RD,RA,imm) _D(50,RD,RA,imm) -#define LFDUrri(RD,RA,imm) _D(51,RD,RA,imm) -#define LFDUxrrr(RD,RA,RB) _X(31,RD,RA,RB,631,0) -#define LFDxrrr(RD,RA,RB) _X(31,RD,RA,RB,599,0) - -#define LFSrri(RD,RA,imm) _D(48,RD,RA,imm) -#define LFSUrri(RD,RA,imm) _D(49,RD,RA,imm) -#define LFSUxrrr(RD,RA,RB) _X(31,RD,RA,RB,567,0) -#define LFSxrrr(RD,RA,RB) _X(31,RD,RA,RB,535,0) - -#define STFDrri(RS,RA,imm) _D(54,RS,RA,imm) -#define STFDUrri(RS,RA,imm) _D(55,RS,RA,imm) -#define STFDUxrrr(RS,RA,RB) _X(31,RS,RA,RB,759,0) -#define STFDxrrr(RS,RA,RB) _X(31,RS,RA,RB,727,0) - -#define STFSrri(RS,RA,imm) _D(52,RS,RA,imm) -#define STFSUrri(RS,RA,imm) _D(53,RS,RA,imm) -#define STFSUxrrr(RS,RA,RB) _X(31,RS,RA,RB,695,0) -#define STFSxrrr(RS,RA,RB) _X(31,RS,RA,RB,663,0) -#define STFIWXrrr(RS,RA,RB) _X(31,RS,RA,RB,983,0) - -#define FADDDrrr(RD,RA,RB) _A(63,RD,RA,RB,0,21,0) -#define FADDSrrr(RD,RA,RB) _A(59,RD,RA,RB,0,21,0) -#define FSUBDrrr(RD,RA,RB) _A(63,RD,RA,RB,0,20,0) -#define FSUBSrrr(RD,RA,RB) _A(59,RD,RA,RB,0,20,0) -#define FMULDrrr(RD,RA,RC) _A(63,RD,RA,0,RC,25,0) -#define FMULSrrr(RD,RA,RC) _A(59,RD,RA,0,RC,25,0) -#define FDIVDrrr(RD,RA,RB) _A(63,RD,RA,RB,0,18,0) -#define FDIVSrrr(RD,RA,RB) _A(59,RD,RA,RB,0,25,0) -#define FSQRTDrr(RD,RB) _A(63,RD,0,RB,0,22,0) -#define FSQRTSrr(RD,RB) _A(59,RD,0,RB,0,22,0) -#define FSELrrrr(RD,RA,RB,RC) _A(63,RD,RA,RB,RC,23,0) -#define FCTIWrr(RD,RB) _X(63,RD,0,RB,14,0) -#define FCTIWZrr(RD,RB) _X(63,RD,0,RB,15,0) -#define FRSPrr(RD,RB) _X(63,RD,0,RB,12,0) -#define FABSrr(RD,RB) _X(63,RD,0,RB,264,0) -#define FNABSrr(RD,RB) _X(63,RD,0,RB,136,0) -#define FNEGrr(RD,RB) _X(63,RD,0,RB,40,0) -#define FMOVErr(RD,RB) _X(63,RD,0,RB,72,0) -#define FCMPOrrr(CR,RA,RB) _X(63,_u3((CR)<<2),RA,RB,32,0) -#define FCMPUrrr(CR,RA,RB) _X(63,_u3((CR)<<2),RA,RB,0,0) -#define MTFSFIri(CR,IMM) _X(63,_u5((CR)<<2),0,_u5((IMM)<<1),134,0) - -/*** References: - * - * [1] "PowerPC Microprocessor Family: The Programming Environments For 32-Bit Microprocessors", Motorola, 1997. - */ - - -#endif -#endif /* __ccg_asm_ppc_h */ diff --git a/lightning/ppc/core.h b/lightning/ppc/core.h deleted file mode 100644 index 40de69ce1..000000000 --- a/lightning/ppc/core.h +++ /dev/null @@ -1,317 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer (PowerPC version) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_core_h -#define __lightning_core_h - -struct jit_local_state { - int nextarg_puti; /* number of integer args */ - int nextarg_putf; /* number of float args */ - int nextarg_putd; /* number of double args */ - int nextarg_geti; /* Next r20-r25 reg. to be read */ - int nextarg_getd; /* The FP args are picked up from FPR1 -> FPR10 */ - int nbArgs; /* Number of arguments for the prolog */ - - int frame_size, slack; - jit_insn *stwu; -}; - -/* Patch a `stwu' instruction (with immediate operand) so that it decreases - r1 by AMOUNT. AMOUNT should already be rounded so that %sp remains quadword - aligned. */ -#define jit_patch_stwu(amount) \ - (*(_jitl.stwu) &= ~_MASK (16), \ - *(_jitl.stwu) |= _s16 ((amount))) - -#define jit_allocai(n) \ - (_jitl.frame_size += (n), \ - ((n) <= _jitl.slack \ - ? 0 : jit_patch_stwu (-((_jitl.frame_size + 15) & ~15))), \ - _jitl.slack = ((_jitl.frame_size + 15) & ~15) - _jitl.frame_size, \ - _jitl.frame_size - (n)) - -#define JIT_SP 1 -#define JIT_FP 1 -#define JIT_RET 3 -#define JIT_R_NUM 3 -#define JIT_V_NUM 7 -#define JIT_R(i) (9+(i)) -#define JIT_V(i) (31-(i)) -#define JIT_AUX JIT_V(JIT_V_NUM) /* 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)) ) - -#define jit_big_ims(imm, big) (MOVEIri(JIT_AUX, imm), (big)) -#define jit_big_imu(imm, big) (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.x.pc) -#define jit_s_brar(s1, s2, jmp) ( CMPWrr(s1, s2), jmp, _jit.x.pc) -#define jit_u_brai(rs, is, jmp) (jit_chk_imu (is, CMPLWIri(rs, is), CMPLWrr(rs, JIT_AUX)), jmp, _jit.x.pc) -#define jit_u_brar(s1, s2, jmp) ( CMPLWrr(s1, s2), jmp, _jit.x.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 big immediate with small immediate - * movei r24, imm movei r24, imm - * mtlr r31 - * divw r31, rs, r24 (or divwu) divw r24, rs, r24 - * mullw r31, r31, r24 mulli r24, r24, imm - * sub d, rs, r31 sub d, rs, r24 - * mflr r31 - * - * - * jit_mod_big expects immediate in JIT_AUX. */ - -#define _jit_mod_big(div, d, rs) (MTLRr(31), div(31, (rs), JIT_AUX), \ - MULLWrrr(31, 31, JIT_AUX), SUBrrr((d), (rs), 31), \ - MFLRr(31)) - -#define _jit_mod_small(div, d, rs, imm) (MOVEIri(JIT_AUX, (imm)), div(JIT_AUX, (rs), JIT_AUX), \ - MULLIrri(JIT_AUX, JIT_AUX, (imm)), SUBrrr((d), (rs), JIT_AUX)) - -/* 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, dest) \ - (*(lis_pc) &= ~_MASK(16), *(lis_pc) |= _HI(dest), \ - *(ori_pc) &= ~_MASK(16), *(ori_pc) |= _LO(dest)) \ - -/* Patch a branch instruction */ -#define jit_patch_branch(jump_pc,pv) \ - (*(jump_pc) &= ~_MASK(16) | 3, \ - *(jump_pc) |= (_jit_UL(pv) - _jit_UL(jump_pc)) & _MASK(16)) - -#define jit_patch_ucbranch(jump_pc,pv) \ - (*(jump_pc) &= ~_MASK(26) | 3, \ - (*(jump_pc) |= (_jit_UL((pv)) - _jit_UL(jump_pc)) & _MASK(26))) - -#define _jit_b_encoding (18 << 26) -#define _jit_blr_encoding ((19 << 26) | (20 << 21) | (00 << 16) | (00 << 11) | (16 << 1)) -#define _jit_is_ucbranch(a) (((*(a) & (63<<26)) == _jit_b_encoding)) - -#define jit_patch_at(jump_pc, value) ( \ - ((*(jump_pc - 1) & ~1) == _jit_blr_encoding) \ - ? jit_patch_movei(((jump_pc) - 4), ((jump_pc) - 3), (value)) \ - : ( _jit_is_ucbranch((jump_pc) - 1) \ - ? jit_patch_ucbranch((jump_pc) - 1, (value)) \ - : jit_patch_branch((jump_pc) - 1, (value)))) - -#define jit_patch_movi(movi_pc, val) \ - jit_patch_movei((movi_pc) - 2, (movi_pc) - 1, (val)) - -#define jit_arg_c() (_jitl.nextarg_geti--) -#define jit_arg_i() (_jitl.nextarg_geti--) -#define jit_arg_l() (_jitl.nextarg_geti--) -#define jit_arg_p() (_jitl.nextarg_geti--) -#define jit_arg_s() (_jitl.nextarg_geti--) -#define jit_arg_uc() (_jitl.nextarg_geti--) -#define jit_arg_ui() (_jitl.nextarg_geti--) -#define jit_arg_ul() (_jitl.nextarg_geti--) -#define jit_arg_us() (_jitl.nextarg_geti--) - -/* Check Mach-O-Runtime documentation: Must skip GPR(s) whenever "corresponding" FPR is used */ -#define jit_arg_f() (_jitl.nextarg_geti-- ,_jitl.nextarg_getd++) -#define jit_arg_d() (_jitl.nextarg_geti-=2,_jitl.nextarg_getd++) - -#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)), BNEi((label)), _jit.x.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.x.pc) -#define jit_bmsr_i(label, s1, s2) ( AND_rrr(JIT_AUX, (s1), (s2)), BNEi((label)), _jit.x.pc) -#define jit_bmcr_i(label, s1, s2) ( AND_rrr(JIT_AUX, (s1), (s2)), BEQi((label)), _jit.x.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.x.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.x.pc) -#define jit_boaddr_i(label, s1, s2) ( ADDOrrr((s1), (s1), (s2)), MCRXRi(0), BGTi((label)), _jit.x.pc) -#define jit_bosubr_i(label, s1, s2) ( SUBCOrrr((s1), (s1), (s2)), MCRXRi(0), BGTi((label)), _jit.x.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.x.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.x.pc) -#define jit_boaddr_ui(label, s1, s2) ( ADDCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.x.pc) -#define jit_bosubr_ui(label, s1, s2) ( SUBCrr((s1), (s1), (s2)), MCRXRi(0), BEQi((label)), _jit.x.pc) -#define jit_calli(label) ((void)jit_movi_p(JIT_AUX, (label)), MTCTRr(JIT_AUX), BCTRL(), _jitl.nextarg_puti = _jitl.nextarg_putf = _jitl.nextarg_putd = 0, _jit.x.pc) -#define jit_callr(reg) (MTCTRr(reg), BCTRL()) -#define jit_divi_i(d, rs, is) jit_big_ims((is), DIVWrrr ((d), (rs), JIT_AUX)) -#define jit_divi_ui(d, rs, is) jit_big_imu((is), 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_big_ims((is), MULHWrrr ((d), (rs), JIT_AUX)) -#define jit_hmuli_ui(d, rs, is) jit_big_imu((is), 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.x.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((is), LWZrm((d), (is), (rs)), LWZrx((d), JIT_AUX, (rs))) -#define jit_ldxi_s(d, rs, is) jit_chk_ims((is), LHArm((d), (is), (rs)), LHArx((d), JIT_AUX, (rs))) -#define jit_ldxi_uc(d, rs, is) jit_chk_ims((is), LBZrm((d), (is), (rs)), LBZrx((d), JIT_AUX, (rs))) -#define jit_ldxi_us(d, rs, is) jit_chk_ims((is), 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) (ANDI_rri(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_chk_ims ((is), _jit_mod_small(jit_divr_i , (d), (rs), (is)), _jit_mod_big(jit_divr_i , (d), (rs))) -#define jit_modi_ui(d, rs, is) jit_chk_imu15((is), _jit_mod_small(jit_divr_ui, (d), (rs), (is)), _jit_mod_big(jit_divr_ui, (d), (rs))) -#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_movi_p(d, is) (LISri((d), _HI((is))),ORIrri((d),(d),_LO((is))),_jit.x.pc) - -#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_prepare_i(numi) (_jitl.nextarg_puti = numi) -#define jit_prepare_f(numf) (_jitl.nextarg_putf = numf) -#define jit_prepare_d(numd) (_jitl.nextarg_putd = numd) -#define jit_prolog(n) _jit_prolog(&_jit, (n)) -#define jit_pusharg_i(rs) (--_jitl.nextarg_puti, MRrr((3 + _jitl.nextarg_putd * 2 + _jitl.nextarg_putf + _jitl.nextarg_puti), (rs))) -#define jit_ret() _jit_epilog(&_jit) -#define jit_retval_i(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) (ANDI_rri(JIT_AUX, (s2), 31), SRAWrrr ((d), (s1), JIT_AUX)) -#define jit_rshr_ui(d, s1, s2) (ANDI_rri(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_big_ims((is), 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) ((_jit_UL(addr) >> 16) + (_jit_US(_jit_UL(addr)) >> 15)) -#define _LA(addr) (_jit_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 */ diff --git a/lightning/ppc/fp.h b/lightning/ppc/fp.h deleted file mode 100644 index feed42ce5..000000000 --- a/lightning/ppc/fp.h +++ /dev/null @@ -1,212 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_asm_fp_h -#define __lightning_asm_fp_h - - -#define JIT_FPR_NUM 6 -#define JIT_FPRET 1 -#define JIT_FPR(i) (8+(i)) - - -/* Make space for 1 or 2 words, store address in REG */ -#define jit_data(REG, D1) (_FBA (18, 8, 0, 1), _jit_L(D1), MFLRr(REG)) - -#define jit_addr_d(rd,s1,s2) FADDDrrr((rd),(s1),(s2)) -#define jit_subr_d(rd,s1,s2) FSUBDrrr((rd),(s1),(s2)) -#define jit_mulr_d(rd,s1,s2) FMULDrrr((rd),(s1),(s2)) -#define jit_divr_d(rd,s1,s2) FDIVDrrr((rd),(s1),(s2)) - -#define jit_addr_f(rd,s1,s2) FADDSrrr((rd),(s1),(s2)) -#define jit_subr_f(rd,s1,s2) FSUBSrrr((rd),(s1),(s2)) -#define jit_mulr_f(rd,s1,s2) FMULSrrr((rd),(s1),(s2)) -#define jit_divr_f(rd,s1,s2) FDIVSrrr((rd),(s1),(s2)) - -#define jit_movr_d(rd,rs) ( (rd) == (rs) ? 0 : FMOVErr((rd),(rs))) -#define jit_movi_d(reg0,d) do { \ - double _v = (d); \ - _FBA (18, 12, 0, 1); \ - memcpy(_jit.x.uc_pc, &_v, sizeof (double)); \ - _jit.x.uc_pc += sizeof (double); \ - MFLRr (JIT_AUX); \ - jit_ldxi_d((reg0), JIT_AUX, 0); \ - } while(0) - - -#define jit_movr_f(rd,rs) ( (rd) == (rs) ? 0 : FMOVErr((rd),(rs))) -#define jit_movi_f(reg0,f) do { \ - float _v = (f); \ - _FBA (18, 8, 0, 1); \ - memcpy(_jit.x.uc_pc, &_v, sizeof (float)); \ - _jit.x.uc_pc += sizeof (float); \ - MFLRr (JIT_AUX); \ - jit_ldxi_f((reg0), JIT_AUX, 0); \ - } while(0) - - -#define jit_abs_d(rd,rs) FABSrr((rd),(rs)) -#define jit_negr_d(rd,rs) FNEGrr((rd),(rs)) -#define jit_sqrt_d(rd,rs) FSQRTDrr((rd),(rs)) - - -#define jit_ldxi_f(reg0, rs, is) (_siP(16,(is)) ? LFSrri((reg0),(rs),(is)) : (MOVEIri(JIT_AUX,(is)),LFSxrrr((reg0),(rs),JIT_AUX))) -#define jit_ldxi_d(reg0, rs, is) (_siP(16,(is)) ? LFDrri((reg0),(rs),(is)) : (MOVEIri(JIT_AUX,(is)),LFDxrrr((reg0),(rs),JIT_AUX))) -#define jit_ldxr_f(reg0, s1, s2) LFSxrrr((reg0),(s1),(s2)) -#define jit_ldxr_d(reg0, s1, s2) LFDxrrr((reg0),(s1),(s2)) -#define jit_ldi_f(reg0, is) (_siP(16,(is)) ? LFSrri((reg0),0,(is)) : (MOVEIri(JIT_AUX,(is)),LFSrri((reg0),JIT_AUX,0))) -#define jit_ldi_d(reg0, is) (_siP(16,(is)) ? LFDrri((reg0),0,(is)) : (MOVEIri(JIT_AUX,(is)),LFDrri((reg0),JIT_AUX,0))) -#define jit_ldr_f(reg0, rs) LFSrri((reg0),(rs),0) -#define jit_ldr_d(reg0, rs) LFDrri((reg0),(rs),0) -#define jit_stxi_f(id, rd, reg0) (_siP(16,(id)) ? STFSrri((reg0),(rd),(id)) : (MOVEIri(JIT_AUX,(id)),STFSrri((reg0),(rd),JIT_AUX))) -#define jit_stxi_d(id, rd, reg0) (_siP(16,(id)) ? STFDrri((reg0),(rd),(id)) : (MOVEIri(JIT_AUX,(id)),STFDrri((reg0),(rd),JIT_AUX))) -#define jit_stxr_f(d1, d2, reg0) STFSxrrr((reg0),(d1),(d2)) -#define jit_stxr_d(d1, d2, reg0) STFDxrrr((reg0),(d1),(d2)) -#define jit_sti_f(id, reg0) (_siP(16,(id)) ? STFSrri((reg0),0,(id)) : (MOVEIri(JIT_AUX,(id)),STFSrri((reg0),JIT_AUX,0))) -#define jit_sti_d(id, reg0) (_siP(16,(id)) ? STFDrri((reg0),0,(id)) : (MOVEIri(JIT_AUX,(id)),STFDrri((reg0),JIT_AUX,0))) -#define jit_str_f(rd, reg0) STFSrri((reg0),(rd),0) -#define jit_str_d(rd, reg0) STFDrri((reg0),(rd),0) - -#define jit_fpboolr(d, s1, s2, rcbit) ( \ - FCMPOrrr(_cr0,(s1),(s2)), \ - MFCRr((d)), \ - EXTRWIrrii((d), (d), 1, (rcbit))) - -#define jit_fpboolr_neg(d, s1, s2,rcbit) ( \ - FCMPOrrr(_cr0,(s1),(s2)), \ - MFCRr((d)), \ - EXTRWIrrii((d), (d), 1, (rcbit)), \ - XORIrri((d), (d), 1)) - -#define jit_fpboolur(d, s1, s2, rcbit) ( \ - FCMPUrrr(_cr0,(s1),(s2)), \ - MFCRr((d)), \ - EXTRWIrrii((d), (d), 1, (rcbit))) - -#define jit_fpboolur_neg(d, s1, s2,rcbit) ( \ - FCMPUrrr(_cr0,(s1),(s2)), \ - MFCRr((d)), \ - EXTRWIrrii((d), (d), 1, (rcbit)), \ - XORIrri((d), (d), 1)) - -#define jit_fpboolur_or(d, s1, s2, bit1, bit2) (\ - FCMPUrrr(_cr0,(s1),(s2)), \ - CRORiii((bit1), (bit1), (bit2)), \ - MFCRr((d)), \ - EXTRWIrrii((d), (d), 1, (bit1))) - -#define jit_gtr_d(d, s1, s2) jit_fpboolr ((d),(s1),(s2),_gt) -#define jit_ger_d(d, s1, s2) jit_fpboolr_neg((d),(s1),(s2),_lt) -#define jit_ltr_d(d, s1, s2) jit_fpboolr ((d),(s1),(s2),_lt) -#define jit_ler_d(d, s1, s2) jit_fpboolr_neg((d),(s1),(s2),_gt) -#define jit_eqr_d(d, s1, s2) jit_fpboolr ((d),(s1),(s2),_eq) -#define jit_ner_d(d, s1, s2) jit_fpboolr_neg((d),(s1),(s2),_eq) -#define jit_unordr_d(d, s1, s2) jit_fpboolur ((d),(s1),(s2),_un) -#define jit_ordr_d(d, s1, s2) jit_fpboolur_neg((d),(s1),(s2),_un) -#define jit_unler_d(d, s1, s2) jit_fpboolur_neg ((d), (s1), (s2), _gt) -#define jit_unltr_d(d, s1, s2) jit_fpboolur_or ((d), (s1), (s2), _un, _lt) -#define jit_unger_d(d, s1, s2) jit_fpboolur_neg ((d), (s1), (s2), _lt) -#define jit_ungtr_d(d, s1, s2) jit_fpboolur_or ((d), (s1), (s2), _un, _gt) -#define jit_ltgtr_d(d, s1, s2) jit_fpboolur_or ((d), (s1), (s2), _gt, _lt) -#define jit_uneqr_d(d, s1, s2) jit_fpboolur_or ((d), (s1), (s2), _un, _eq) - -#define jit_fpbr(d, s1, s2, rcbit) ( \ - FCMPOrrr(_cr0,(s1),(s2)), \ - BTii ((rcbit), (d)), \ - _jit.x.pc) - -#define jit_fpbr_neg(d, s1, s2,rcbit) ( \ - FCMPOrrr(_cr0,(s1),(s2)), \ - BFii ((rcbit), (d)), \ - _jit.x.pc) - -#define jit_fpbur(d, s1, s2, rcbit) ( \ - FCMPUrrr(_cr0,(s1),(s2)), \ - BTii ((rcbit), (d)), \ - _jit.x.pc) - -#define jit_fpbur_neg(d, s1, s2,rcbit) ( \ - FCMPUrrr(_cr0,(s1),(s2)), \ - BFii ((rcbit), (d)), \ - _jit.x.pc) - -#define jit_fpbur_or(d, s1, s2, bit1, bit2) ( \ - FCMPUrrr(_cr0,(s1),(s2)), \ - CRORiii((bit1), (bit1), (bit2)), \ - BTii ((bit1), (d)), \ - _jit.x.pc) - -#define jit_bgtr_d(d, s1, s2) jit_fpbr ((d),(s1),(s2),_gt) -#define jit_bger_d(d, s1, s2) jit_fpbr_neg((d),(s1),(s2),_lt) -#define jit_bltr_d(d, s1, s2) jit_fpbr ((d),(s1),(s2),_lt) -#define jit_bler_d(d, s1, s2) jit_fpbr_neg((d),(s1),(s2),_gt) -#define jit_beqr_d(d, s1, s2) jit_fpbr ((d),(s1),(s2),_eq) -#define jit_bner_d(d, s1, s2) jit_fpbr_neg((d),(s1),(s2),_eq) -#define jit_bunordr_d(d, s1, s2) jit_fpbur ((d),(s1),(s2),_un) -#define jit_bordr_d(d, s1, s2) jit_fpbur_neg((d),(s1),(s2),_un) -#define jit_bunler_d(d, s1, s2) jit_fpbur_neg ((d), (s1), (s2), _gt) -#define jit_bunltr_d(d, s1, s2) jit_fpbur_or ((d), (s1), (s2), _un, _lt) -#define jit_bunger_d(d, s1, s2) jit_fpbur_neg ((d), (s1), (s2), _lt) -#define jit_bungtr_d(d, s1, s2) jit_fpbur_or ((d), (s1), (s2), _un, _gt) -#define jit_bltgtr_d(d, s1, s2) jit_fpbur_or ((d), (s1), (s2), _gt, _lt) -#define jit_buneqr_d(d, s1, s2) jit_fpbur_or ((d), (s1), (s2), _un, _eq) - -#define jit_pusharg_d(rs) (_jitl.nextarg_putd--,jit_movr_d((_jitl.nextarg_putf+_jitl.nextarg_putd+1), (rs))) -#define jit_pusharg_f(rs) (_jitl.nextarg_putf--,jit_movr_f((_jitl.nextarg_putf+_jitl.nextarg_putd+1), (rs))) - - -#define jit_floorr_d_i(rd,rs) (MTFSFIri(7,3), \ - FCTIWrr(7,(rs)), \ - MOVEIri(JIT_AUX,-4), \ - STFIWXrrr(7,JIT_SP,JIT_AUX), \ - LWZrm((rd),-4,JIT_SP)) - -#define jit_ceilr_d_i(rd,rs) (MTFSFIri(7,2), \ - FCTIWrr(7,(rs)), \ - MOVEIri(JIT_AUX,-4), \ - STFIWXrrr(7,JIT_SP,JIT_AUX), \ - LWZrm((rd),-4,JIT_SP)) - -#define jit_roundr_d_i(rd,rs) (MTFSFIri(7,0), \ - FCTIWrr(7,(rs)), \ - MOVEIri(JIT_AUX,-4), \ - STFIWXrrr(7,JIT_SP,JIT_AUX), \ - LWZrm((rd),-4,JIT_SP)) - -#define jit_truncr_d_i(rd,rs) (FCTIWZrr(7,(rs)), \ - MOVEIri(JIT_AUX,-4), \ - STFIWXrrr(7,JIT_SP,JIT_AUX), \ - LWZrm((rd),-4,JIT_SP)) - -#endif /* __lightning_asm_h */ diff --git a/lightning/ppc/funcs.h b/lightning/ppc/funcs.h deleted file mode 100644 index 306c3fa09..000000000 --- a/lightning/ppc/funcs.h +++ /dev/null @@ -1,166 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer inline functions (PowerPC) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - -#ifndef __lightning_funcs_h -#define __lightning_funcs_h - -#include - -#if !defined(__GNUC__) && !defined(__GNUG__) -#error Go get GNU C, I do not know how to flush the cache -#error with this compiler. -#else -static void -jit_flush_code(void *start, void *end) -{ - register char *ddest, *idest; - - static int cache_line_size; - 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_size = 1; i + cache_line_size < 8192; cache_line_size <<= 1) - if (buffer[i + cache_line_size] != 0x00) - break; - } - - /* Point end to the last byte being flushed. */ - end =(void*)( (long)(end - 1)); - - start =(void*)( (long)start - (((long) start) & (cache_line_size - 1))); - end =(void*)( (long)end - (((long) end) & (cache_line_size - 1))); - - /* Force data cache write-backs */ - for (ddest = (char *) start; ddest <= (char *) end; ddest += cache_line_size) { - __asm__ __volatile__ ("dcbst 0,%0" : : "r"(ddest)); - } - __asm__ __volatile__ ("sync" : : ); - - /* Now invalidate the instruction cache */ - for (idest = (char *) start; idest <= (char *) end; idest += cache_line_size) { - __asm__ __volatile__ ("icbi 0,%0" : : "r"(idest)); - } - __asm__ __volatile__ ("isync" : : ); -} -#endif /* __GNUC__ || __GNUG__ */ - -#define _jit (*jit) - -static void -_jit_epilog(jit_state *jit) -{ - int n = _jitl.nbArgs; - int first_saved_reg = JIT_AUX - n; - int frame_size = (_jitl.frame_size + 15) & ~15; - -#ifdef __APPLE__ - LWZrm(0, frame_size + 8, 1); /* lwz r0, x+8(r1) (ret.addr.) */ -#else - LWZrm(0, frame_size + 4, 1); /* lwz r0, x+4(r1) (ret.addr.) */ -#endif - MTLRr(0); /* mtspr LR, r0 */ - - LMWrm(first_saved_reg, 24 + 32, 1); /* lmw rI, ofs(r1) */ - ADDIrri(1, 1, frame_size); /* addi r1, r1, x */ - BLR(); /* blr */ -} - -/* Emit a prolog for a function. - - The +32 in frame_size computation is to accound for the parameter area of - a function frame. - - On PPC the frame must have space to host the arguments of any callee. - However, as it currently stands, the argument to jit_trampoline (n) is - the number of arguments of the caller we generate. Therefore, the - callee can overwrite a part of the stack (saved register area) when it - flushes its own parameter on the stack. The addition of a constant - offset = 32 is enough to hold eight 4 bytes arguments. This is less - than perfect but is a reasonable work around for now. - Better solution must be investigated. */ -static void -_jit_prolog(jit_state *jit, int n) -{ - int frame_size; - int i; - int first_saved_reg = JIT_AUX - n; - int num_saved_regs = 32 - first_saved_reg; - - _jitl.nextarg_geti = JIT_AUX - 1; - _jitl.nextarg_getd = 1; - _jitl.nbArgs = n; - - MFLRr(0); - -#ifdef __APPLE__ - STWrm(0, 8, 1); /* stw r0, 8(r1) */ -#else - STWrm(0, 4, 1); /* stw r0, 4(r1) */ -#endif - - /* 0..55 -> frame data - 56..frame_size -> saved registers - - The STMW instruction is patched by jit_allocai, thus leaving - the space for the allocai above the 56 bytes. jit_allocai is - also able to reuse the slack space needed to keep the stack - quadword-aligned. */ - - _jitl.frame_size = 24 + 32 + num_saved_regs * 4; /* r27..r31 + args */ - - /* The stack must be quad-word aligned. */ - frame_size = (_jitl.frame_size + 15) & ~15; - _jitl.slack = frame_size - _jitl.frame_size; - _jitl.stwu = _jit.x.pc; - STWUrm(1, -frame_size, 1); /* stwu r1, -x(r1) */ - - STMWrm(first_saved_reg, 24 + 32, 1); /* stmw rI, ofs(r1) */ - for (i = 0; i < n; i++) - MRrr(JIT_AUX-1-i, 3+i); /* save parameters below r24 */ -} - -#undef _jit - -#endif /* __lightning_funcs_h */ diff --git a/lightning/sparc/asm.h b/lightning/sparc/asm.h deleted file mode 100644 index 87903d206..000000000 --- a/lightning/sparc/asm.h +++ /dev/null @@ -1,383 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - - - -#ifndef __lightning_asm_h -#define __lightning_asm_h - - -/* = [0-9]+ -> add i, one parameter (imm) - * = % -> add r, one parameter (imm or _Rr(imm) ) - * %g -> add r, one parameter (imm or _Rg(imm) ) - * %o -> add r, one parameter (imm+8 or _Ro(imm) ) - * %l -> add r, one parameter (imm+16 or _Rl(imm) ) - * %i -> add r, one parameter (imm+24 or _Ri(imm) ) - * = () -> add m, two parameters (reg,imm) - * = () -> add x, two parameters (reg,reg) - */ - - -typedef unsigned int jit_insn; - -#ifndef LIGHTNING_DEBUG -#define _d30(BD) (_ck_d (30, ((_jit_SL (_jit_UL (BD) - _jit_UL (_jit.x.pc))) >> 2))) -#define _d22(BD) (_ck_d (22, ((_jit_SL (_jit_UL (BD) - _jit_UL (_jit.x.pc)) >> 2)))) - -#define _HI(I) (_jit_UL(I) >> (10)) -#define _LO(I) (_jit_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) _jit_I((0<<30)| (_u5(RD)<<25)|(_u3(OP2)<<22)| _u22(IMM)) -#define _0( A, CC, OP2, DSP) _jit_I((0<<30)|(_u1(A)<<29)|(_u4(CC)<<25)|(_u3(OP2)<<22)| _d22(DSP)) -#define _0d( A, CC, OP2, DSP) _jit_I((0<<30)|(_u1(A)<<29)|(_u4(CC)<<25)|(_u3(OP2)<<22)| _u22(DSP)) - -#define _1( DSP) _jit_I((1<<30)| _d30(DSP)) - -#define _2( RD, OP3, RS1, I, ASI, RS2) _jit_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) _jit_I((2<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)| _s13(IMM)) -#define _2f(RD, OP3, RS1, OPF, RS2) _jit_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) _jit_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) _jit_I((3<<30)| (_u5(RD)<<25)|(_u6(OP3)<<19)|(_u5(RS1)<<14)|(_u1(I)<<13)| _s13(IMM)) - -#define _FP1(RD, RS1, OPF, RS2) _2f((RD), 52, (RS1), (OPF), (RS2)) -#define _FP2(RD, RS1, OPF, RS2) _2f((RD), 53, (RS1), (OPF), (RS2)) - -/* 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)) - -#define LDFSRx(RS1, RS2) _3 (0, 33, (RS1), 0, 0, (RS2)) -#define LDFSRm(RS1, IMM) _3i (0, 33, (RS1), 1, (IMM)) -#define STFSRx(RD1, RD2) _3 (0, 37, (RD1), 0, 0, (RD2)) -#define STFSRm(RD, IMM) _3i (0, 37, (RD), 1, (IMM)) - -#define FITODrr(FRS, FRD) _FP1((FRD), 0, 200, (FRS)) -#define FITOSrr(FRS, FRD) _FP1((FRD), 0, 196, (FRS)) -#define FDTOIrr(FRS, FRD) _FP1((FRD), 0, 210, (FRS)) -#define FSTOIrr(FRS, FRD) _FP1((FRD), 0, 209, (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 FMOVDrr(FRS, FRD) _FP1((FRD), 0, 2, (FRS)) -#define FNEGDrr(FRS, FRD) _FP1((FRD), 0, 6, (FRS)) -#define FABSDrr(FRS, FRD) _FP1((FRD), 0, 10, (FRS)) -#define FSQRTDrr(FRS, FRD) _FP1((FRD), 0, 42, (FRS)) -#define FSQRTSrr(FRS, FRD) _FP1((FRD), 0, 41, (FRS)) - -#define FADDSrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 65, (FRS2)) -#define FSUBSrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 69, (FRS2)) -#define FMULSrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 73, (FRS2)) -#define FDIVSrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 77, (FRS2)) - -#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), 74, (FRS2)) -#define FDIVDrrr(FRS1, FRS2, FRD) _FP1((FRD), (FRS1), 78, (FRS2)) - -#define FCMPSrr(FRS1, FRS2) _FP2(0, (FRS1), 81, (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)) - -#endif -#endif /* __ccg_asm_sparc_h */ diff --git a/lightning/sparc/core.h b/lightning/sparc/core.h deleted file mode 100644 index da088893e..000000000 --- a/lightning/sparc/core.h +++ /dev/null @@ -1,323 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Platform-independent layer (SPARC version) - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2006 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - -#ifndef __lightning_core_h -#define __lightning_core_h - -#define JIT_R_NUM 3 -#define JIT_V_NUM 8 - -#define JIT_R(i) _Rg(2 + (i)) -#define JIT_V(i) _Rl(i) - -#define JIT_BIG _Rg(1) /* %g1 used to make 32-bit operands */ -#define JIT_BIG2 _Ro(7) /* %o7 used to make 32-bit compare operands */ -#define JIT_SP _Ro(6) -#define JIT_FP _Ri(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.x.pc - * insn X X before - * cmp branch insn X X after (branch) - * `--- _jit.x.pc - * call insn insn X after (call) - * `--- _jit.x.pc - */ - - -/* Implementation of `allocai', `pushr' and `popr'. - * - * The SysV ABI for SPARC is specified in "System V Application Binary - * Interface, SPARC Processor Supplement, Third Edition", available from - * http://www.sparc.org/resource.htm . - * - * According to the SysV ABI specs: "At all times the stack pointer must - * point to a doubleword aligned, 16- word window save area." (p 3-12). The - * stack layout is shown in Figure 3-16 and the layout of a C stack frame is - * given in Figure 3-47: the area between %sp and %sp+104 is reserved for - * specific purposes, and automatic variables go between %sp+104 and %fp and - * are typically addressed using negative offsets relative to %fp. - * - * Stack space may be allocated dynamically as decribed in Section - * "Allocating Stack Space Dynamically", p. 3-36, and shown in Figure 3-49. - * `allocai' is implemented by patching a function prolog's `save' - * instruction in order to increase the initial frame size. `pushr' is - * implemented by storing register into a fixed-size region right below %fp - * (thereby limiting the number of registers that may be pushed). - * - * Thus, %fp to %fp - JIT_SPARC_MAX_STACK_REGISTER_AREA is reserved for - * pushed registers, and %fp - JIT_SPARC_MAX_STACK_REGISTER_AREA and below is - * used for the memory allocated via `allocai'. */ - - -struct jit_local_state { - int nextarg_put; /* Next %o reg. to be written */ - int nextarg_get; /* Next %i reg. to be read */ - - jit_insn *save; /* Pointer to the `save' instruction */ - unsigned frame_size; /* Current frame size as allocated by `save' */ - int alloca_offset; /* Current offset to the alloca'd memory (negative - offset relative to %fp) */ - jit_insn delay; -}; - -#define JIT_SPARC_MAX_STACK_REGISTER_AREA 0 - -/* Minimum size of a stack frame. */ -#define JIT_SPARC_MIN_FRAME_SIZE (104 + JIT_SPARC_MAX_STACK_REGISTER_AREA) - - -/* Round AMOUNT to the closest higher multiple of 2^ALIGNMENT. */ -#define _jit_round(alignment, amount) \ - (((amount) & (_MASK (alignment))) \ - ? (((amount) & (~_MASK (alignment))) + (1 << (alignment))) \ - : (amount)) - -/* Patch a `save' instruction (with immediate operand) so that it increases - %sp by AMOUNT. AMOUNT is rounded so that %sp remains 8-octet aligned. */ -#define jit_patch_save(amount) \ - (* (_jitl).save &= ~_MASK (13), \ - * (_jitl).save |= _ck_d (13, -_jit_round (3, amount))) - -/* Allocate AMOUNT octets on the frame by patching the `save' instruction. */ -#define jit_allocai(amount) \ - (jit_patch_save ((_jitl).frame_size + (amount)), \ - (_jitl).frame_size += (amount), \ - (_jitl).alloca_offset -= (amount), \ - (_jitl).alloca_offset) - -#define jit_fill_delay_after(branch) (_jitl.delay = *--_jit.x.pc, \ - ((branch) == _jit.x.pc /* check if NOP was inserted */ \ - ? (_jit.x.pc[-1] ^= 1<<29) /* no if branch, toggle annul bit */ \ - : (_jit.x.pc[-1] = _jitl.delay)), /* yes if call, replace NOP with delay insn */ \ - *_jit.x.pc = _jitl.delay, _jit.x.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.x.pc - 1) -#define jit_branchr(s1, s2, jmp, nop) ( CMPrr(s1, s2), jmp, nop, _jit.x.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.x.pc -= jit_immsize(is)) -#define jit_clr_y(rs, is) ( WRri(0, _y), NOP(), NOP(), NOP(), _jit.x.pc -= jit_immsize(is)) - -#define jit_modr(jit_div, jit_mul, d, s1, s2) \ - (jit_div (JIT_BIG, s1, s2), \ - jit_mul (JIT_BIG, JIT_BIG, s2), \ - jit_subr_i (d, s1, JIT_BIG)) - -#define jit_modi(jit_divi, jit_muli, jit_divr, jit_mulr, d, rs, is) \ - (_siP(13,(is)) \ - ? (jit_divi (JIT_BIG, rs, is), \ - jit_muli (JIT_BIG, JIT_BIG, is), \ - jit_subr_i (d, rs, JIT_BIG)) \ - : (SETir ((is), JIT_BIG2), \ - jit_modr (jit_divr, jit_mulr, d, rs, JIT_BIG2))) - -/* How many instruction are needed to put imm in a register. */ -#define jit_immsize(imm) (!(imm) ? 0 : \ - (!_siP(13,(imm)) && ((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,pv) \ - (*jump_pc &= ~_MASK(22), \ - *jump_pc |= ((_jit_UL((pv)) - _jit_UL(jump_pc)) >> 2) & _MASK(22)) - -#define jit_patch_set(sethi_pc, or_pc, dest) \ - (*(sethi_pc) &= ~_MASK(22), *(sethi_pc) |= _HI(dest), \ - *(or_pc) &= ~_MASK(13), *(or_pc) |= _LO(dest)) \ - -#define jit_patch_movi(movi_pc, val) \ - jit_patch_set((movi_pc) - 2, (movi_pc) - 1, (val)) - -#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.x.pc - 1) -#define jit_bmci_i(label, rs, is) (jit_chk_imm((is), BTSTir((is), (rs)), BTSTrr((rs), JIT_BIG)), BEi((label)), NOP(), _jit.x.pc - 1) -#define jit_bmsr_i(label, s1, s2) ( BTSTrr((s1), (s2)), BNEi((label)), NOP(), _jit.x.pc - 1) -#define jit_bmcr_i(label, s1, s2) ( BTSTrr((s1), (s2)), BEi((label)), NOP(), _jit.x.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.x.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.x.pc - 1) -#define jit_boaddr_i(label, s1, s2) ( ADDCCrrr((s1), (s2), (s1)), BVSi((label)), NOP(), _jit.x.pc - 1) -#define jit_bosubr_i(label, s1, s2) ( SUBCCrrr((s1), (s2), (s1)), BVSi((label)), NOP(), _jit.x.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.x.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.x.pc - 1) -#define jit_boaddr_ui(label, s1, s2) ( ADDCCrrr((s1), (s2), (s1)), BCSi((label)), NOP(), _jit.x.pc - 1) -#define jit_bosubr_ui(label, s1, s2) ( SUBCCrrr((s1), (s2), (s1)), BCSi((label)), NOP(), _jit.x.pc - 1) -#define jit_calli(label) (CALLi(label), NOP(), _jit.x.pc - 1) -#define jit_callr(reg) (CALLx((reg), 0), NOP()) - -#define jit_divi_i(d, rs, is) (jit_prepare_y((rs), 0x12345678), SETir((is), JIT_BIG), SDIVrrr((rs), JIT_BIG, (d)) ) -#define jit_divi_ui(d, rs, is) (jit_clr_y((rs), 0x12345678), SETir((is), JIT_BIG), UDIVrrr((rs), JIT_BIG, (d)) ) -#define jit_divr_i(d, s1, s2) (jit_prepare_y((s1), 0), SDIVrrr((s1), (s2), (d))) -#define jit_divr_ui(d, s1, s2) (jit_clr_y((s1), 0), 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.x.pc + 3) ) -#define jit_gei_ui(d, rs, is) jit_booli ((d), (rs), (is), BGEUi(_jit.x.pc + 3)) -#define jit_ger_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BGEi(_jit.x.pc + 3) ) -#define jit_ger_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BGEUi(_jit.x.pc + 3)) -#define jit_gti_i(d, rs, is) jit_booli ((d), (rs), (is), BGi(_jit.x.pc + 3) ) -#define jit_gti_ui(d, rs, is) jit_booli ((d), (rs), (is), BGUi(_jit.x.pc + 3) ) -#define jit_gtr_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BGi(_jit.x.pc + 3) ) -#define jit_gtr_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BGUi(_jit.x.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.x.pc) -#define jit_jmpr(reg) (JMPx(JIT_RZERO, (reg)), NOP(), _jit.x.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.x.pc + 3) ) -#define jit_lei_ui(d, rs, is) jit_booli ((d), (rs), (is), BLEUi(_jit.x.pc + 3)) -#define jit_ler_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BLEi(_jit.x.pc + 3) ) -#define jit_ler_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BLEUi(_jit.x.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.x.pc + 3) ) -#define jit_lti_ui(d, rs, is) jit_booli ((d), (rs), (is), BLUi(_jit.x.pc + 3) ) -#define jit_ltr_i(d, s1, s2) jit_boolr ((d), (s1), (s2), BLi(_jit.x.pc + 3) ) -#define jit_ltr_ui(d, s1, s2) jit_boolr ((d), (s1), (s2), BLUi(_jit.x.pc + 3) ) -#define jit_modi_i(d, rs, is) jit_modi(jit_divi_i, jit_muli_i, jit_divr_i, jit_mulr_i, (d), (rs), (is)) -#define jit_modi_ui(d, rs, is) jit_modi(jit_divi_ui, jit_muli_ui, jit_divr_ui, jit_mulr_ui, (d), (rs), (is)) -#define jit_modr_i(d, s1, s2) jit_modr(jit_divr_i, jit_mulr_i, (d), (s1), (s2)) -#define jit_modr_ui(d, s1, s2) jit_modr(jit_divr_ui, jit_mulr_ui, (d), (s1), (s2)) -#define jit_movi_i(d, is) SETir((is), (d)) -#define jit_movi_p(d, is) (SETir2(_HI((is)), _LO((is)), (d)), _jit.x.pc) -#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_at(delay_pc, pv) jit_patch_ (((delay_pc) - 1) , (pv)) -#define jit_prepare_i(num) (_jitl.nextarg_put += (num)) -#define jit_prolog(numargs) (_jitl.save = (jit_insn *) _jit.x.pc, SAVErir (JIT_SP, -JIT_SPARC_MIN_FRAME_SIZE, JIT_SP), _jitl.frame_size = JIT_SPARC_MIN_FRAME_SIZE, _jitl.alloca_offset = -JIT_SPARC_MAX_STACK_REGISTER_AREA, _jitl.nextarg_get = _Ri(0), 0) - -#define jit_pusharg_i(rs) (--_jitl.nextarg_put, MOVrr((rs), _Ro(_jitl.nextarg_put))) -#define jit_ret() (RET(), RESTORE()) -#define jit_retval_i(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 */ diff --git a/lightning/sparc/fp.h b/lightning/sparc/fp.h deleted file mode 100644 index bdfc626d0..000000000 --- a/lightning/sparc/fp.h +++ /dev/null @@ -1,252 +0,0 @@ -/******************************** -*- C -*- **************************** - * - * Run-time assembler & support macros for the SPARC math unit - * - ***********************************************************************/ - - -/*********************************************************************** - * - * Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc. - * Written by Paolo Bonzini. - * - * This file is part of GNU lightning. - * - * GNU lightning is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - - -#ifndef __lightning_asm_fp_h -#define __lightning_asm_fp_h - -#include - -#define JIT_FPR_NUM 6 -#define JIT_FPRET 0 -#define JIT_FPR(i) (30-(i)*2) -#define JIT_FPTMP 18 - -#define jit_addr_f(rd,s1,s2) FADDSrrr((s1), (s2), (rd)) -#define jit_subr_f(rd,s1,s2) FSUBSrrr((s1), (s2), (rd)) -#define jit_mulr_f(rd,s1,s2) FMULSrrr((s1), (s2), (rd)) -#define jit_divr_f(rd,s1,s2) FDIVSrrr((s1), (s2), (rd)) - -#define jit_addr_d(rd,s1,s2) FADDDrrr((s1), (s2), (rd)) -#define jit_subr_d(rd,s1,s2) FSUBDrrr((s1), (s2), (rd)) -#define jit_mulr_d(rd,s1,s2) FMULDrrr((s1), (s2), (rd)) -#define jit_divr_d(rd,s1,s2) FDIVDrrr((s1), (s2), (rd)) - -#define jit_movr_f(rd,rs) FMOVSrr((rs), (rd)) -#define jit_abs_d(rd,rs) FABSSrr((rs), (rd)) -#define jit_negr_d(rd,rs) FNEGSrr((rs), (rd)) -#define jit_sqrt_d(rd,rs) FSQRTSrr((rs), (rd)) -#define jit_movr_d(rd,rs) FMOVDrr((rs), (rd)) -#define jit_abs_f(rd,rs) FABSDrr((rs), (rd)) -#define jit_negr_f(rd,rs) FNEGDrr((rs), (rd)) -#define jit_sqrt_f(rd,rs) FSQRTDrr((rs), (rd)) -#define jit_extr_f_d(rd, rs) FSTODrr((rs), (rd)) -#define jit_extr_d_f(rd, rs) FDTOSrr((rs), (rd)) - -#define jit_movi_f(rd,immf) \ - do { \ - float _v = (immf); \ - _1(_jit.x.pc + 3), LDFmr(_Ro(7), 8, (rd)); \ - memcpy(_jit.x.uc_pc, &_v, sizeof (float)); \ - _jit.x.uc_pc += sizeof (float); \ - } while(0) - -#define jit_movi_d(rd,immd) \ - do { \ - double _v = (immd); \ - if ((long)_jit.x.pc & 4) NOP(); \ - _1(_jit.x.pc + 4); \ - LDDFmr(_Ro(7), 8, (rd)); \ - memcpy(_jit.x.uc_pc, &_v, sizeof (double)); \ - _jit.x.uc_pc += sizeof (double); \ - } while(0) - - -#define jit_ldxi_f(rd, rs, is) jit_chk_imm((is), LDFmr((rs), (is), (rd)), LDFxr((rs), JIT_BIG, (rd))) -#define jit_ldxi_d(rd, rs, is) jit_chk_imm((is), LDDFmr((rs), (is), (rd)), LDDFxr((rs), JIT_BIG, (rd))) -#define jit_ldxr_f(rd, s1, s2) LDFxr((s1), (s2), (rd)) -#define jit_ldxr_d(rd, s1, s2) LDDFxr((s1), (s2), (rd)) -#define jit_stxi_f(id, rd, rs) jit_chk_imm((id), STFrm((rs), (rd), (id)), STFrx((rs), (rd), JIT_BIG)) -#define jit_stxi_d(id, rd, rs) jit_chk_imm((id), STDFrm((rs), (rd), (id)), STDFrx((rs), (rd), JIT_BIG)) -#define jit_stxr_f(d1, d2, rs) STFrx((rs), (d1), (d2)) -#define jit_stxr_d(d1, d2, rs) STDFrx((rs), (d1), (d2)) - -#define jit_truncr_f_i(rd, rs) ( \ - _1(_jit.x.pc + 3), \ - FSTOIrr((rs), JIT_FPTMP), \ - NOP(), \ - STFrm(JIT_FPTMP, _Ro(7), 8), \ - LDmr(_Ro(7), 8, (rd))) - -#define jit_truncr_d_i(rd, rs) ( \ - _1(_jit.x.pc + 3), \ - FDTOIrr((rs), JIT_FPTMP), \ - NOP(), \ - STFrm(JIT_FPTMP, _Ro(7), 8), \ - LDmr(_Ro(7), 8, (rd))) - -#define jit_extr_i_d(rd, rs) (_1 (_jit.x.pc + 3), NOP(), NOP(), STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITODrr((rd), (rd))) -#define jit_extr_i_f(rd, rs) (_1 (_jit.x.pc + 3), NOP(), NOP(), STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITOSrr((rd), (rd))) - -#define jit_do_round_f(rd, rs, fixup, mode) do { \ - jit_movi_f (JIT_FPTMP, fixup); \ - _1(_jit.x.pc + 4); \ - SETHIir(_HI(mode << 29), JIT_BIG); \ - NOP(); \ - 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), 12); \ - LDFSRm(_Ro(7), 12); /* load fsr */ \ - FADDSrrr ((rs), JIT_FPTMP, JIT_FPTMP); \ - LDFSRm(_Ro(7), 8); \ - FSTOIrr(JIT_FPTMP, JIT_FPTMP); \ - STFrm(JIT_FPTMP, _Ro(7), 8); \ - LDmr(_Ro(7), 8, (rd)); \ - ADDCCrrr ((rd), (rd), 0); \ - SUBXrrr ((rd), 0, (rd)); \ - } while (0); - -#define jit_do_round_d(rd, rs, fixup, mode) do { \ - jit_movi_d (JIT_FPTMP, fixup); \ - _1(_jit.x.pc + 4); \ - SETHIir(_HI(mode << 29), JIT_BIG); \ - NOP(); \ - 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), 12); \ - LDFSRm(_Ro(7), 12); /* load fsr */ \ - FADDDrrr ((rs), JIT_FPTMP, JIT_FPTMP); \ - LDFSRm(_Ro(7), 8); \ - FDTOIrr(JIT_FPTMP, JIT_FPTMP); \ - STFrm(JIT_FPTMP, _Ro(7), 8); \ - LDmr(_Ro(7), 8, (rd)); \ - ADDCCrrr ((rd), (rd), 0); \ - SUBXrrr ((rd), 0, (rd)); \ - } while (0); - -#define jit_roundr_f_i(rd, rs) do { \ - jit_movi_f (JIT_FPTMP, 0.5); \ - FADDSrrr ((rs), JIT_FPTMP, JIT_FPTMP); \ - jit_truncr_f_i ((rd), JIT_FPTMP); \ - ADDCCrrr ((rd), (rd), 0); \ - SUBXrrr ((rd), 0, (rd)); \ - } while (0) - -#define jit_roundr_d_i(rd, rs) do { \ - jit_movi_d (JIT_FPTMP, 0.5); \ - FADDDrrr ((rs), JIT_FPTMP, JIT_FPTMP); \ - jit_truncr_d_i ((rd), JIT_FPTMP); \ - ADDCCrrr ((rd), (rd), 0); \ - SUBXrrr ((rd), 0, (rd)); \ - } while (0) - -#define jit_ceilr_f_i(rd, rs) \ - jit_do_round_f ((rd), (rs), 1.0f - FLT_EPSILON, 3) - -#define jit_ceilr_d_i(rd, rs) \ - jit_do_round_d ((rd), (rs), 1.0 - DBL_EPSILON, 3) - -#define jit_floorr_f_i(rd, rs) \ - jit_do_round_f ((rd), (rs), FLT_EPSILON, 2) - -#define jit_floorr_d_i(rd, rs) \ - jit_do_round_d ((rd), (rs), DBL_EPSILON, 2) - -#define jit_ltr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBLi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ltr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBLi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ler_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBLEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ler_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBLEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_eqr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_eqr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ner_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBNEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ner_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBNEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ger_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBGEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ger_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBGEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_gtr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_gtr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unltr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBULi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unltr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBULi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unler_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBULEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unler_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBULEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_uneqr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBUEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_uneqr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBUEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ltgtr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBLGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ltgtr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBLGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unger_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBUGEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unger_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBUGEi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ungtr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBUGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ungtr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBUGi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ordr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBOi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_ordr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBOi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unordr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBUi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) -#define jit_unordr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBUi(_jit.x.pc + 3), MOVir (1, (d)), MOVir (0, (d))) - -#define jit_branchr_f(s1, s2, jmp) (FCMPSrr(s1, s2), jmp, NOP(), _jit.x.pc - 1) -#define jit_branchr_d(s1, s2, jmp) (FCMPDrr(s1, s2), jmp, NOP(), _jit.x.pc - 1) - -#define jit_bltr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBLi((label))) -#define jit_bltr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBLi((label))) -#define jit_bler_d(label, s1, s2) jit_branchr_d((s1), (s2), FBLEi((label))) -#define jit_bler_f(label, s1, s2) jit_branchr_f((s1), (s2), FBLEi((label))) -#define jit_beqr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBEi((label))) -#define jit_beqr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBEi((label))) -#define jit_bner_d(label, s1, s2) jit_branchr_d((s1), (s2), FBNEi((label))) -#define jit_bner_f(label, s1, s2) jit_branchr_f((s1), (s2), FBNEi((label))) -#define jit_bger_d(label, s1, s2) jit_branchr_d((s1), (s2), FBGEi((label))) -#define jit_bger_f(label, s1, s2) jit_branchr_f((s1), (s2), FBGEi((label))) -#define jit_bgtr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBGi((label))) -#define jit_bgtr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBGi((label))) -#define jit_bunltr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBULi((label))) -#define jit_bunltr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBULi((label))) -#define jit_bunler_d(label, s1, s2) jit_branchr_d((s1), (s2), FBULEi((label))) -#define jit_bunler_f(label, s1, s2) jit_branchr_f((s1), (s2), FBULEi((label))) -#define jit_buneqr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBUEi((label))) -#define jit_buneqr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBUEi((label))) -#define jit_bltgtr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBLGi((label))) -#define jit_bltgtr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBLGi((label))) -#define jit_bunger_d(label, s1, s2) jit_branchr_d((s1), (s2), FBUGEi((label))) -#define jit_bunger_f(label, s1, s2) jit_branchr_f((s1), (s2), FBUGEi((label))) -#define jit_bungtr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBUGi((label))) -#define jit_bungtr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBUGi((label))) -#define jit_bordr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBOi((label))) -#define jit_bordr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBOi((label))) -#define jit_bunordr_d(label, s1, s2) jit_branchr_d((s1), (s2), FBUi((label))) -#define jit_bunordr_f(label, s1, s2) jit_branchr_f((s1), (s2), FBUi((label))) - -#define jit_prepare_f(num) (_jitl.nextarg_put += (num)) -#define jit_prepare_d(num) (_jitl.nextarg_put += 2 * (num)) - -#define jit_arg_f() (_jitl.nextarg_get++) -#define jit_arg_d() (_jitl.nextarg_get += _jitl.nextarg_get & 1, _jitl.nextarg_get += 2, _jitl.nextarg_get - 2) - -#define jit_getarg_f(rd, ofs) (STrm(ofs, _Ri(6), -24), LDFmr (_Ri(6), -24, (rd))) -#define jit_getarg_d(rd, ofs) (STDrm(ofs, _Ri(6), -24), LDDFmr (_Ri(6), -24, (rd))) - -#define jit_pusharg_f(rs) (STFrm((rs), _Ri(6), -24), --_jitl.nextarg_put, LDmr (_Ri(6), -24, _Ro(_jitl.nextarg_put))) -#define jit_pusharg_d(rs) (STDFrm((rs), _Ri(6), -24), _jitl.nextarg_put -= 2, LDmr (_Ri(6), -24, _Ro(_jitl.nextarg_put))) - -#endif /* __lightning_asm_fp_h */ diff --git a/lightning/sparc/funcs.h b/lightning/sparc/funcs.h deleted file mode 100644 index 68079b9e5..000000000 --- a/lightning/sparc/funcs.h +++ /dev/null @@ -1,63 +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 3, or (at your option) - * any later version. - * - * GNU lightning is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GNU lightning; see the file COPYING.LESSER; if not, write to the - * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - ***********************************************************************/ - - - -#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) -{ - 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 /* __lightning_core_h */