Merge branch 'master' into gallium-0.2
[mesa.git] / src / gallium / auxiliary / rtasm / rtasm_ppc.h
1 /**************************************************************************
2 *
3 * Copyright (C) 2008 Tungsten Graphics, Inc. All Rights Reserved.
4 *
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:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
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.
21 *
22 **************************************************************************/
23
24 /**
25 * PPC code generation.
26 * \author Brian Paul
27 */
28
29
30 #ifndef RTASM_PPC_H
31 #define RTASM_PPC_H
32
33
34 #include "pipe/p_compiler.h"
35
36
37 #define PPC_INST_SIZE 4 /**< 4 bytes / instruction */
38
39 #define PPC_NUM_VEC_REGS 32
40
41
42 struct ppc_function
43 {
44 uint32_t *store; /**< instruction buffer */
45 uint num_inst;
46 uint max_inst;
47 uint32_t vec_used; /** used/free vector registers bitmask */
48 uint32_t reg_used; /** used/free general-purpose registers bitmask */
49 };
50
51
52
53 extern void ppc_init_func(struct ppc_function *p, unsigned max_inst);
54 extern void ppc_release_func(struct ppc_function *p);
55
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);
58
59
60 /**
61 ** float vector arithmetic
62 **/
63
64 /** vector float add */
65 extern void
66 ppc_vaddfp(struct ppc_function *p,uint vD, uint vA, uint vB);
67
68 /** vector float substract */
69 extern void
70 ppc_vsubfp(struct ppc_function *p, uint vD, uint vA, uint vB);
71
72 /** vector float min */
73 extern void
74 ppc_vminfp(struct ppc_function *p, uint vD, uint vA, uint vB);
75
76 /** vector float max */
77 extern void
78 ppc_vmaxfp(struct ppc_function *p, uint vD, uint vA, uint vB);
79
80 /** vector float mult add */
81 extern void
82 ppc_vmaddfp(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
83
84 /** vector float compare greater than */
85 extern void
86 ppc_vcmpgtfpx(struct ppc_function *p, uint vD, uint vA, uint vB);
87
88 /** vector float compare greater than or equal to */
89 extern void
90 ppc_vcmpgefpx(struct ppc_function *p, uint vD, uint vA, uint vB);
91
92 /** vector float compare equal */
93 extern void
94 ppc_vcmpeqfpx(struct ppc_function *p, uint vD, uint vA, uint vB);
95
96 /** vector float 2^x */
97 extern void
98 ppc_vexptefp(struct ppc_function *p, uint vD, uint vB);
99
100 /** vector float log2(x) */
101 extern void
102 ppc_vlogefp(struct ppc_function *p, uint vD, uint vB);
103
104 /** vector float reciprocol */
105 extern void
106 ppc_vrefp(struct ppc_function *p, uint vD, uint vB);
107
108 /** vector float reciprocol sqrt estimate */
109 extern void
110 ppc_vrsqrtefp(struct ppc_function *p, uint vD, uint vB);
111
112 /** vector float round to negative infinity */
113 extern void
114 ppc_vrfim(struct ppc_function *p, uint vD, uint vB);
115
116 /** vector float round to positive infinity */
117 extern void
118 ppc_vrfip(struct ppc_function *p, uint vD, uint vB);
119
120 /** vector float round to nearest int */
121 extern void
122 ppc_vrfin(struct ppc_function *p, uint vD, uint vB);
123
124 /** vector float round to int toward zero */
125 extern void
126 ppc_vrfiz(struct ppc_function *p, uint vD, uint vB);
127
128
129
130 /**
131 ** bitwise operations
132 **/
133
134
135 /** vector and */
136 extern void
137 ppc_vand(struct ppc_function *p, uint vD, uint vA, uint vB);
138
139 /** vector and complement */
140 extern void
141 ppc_vandc(struct ppc_function *p, uint vD, uint vA, uint vB);
142
143 /** vector or */
144 extern void
145 ppc_vor(struct ppc_function *p, uint vD, uint vA, uint vB);
146
147 /** vector nor */
148 extern void
149 ppc_vnor(struct ppc_function *p, uint vD, uint vA, uint vB);
150
151 /** vector xor */
152 extern void
153 ppc_vxor(struct ppc_function *p, uint vD, uint vA, uint vB);
154
155
156 /**
157 ** Vector shuffle / select / splat / etc
158 **/
159
160 /** vector permute */
161 extern void
162 ppc_vperm(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
163
164 /** vector select */
165 extern void
166 ppc_vsel(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
167
168 /** vector splat byte */
169 extern void
170 ppc_vspltb(struct ppc_function *p, uint vD, uint vB, uint imm);
171
172 /** vector splat half word */
173 extern void
174 ppc_vsplthw(struct ppc_function *p, uint vD, uint vB, uint imm);
175
176 /** vector splat word */
177 extern void
178 ppc_vspltw(struct ppc_function *p, uint vD, uint vB, uint imm);
179
180
181 #endif /* RTASM_PPC_H */