Back to index

plt-scheme  4.2.1
fp.h
Go to the documentation of this file.
00001 /******************************** -*- C -*- ****************************
00002  *
00003  *     Run-time assembler & support macros for the Sparc math unit
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_asm_fp_h
00036 #define __lightning_asm_fp_h
00037 
00038 
00039 #define JIT_FPR_NUM         6
00040 #define JIT_FPR(i)          (8+(i))
00041 
00042 #define JIT_FPFR            0
00043 
00044 /* Make space for 1 or 2 words, store address in REG */
00045 #define jit_data(REG, D1)           (_FBA (18, 8, 0, 1),  _jit_L(D1), MFLRr(REG))
00046 
00047 #define jit_addr_d(rd,s1,s2)  FADDDrrr((rd),(s1),(s2))
00048 #define jit_subr_d(rd,s1,s2)  FSUBDrrr((rd),(s1),(s2))
00049 #define jit_subrr_d(rd,s1,s2) FSUBDrrr((rd),(s2),(s1))
00050 #define jit_mulr_d(rd,s1,s2)  FMULDrrr((rd),(s1),(s2))
00051 #define jit_divr_d(rd,s1,s2)  FDIVDrrr((rd),(s1),(s2))
00052 #define jit_divrr_d(rd,s1,s2) FDIVDrrr((rd),(s2),(s1))
00053 
00054 #define jit_addr_f(rd,s1,s2)  FADDSrrr((rd),(s1),(s2))
00055 #define jit_subr_f(rd,s1,s2)  FSUBSrrr((rd),(s1),(s2))
00056 #define jit_mulr_f(rd,s1,s2)  FMULSrrr((rd),(s1),(s2))
00057 #define jit_divr_f(rd,s1,s2)  FDIVSrrr((rd),(s1),(s2))
00058 
00059 #define jit_movr_d(rd,rs)     ( (rd) == (rs) ? 0 : FMOVErr((rd),(rs)))
00060 #define jit_movi_d(reg0,d) do {                   \
00061       double _v = (d);                            \
00062       _FBA (18, 12, 0, 1);                  \
00063       memcpy(_jit.x.uc_pc, &_v, sizeof (double)); \
00064       _jit.x.uc_pc += sizeof (double);            \
00065       MFLRr (JIT_AUX);                             \
00066       jit_ldxi_d((reg0), JIT_AUX, 0);              \
00067    } while(0) 
00068 
00069 
00070 #define jit_movr_f(rd,rs)     ( (rd) == (rs) ? 0 : FMOVErr((rd),(rs)))
00071 #define jit_movi_f(reg0,f) do {                   \
00072       float _v = (f);                             \
00073       _FBA (18, 8, 0, 1);                   \
00074       memcpy(_jit.x.uc_pc, &_v, sizeof (float));  \
00075       _jit.x.uc_pc += sizeof (float);             \
00076       MFLRr (JIT_AUX);                             \
00077       jit_ldxi_f((reg0), JIT_AUX, 0);              \
00078    } while(0) 
00079 
00080 
00081 #define jit_abs_d(rd,rs)       FABSrr((rd),(rs))
00082 #define jit_negr_d(rd,rs)      FNEGrr((rd),(rs))
00083 #define jit_sqrt_d(rd,rs)      FSQRTDrr((rd),(rs))
00084 
00085 
00086 #define jit_ldxi_f(reg0, rs, is)    (_siP(16,(is)) ? LFSrri((reg0),(rs),(is)) : (MOVEIri(JIT_AUX,(is)),LFSxrrr((reg0),(rs),JIT_AUX))) 
00087 #define jit_ldxi_d(reg0, rs, is)    (_siP(16,(is)) ? LFDrri((reg0),(rs),(is)) : (MOVEIri(JIT_AUX,(is)),LFDxrrr((reg0),(rs),JIT_AUX)))
00088 #define jit_ldxr_f(reg0, s1, s2)    LFSxrrr((reg0),(s1),(s2))
00089 #define jit_ldxr_d(reg0, s1, s2)    LFDxrrr((reg0),(s1),(s2))
00090 #define jit_ldi_f(reg0, is)          (_siP(16,(is)) ? LFSrri((reg0),0,(is)) : (MOVEIri(JIT_AUX,(is)),LFSrri((reg0),JIT_AUX,0)))
00091 #define jit_ldi_d(reg0, is)          (_siP(16,(is)) ? LFDrri((reg0),0,(is)) : (MOVEIri(JIT_AUX,(is)),LFDrri((reg0),JIT_AUX,0)))
00092 #define jit_ldr_f(reg0, rs)          LFSrri((reg0),(rs),0)
00093 #define jit_ldr_d(reg0, rs)          LFDrri((reg0),(rs),0)
00094 #define jit_stxi_f(id, rd, reg0)     (_siP(16,(id)) ? STFSrri((reg0),(rd),(id)) : (MOVEIri(JIT_AUX,(id)),STFSrri((reg0),(rd),JIT_AUX))) 
00095 #define jit_stxi_d(id, rd, reg0)     (_siP(16,(id)) ? STFDrri((reg0),(rd),(id)) : (MOVEIri(JIT_AUX,(id)),STFDrri((reg0),(rd),JIT_AUX))) 
00096 #define jit_stxr_f(d1, d2, reg0)     STFSxrrr((reg0),(d1),(d2))
00097 #define jit_stxr_d(d1, d2, reg0)     STFDxrrr((reg0),(d1),(d2))
00098 #define jit_sti_f(id, reg0)          (_siP(16,(id)) ? STFSrri((reg0),0,(id)) : (MOVEIri(JIT_AUX,(id)),STFSrri((reg0),JIT_AUX,0)))
00099 #define jit_sti_d(id, reg0)          (_siP(16,(id)) ? STFDrri((reg0),0,(id)) : (MOVEIri(JIT_AUX,(id)),STFDrri((reg0),JIT_AUX,0)))
00100 #define jit_str_f(rd, reg0)          STFSrri((reg0),(rd),0)
00101 #define jit_str_d(rd, reg0)          STFDrri((reg0),(rd),0)
00102 
00103 #define jit_fpboolr(d, s1, s2, rcbit) (          \
00104        FCMPOrrr(_cr0,(s1),(s2)),          \
00105        MFCRr((d)),                        \
00106        EXTRWIrrii((d), (d), 1, (rcbit)))
00107 
00108 #define jit_fpboolr_neg(d, s1, s2,rcbit) (       \
00109        FCMPOrrr(_cr0,(s1),(s2)),          \
00110        MFCRr((d)),                        \
00111        EXTRWIrrii((d), (d), 1, (rcbit)),  \
00112        XORIrri((d), (d), 1))
00113 
00114 #define jit_fpboolur(d, s1, s2, rcbit) (  \
00115        FCMPUrrr(_cr0,(s1),(s2)),          \
00116        MFCRr((d)),                        \
00117        EXTRWIrrii((d), (d), 1, (rcbit)))
00118 
00119 #define jit_fpboolur_neg(d, s1, s2,rcbit) (      \
00120        FCMPUrrr(_cr0,(s1),(s2)),          \
00121        MFCRr((d)),                        \
00122        EXTRWIrrii((d), (d), 1, (rcbit)),  \
00123        XORIrri((d), (d), 1))
00124 
00125 #define jit_fpboolur_or(d, s1, s2, bit1, bit2) (\
00126        FCMPUrrr(_cr0,(s1),(s2)),          \
00127        CRORiii((bit1), (bit1), (bit2)),   \
00128        MFCRr((d)),                        \
00129        EXTRWIrrii((d), (d), 1, (bit1)))
00130 
00131 #define jit_gtr_d(d, s1, s2)      jit_fpboolr ((d),(s1),(s2),_gt)   
00132 #define jit_ger_d(d, s1, s2)      jit_fpboolr_neg((d),(s1),(s2),_lt)   
00133 #define jit_ltr_d(d, s1, s2)      jit_fpboolr ((d),(s1),(s2),_lt)         
00134 #define jit_ler_d(d, s1, s2)      jit_fpboolr_neg((d),(s1),(s2),_gt)         
00135 #define jit_eqr_d(d, s1, s2)      jit_fpboolr ((d),(s1),(s2),_eq)         
00136 #define jit_ner_d(d, s1, s2)      jit_fpboolr_neg((d),(s1),(s2),_eq)
00137 #define jit_unordr_d(d, s1, s2)   jit_fpboolur ((d),(s1),(s2),_un)
00138 #define jit_ordr_d(d, s1, s2)     jit_fpboolur_neg((d),(s1),(s2),_un)
00139 #define jit_unler_d(d, s1, s2)    jit_fpboolur_neg ((d), (s1), (s2), _gt)
00140 #define jit_unltr_d(d, s1, s2)    jit_fpboolur_or ((d), (s1), (s2), _un, _lt)
00141 #define jit_unger_d(d, s1, s2)    jit_fpboolur_neg ((d), (s1), (s2), _lt)
00142 #define jit_ungtr_d(d, s1, s2)    jit_fpboolur_or ((d), (s1), (s2), _un, _gt)
00143 #define jit_ltgtr_d(d, s1, s2)    jit_fpboolur_or ((d), (s1), (s2), _gt, _lt)
00144 #define jit_uneqr_d(d, s1, s2)    jit_fpboolur_or ((d), (s1), (s2), _un, _eq)
00145 
00146 #define jit_fpbr(d, s1, s2, rcbit) (             \
00147        FCMPOrrr(_cr0,(s1),(s2)),          \
00148        BTii ((rcbit), (d)), _jit.x.pc)
00149 
00150 #define jit_fpbr_neg(d, s1, s2,rcbit) (   \
00151        FCMPOrrr(_cr0,(s1),(s2)),          \
00152        BFii ((rcbit), (d)), _jit.x.pc)
00153 
00154 #define jit_fpbur(d, s1, s2, rcbit) (            \
00155        FCMPUrrr(_cr0,(s1),(s2)),          \
00156        BTii ((rcbit), (d)), _jit.x.pc)
00157 
00158 #define jit_fpbur_neg(d, s1, s2,rcbit) (  \
00159        FCMPUrrr(_cr0,(s1),(s2)),          \
00160        BFii ((rcbit), (d)), _jit.x.pc)
00161 
00162 #define jit_fpbur_or(d, s1, s2, bit1, bit2) (    \
00163        FCMPUrrr(_cr0,(s1),(s2)),          \
00164        CRORiii((bit1), (bit1), (bit2)),   \
00165        BTii ((bit1), (d)), _jit.x.pc)
00166 
00167 #define jit_fpbur_or_neg(d, s1, s2, bit1, bit2) (       \
00168        FCMPUrrr(_cr0,(s1),(s2)),          \
00169        CRORiii((bit1), (bit1), (bit2)),   \
00170        BFii ((bit1), (d)), _jit.x.pc)
00171 
00172 #define jit_bgtr_d(d, s1, s2)      jit_fpbur ((d),(s1),(s2),_gt)   
00173 #define jit_bger_d(d, s1, s2)      jit_fpbur_or((d),(s1),(s2),_gt, _eq)   
00174 #define jit_bltr_d(d, s1, s2)      jit_fpbur ((d),(s1),(s2),_lt)         
00175 #define jit_bler_d(d, s1, s2)      jit_fpbur_or((d),(s1),(s2),_lt, _eq)
00176 #define jit_beqr_d(d, s1, s2)      jit_fpbur ((d),(s1),(s2),_eq)         
00177 #define jit_bner_d(d, s1, s2)      jit_fpbur_neg((d),(s1),(s2),_eq)
00178 #define jit_bunordr_d(d, s1, s2)   jit_fpbur ((d),(s1),(s2),_un)
00179 #define jit_bordr_d(d, s1, s2)     jit_fpbur_neg((d),(s1),(s2),_un)
00180 #define jit_bunler_d(d, s1, s2)    jit_fpbur_neg ((d), (s1), (s2), _gt)
00181 #define jit_bunltr_d(d, s1, s2)    jit_fpbur_or ((d), (s1), (s2), _un, _lt)
00182 #define jit_bunger_d(d, s1, s2)    jit_fpbur_neg ((d), (s1), (s2), _lt)
00183 #define jit_bungtr_d(d, s1, s2)    jit_fpbur_or ((d), (s1), (s2), _un, _gt)
00184 #define jit_bltgtr_d(d, s1, s2)    jit_fpbur_or ((d), (s1), (s2), _gt, _lt)
00185 #define jit_buneqr_d(d, s1, s2)    jit_fpbur_or ((d), (s1), (s2), _un, _eq)
00186 
00187 #define jit_bantiltr_d(d, s1, s2)  jit_fpbur_neg ((d),(s1),(s2),_lt)
00188 #define jit_bantiler_d(d, s1, s2)  jit_fpbur_or_neg ((d),(s1),(s2),_lt, _eq)
00189 #define jit_bantieqr_d(d, s1, s2)  jit_fpbur_neg ((d),(s1),(s2),_eq)
00190 #define jit_bantiger_d(d, s1, s2)  jit_fpbur_or_neg ((d),(s1),(s2),_gt, _eq)
00191 #define jit_bantigtr_d(d, s1, s2)  jit_fpbur_neg ((d),(s1),(s2),_gt)
00192 
00193 #define jit_getarg_f(rd, ofs)        jit_movr_f((rd),(ofs))
00194 #define jit_getarg_d(rd, ofs)        jit_movr_d((rd),(ofs))
00195 #define jit_pusharg_d(rs)        (_jitl.nextarg_putd--,jit_movr_d((_jitl.nextarg_putf+_jitl.nextarg_putd+1), (rs)))
00196 #define jit_pusharg_f(rs)        (_jitl.nextarg_putf--,jit_movr_f((_jitl.nextarg_putf+_jitl.nextarg_putd+1), (rs)))
00197 #define jit_retval_d(op1)            jit_movr_d(1, (op1))
00198 #define jit_retval_f(op1)            jit_movr_f(1, (op1))
00199 
00200 
00201 #define jit_floorr_d_i(rd,rs)  (MTFSFIri(7,3), \
00202                                   FCTIWrr(7,(rs)),    \
00203                                   MOVEIri(JIT_AUX,-4), \
00204                                   STFIWXrrr(7,JIT_SP,JIT_AUX),   \
00205                                   LWZrm((rd),-4,JIT_SP))
00206 
00207 #define jit_ceilr_d_i(rd,rs)   (MTFSFIri(7,2), \
00208                                   FCTIWrr(7,(rs)),    \
00209                                   MOVEIri(JIT_AUX,-4), \
00210                                   STFIWXrrr(7,JIT_SP,JIT_AUX),   \
00211                                   LWZrm((rd),-4,JIT_SP))
00212 
00213 #define jit_roundr_d_i(rd,rs)  (MTFSFIri(7,0), \
00214                                   FCTIWrr(7,(rs)),    \
00215                                   MOVEIri(JIT_AUX,-4), \
00216                                   STFIWXrrr(7,JIT_SP,JIT_AUX),   \
00217                                   LWZrm((rd),-4,JIT_SP))
00218 
00219 #define jit_truncr_d_i(rd,rs)  (FCTIWZrr(7,(rs)), \
00220                                   MOVEIri(JIT_AUX,-4), \
00221                                   STFIWXrrr(7,JIT_SP,JIT_AUX),   \
00222                                   LWZrm((rd),-4,JIT_SP))
00223 
00224 #endif /* __lightning_asm_h */