Back to index

plt-scheme  4.2.1
core.h
Go to the documentation of this file.
00001 /******************************** -*- C -*- ****************************
00002  *
00003  *     Platform-independent layer (PowerPC version)
00004  *
00005  ***********************************************************************/
00006 
00007 
00008 /***********************************************************************
00009  *
00010  * Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
00011  * Written by Paolo Bonzini.
00012  *
00013  * This file is part of GNU lightning.
00014  *
00015  * GNU lightning is free software; you can redistribute it and/or modify it
00016  * under the terms of the GNU Lesser General Public License as published
00017  * by the Free Software Foundation; either version 2.1, or (at your option)
00018  * any later version.
00019  * 
00020  * GNU lightning is distributed in the hope that it will be useful, but 
00021  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00022  * or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00023  * License for more details.
00024  * 
00025  * You should have received a copy of the GNU Lesser General Public License
00026  * along with GNU lightning; see the file COPYING.LESSER; if not, write to the
00027  * Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00028  * MA 02111-1307, USA.
00029  *
00030  ***********************************************************************/
00031 
00032 
00033 
00034 
00035 #ifndef __lightning_core_h
00036 #define __lightning_core_h
00037 
00038 struct jit_local_state {
00039    int nextarg_puti;  /* number of integer args */
00040    int nextarg_putf;  /* number of float args   */
00041    int nextarg_putd;  /* number of double args  */
00042    int nextarg_geti;  /* Next r20-r25 reg. to be read */
00043    int nextarg_getd;  /* The FP args are picked up from FPR1 -> FPR10 */
00044    int  nbArgs;        /* Number of arguments for the prolog */
00045    int long_jumps;    /* 1 => patch or leave room for long jumps */
00046 };
00047 
00048 #define JIT_SP                     1
00049 #define JIT_RET                    3
00050 #define JIT_R_NUM           3
00051 #define JIT_V_NUM           7
00052 #define JIT_R(i)            (9+(i))
00053 #define JIT_V(i)            (31-(i))
00054 #define JIT_AUX                    JIT_V(JIT_V_NUM)  /* for 32-bit operands & shift counts */
00055 
00056 #define jit_pfx_start()   (_jit.jitl.trampolines)
00057 #define jit_pfx_end()     (_jit.jitl.free)
00058 
00059 /* If possible, use the `small' instruction (rd, rs, imm)
00060  * else load imm into r26 and use the `big' instruction (rd, rs, r26)
00061  */
00062 #define jit_chk_ims(imm, small, big)             (_siP(16,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm),  (big)) )
00063 #define jit_chk_imu(imm, small, big)             (_uiP(16,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm),  (big)) )
00064 #define jit_chk_imu15(imm, small, big)           (_uiP(15,(imm)) ? (small) : (MOVEIri(JIT_AUX, imm),  (big)) )
00065 
00066 #define jit_big_ims(imm, big)                     (MOVEIri(JIT_AUX, imm),  (big))
00067 #define jit_big_imu(imm, big)                     (MOVEIri(JIT_AUX, imm),  (big))
00068 
00069 /* Helper macros for branches */
00070 #define jit_s_brai(rs, is, jmp)                  (jit_chk_ims (is, CMPWIri(rs, is), CMPWrr(rs, JIT_AUX)),   jmp, _jit.x.pc)
00071 #define jit_s_brar(s1, s2, jmp)                  (               CMPWrr(s1, s2),                      jmp, _jit.x.pc)
00072 #define jit_u_brai(rs, is, jmp)                  (jit_chk_imu (is, CMPLWIri(rs, is), CMPLWrr(rs, JIT_AUX)), jmp, _jit.x.pc)
00073 #define jit_u_brar(s1, s2, jmp)                  (               CMPLWrr(s1, s2),                     jmp, _jit.x.pc)
00074 
00075 /* Helper macros for boolean tests. */
00076 #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)))
00077 #define jit_sboolr(d, s1, s2, jmp)        (               CMPWrr  (s1, s2),                    MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
00078 #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))
00079 #define jit_sboolr2(d, s1, s2, jmp)              (               CMPWrr  (s1, s2),                    MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
00080 #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)))
00081 #define jit_uboolr(d, s1, s2, jmp)        (               CMPLWrr (s1, s2),                    MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)))
00082 #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))
00083 #define jit_uboolr2(d, s1, s2, jmp)              (               CMPLWrr (s1, s2),                    MFCRr((d)), EXTRWIrrii((d), (d), 1, (jmp)), XORIrri((d), (d), 1))
00084 
00085 /* modulus with immediate
00086  * movei r26, imm
00087  * mtlr  r31
00088  * divw  r31, rs, r26              (or divwu)
00089  * mullw r31, r31, r26
00090  * sub   rs, rs, r26
00091  * mflr  r31
00092  */
00093 
00094 #define _jit_mod(div, rs, imm)                   (MOVEIri(JIT_AUX, (imm)), MTLRr(31), (div), \
00095                                           MULLWrrr(31, 31, JIT_AUX), SUBrrr((rs), (rs), JIT_AUX), \
00096                                           MFLRr(31))
00097 
00098 /* Patch a movei instruction made of a LIS at lis_pc and an ORI at ori_pc. */
00099 #define jit_patch_movei(lis_pc, ori_pc, dest)                  \
00100        (*(lis_pc) &= ~_MASK(16), *(lis_pc) |= _HI(dest),              \
00101         *(ori_pc) &= ~_MASK(16), *(ori_pc) |= _LO(dest))              \
00102 
00103 /* Patch a branch instruction */
00104 #define jit_patch_branch(jump_pc,pv)                           \
00105        (*(jump_pc) &= ~_MASK(16) | 3,                          \
00106         *(jump_pc) |= (_jit_UL(pv) - _jit_UL(jump_pc)) & _MASK(16))
00107 
00108 #define jit_patch_ucbranch(jump_pc,pv)                          \
00109          (*(jump_pc) &= ~_MASK(26) | 3,                         \
00110          (*(jump_pc) |= (_jit_UL((pv)) - _jit_UL(jump_pc)) & _MASK(26)))
00111 
00112 #define _jit_b_encoding            (18 << 26)
00113 #define _jit_blr_encoding   ((19 << 26) | (20 << 21) | (00 << 16) | (00 << 11) | (16 << 1))
00114 #define _jit_is_ucbranch(a)     (((*(a) & (63<<26)) == _jit_b_encoding))
00115 
00116 #define jit_patch_at(jump_pc, value) (                         \
00117        ((*(jump_pc - 1) & ~1) == _jit_blr_encoding)            \
00118          ? jit_patch_movei(((jump_pc) - 4), ((jump_pc) - 3), (value)) \
00119          : ( _jit_is_ucbranch((jump_pc) - 1)                   \
00120              ? jit_patch_ucbranch((jump_pc) - 1, (value))       \
00121              : jit_patch_branch((jump_pc) - 1, (value))))
00122 
00123 #define jit_patch_movi(movi_pc, val)                                  \
00124        jit_patch_movei((movi_pc) - 2, (movi_pc) - 1, (val))
00125 
00126 #define       jit_arg_c()                 (_jitl.nextarg_geti++)
00127 #define       jit_arg_i()                 (_jitl.nextarg_geti++)
00128 #define       jit_arg_l()                 (_jitl.nextarg_geti++)
00129 #define       jit_arg_p()                 (_jitl.nextarg_geti++)
00130 #define       jit_arg_s()                 (_jitl.nextarg_geti++)
00131 #define       jit_arg_uc()                (_jitl.nextarg_geti++)
00132 #define       jit_arg_ui()                (_jitl.nextarg_geti++)
00133 #define       jit_arg_ul()                (_jitl.nextarg_geti++)
00134 #define       jit_arg_us()                (_jitl.nextarg_geti++)
00135 
00136 /* Check Mach-O-Runtime documentation: Must skip GPR(s) whenever "corresponding" FPR is used */
00137 #define jit_arg_f()                    (_jitl.nextarg_geti-- ,_jitl.nextarg_getd++)
00138 #define jit_arg_d()                    (_jitl.nextarg_geti-=2,_jitl.nextarg_getd++)
00139 
00140 #define jit_addi_i(d, rs, is)             jit_chk_ims((is), ADDICrri((d), (rs), (is)), ADDrrr((d), (rs), JIT_AUX))
00141 #define jit_addr_i(d, s1, s2)                             ADDrrr((d), (s1), (s2))
00142 #define jit_addci_i(d, rs, is)            jit_chk_ims((is), ADDICrri((d), (rs), (is)), ADDCrrr((d), (rs), JIT_AUX))
00143 #define jit_addcr_i(d, s1, s2)                            ADDCrrr((d), (s1), (s2))
00144 #define jit_addxi_i(d, rs, is)            (MOVEIri(JIT_AUX, (is)), ADDErrr((d), (rs), JIT_AUX))
00145 #define jit_addxr_i(d, s1, s2)                                   ADDErrr((d), (s1), (s2))
00146 #define jit_andi_i(d, rs, is)             jit_chk_imu((is), ANDI_rri((d), (rs), (is)), ANDrrr((d), (rs), JIT_AUX))
00147 #define jit_andr_i(d, s1, s2)                             ANDrrr((d), (s1), (s2))
00148 #define jit_bmsi_i(label, rs, is)  (jit_chk_imu((is), ANDI_rri(JIT_AUX, (rs), (is)), AND_rrr(JIT_AUX, (rs), JIT_AUX)), BGTi((label)), _jit.x.pc)
00149 #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)
00150 #define jit_bmsr_i(label, s1, s2)  (                AND_rrr(JIT_AUX, (s1), (s2)),                            BGTi((label)), _jit.x.pc)
00151 #define jit_bmcr_i(label, s1, s2)  (                AND_rrr(JIT_AUX, (s1), (s2)),                            BEQi((label)), _jit.x.pc)
00152 #define jit_beqi_i(label, rs, is)  jit_s_brai((rs), (is), BEQi((label)) )
00153 #define jit_beqr_i(label, s1, s2)  jit_s_brar((s1), (s2), BEQi((label)) )
00154 #define jit_bgei_i(label, rs, is)  jit_s_brai((rs), (is), BGEi((label)) )
00155 #define jit_bgei_ui(label, rs, is) jit_u_brai((rs), (is), BGEi((label)) )
00156 #define jit_bger_i(label, s1, s2)  jit_s_brar((s1), (s2), BGEi((label)) )
00157 #define jit_bger_ui(label, s1, s2) jit_u_brar((s1), (s2), BGEi((label)) )
00158 #define jit_bgti_i(label, rs, is)  jit_s_brai((rs), (is), BGTi((label)) )
00159 #define jit_bgti_ui(label, rs, is) jit_u_brai((rs), (is), BGTi((label)) )
00160 #define jit_bgtr_i(label, s1, s2)  jit_s_brar((s1), (s2), BGTi((label)) )
00161 #define jit_bgtr_ui(label, s1, s2) jit_u_brar((s1), (s2), BGTi((label)) )
00162 #define jit_blei_i(label, rs, is)  jit_s_brai((rs), (is), BLEi((label)) )
00163 #define jit_blei_ui(label, rs, is) jit_u_brai((rs), (is), BLEi((label)) )
00164 #define jit_bler_i(label, s1, s2)  jit_s_brar((s1), (s2), BLEi((label)) )
00165 #define jit_bler_ui(label, s1, s2) jit_u_brar((s1), (s2), BLEi((label)) )
00166 #define jit_blti_i(label, rs, is)  jit_s_brai((rs), (is), BLTi((label)) )
00167 #define jit_blti_ui(label, rs, is) jit_u_brai((rs), (is), BLTi((label)) )
00168 #define jit_bltr_i(label, s1, s2)  jit_s_brar((s1), (s2), BLTi((label)) )
00169 #define jit_bltr_ui(label, s1, s2) jit_u_brar((s1), (s2), BLTi((label)) )
00170 #define jit_bnei_i(label, rs, is)  jit_s_brai((rs), (is), BNEi((label)) )
00171 #define jit_bner_i(label, s1, s2)  jit_s_brar((s1), (s2), BNEi((label)) )
00172 #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 */
00173 #define jit_bosubi_i(label, rs, is)       (MOVEIri(JIT_AUX, (is)), SUBCOrrr((rs), (rs), JIT_AUX), MCRXRi(0), BGTi((label)), _jit.x.pc)
00174 #define jit_boaddr_i(label, s1, s2)       (                      ADDOrrr((s1), (s1), (s2)),          MCRXRi(0), BGTi((label)), _jit.x.pc)
00175 #define jit_bosubr_i(label, s1, s2)       (                     SUBCOrrr((s1), (s1), (s2)),          MCRXRi(0), BGTi((label)), _jit.x.pc)
00176 #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 */
00177 #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)
00178 #define jit_boaddr_ui(label, s1, s2)      (                                       ADDCrr((s1), (s1), (s2)),        MCRXRi(0), BEQi((label)), _jit.x.pc)
00179 #define jit_bosubr_ui(label, s1, s2)      (                                       SUBCrr((s1), (s1), (s2)),        MCRXRi(0), BEQi((label)), _jit.x.pc)
00180 #define jit_bomulr_i(label, s1, s2)       (                      MULLWOrrr((s1), (s1), (s2)),        MCRXRi(0), BGTi((label)), _jit.x.pc)
00181 #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)
00182 #define jit_callr(reg)                    (MTCTRr(reg), BCTRL())
00183 #define jit_divi_i(d, rs, is)             jit_big_ims((is), DIVWrrr ((d), (rs), JIT_AUX))
00184 #define jit_divi_ui(d, rs, is)     jit_big_imu((is), DIVWUrrr((d), (rs), JIT_AUX))
00185 #define jit_divr_i(d, s1, s2)             DIVWrrr ((d), (s1), (s2))
00186 #define jit_divr_ui(d, s1, s2)     DIVWUrrr((d), (s1), (s2))
00187 #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))
00188 #define jit_eqr_i(d, s1, s2)              (SUBrrr(JIT_AUX, (s1), (s2)), SUBFICrri((d), JIT_AUX, 0), ADDErrr((d), (d), JIT_AUX))
00189 #define jit_extr_c_i(d, rs)        EXTSBrr((d), (rs))
00190 #define jit_extr_s_i(d, rs)        EXTSHrr((d), (rs))
00191 #define jit_gei_i(d, rs, is)              jit_sbooli2((d), (rs), (is), _lt)
00192 #define jit_gei_ui(d, rs, is)             jit_ubooli2((d), (rs), (is), _lt)
00193 #define jit_ger_i(d, s1, s2)              jit_sboolr2((d), (s1), (s2), _lt)
00194 #define jit_ger_ui(d, s1, s2)             jit_uboolr2((d), (s1), (s2), _lt)
00195 #define jit_gti_i(d, rs, is)              jit_sbooli ((d), (rs), (is), _gt)
00196 #define jit_gti_ui(d, rs, is)             jit_ubooli ((d), (rs), (is), _gt)
00197 #define jit_gtr_i(d, s1, s2)              jit_sboolr ((d), (s1), (s2), _gt)
00198 #define jit_gtr_ui(d, s1, s2)             jit_uboolr ((d), (s1), (s2), _gt)
00199 #define jit_hmuli_i(d, rs, is)            jit_big_ims((is), MULHWrrr ((d), (rs), JIT_AUX))
00200 #define jit_hmuli_ui(d, rs, is)           jit_big_imu((is), MULHWUrrr((d), (rs), JIT_AUX))
00201 #define jit_hmulr_i(d, s1, s2)                                  MULHWrrr ((d), (s1), (s2))
00202 #define jit_hmulr_ui(d, s1, s2)                                 MULHWUrrr((d), (s1), (s2))
00203 #define jit_jmpi(label)                   (B_EXT((label)), _jit.x.pc)
00204 #define jit_jmpr(reg)                     (MTLRr(reg), BLR())
00205 #define jit_ldxi_c(d, rs, is)             (jit_ldxi_uc((d), (rs), (is)), jit_extr_c_i((d), (d)))
00206 #define jit_ldxr_c(d, s1, s2)             (jit_ldxr_uc((d), (s1), (s2)), jit_extr_c_i((d), (d)))
00207 #define jit_ldxi_i(d, rs, is)             jit_chk_ims((is), LWZrm((d), (is), (rs)), LWZrx((d), JIT_AUX, (rs)))
00208 #define jit_ldxi_s(d, rs, is)             jit_chk_ims((is), LHArm((d), (is), (rs)), LHArx((d), JIT_AUX, (rs)))
00209 #define jit_ldxi_uc(d, rs, is)            jit_chk_ims((is), LBZrm((d), (is), (rs)), LBZrx((d), JIT_AUX, (rs)))
00210 #define jit_ldxi_us(d, rs, is)            jit_chk_ims((is), LHZrm((d), (is), (rs)), LHZrx((d), JIT_AUX, (rs)))
00211 #define jit_ldxr_i(d, s1, s2)                            LWZrx((d), (s1), (s2))
00212 #define jit_ldxr_s(d, s1, s2)                            LHArx((d), (s1), (s2))
00213 #define jit_ldxr_uc(d, s1, s2)                           LBZrx((d), (s1), (s2))
00214 #define jit_ldxr_us(d, s1, s2)                           LHZrx((d), (s1), (s2))
00215 #define jit_lei_i(d, rs, is)              jit_sbooli2((d), (rs), (is), _gt )
00216 #define jit_lei_ui(d, rs, is)             jit_ubooli2((d), (rs), (is), _gt )
00217 #define jit_ler_i(d, s1, s2)              jit_sboolr2((d), (s1), (s2), _gt )
00218 #define jit_ler_ui(d, s1, s2)             jit_uboolr2((d), (s1), (s2), _gt )
00219 #define jit_lshi_i(d, rs, is)                                       SLWIrri((d), (rs), (is))
00220 #define jit_lshr_i(d, s1, s2)             (ANDI_rri(JIT_AUX, (s2), 31), SLWrrr ((d), (s1), JIT_AUX))
00221 #define jit_lti_i(d, rs, is)              jit_sbooli ((d), (rs), (is), _lt )
00222 #define jit_lti_ui(d, rs, is)             jit_ubooli ((d), (rs), (is), _lt )
00223 #define jit_ltr_i(d, s1, s2)              jit_sboolr ((d), (s1), (s2), _lt )
00224 #define jit_ltr_ui(d, s1, s2)             jit_uboolr ((d), (s1), (s2), _lt )
00225 #define jit_modi_i(d, rs, is)             _jit_mod(jit_divi_i (31, (rs), JIT_AUX), (rs), (is))
00226 #define jit_modi_ui(d, rs, is)            _jit_mod(jit_divi_ui(31, (rs), JIT_AUX), (rs), (is))
00227 #define jit_modr_i(d, s1, s2)             (DIVWrrr(JIT_AUX, (s1), (s2)), MULLWrrr(JIT_AUX, JIT_AUX, (s2)), SUBrrr((d), (s1), JIT_AUX))
00228 #define jit_modr_ui(d, s1, s2)            (DIVWUrrr(JIT_AUX, (s1), (s2)), MULLWrrr(JIT_AUX, JIT_AUX, (s2)), SUBrrr((d), (s1), JIT_AUX))
00229 #define jit_movi_i(d, is)          MOVEIri((d), (is))
00230 #define jit_movi_p(d, is)          (LISri((d), _HI((is))),ORIrri((d),(d),_LO((is))),_jit.x.pc)
00231 
00232 #define jit_movr_i(d, rs)          MRrr((d), (rs))
00233 #define jit_muli_i(d, rs, is)             jit_chk_ims  ((is), MULLIrri((d), (rs), (is)), MULLWrrr((d), (rs), JIT_AUX))
00234 #define jit_muli_ui(d, rs, is)            jit_chk_imu15((is), MULLIrri((d), (rs), (is)), MULLWrrr((d), (rs), JIT_AUX))
00235 #define jit_mulr_i(d, s1, s2)                               MULLWrrr((d), (s1), (s2))
00236 #define jit_mulr_ui(d, s1, s2)                              MULLWrrr((d), (s1), (s2))
00237 #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))
00238 #define jit_ner_i(d, s1, s2)              (SUBrrr(JIT_AUX, (s1), (s2)), ADDICrri((d), JIT_AUX, -1), SUBFErrr((d), (d), JIT_AUX))
00239 #define jit_nop()                  NOP()
00240 #define jit_ori_i(d, rs, is)              jit_chk_imu((is), ORIrri((d), (rs), (is)), ORrrr((d), (rs), JIT_AUX))
00241 #define jit_orr_i(d, s1, s2)                              ORrrr((d), (s1), (s2))
00242 #define jit_popr_i(rs)                    (LWZrm((rs), 0, 1), ADDIrri(1, 1, 4))
00243 #define jit_prepare_i(numi)        (_jitl.nextarg_puti = numi)
00244 #define jit_prepare_f(numf)        (_jitl.nextarg_putf = numf)
00245 #define jit_prepare_d(numd)        (_jitl.nextarg_putd = numd)
00246 #define jit_prolog(n)                     _jit_prolog(&_jit, (n))
00247 #define jit_pushr_i(rs)                   STWUrm((rs), -4, 1)
00248 #define jit_pusharg_i(rs)          (--_jitl.nextarg_puti, MRrr((3 + _jitl.nextarg_putd * 2 + _jitl.nextarg_putf + _jitl.nextarg_puti), (rs)))
00249 #define jit_ret()                  _jit_epilog(&_jit)
00250 #define jit_retval_i(rd)           MRrr((rd), 3)
00251 #define jit_rsbi_i(d, rs, is)             jit_chk_ims((is), SUBFICrri((d), (rs), (is)), SUBFCrrr((d), (rs), JIT_AUX))
00252 #define jit_rshi_i(d, rs, is)                                       SRAWIrri((d), (rs), (is))
00253 #define jit_rshi_ui(d, rs, is)                                      SRWIrri ((d), (rs), (is))
00254 #define jit_rshr_i(d, s1, s2)             (ANDI_rri(JIT_AUX, (s2), 31), SRAWrrr ((d), (s1), JIT_AUX))
00255 #define jit_rshr_ui(d, s1, s2)            (ANDI_rri(JIT_AUX, (s2), 31), SRWrrr  ((d), (s1), JIT_AUX))
00256 #define jit_stxi_c(id, rd, rs)            jit_chk_ims((id), STBrm((rs), (id), (rd)), STBrx((rs), (rd), JIT_AUX))
00257 #define jit_stxi_i(id, rd, rs)            jit_chk_ims((id), STWrm((rs), (id), (rd)), STWrx((rs), (rd), JIT_AUX))
00258 #define jit_stxi_s(id, rd, rs)            jit_chk_ims((id), STHrm((rs), (id), (rd)), STHrx((rs), (rd), JIT_AUX))
00259 #define jit_stxr_c(d1, d2, rs)                            STBrx((rs), (d1), (d2))
00260 #define jit_stxr_i(d1, d2, rs)                            STWrx((rs), (d1), (d2))
00261 #define jit_stxr_s(d1, d2, rs)                            STHrx((rs), (d1), (d2))
00262 #define jit_subr_i(d, s1, s2)                             SUBrrr((d), (s1), (s2))
00263 #define jit_subcr_i(d, s1, s2)                            SUBCrrr((d), (s1), (s2))
00264 #define jit_subxi_i(d, rs, is)            jit_big_ims((is), SUBErrr((d), (rs), JIT_AUX))
00265 #define jit_subxr_i(d, s1, s2)                            SUBErrr((d), (s1), (s2))
00266 #define jit_xori_i(d, rs, is)             jit_chk_imu((is), XORIrri((d), (rs), (is)), XORrrr((d), (rs), JIT_AUX))
00267 #define jit_xorr_i(d, s1, s2)                             XORrrr((d), (s1), (s2))
00268 
00269 /* Cannot use JIT_RZERO because having 0 in a register field on the PowerPC
00270  * does not mean `a register whose value is 0', but rather `no register at
00271  * all' */
00272 
00273 #define jit_negr_i(d, rs)          jit_rsbi_i((d), (rs), 0)
00274 #define jit_negr_l(d, rs)          jit_rsbi_l((d), (rs), 0)
00275 #define jit_ldr_c(rd, rs)          jit_ldxr_c((rd), 0, (rs))         
00276 #define jit_str_c(rd, rs)          jit_stxr_c(0, (rd), (rs))         
00277 #define jit_ldr_s(rd, rs)          jit_ldxr_s((rd), 0, (rs))         
00278 #define jit_str_s(rd, rs)          jit_stxr_s(0, (rd), (rs))         
00279 #define jit_ldr_i(rd, rs)          jit_ldxr_i((rd), 0, (rs))         
00280 #define jit_str_i(rd, rs)          jit_stxr_i(0, (rd), (rs))         
00281 #define jit_ldr_uc(rd, rs)         jit_ldxr_uc((rd), 0, (rs))        
00282 #define jit_ldr_us(rd, rs)         jit_ldxr_us((rd), 0, (rs))        
00283 
00284 /* e.g.
00285  *     0x01234567    _HA << 16 = 0x01230000      _LA = 0x00004567 _HA << 16 + LA = 0x01234567
00286  *     0x89abcdef    _HA << 16 = 0x89ac0000  _LA = 0xffffcdef _HA << 16 + LA = 0x89abcdef
00287  */
00288 #define _HA(addr)                  ((_jit_UL(addr) >> 16) + (_jit_US(_jit_UL(addr)) >> 15))
00289 #define _LA(addr)                  (_jit_UL(addr) - (_HA(addr) << 16))
00290 
00291 #define jit_ldi_c(rd, is)          (LISri(JIT_AUX, _HA(is)), jit_ldxi_c((rd), JIT_AUX, _LA(is)))
00292 #define jit_sti_c(id, rs)          (LISri(JIT_AUX, _HA(id)), jit_stxi_c(_LA(id), JIT_AUX, (rs)))
00293 #define jit_ldi_s(rd, is)          (LISri(JIT_AUX, _HA(is)), jit_ldxi_s((rd), JIT_AUX, _LA(is)))
00294 #define jit_sti_s(id, rs)          (LISri(JIT_AUX, _HA(id)), jit_stxi_s(_LA(id), JIT_AUX, (rs)))
00295 #define jit_ldi_i(rd, is)          (LISri(JIT_AUX, _HA(is)), jit_ldxi_i((rd), JIT_AUX, _LA(is)))
00296 #define jit_sti_i(id, rs)          (LISri(JIT_AUX, _HA(id)), jit_stxi_i(_LA(id), JIT_AUX, (rs)))
00297 #define jit_ldi_uc(rd, is)         (LISri(JIT_AUX, _HA(is)), jit_ldxi_uc((rd), JIT_AUX, _LA(is)))
00298 #define jit_ldi_us(rd, is)         (LISri(JIT_AUX, _HA(is)), jit_ldxi_us((rd), JIT_AUX, _LA(is)))
00299 
00300 #endif /* __lightning_core_h */