rtasm_ppc_spe.h

Go to the documentation of this file.
00001 /*
00002  * (C) Copyright IBM Corporation 2008
00003  * All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * on the rights to use, copy, modify, merge, publish, distribute, sub
00009  * license, and/or sell copies of the Software, and to permit persons to whom
00010  * the Software is furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice (including the next
00013  * paragraph) shall be included in all copies or substantial portions of the
00014  * Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
00019  * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
00020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
00021  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
00022  * USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00033 #ifndef RTASM_PPC_SPE_H
00034 #define RTASM_PPC_SPE_H
00035 
00037 #define SPE_INST_SIZE 4
00038 
00040 #define SPE_NUM_REGS  128
00041 
00043 #define SPE_REG_RA  0
00044 
00046 #define SPE_REG_SP  1
00047 
00048 
00049 struct spe_function
00050 {
00051    uint32_t *store;  
00052    uint num_inst;
00053    uint max_inst;
00054 
00065     uint64_t regs[SPE_NUM_REGS / 64];
00066 };
00067 
00068 extern void spe_init_func(struct spe_function *p, unsigned code_size);
00069 extern void spe_release_func(struct spe_function *p);
00070 
00071 extern int spe_allocate_available_register(struct spe_function *p);
00072 extern int spe_allocate_register(struct spe_function *p, int reg);
00073 extern void spe_release_register(struct spe_function *p, int reg);
00074 
00075 #endif /* RTASM_PPC_SPE_H */
00076 
00077 #ifndef EMIT_
00078 #define EMIT_(name, _op) \
00079     extern void _name (struct spe_function *p, unsigned rT)
00080 #define EMIT_R(_name, _op) \
00081     extern void _name (struct spe_function *p, unsigned rT, unsigned rA)
00082 #define EMIT_RR(_name, _op) \
00083     extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
00084                            unsigned rB)
00085 #define EMIT_RRR(_name, _op) \
00086     extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
00087                            unsigned rB, unsigned rC)
00088 #define EMIT_RI7(_name, _op) \
00089     extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
00090                            int imm)
00091 #define EMIT_RI8(_name, _op, bias) \
00092     extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
00093                            int imm)
00094 #define EMIT_RI10(_name, _op) \
00095     extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
00096                            int imm)
00097 #define EMIT_RI16(_name, _op) \
00098     extern void _name (struct spe_function *p, unsigned rT, int imm)
00099 #define EMIT_RI18(_name, _op) \
00100     extern void _name (struct spe_function *p, unsigned rT, int imm)
00101 #define EMIT_I16(_name, _op) \
00102     extern void _name (struct spe_function *p, int imm)
00103 #define UNDEF_EMIT_MACROS
00104 #endif /* EMIT_ */
00105 
00106 
00107 /* Memory load / store instructions
00108  */
00109 EMIT_RI10(spe_lqd,  0x034);
00110 EMIT_RR  (spe_lqx,  0x1c4);
00111 EMIT_RI16(spe_lqa,  0x061);
00112 EMIT_RI16(spe_lqr,  0x067);
00113 EMIT_RI10(spe_stqd, 0x024);
00114 EMIT_RR  (spe_stqx, 0x144);
00115 EMIT_RI16(spe_stqa, 0x041);
00116 EMIT_RI16(spe_stqr, 0x047);
00117 EMIT_RI7 (spe_cbd,  0x1f4);
00118 EMIT_RR  (spe_cbx,  0x1d4);
00119 EMIT_RI7 (spe_chd,  0x1f5);
00120 EMIT_RI7 (spe_chx,  0x1d5);
00121 EMIT_RI7 (spe_cwd,  0x1f6);
00122 EMIT_RI7 (spe_cwx,  0x1d6);
00123 EMIT_RI7 (spe_cdd,  0x1f7);
00124 EMIT_RI7 (spe_cdx,  0x1d7);
00125 
00126 
00127 /* Constant formation instructions
00128  */
00129 EMIT_RI16(spe_ilh,   0x083);
00130 EMIT_RI16(spe_ilhu,  0x082);
00131 EMIT_RI16(spe_il,    0x081);
00132 EMIT_RI18(spe_ila,   0x021);
00133 EMIT_RI16(spe_iohl,  0x0c1);
00134 EMIT_RI16(spe_fsmbi, 0x065);
00135 
00136 
00137 
00138 /* Integer and logical instructions
00139  */
00140 EMIT_RR  (spe_ah,      0x0c8);
00141 EMIT_RI10(spe_ahi,     0x01d);
00142 EMIT_RR  (spe_a,       0x0c0);
00143 EMIT_RI10(spe_ai,      0x01c);
00144 EMIT_RR  (spe_sfh,     0x048);
00145 EMIT_RI10(spe_sfhi,    0x00d);
00146 EMIT_RR  (spe_sf,      0x040);
00147 EMIT_RI10(spe_sfi,     0x00c);
00148 EMIT_RR  (spe_addx,    0x340);
00149 EMIT_RR  (spe_cg,      0x0c2);
00150 EMIT_RR  (spe_cgx,     0x342);
00151 EMIT_RR  (spe_sfx,     0x341);
00152 EMIT_RR  (spe_bg,      0x042);
00153 EMIT_RR  (spe_bgx,     0x343);
00154 EMIT_RR  (spe_mpy,     0x3c4);
00155 EMIT_RR  (spe_mpyu,    0x3cc);
00156 EMIT_RI10(spe_mpyi,    0x074);
00157 EMIT_RI10(spe_mpyui,   0x075);
00158 EMIT_RRR (spe_mpya,    0x00c);
00159 EMIT_RR  (spe_mpyh,    0x3c5);
00160 EMIT_RR  (spe_mpys,    0x3c7);
00161 EMIT_RR  (spe_mpyhh,   0x3c6);
00162 EMIT_RR  (spe_mpyhha,  0x346);
00163 EMIT_RR  (spe_mpyhhu,  0x3ce);
00164 EMIT_RR  (spe_mpyhhau, 0x34e);
00165 EMIT_R   (spe_clz,     0x2a5);
00166 EMIT_R   (spe_cntb,    0x2b4);
00167 EMIT_R   (spe_fsmb,    0x1b6);
00168 EMIT_R   (spe_fsmh,    0x1b5);
00169 EMIT_R   (spe_fsm,     0x1b4);
00170 EMIT_R   (spe_gbb,     0x1b2);
00171 EMIT_R   (spe_gbh,     0x1b1);
00172 EMIT_R   (spe_gb,      0x1b0);
00173 EMIT_RR  (spe_avgb,    0x0d3);
00174 EMIT_RR  (spe_absdb,   0x053);
00175 EMIT_RR  (spe_sumb,    0x253);
00176 EMIT_R   (spe_xsbh,    0x2b6);
00177 EMIT_R   (spe_xshw,    0x2ae);
00178 EMIT_R   (spe_xswd,    0x2a6);
00179 EMIT_RR  (spe_and,     0x0c1);
00180 EMIT_RR  (spe_andc,    0x2c1);
00181 EMIT_RI10(spe_andbi,   0x016);
00182 EMIT_RI10(spe_andhi,   0x015);
00183 EMIT_RI10(spe_andi,    0x014);
00184 EMIT_RR  (spe_or,      0x041);
00185 EMIT_RR  (spe_orc,     0x2c9);
00186 EMIT_RI10(spe_orbi,    0x006);
00187 EMIT_RI10(spe_orhi,    0x005);
00188 EMIT_RI10(spe_ori,     0x004);
00189 EMIT_R   (spe_orx,     0x1f0);
00190 EMIT_RR  (spe_xor,     0x241);
00191 EMIT_RI10(spe_xorbi,   0x026);
00192 EMIT_RI10(spe_xorhi,   0x025);
00193 EMIT_RI10(spe_xori,    0x024);
00194 EMIT_RR  (spe_nand,    0x0c9);
00195 EMIT_RR  (spe_nor,     0x049);
00196 EMIT_RR  (spe_eqv,     0x249);
00197 EMIT_RRR (spe_selb,    0x008);
00198 EMIT_RRR (spe_shufb,   0x00b);
00199 
00200 
00201 /* Shift and rotate instructions
00202  */
00203 EMIT_RR  (spe_shlh,      0x05f);
00204 EMIT_RI7 (spe_shlhi,     0x07f);
00205 EMIT_RR  (spe_shl,       0x05b);
00206 EMIT_RI7 (spe_shli,      0x07b);
00207 EMIT_RR  (spe_shlqbi,    0x1db);
00208 EMIT_RI7 (spe_shlqbii,   0x1fb);
00209 EMIT_RR  (spe_shlqby,    0x1df);
00210 EMIT_RI7 (spe_shlqbyi,   0x1ff);
00211 EMIT_RR  (spe_shlqbybi,  0x1cf);
00212 EMIT_RR  (spe_roth,      0x05c);
00213 EMIT_RI7 (spe_rothi,     0x07c);
00214 EMIT_RR  (spe_rot,       0x058);
00215 EMIT_RI7 (spe_roti,      0x078);
00216 EMIT_RR  (spe_rotqby,    0x1dc);
00217 EMIT_RI7 (spe_rotqbyi,   0x1fc);
00218 EMIT_RR  (spe_rotqbybi,  0x1cc);
00219 EMIT_RR  (spe_rotqbi,    0x1d8);
00220 EMIT_RI7 (spe_rotqbii,   0x1f8);
00221 EMIT_RR  (spe_rothm,     0x05d);
00222 EMIT_RI7 (spe_rothmi,    0x07d);
00223 EMIT_RR  (spe_rotm,      0x059);
00224 EMIT_RI7 (spe_rotmi,     0x079);
00225 EMIT_RR  (spe_rotqmby,   0x1dd);
00226 EMIT_RI7 (spe_rotqmbyi,  0x1fd);
00227 EMIT_RR  (spe_rotqmbybi, 0x1cd);
00228 EMIT_RR  (spe_rotqmbi,   0x1c9);
00229 EMIT_RI7 (spe_rotqmbii,  0x1f9);
00230 EMIT_RR  (spe_rotmah,    0x05e);
00231 EMIT_RI7 (spe_rotmahi,   0x07e);
00232 EMIT_RR  (spe_rotma,     0x05a);
00233 EMIT_RI7 (spe_rotmai,    0x07a);
00234 
00235 
00236 /* Compare, branch, and halt instructions
00237  */
00238 EMIT_RR  (spe_heq,       0x3d8);
00239 EMIT_RI10(spe_heqi,      0x07f);
00240 EMIT_RR  (spe_hgt,       0x258);
00241 EMIT_RI10(spe_hgti,      0x04f);
00242 EMIT_RR  (spe_hlgt,      0x2d8);
00243 EMIT_RI10(spe_hlgti,     0x05f);
00244 EMIT_RR  (spe_ceqb,      0x3d0);
00245 EMIT_RI10(spe_ceqbi,     0x07e);
00246 EMIT_RR  (spe_ceqh,      0x3c8);
00247 EMIT_RI10(spe_ceqhi,     0x07d);
00248 EMIT_RR  (spe_ceq,       0x3c0);
00249 EMIT_RI10(spe_ceqi,      0x07c);
00250 EMIT_RR  (spe_cgtb,      0x250);
00251 EMIT_RI10(spe_cgtbi,     0x04e);
00252 EMIT_RR  (spe_cgth,      0x248);
00253 EMIT_RI10(spe_cgthi,     0x04d);
00254 EMIT_RR  (spe_cgt,       0x240);
00255 EMIT_RI10(spe_cgti,      0x04c);
00256 EMIT_RR  (spe_clgtb,     0x2d0);
00257 EMIT_RI10(spe_clgtbi,    0x05e);
00258 EMIT_RR  (spe_clgth,     0x2c8);
00259 EMIT_RI10(spe_clgthi,    0x05d);
00260 EMIT_RR  (spe_clgt,      0x2c0);
00261 EMIT_RI10(spe_clgti,     0x05c);
00262 EMIT_I16 (spe_br,        0x064);
00263 EMIT_I16 (spe_bra,       0x060);
00264 EMIT_RI16(spe_brsl,      0x066);
00265 EMIT_RI16(spe_brasl,     0x062);
00266 EMIT_RI16(spe_brnz,      0x042);
00267 EMIT_RI16(spe_brz,       0x040);
00268 EMIT_RI16(spe_brhnz,     0x046);
00269 EMIT_RI16(spe_brhz,      0x044);
00270 
00271 extern void spe_bi(struct spe_function *p, unsigned rA, int d, int e);
00272 extern void spe_iret(struct spe_function *p, unsigned rA, int d, int e);
00273 extern void spe_bisled(struct spe_function *p, unsigned rT, unsigned rA,
00274     int d, int e);
00275 extern void spe_bisl(struct spe_function *p, unsigned rT, unsigned rA,
00276     int d, int e);
00277 extern void spe_biz(struct spe_function *p, unsigned rT, unsigned rA,
00278     int d, int e);
00279 extern void spe_binz(struct spe_function *p, unsigned rT, unsigned rA,
00280     int d, int e);
00281 extern void spe_bihz(struct spe_function *p, unsigned rT, unsigned rA,
00282     int d, int e);
00283 extern void spe_bihnz(struct spe_function *p, unsigned rT, unsigned rA,
00284     int d, int e);
00285 
00286 
00288 extern void
00289 spe_load_float(struct spe_function *p, unsigned rT, float x);
00290 
00292 extern void
00293 spe_load_int(struct spe_function *p, unsigned rT, int i);
00294 
00296 extern void
00297 spe_splat(struct spe_function *p, unsigned rT, unsigned rA);
00298 
00300 extern void
00301 spe_complement(struct spe_function *p, unsigned rT);
00302 
00304 extern void
00305 spe_move(struct spe_function *p, unsigned rT, unsigned rA);
00306 
00308 extern void
00309 spe_zero(struct spe_function *p, unsigned rT);
00310 
00311 
00312 /* Floating-point instructions
00313  */
00314 EMIT_RR  (spe_fa,         0x2c4);
00315 EMIT_RR  (spe_dfa,        0x2cc);
00316 EMIT_RR  (spe_fs,         0x2c5);
00317 EMIT_RR  (spe_dfs,        0x2cd);
00318 EMIT_RR  (spe_fm,         0x2c6);
00319 EMIT_RR  (spe_dfm,        0x2ce);
00320 EMIT_RRR (spe_fma,        0x00e);
00321 EMIT_RR  (spe_dfma,       0x35c);
00322 EMIT_RRR (spe_fnms,       0x00d);
00323 EMIT_RR  (spe_dfnms,      0x35e);
00324 EMIT_RRR (spe_fms,        0x00f);
00325 EMIT_RR  (spe_dfms,       0x35d);
00326 EMIT_RR  (spe_dfnma,      0x35f);
00327 EMIT_R   (spe_frest,      0x1b8);
00328 EMIT_R   (spe_frsqest,    0x1b9);
00329 EMIT_RR  (spe_fi,         0x3d4);
00330 EMIT_RI8 (spe_csflt,      0x1da, 155);
00331 EMIT_RI8 (spe_cflts,      0x1d8, 173);
00332 EMIT_RI8 (spe_cuflt,      0x1db, 155);
00333 EMIT_RI8 (spe_cfltu,      0x1d9, 173);
00334 EMIT_R   (spe_frds,       0x3b9);
00335 EMIT_R   (spe_fesd,       0x3b8);
00336 EMIT_RR  (spe_dfceq,      0x3c3);
00337 EMIT_RR  (spe_dfcmeq,     0x3cb);
00338 EMIT_RR  (spe_dfcgt,      0x2c3);
00339 EMIT_RR  (spe_dfcmgt,     0x2cb);
00340 EMIT_RI7 (spe_dftsv,      0x3bf);
00341 EMIT_RR  (spe_fceq,       0x3c2);
00342 EMIT_RR  (spe_fcmeq,      0x3ca);
00343 EMIT_RR  (spe_fcgt,       0x2c2);
00344 EMIT_RR  (spe_fcmgt,      0x2ca);
00345 EMIT_R   (spe_fscrwr,     0x3ba);
00346 EMIT_    (spe_fscrrd,     0x398);
00347 
00348 
00349 /* Channel instructions
00350  */
00351 EMIT_R   (spe_rdch,       0x00d);
00352 EMIT_R   (spe_rdchcnt,    0x00f);
00353 EMIT_R   (spe_wrch,       0x10d);
00354 
00355 
00356 #ifdef UNDEF_EMIT_MACROS
00357 #undef EMIT_
00358 #undef EMIT_R
00359 #undef EMIT_RR
00360 #undef EMIT_RRR
00361 #undef EMIT_RI7
00362 #undef EMIT_RI8
00363 #undef EMIT_RI10
00364 #undef EMIT_RI16
00365 #undef EMIT_RI18
00366 #undef EMIT_I16
00367 #undef UNDEF_EMIT_MACROS
00368 #endif /* EMIT_ */

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4