1 /**************************************************************************
3 * Copyright (C) 2008 Tungsten Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 **************************************************************************/
25 * PPC code generation.
34 #include "pipe/p_compiler.h"
37 #define PPC_INST_SIZE 4 /**< 4 bytes / instruction */
39 #define PPC_NUM_VEC_REGS 32
44 uint32_t *store
; /**< instruction buffer */
47 uint32_t vec_used
; /** used/free vector registers bitmask */
48 uint32_t reg_used
; /** used/free general-purpose registers bitmask */
53 extern void ppc_init_func(struct ppc_function
*p
, unsigned max_inst
);
54 extern void ppc_release_func(struct ppc_function
*p
);
56 extern int ppc_allocate_vec_register(struct ppc_function
*p
, int reg
);
57 extern void ppc_release_vec_register(struct ppc_function
*p
, int reg
);
61 ** float vector arithmetic
64 /** vector float add */
66 ppc_vaddfp(struct ppc_function
*p
,uint vD
, uint vA
, uint vB
);
68 /** vector float substract */
70 ppc_vsubfp(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
72 /** vector float min */
74 ppc_vminfp(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
76 /** vector float max */
78 ppc_vmaxfp(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
80 /** vector float mult add */
82 ppc_vmaddfp(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
, uint vC
);
84 /** vector float compare greater than */
86 ppc_vcmpgtfpx(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
88 /** vector float compare greater than or equal to */
90 ppc_vcmpgefpx(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
92 /** vector float compare equal */
94 ppc_vcmpeqfpx(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
96 /** vector float 2^x */
98 ppc_vexptefp(struct ppc_function
*p
, uint vD
, uint vB
);
100 /** vector float log2(x) */
102 ppc_vlogefp(struct ppc_function
*p
, uint vD
, uint vB
);
104 /** vector float reciprocol */
106 ppc_vrefp(struct ppc_function
*p
, uint vD
, uint vB
);
108 /** vector float reciprocol sqrt estimate */
110 ppc_vrsqrtefp(struct ppc_function
*p
, uint vD
, uint vB
);
112 /** vector float round to negative infinity */
114 ppc_vrfim(struct ppc_function
*p
, uint vD
, uint vB
);
116 /** vector float round to positive infinity */
118 ppc_vrfip(struct ppc_function
*p
, uint vD
, uint vB
);
120 /** vector float round to nearest int */
122 ppc_vrfin(struct ppc_function
*p
, uint vD
, uint vB
);
124 /** vector float round to int toward zero */
126 ppc_vrfiz(struct ppc_function
*p
, uint vD
, uint vB
);
131 ** bitwise operations
137 ppc_vand(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
139 /** vector and complement */
141 ppc_vandc(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
145 ppc_vor(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
149 ppc_vnor(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
153 ppc_vxor(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
);
157 ** Vector shuffle / select / splat / etc
160 /** vector permute */
162 ppc_vperm(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
, uint vC
);
166 ppc_vsel(struct ppc_function
*p
, uint vD
, uint vA
, uint vB
, uint vC
);
168 /** vector splat byte */
170 ppc_vspltb(struct ppc_function
*p
, uint vD
, uint vB
, uint imm
);
172 /** vector splat half word */
174 ppc_vsplthw(struct ppc_function
*p
, uint vD
, uint vB
, uint imm
);
176 /** vector splat word */
178 ppc_vspltw(struct ppc_function
*p
, uint vD
, uint vB
, uint imm
);
181 #endif /* RTASM_PPC_H */