Back to index

plt-scheme  4.2.1
core-common.h
Go to the documentation of this file.
00001 /******************************** -*- C -*- ****************************
00002  *
00003  *     Platform-independent layer support
00004  *
00005  ***********************************************************************/
00006 
00007 
00008 /***********************************************************************
00009  *
00010  * Copyright 2000, 2001, 2002, 2003 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 #ifndef __lightning_core_common_h
00034 #define __lightning_core_common_h_
00035 
00036 /* jit_code: union of many possible function pointer types.  Returned
00037  * by jit_get_ip().
00038  */
00039 typedef union jit_code {    
00040   char         *ptr;
00041   void         (*vptr)(void);
00042   char         (*cptr)(void);
00043   unsigned char       (*ucptr)(void);
00044   short               (*sptr)(void);
00045   unsigned short (*usptr)(void);
00046   int          (*iptr)(void);
00047   unsigned int        (*uiptr)(void);
00048   long         (*lptr)(void);
00049   unsigned long       (*ulptr)(void);
00050   void *       (*pptr)(void);
00051   float               (*fptr)(void);
00052   double       (*dptr)(void);
00053 } jit_code;
00054 
00055 typedef struct {
00056   union {
00057     jit_insn             *pc;
00058     _uc                  *uc_pc;
00059     _us                  *us_pc;
00060     _ui                  *ui_pc;
00061     _ul                  *ul_pc;
00062     jit_code             code;
00063   }                       x;
00064   struct jit_fp              *fp;
00065   struct jit_local_state jitl;
00066 } jit_state;
00067 
00068 #if 0
00069 # ifdef jit_init
00070 static jit_state                   _jit = jit_init ();
00071 # else
00072 static jit_state                   _jit;
00073 # endif
00074 #endif
00075 
00076 #define JIT_NOREG                  (-1)
00077 #define JIT_R0                            JIT_R(0)
00078 #define JIT_R1                            JIT_R(1)
00079 #define JIT_R2                            JIT_R(2)
00080 #define JIT_V0                            JIT_V(0)
00081 #define JIT_V1                            JIT_V(1)
00082 #define JIT_V2                            JIT_V(2)
00083 
00084 #define _jitl                      _jit.jitl
00085 
00086 #define       jit_get_ip()                (_jit.x.code)
00087 #define       jit_set_ip(ptr)                    (_jit.x.pc = (ptr), jit_get_ip ())
00088 #define       jit_get_label()                    (_jit.x.pc)
00089 #define       jit_forward()               (_jit.x.pc)
00090 
00091 #define       jit_field(struc, f)         ( ((long) (&((struc *) 8)->f) ) - 8)
00092 #define       jit_ptr_field(struc_p, f)   ( ((long) (&((struc_p) 8)->f) ) - 8)
00093 
00094 /* realignment via N-byte no-ops */
00095 
00096 #ifndef jit_align
00097 #define jit_align(n)
00098 #endif
00099 
00100 
00101 #ifndef jit_fill_delay_after
00102 #define jit_fill_delay_after(branch)      (branch)
00103 #endif
00104 
00105 #define jit_delay(insn, branch)           ((insn), jit_fill_delay_after(branch))
00106 
00107 
00108 /* ALU synonyms */
00109 #define jit_addi_ui(d, rs, is)            jit_addi_i((d), (rs), (is)) 
00110 #define jit_addr_ui(d, s1, s2)            jit_addr_i((d), (s1), (s2))
00111 #define jit_addci_ui(d, rs, is)           jit_addci_i((d), (rs), (is))       
00112 #define jit_addcr_ui(d, s1, s2)           jit_addcr_i((d), (s1), (s2))
00113 #define jit_addxi_ui(d, rs, is)           jit_addxi_i((d), (rs), (is))       
00114 #define jit_addxr_ui(d, s1, s2)           jit_addxr_i((d), (s1), (s2))
00115 #define jit_andi_ui(d, rs, is)            jit_andi_i((d), (rs), (is)) 
00116 #define jit_andr_ui(d, s1, s2)            jit_andr_i((d), (s1), (s2))
00117 #define jit_lshi_ui(d, rs, is)            jit_lshi_i((d), (rs), (is)) 
00118 #define jit_lshr_ui(d, s1, s2)            jit_lshr_i((d), (s1), (s2))
00119 #define jit_movi_ui(d, rs)         jit_movi_i((d), (rs))
00120 #define jit_movr_ui(d, rs)         jit_movr_i((d), (rs))
00121 #define jit_ori_ui(d, rs, is)             jit_ori_i((d), (rs), (is))  
00122 #define jit_orr_ui(d, s1, s2)             jit_orr_i((d), (s1), (s2))
00123 #define jit_rsbi_ui(d, rs, is)            jit_rsbi_i((d), (rs), (is)) 
00124 #define jit_rsbr_ui(d, s1, s2)            jit_rsbr_i((d), (s1), (s2))
00125 #define jit_subi_ui(d, rs, is)            jit_subi_i((d), (rs), (is)) 
00126 #define jit_subr_ui(d, s1, s2)            jit_subr_i((d), (s1), (s2))
00127 #define jit_subci_ui(d, rs, is)           jit_subci_i((d), (rs), (is))       
00128 #define jit_subcr_ui(d, s1, s2)           jit_subcr_i((d), (s1), (s2))
00129 #define jit_subxi_ui(d, rs, is)           jit_subxi_i((d), (rs), (is))       
00130 #define jit_subxr_ui(d, s1, s2)           jit_subxr_i((d), (s1), (s2))
00131 #define jit_xori_ui(d, rs, is)            jit_xori_i((d), (rs), (is)) 
00132 #define jit_xorr_ui(d, s1, s2)            jit_xorr_i((d), (s1), (s2))
00133 
00134 #define jit_addi_ul(d, rs, is)            jit_addi_l((d), (rs), (is)) 
00135 #define jit_addr_ul(d, s1, s2)            jit_addr_l((d), (s1), (s2))
00136 #define jit_addci_ul(d, rs, is)           jit_addci_l((d), (rs), (is))       
00137 #define jit_addcr_ul(d, s1, s2)           jit_addcr_l((d), (s1), (s2))
00138 #define jit_addxi_ul(d, rs, is)           jit_addxi_l((d), (rs), (is))       
00139 #define jit_addxr_ul(d, s1, s2)           jit_addxr_l((d), (s1), (s2))
00140 #define jit_andi_ul(d, rs, is)            jit_andi_l((d), (rs), (is)) 
00141 #define jit_andr_ul(d, s1, s2)            jit_andr_l((d), (s1), (s2))
00142 #define jit_lshi_ul(d, rs, is)            jit_lshi_l((d), (rs), (is)) 
00143 #define jit_lshr_ul(d, s1, s2)            jit_lshr_l((d), (s1), (s2))
00144 #define jit_movi_ul(d, rs)         jit_movi_l((d), (rs))
00145 #define jit_movr_ul(d, rs)         jit_movr_l((d), (rs))
00146 #define jit_ori_ul(d, rs, is)             jit_ori_l((d), (rs), (is))  
00147 #define jit_orr_ul(d, s1, s2)             jit_orr_l((d), (s1), (s2))
00148 #define jit_rsbi_ul(d, rs, is)            jit_rsbi_l((d), (rs), (is)) 
00149 #define jit_rsbr_ul(d, s1, s2)            jit_rsbr_l((d), (s1), (s2))
00150 #define jit_subi_ul(d, rs, is)            jit_subi_l((d), (rs), (is)) 
00151 #define jit_subr_ul(d, s1, s2)            jit_subr_l((d), (s1), (s2))
00152 #define jit_subci_ul(d, rs, is)           jit_subci_l((d), (rs), (is))       
00153 #define jit_subcr_ul(d, s1, s2)           jit_subcr_l((d), (s1), (s2))
00154 #define jit_subxi_ui(d, rs, is)           jit_subxi_i((d), (rs), (is))       
00155 #define jit_subxi_ul(d, rs, is)           jit_subxi_l((d), (rs), (is))       
00156 #define jit_subxr_ui(d, s1, s2)           jit_subxr_i((d), (s1), (s2))
00157 #define jit_subxr_ul(d, s1, s2)           jit_subxr_i((d), (s1), (s2))
00158 #define jit_xori_ul(d, rs, is)            jit_xori_l((d), (rs), (is)) 
00159 #define jit_xorr_ul(d, s1, s2)            jit_xorr_l((d), (s1), (s2))
00160 
00161 #define jit_addr_p(d, s1, s2)             jit_addr_ul((d), (s1),            (s2))
00162 #define jit_addi_p(d, rs, is)             jit_addi_ul((d), (rs), (long) (is))
00163 #define jit_movr_p(d, rs)          jit_movr_ul((d),              (rs))
00164 #define jit_subr_p(d, s1, s2)             jit_subr_ul((d), (s1),        (s2))
00165 #define jit_subi_p(d, rs, is)             jit_subi_ul((d), (rs), (long) (is))
00166 #define jit_rsbi_p(d, rs, is)             jit_rsbi_ul((d), (rs), (long) (is))
00167 
00168 #ifndef jit_movi_p
00169 #define jit_movi_p(d, is)          (jit_movi_ul((d),       (long) (is)), _jit.x.pc)
00170 #endif
00171 
00172 #define jit_patchable_movi_p(r, i)      jit_movi_p(r, i)
00173 #define jit_patch(pv)                     jit_patch_at ((pv), (_jit.x.pc))
00174 
00175 #ifndef jit_addci_i
00176 #define jit_addci_i(d, rs, is)            jit_addi_i((d), (rs), (is)) 
00177 #define jit_addcr_i(d, s1, s2)            jit_addr_i((d), (s1), (s2))
00178 #define jit_addci_l(d, rs, is)            jit_addi_l((d), (rs), (is)) 
00179 #define jit_addcr_l(d, s1, s2)            jit_addr_l((d), (s1), (s2))
00180 #endif
00181 
00182 #ifndef jit_subcr_i
00183 #define jit_subcr_i(d, s1, s2)            jit_subr_i((d), (s1), (s2))
00184 #endif
00185 
00186 /* NEG is not mandatory -- pick an appropriate implementation */
00187 #ifndef jit_negr_i
00188 # ifdef JIT_RZERO
00189 #  define jit_negr_i(d, rs)        jit_subr_i((d), JIT_RZERO, (rs))
00190 #  define jit_negr_l(d, rs)        jit_subr_l((d), JIT_RZERO, (rs))
00191 # else /* !JIT_RZERO */
00192 #  ifndef jit_rsbi_i
00193 #   define jit_negr_i(d, rs)              (jit_xori_i((d), (rs), -1), jit_addi_l((d), (d), 1))
00194 #   define jit_negr_l(d, rs)              (jit_xori_l((d), (rs), -1), jit_addi_l((d), (d), 1))
00195 #  else /* jit_rsbi_i */
00196 #   define jit_negr_i(d, rs)              jit_rsbi_i((d), (rs), 0)
00197 #   define jit_negr_l(d, rs)              jit_rsbi_l((d), (rs), 0)
00198 #  endif /* jit_rsbi_i */
00199 # endif /* !JIT_RZERO */
00200 #endif /* !jit_negr_i */
00201 
00202 /* RSB is not mandatory */
00203 #ifndef jit_rsbi_i
00204 # define jit_rsbi_i(d, rs, is)            (jit_subi_i((d), (rs), (is)), jit_negr_i((d), (d)))
00205 
00206 # ifndef jit_rsbi_l
00207 #  define jit_rsbi_l(d, rs, is)           (jit_subi_l((d), (rs), (is)), jit_negr_l((d), (d)))
00208 # endif
00209 #endif
00210 
00211 /* Common 'shortcut' implementations */
00212 #define jit_subi_i(d, rs, is)             jit_addi_i((d), (rs), -(is))
00213 #define jit_subi_l(d, rs, is)             jit_addi_l((d), (rs), -(is))
00214 #define jit_subci_i(d, rs, is)            jit_addci_i((d), (rs), -(is))
00215 #define jit_subci_l(d, rs, is)            jit_addci_l((d), (rs), -(is))
00216 #define jit_rsbr_f(d, s1, s2)             jit_subr_f((d), (s2), (s1))
00217 #define jit_rsbr_d(d, s1, s2)             jit_subr_d((d), (s2), (s1))
00218 #define jit_rsbr_i(d, s1, s2)             jit_subr_i((d), (s2), (s1))
00219 #define jit_rsbr_l(d, s1, s2)             jit_subr_l((d), (s2), (s1))
00220 #define jit_rsbr_p(d, s1, s2)             jit_subr_p((d), (s2), (s1))
00221 
00222 /* Unary */
00223 #define jit_notr_c(d, rs)          jit_xori_c((d), (rs), 255)
00224 #define jit_notr_uc(d, rs)         jit_xori_c((d), (rs), 255)
00225 #define jit_notr_s(d, rs)          jit_xori_s((d), (rs), 65535)
00226 #define jit_notr_us(d, rs)         jit_xori_s((d), (rs), 65535)
00227 #define jit_notr_i(d, rs)          jit_xori_i((d), (rs), ~0)
00228 #define jit_notr_ui(d, rs)         jit_xori_i((d), (rs), ~0)
00229 #define jit_notr_l(d, rs)          jit_xori_l((d), (rs), ~0L)
00230 #define jit_notr_ul(d, rs)         jit_xori_l((d), (rs), ~0L)
00231 
00232 #ifndef jit_extr_c_ui
00233 #define jit_extr_c_ui(d, rs)              jit_andi_ui((d), (rs), 0xFF)
00234 #endif
00235 #ifndef jit_extr_s_ui
00236 #define jit_extr_s_ui(d, rs)              jit_andi_ui((d), (rs), 0xFFFF)
00237 #endif
00238 #ifndef jit_extr_c_i
00239 #define jit_extr_c_i(d, rs)        (jit_lshi_i((d), (rs), 24), jit_rshi_i((d), (d), 24))
00240 #endif
00241 #ifndef jit_extr_s_i
00242 #define jit_extr_s_i(d, rs)        (jit_lshi_i((d), (rs), 16), jit_rshi_i((d), (d), 16))
00243 #endif
00244 
00245 #ifdef jit_addi_l /* sizeof(long) != sizeof(int) */
00246 #ifndef jit_extr_c_l
00247 #define jit_extr_c_l(d, rs)        (jit_lshi_l((d), (rs), 56), jit_rshi_l((d), (d), 56))
00248 #endif
00249 #ifndef jit_extr_s_l
00250 #define jit_extr_s_l(d, rs)        (jit_lshi_l((d), (rs), 48), jit_rshi_l((d), (d), 48))
00251 #endif
00252 #ifndef jit_extr_i_l
00253 #define jit_extr_i_l(d, rs)        (jit_lshi_l((d), (rs), 32), jit_rshi_l((d), (d), 32))
00254 #endif
00255 #ifndef jit_extr_c_ul
00256 #define jit_extr_c_ul(d, rs)              jit_andi_l((d), (rs), 0xFF)
00257 #endif
00258 #ifndef jit_extr_s_ul
00259 #define jit_extr_s_ul(d, rs)              jit_andi_l((d), (rs), 0xFFFF)
00260 #endif
00261 #ifndef jit_extr_i_ul
00262 #define jit_extr_i_ul(d, rs)              jit_andi_l((d), (rs), 0xFFFFFFFFUL)
00263 #endif
00264 #endif
00265 
00266 #define jit_extr_c_s(d, rs)        jit_extr_c_i((d), (rs))
00267 #define jit_extr_c_us(d, rs)              jit_extr_c_ui((d), (rs))
00268 #define jit_extr_uc_s(d, rs)              jit_extr_uc_i((d), (rs))
00269 #define jit_extr_uc_us(d, rs)             jit_extr_uc_ui((d), (rs))
00270 #define jit_extr_uc_i(d, rs)              jit_extr_c_ui((d), (rs))
00271 #define jit_extr_uc_ui(d, rs)             jit_extr_c_ui((d), (rs))
00272 #define jit_extr_us_i(d, rs)              jit_extr_s_ui((d), (rs))
00273 #define jit_extr_us_ui(d, rs)             jit_extr_s_ui((d), (rs))
00274 #define jit_extr_uc_l(d, rs)              jit_extr_c_ul((d), (rs))
00275 #define jit_extr_uc_ul(d, rs)             jit_extr_c_ul((d), (rs))
00276 #define jit_extr_us_l(d, rs)              jit_extr_s_ul((d), (rs))
00277 #define jit_extr_us_ul(d, rs)             jit_extr_s_ul((d), (rs))
00278 #define jit_extr_ui_l(d, rs)              jit_extr_i_ul((d), (rs))
00279 #define jit_extr_ui_ul(d, rs)             jit_extr_i_ul((d), (rs))
00280 
00281 
00282 /* NTOH/HTON is not mandatory for big endian architectures */
00283 #ifndef jit_ntoh_ui /* big endian */
00284 #define jit_ntoh_ui(d, rs)         ((d) == (rs) ? (void)0 : jit_movr_i((d), (rs)))
00285 #define jit_ntoh_us(d, rs)         ((d) == (rs) ? (void)0 : jit_movr_i((d), (rs)))
00286 #endif /* big endian */
00287 
00288 /* hton is a synonym for ntoh */
00289 #define jit_hton_ui(d, rs)         jit_ntoh_ui((d), (rs))
00290 #define jit_hton_us(d, rs)         jit_ntoh_us((d), (rs))
00291 
00292 /* Stack synonyms */
00293 #define jit_pushr_ui(rs)           jit_pushr_i(rs)
00294 #define jit_popr_ui(rs)                   jit_popr_i(rs)              
00295 #define jit_pushr_ul(rs)           jit_pushr_l(rs)
00296 #define jit_popr_ul(rs)                   jit_popr_l(rs)              
00297 #define jit_pushr_p(rs)                   jit_pushr_ul(rs)
00298 #define jit_popr_p(rs)                    jit_popr_ul(rs)             
00299 
00300 #define jit_prepare(nint)          jit_prepare_i((nint))
00301 #define jit_pusharg_c(rs)          jit_pusharg_i(rs)
00302 #define jit_pusharg_s(rs)          jit_pusharg_i(rs)
00303 #define jit_pusharg_uc(rs)         jit_pusharg_i(rs)
00304 #define jit_pusharg_us(rs)         jit_pusharg_i(rs)
00305 #define jit_pusharg_ui(rs)         jit_pusharg_i(rs)
00306 #define jit_pusharg_ul(rs)         jit_pusharg_l(rs)
00307 #define jit_pusharg_p(rs)          jit_pusharg_ul(rs)
00308 
00309 /* Memory synonyms */
00310 
00311 #ifdef JIT_RZERO
00312 #ifndef jit_ldi_c
00313 #define jit_ldi_c(rd, is)          jit_ldxi_c((rd), JIT_RZERO, (is))         
00314 #define jit_sti_c(id, rs)          jit_stxi_c((id), JIT_RZERO, (rs))         
00315 #define jit_ldi_s(rd, is)          jit_ldxi_s((rd), JIT_RZERO, (is))         
00316 #define jit_sti_s(id, rs)          jit_stxi_s((id), JIT_RZERO, (rs))         
00317 #define jit_ldi_i(rd, is)          jit_ldxi_i((rd), JIT_RZERO, (is))         
00318 #define jit_sti_i(id, rs)          jit_stxi_i((id), JIT_RZERO, (rs))         
00319 #define jit_ldi_l(rd, is)          jit_ldxi_l((rd), JIT_RZERO, (is))         
00320 #define jit_sti_l(id, rs)          jit_stxi_l((id), JIT_RZERO, (rs))         
00321 #define jit_ldi_uc(rd, is)         jit_ldxi_uc((rd), JIT_RZERO, (is))        
00322 #define jit_ldi_us(rd, is)         jit_ldxi_us((rd), JIT_RZERO, (is))        
00323 #define jit_ldi_ui(rd, is)         jit_ldxi_ui((rd), JIT_RZERO, (is))        
00324 #define jit_ldi_ul(rd, is)         jit_ldxi_ul((rd), JIT_RZERO, (is))        
00325 #endif
00326 
00327 #ifndef jit_ldr_c
00328 #define jit_ldr_c(rd, rs)          jit_ldxr_c((rd), JIT_RZERO, (rs))         
00329 #define jit_str_c(rd, rs)          jit_stxr_c(JIT_RZERO, (rd), (rs))         
00330 #define jit_ldr_s(rd, rs)          jit_ldxr_s((rd), JIT_RZERO, (rs))         
00331 #define jit_str_s(rd, rs)          jit_stxr_s(JIT_RZERO, (rd), (rs))         
00332 #define jit_ldr_i(rd, rs)          jit_ldxr_i((rd), JIT_RZERO, (rs))         
00333 #define jit_str_i(rd, rs)          jit_stxr_i(JIT_RZERO, (rd), (rs))         
00334 #define jit_ldr_l(rd, rs)          jit_ldxr_l((rd), JIT_RZERO, (rs))         
00335 #define jit_str_l(rd, rs)          jit_stxr_l(JIT_RZERO, (rd), (rs))         
00336 #define jit_ldr_uc(rd, rs)         jit_ldxr_uc((rd), JIT_RZERO, (rs))        
00337 #define jit_ldr_us(rd, rs)         jit_ldxr_us((rd), JIT_RZERO, (rs))        
00338 #define jit_ldr_ui(rd, rs)         jit_ldxr_ui((rd), JIT_RZERO, (rs))        
00339 #define jit_ldr_ul(rd, rs)         jit_ldxr_ul((rd), JIT_RZERO, (rs))        
00340 #endif
00341 #endif
00342 
00343 #define jit_str_uc(rd, rs)         jit_str_c((rd), (rs))
00344 #define jit_sti_uc(id, rs)         jit_sti_c((id), (rs))
00345 #define jit_stxr_uc(d1, d2, rs)           jit_stxr_c((d1), (d2), (rs))
00346 #define jit_stxi_uc(id, rd, is)           jit_stxi_c((id), (rd), (is))
00347 
00348 #define jit_str_us(rd, rs)         jit_str_s((rd), (rs))
00349 #define jit_sti_us(id, rs)         jit_sti_s((id), (rs))
00350 #define jit_stxr_us(d1, d2, rs)           jit_stxr_s((d1), (d2), (rs))
00351 #define jit_stxi_us(id, rd, is)           jit_stxi_s((id), (rd), (is))
00352 
00353 #define jit_str_ui(rd, rs)         jit_str_i((rd), (rs))
00354 #define jit_sti_ui(id, rs)         jit_sti_i((id), (rs))
00355 #define jit_stxr_ui(d1, d2, rs)           jit_stxr_i((d1), (d2), (rs))
00356 #define jit_stxi_ui(id, rd, is)           jit_stxi_i((id), (rd), (is))
00357 
00358 #define jit_str_ul(rd, rs)         jit_str_l((rd), (rs))
00359 #define jit_sti_ul(id, rs)         jit_sti_l((id), (rs))
00360 #define jit_stxr_ul(d1, d2, rs)           jit_stxr_l((d1), (d2), (rs))
00361 #define jit_stxi_ul(id, rd, is)           jit_stxi_l((id), (rd), (is))
00362 
00363 #define jit_str_p(rd, rs)          jit_str_l((rd), (rs))
00364 #define jit_sti_p(id, rs)          jit_sti_l((id), (rs))
00365 #define jit_stxr_p(d1, d2, rs)            jit_stxr_l((d1), (d2), (rs))
00366 #define jit_stxi_p(id, rd, is)            jit_stxi_l((id), (rd), (is))
00367 
00368 #define jit_ldr_p(rd, rs)          jit_ldr_l((rd), (rs))
00369 #define jit_ldi_p(rd, is)          jit_ldi_l((rd), (is))
00370 #define jit_ldxr_p(rd, s1, s2)            jit_ldxr_l((rd), (s1), (s2))
00371 #define jit_ldxi_p(rd, rs, is)            jit_ldxi_l((rd), (rs), (is))
00372 
00373 
00374 /* Boolean & branch synonyms */
00375 #define jit_eqr_ui(d, s1, s2)             jit_eqr_i((d), (s1), (s2))
00376 #define jit_eqi_ui(d, rs, is)             jit_eqi_i((d), (rs), (is))
00377 #define jit_ner_ui(d, s1, s2)             jit_ner_i((d), (s1), (s2))
00378 #define jit_nei_ui(d, rs, is)             jit_nei_i((d), (rs), (is))
00379 
00380 #define jit_eqr_ul(d, s1, s2)             jit_eqr_l((d), (s1), (s2))
00381 #define jit_eqi_ul(d, rs, is)             jit_eqi_l((d), (rs), (is))
00382 #define jit_ner_ul(d, s1, s2)             jit_ner_l((d), (s1), (s2))
00383 #define jit_nei_ul(d, rs, is)             jit_nei_l((d), (rs), (is))
00384 
00385 #define jit_beqr_ui(label, s1, s2) jit_beqr_i((label), (s1), (s2))
00386 #define jit_beqi_ui(label, rs, is) jit_beqi_i((label), (rs), (is))
00387 #define jit_bner_ui(label, s1, s2) jit_bner_i((label), (s1), (s2))
00388 #define jit_bnei_ui(label, rs, is) jit_bnei_i((label), (rs), (is))
00389 #define jit_bmcr_ui(label, s1, s2) jit_bmcr_i((label), (s1), (s2))
00390 #define jit_bmci_ui(label, rs, is) jit_bmci_i((label), (rs), (is))
00391 #define jit_bmsr_ui(label, s1, s2) jit_bmsr_i((label), (s1), (s2))
00392 #define jit_bmsi_ui(label, rs, is) jit_bmsi_i((label), (rs), (is))
00393 
00394 #define jit_beqr_ul(label, s1, s2) jit_beqr_l((label), (s1), (s2))
00395 #define jit_beqi_ul(label, rs, is) jit_beqi_l((label), (rs), (is))
00396 #define jit_bner_ul(label, s1, s2) jit_bner_l((label), (s1), (s2))
00397 #define jit_bnei_ul(label, rs, is) jit_bnei_l((label), (rs), (is))
00398 #define jit_bmcr_ul(label, s1, s2) jit_bmcr_l((label), (s1), (s2))
00399 #define jit_bmci_ul(label, rs, is) jit_bmci_l((label), (rs), (is))
00400 #define jit_bmsr_ul(label, s1, s2) jit_bmsr_l((label), (s1), (s2))
00401 #define jit_bmsi_ul(label, rs, is) jit_bmsi_l((label), (rs), (is))
00402 
00403 #define jit_ltr_p(d, s1, s2)              jit_ltr_ul((d), (s1), (s2))
00404 #define jit_lti_p(d, rs, is)              jit_lti_ul((d), (rs), (is))
00405 #define jit_ler_p(d, s1, s2)              jit_ler_ul((d), (s1), (s2))
00406 #define jit_lei_p(d, rs, is)              jit_lei_ul((d), (rs), (is))
00407 #define jit_gtr_p(d, s1, s2)              jit_gtr_ul((d), (s1), (s2))
00408 #define jit_gti_p(d, rs, is)              jit_gti_ul((d), (rs), (is))
00409 #define jit_ger_p(d, s1, s2)              jit_ger_ul((d), (s1), (s2))
00410 #define jit_gei_p(d, rs, is)              jit_gei_ul((d), (rs), (is))
00411 #define jit_eqr_p(d, s1, s2)              jit_eqr_ul((d), (s1), (s2))
00412 #define jit_eqi_p(d, rs, is)              jit_eqi_ul((d), (rs), (is))
00413 #define jit_ner_p(d, s1, s2)              jit_ner_ul((d), (s1), (s2))
00414 #define jit_nei_p(d, rs, is)              jit_nei_ul((d), (rs), (is))
00415 
00416 #define jit_bltr_p(label, s1, s2)  jit_bltr_ul((label), (s1), (s2))
00417 #define jit_blti_p(label, rs, is)  jit_blti_ul((label), (rs), (is))
00418 #define jit_bler_p(label, s1, s2)  jit_bler_ul((label), (s1), (s2))
00419 #define jit_blei_p(label, rs, is)  jit_blei_ul((label), (rs), (is))
00420 #define jit_bgtr_p(label, s1, s2)  jit_bgtr_ul((label), (s1), (s2))
00421 #define jit_bgti_p(label, rs, is)  jit_bgti_ul((label), (rs), (is))
00422 #define jit_bger_p(label, s1, s2)  jit_bger_ul((label), (s1), (s2))
00423 #define jit_bgei_p(label, rs, is)  jit_bgei_ul((label), (rs), (is))
00424 #define jit_beqr_p(label, s1, s2)  jit_beqr_ul((label), (s1), (s2))
00425 #define jit_beqi_p(label, rs, is)  jit_beqi_ul((label), (rs), (is))
00426 #define jit_bner_p(label, s1, s2)  jit_bner_ul((label), (s1), (s2))
00427 #define jit_bnei_p(label, rs, is)  jit_bnei_ul((label), (rs), (is))
00428 
00429 #define jit_retval_ui(rd)          jit_retval_i((rd))
00430 #define jit_retval_uc(rd)          jit_retval_i((rd))
00431 #define jit_retval_us(rd)          jit_retval_i((rd))
00432 #define jit_retval_ul(rd)          jit_retval_l((rd))
00433 #define jit_retval_p(rd)           jit_retval_ul((rd))
00434 #define jit_retval_c(rd)           jit_retval_i((rd))
00435 #define jit_retval_s(rd)           jit_retval_i((rd))
00436 
00437 /* This was a bug, but we keep it.  */
00438 #define jit_retval(rd)                    jit_retval_i ((rd))
00439 
00440 #ifndef jit_finish
00441 #define jit_finish(sub)                   jit_calli(sub)
00442 #endif
00443 
00444 #ifndef jit_finishr
00445 #define jit_finishr(reg)           jit_callr(reg)
00446 #endif
00447 
00448 #ifndef jit_prolog
00449 #define jit_prolog(numargs)
00450 #endif
00451 
00452 #ifndef jit_leaf
00453 #define jit_leaf(numargs)          jit_prolog(numargs)
00454 #endif
00455 
00456 #ifndef jit_getarg_c
00457 #ifndef JIT_FP
00458 #define jit_getarg_c(reg, ofs)            jit_extr_c_i  ((reg), (ofs))
00459 #define jit_getarg_i(reg, ofs)            jit_movr_i    ((reg), (ofs))
00460 #define jit_getarg_l(reg, ofs)            jit_movr_l    ((reg), (ofs))
00461 #define jit_getarg_p(reg, ofs)            jit_movr_p    ((reg), (ofs))
00462 #define jit_getarg_s(reg, ofs)            jit_extr_s_i  ((reg), (ofs))
00463 #define jit_getarg_uc(reg, ofs)           jit_extr_uc_ui((reg), (ofs))
00464 #define jit_getarg_ui(reg, ofs)           jit_movr_ui   ((reg), (ofs))
00465 #define jit_getarg_ul(reg, ofs)           jit_extr_uc_ul((reg), (ofs))
00466 #define jit_getarg_us(reg, ofs)           jit_extr_us_ul((reg), (ofs))
00467 #else
00468 #define jit_getarg_c(reg, ofs)            jit_ldxi_c((reg), JIT_FP, (ofs));
00469 #define jit_getarg_uc(reg, ofs)           jit_ldxi_uc((reg), JIT_FP, (ofs));
00470 #define jit_getarg_s(reg, ofs)            jit_ldxi_s((reg), JIT_FP, (ofs));
00471 #define jit_getarg_us(reg, ofs)           jit_ldxi_us((reg), JIT_FP, (ofs));
00472 #define jit_getarg_i(reg, ofs)            jit_ldxi_i((reg), JIT_FP, (ofs));
00473 #define jit_getarg_ui(reg, ofs)           jit_ldxi_ui((reg), JIT_FP, (ofs));
00474 #define jit_getarg_l(reg, ofs)            jit_ldxi_l((reg), JIT_FP, (ofs));
00475 #define jit_getarg_ul(reg, ofs)           jit_ldxi_ul((reg), JIT_FP, (ofs));
00476 #define jit_getarg_p(reg, ofs)            jit_ldxi_p((reg), JIT_FP, (ofs));
00477 #endif
00478 #endif
00479 
00480 
00481 /* Common definitions when sizeof(long) = sizeof(int) */
00482 #ifndef jit_addi_l
00483 #define JIT_LONG_IS_INT
00484 
00485 /* ALU */
00486 #define jit_addi_l(d, rs, is)             jit_addi_i((d), (rs), (is)) 
00487 #define jit_addr_l(d, s1, s2)             jit_addr_i((d), (s1), (s2))
00488 #define jit_addci_l(d, rs, is)            jit_addci_i((d), (rs), (is))       
00489 #define jit_addcr_l(d, s1, s2)            jit_addcr_i((d), (s1), (s2))
00490 #define jit_addxi_l(d, rs, is)            jit_addxi_i((d), (rs), (is))       
00491 #define jit_addxr_l(d, s1, s2)            jit_addxr_i((d), (s1), (s2))
00492 #define jit_andi_l(d, rs, is)             jit_andi_i((d), (rs), (is)) 
00493 #define jit_andr_l(d, s1, s2)             jit_andr_i((d), (s1), (s2))
00494 #define jit_divi_l(d, rs, is)             jit_divi_i((d), (rs), (is)) 
00495 #define jit_divr_l(d, s1, s2)             jit_divr_i((d), (s1), (s2))
00496 #define jit_hmuli_l(d, rs, is)            jit_hmuli_i((d), (rs), (is))       
00497 #define jit_hmulr_l(d, s1, s2)            jit_hmulr_i((d), (s1), (s2))
00498 #define jit_lshi_l(d, rs, is)             jit_lshi_i((d), (rs), (is)) 
00499 #define jit_lshr_l(d, s1, s2)             jit_lshr_i((d), (s1), (s2))
00500 #define jit_modi_l(d, rs, is)             jit_modi_i((d), (rs), (is)) 
00501 #define jit_modr_l(d, s1, s2)             jit_modr_i((d), (s1), (s2))
00502 #define jit_muli_l(d, rs, is)             jit_muli_i((d), (rs), (is)) 
00503 #define jit_mulr_l(d, s1, s2)             jit_mulr_i((d), (s1), (s2))
00504 #define jit_ori_l(d, rs, is)              jit_ori_i((d), (rs), (is))  
00505 #define jit_orr_l(d, s1, s2)              jit_orr_i((d), (s1), (s2))
00506 #define jit_rshi_l(d, rs, is)             jit_rshi_i((d), (rs), (is)) 
00507 #define jit_rshr_l(d, s1, s2)             jit_rshr_i((d), (s1), (s2))
00508 #define jit_subr_l(d, s1, s2)             jit_subr_i((d), (s1), (s2))
00509 #define jit_subcr_l(d, s1, s2)            jit_subcr_i((d), (s1), (s2))
00510 #define jit_subxi_l(d, rs, is)            jit_subxi_i((d), (rs), (is))       
00511 #define jit_subxr_l(d, s1, s2)            jit_subxr_i((d), (s1), (s2))
00512 #define jit_xori_l(d, rs, is)             jit_xori_i((d), (rs), (is)) 
00513 #define jit_xorr_l(d, s1, s2)             jit_xorr_i((d), (s1), (s2))
00514 
00515 #ifndef jit_rsbi_l
00516 #define jit_rsbi_l(d, rs, is)             jit_rsbi_i((d), (rs), (is)) 
00517 #endif
00518 
00519 #define jit_divi_ul(d, rs, is)            jit_divi_ui((d), (rs), (is))       
00520 #define jit_divr_ul(d, s1, s2)            jit_divr_ui((d), (s1), (s2))
00521 #define jit_hmuli_ul(d, rs, is)           jit_hmuli_ui((d), (rs), (is))      
00522 #define jit_hmulr_ul(d, s1, s2)           jit_hmulr_ui((d), (s1), (s2))
00523 #define jit_modi_ul(d, rs, is)            jit_modi_ui((d), (rs), (is))       
00524 #define jit_modr_ul(d, s1, s2)            jit_modr_ui((d), (s1), (s2))
00525 #define jit_muli_ul(d, rs, is)            jit_muli_ui((d), (rs), (is))       
00526 #define jit_mulr_ul(d, s1, s2)            jit_mulr_ui((d), (s1), (s2))
00527 #define jit_rshi_ul(d, rs, is)            jit_rshi_ui((d), (rs), (is))       
00528 #define jit_rshr_ul(d, s1, s2)            jit_rshr_ui((d), (s1), (s2))
00529 
00530 /* Sign/Zero extension */
00531 #define jit_extr_c_l(d, rs)        jit_extr_c_i(d, rs)
00532 #define jit_extr_c_ul(d, rs)              jit_extr_c_ui(d, rs)
00533 #define jit_extr_s_l(d, rs)        jit_extr_s_i(d, rs)
00534 #define jit_extr_s_ul(d, rs)              jit_extr_s_ui(d, rs)
00535 #define jit_extr_i_l(d, rs)        jit_movr_i(d, rs)
00536 #define jit_extr_i_ul(d, rs)              jit_movr_i(d, rs)
00537 
00538 /* Unary */
00539 #define jit_movi_l(d, rs)          jit_movi_i((d), (rs))
00540 #define jit_movr_l(d, rs)          jit_movr_i((d), (rs))
00541 
00542 /* Stack */
00543 #define jit_pushr_l(rs)                   jit_pushr_i(rs)
00544 #define jit_popr_l(rs)                    jit_popr_i(rs)              
00545 #define jit_pusharg_l(rs)          jit_pusharg_i(rs)
00546 
00547 /* Memory */
00548 #ifndef JIT_RZERO
00549 #define jit_ldr_l(d, rs)           jit_ldr_i((d), (rs))
00550 #define jit_ldi_l(d, is)           jit_ldi_i((d), (is))
00551 #define jit_str_l(d, rs)           jit_str_i((d), (rs))
00552 #define jit_sti_l(d, is)           jit_sti_i((d), (is))
00553 #define jit_ldr_ui(d, rs)          jit_ldr_i((d), (rs))
00554 #define jit_ldi_ui(d, is)          jit_ldi_i((d), (is))
00555 #define jit_ldr_ul(d, rs)          jit_ldr_ui((d), (rs))
00556 #define jit_ldi_ul(d, is)          jit_ldi_ui((d), (is))
00557 #endif
00558 
00559 #define jit_ldxr_l(d, s1, s2)             jit_ldxr_i((d), (s1), (s2))
00560 #define jit_ldxi_l(d, rs, is)             jit_ldxi_i((d), (rs), (is))
00561 #define jit_stxr_l(d, s1, s2)             jit_stxr_i((d), (s1), (s2))
00562 #define jit_stxi_l(d, rs, is)             jit_stxi_i((d), (rs), (is))
00563 #define jit_ldxr_ui(d, s1, s2)            jit_ldxr_i((d), (s1), (s2))
00564 #define jit_ldxi_ui(d, rs, is)            jit_ldxi_i((d), (rs), (is))
00565 #define jit_ldxr_ul(d, s1, s2)            jit_ldxr_ui((d), (s1), (s2))
00566 #define jit_ldxi_ul(d, rs, is)            jit_ldxi_ui((d), (rs), (is))
00567 
00568 
00569 /* Boolean */
00570 #define jit_ltr_l(d, s1, s2)              jit_ltr_i((d), (s1), (s2))
00571 #define jit_lti_l(d, rs, is)              jit_lti_i((d), (rs), (is))
00572 #define jit_ler_l(d, s1, s2)              jit_ler_i((d), (s1), (s2))
00573 #define jit_lei_l(d, rs, is)              jit_lei_i((d), (rs), (is))
00574 #define jit_gtr_l(d, s1, s2)              jit_gtr_i((d), (s1), (s2))
00575 #define jit_gti_l(d, rs, is)              jit_gti_i((d), (rs), (is))
00576 #define jit_ger_l(d, s1, s2)              jit_ger_i((d), (s1), (s2))
00577 #define jit_gei_l(d, rs, is)              jit_gei_i((d), (rs), (is))
00578 #define jit_eqr_l(d, s1, s2)              jit_eqr_i((d), (s1), (s2))
00579 #define jit_eqi_l(d, rs, is)              jit_eqi_i((d), (rs), (is))
00580 #define jit_ner_l(d, s1, s2)              jit_ner_i((d), (s1), (s2))
00581 #define jit_nei_l(d, rs, is)              jit_nei_i((d), (rs), (is))
00582 #define jit_ltr_ul(d, s1, s2)             jit_ltr_ui((d), (s1), (s2))
00583 #define jit_lti_ul(d, rs, is)             jit_lti_ui((d), (rs), (is))
00584 #define jit_ler_ul(d, s1, s2)             jit_ler_ui((d), (s1), (s2))
00585 #define jit_lei_ul(d, rs, is)             jit_lei_ui((d), (rs), (is))
00586 #define jit_gtr_ul(d, s1, s2)             jit_gtr_ui((d), (s1), (s2))
00587 #define jit_gti_ul(d, rs, is)             jit_gti_ui((d), (rs), (is))
00588 #define jit_ger_ul(d, s1, s2)             jit_ger_ui((d), (s1), (s2))
00589 #define jit_gei_ul(d, rs, is)             jit_gei_ui((d), (rs), (is))
00590 
00591 /* Branches */
00592 #define jit_bltr_l(label, s1, s2)  jit_bltr_i((label), (s1), (s2))
00593 #define jit_blti_l(label, rs, is)  jit_blti_i((label), (rs), (is))
00594 #define jit_bler_l(label, s1, s2)  jit_bler_i((label), (s1), (s2))
00595 #define jit_blei_l(label, rs, is)  jit_blei_i((label), (rs), (is))
00596 #define jit_bgtr_l(label, s1, s2)  jit_bgtr_i((label), (s1), (s2))
00597 #define jit_bgti_l(label, rs, is)  jit_bgti_i((label), (rs), (is))
00598 #define jit_bger_l(label, s1, s2)  jit_bger_i((label), (s1), (s2))
00599 #define jit_bgei_l(label, rs, is)  jit_bgei_i((label), (rs), (is))
00600 #define jit_beqr_l(label, s1, s2)  jit_beqr_i((label), (s1), (s2))
00601 #define jit_beqi_l(label, rs, is)  jit_beqi_i((label), (rs), (is))
00602 #define jit_bner_l(label, s1, s2)  jit_bner_i((label), (s1), (s2))
00603 #define jit_bnei_l(label, rs, is)  jit_bnei_i((label), (rs), (is))
00604 #define jit_bmcr_l(label, s1, s2)  jit_bmcr_i((label), (s1), (s2))
00605 #define jit_bmci_l(label, rs, is)  jit_bmci_i((label), (rs), (is))
00606 #define jit_bmsr_l(label, s1, s2)  jit_bmsr_i((label), (s1), (s2))
00607 #define jit_bmsi_l(label, rs, is)  jit_bmsi_i((label), (rs), (is))
00608 #define jit_boaddr_l(label, s1, s2)       jit_boaddr_i((label), (s1), (s2))
00609 #define jit_boaddi_l(label, rs, is)       jit_boaddi_i((label), (rs), (is))
00610 #define jit_bosubr_l(label, s1, s2)       jit_bosubr_i((label), (s1), (s2))
00611 #define jit_bosubi_l(label, rs, is)       jit_bosubi_i((label), (rs), (is))
00612 #define jit_bomulr_l(label, s1, s2)       jit_bomulr_i((label), (s1), (s2))
00613 #define jit_bltr_ul(label, s1, s2) jit_bltr_ui((label), (s1), (s2))
00614 #define jit_blti_ul(label, rs, is) jit_blti_ui((label), (rs), (is))
00615 #define jit_bler_ul(label, s1, s2) jit_bler_ui((label), (s1), (s2))
00616 #define jit_blei_ul(label, rs, is) jit_blei_ui((label), (rs), (is))
00617 #define jit_bgtr_ul(label, s1, s2) jit_bgtr_ui((label), (s1), (s2))
00618 #define jit_bgti_ul(label, rs, is) jit_bgti_ui((label), (rs), (is))
00619 #define jit_bger_ul(label, s1, s2) jit_bger_ui((label), (s1), (s2))
00620 #define jit_bgei_ul(label, rs, is) jit_bgei_ui((label), (rs), (is))
00621 #define jit_boaddr_ul(label, s1, s2)      jit_boaddr_ui((label), (s1), (s2))
00622 #define jit_boaddi_ul(label, rs, is)      jit_boaddi_ui((label), (rs), (is))
00623 #define jit_bosubr_ul(label, s1, s2)      jit_bosubr_ui((label), (s1), (s2))
00624 #define jit_bosubi_ul(label, rs, is)      jit_bosubi_ui((label), (rs), (is))
00625 
00626 #define jit_retval_l(rd)           jit_retval_i((rd))
00627 
00628 #endif
00629 
00630 #endif /* __lightning_core_common_h_ */