1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 * TGSI to PowerPC code generation.
32 #include "pipe/p_config.h"
34 #if defined(PIPE_ARCH_PPC)
36 #include "util/u_debug.h"
37 #include "pipe/p_shader_tokens.h"
38 #include "util/u_math.h"
39 #include "util/u_memory.h"
40 #include "util/u_sse.h"
41 #include "tgsi/tgsi_info.h"
42 #include "tgsi/tgsi_parse.h"
43 #include "tgsi/tgsi_util.h"
44 #include "tgsi_dump.h"
45 #include "tgsi_exec.h"
47 #include "rtasm/rtasm_ppc.h"
51 * Since it's pretty much impossible to form PPC vector immediates, load
52 * them from memory here:
54 const float ppc_builtin_constants
[] ALIGN16_ATTRIB
= {
55 1.0f
, -128.0f
, 128.0, 0.0
59 #define FOR_EACH_CHANNEL( CHAN )\
60 for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
62 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
63 ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
65 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
66 if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
68 #define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
69 FOR_EACH_CHANNEL( CHAN )\
70 IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
79 * How many TGSI temps should be implemented with real PPC vector registers
82 #define MAX_PPC_TEMPS 3
86 * Context/state used during code gen.
90 struct ppc_function
*f
;
91 int inputs_reg
; /**< GP register pointing to input params */
92 int outputs_reg
; /**< GP register pointing to output params */
93 int temps_reg
; /**< GP register pointing to temporary "registers" */
94 int immed_reg
; /**< GP register pointing to immediates buffer */
95 int const_reg
; /**< GP register pointing to constants buffer */
96 int builtins_reg
; /**< GP register pointint to built-in constants */
98 int offset_reg
; /**< used to reduce redundant li instructions */
101 int one_vec
; /**< vector register with {1.0, 1.0, 1.0, 1.0} */
102 int bit31_vec
; /**< vector register with {1<<31, 1<<31, 1<<31, 1<<31} */
105 * Map TGSI temps to PPC vector temps.
106 * We have 32 PPC vector regs. Use 16 of them for storing 4 TGSI temps.
107 * XXX currently only do this for TGSI temps [0..MAX_PPC_TEMPS-1].
109 int temps_map
[MAX_PPC_TEMPS
][4];
112 * Cache of src registers.
113 * This is used to avoid redundant load instructions.
116 struct tgsi_full_src_register src
;
119 } regs
[12]; /* 3 src regs, 4 channels */
125 * Initialize code generation context.
128 init_gen_context(struct gen_context
*gen
, struct ppc_function
*func
)
132 memset(gen
, 0, sizeof(*gen
));
134 gen
->inputs_reg
= ppc_reserve_register(func
, 3); /* first function param */
135 gen
->outputs_reg
= ppc_reserve_register(func
, 4); /* second function param */
136 gen
->temps_reg
= ppc_reserve_register(func
, 5); /* ... */
137 gen
->immed_reg
= ppc_reserve_register(func
, 6);
138 gen
->const_reg
= ppc_reserve_register(func
, 7);
139 gen
->builtins_reg
= ppc_reserve_register(func
, 8);
142 gen
->offset_reg
= -1;
143 gen
->offset_value
= -9999999;
144 for (i
= 0; i
< MAX_PPC_TEMPS
; i
++) {
145 gen
->temps_map
[i
][0] = ppc_allocate_vec_register(gen
->f
);
146 gen
->temps_map
[i
][1] = ppc_allocate_vec_register(gen
->f
);
147 gen
->temps_map
[i
][2] = ppc_allocate_vec_register(gen
->f
);
148 gen
->temps_map
[i
][3] = ppc_allocate_vec_register(gen
->f
);
154 * Is the given TGSI register stored as a real PPC vector register?
157 is_ppc_vec_temporary(const struct tgsi_full_src_register
*reg
)
159 return (reg
->SrcRegister
.File
== TGSI_FILE_TEMPORARY
&&
160 reg
->SrcRegister
.Index
< MAX_PPC_TEMPS
);
165 * Is the given TGSI register stored as a real PPC vector register?
168 is_ppc_vec_temporary_dst(const struct tgsi_full_dst_register
*reg
)
170 return (reg
->DstRegister
.File
== TGSI_FILE_TEMPORARY
&&
171 reg
->DstRegister
.Index
< MAX_PPC_TEMPS
);
177 * All PPC vector load/store instructions form an effective address
178 * by adding the contents of two registers. For example:
179 * lvx v2,r8,r9 # v2 = memory[r8 + r9]
180 * stvx v2,r8,r9 # memory[r8 + r9] = v2;
181 * So our lvx/stvx instructions are typically preceded by an 'li' instruction
182 * to load r9 (above) with an immediate (an offset).
183 * This code emits that 'li' instruction, but only if the offset value is
184 * different than the previous 'li'.
185 * This optimization seems to save about 10% in the instruction count.
186 * Note that we need to unconditionally emit an 'li' inside basic blocks
187 * (such as inside loops).
190 emit_li_offset(struct gen_context
*gen
, int offset
)
192 if (gen
->offset_reg
<= 0) {
193 /* allocate a GP register for storing load/store offset */
194 gen
->offset_reg
= ppc_allocate_register(gen
->f
);
197 /* emit new 'li' if offset is changing */
198 if (gen
->offset_value
< 0 || gen
->offset_value
!= offset
) {
199 gen
->offset_value
= offset
;
200 ppc_li(gen
->f
, gen
->offset_reg
, offset
);
203 return gen
->offset_reg
;
208 * Forces subsequent emit_li_offset() calls to emit an 'li'.
209 * To be called at the top of basic blocks.
212 reset_li_offset(struct gen_context
*gen
)
214 gen
->offset_value
= -9999999;
220 * Load the given vector register with {value, value, value, value}.
221 * The value must be in the ppu_builtin_constants[] array.
222 * We wouldn't need this if there was a simple way to load PPC vector
223 * registers with immediate values!
226 load_constant_vec(struct gen_context
*gen
, int dst_vec
, float value
)
229 for (pos
= 0; pos
< Elements(ppc_builtin_constants
); pos
++) {
230 if (ppc_builtin_constants
[pos
] == value
) {
231 int offset
= pos
* 4;
232 int offset_reg
= emit_li_offset(gen
, offset
);
234 /* Load 4-byte word into vector register.
235 * The vector slot depends on the effective address we load from.
236 * We know that our builtins start at a 16-byte boundary so we
237 * know that 'swizzle' tells us which vector slot will have the
238 * loaded word. The other vector slots will be undefined.
240 ppc_lvewx(gen
->f
, dst_vec
, gen
->builtins_reg
, offset_reg
);
241 /* splat word[pos % 4] across the vector reg */
242 ppc_vspltw(gen
->f
, dst_vec
, dst_vec
, pos
% 4);
246 assert(0 && "Need to add new constant to ppc_builtin_constants array");
251 * Return index of vector register containing {1.0, 1.0, 1.0, 1.0}.
254 gen_one_vec(struct gen_context
*gen
)
256 if (gen
->one_vec
< 0) {
257 gen
->one_vec
= ppc_allocate_vec_register(gen
->f
);
258 load_constant_vec(gen
, gen
->one_vec
, 1.0f
);
264 * Return index of vector register containing {1<<31, 1<<31, 1<<31, 1<<31}.
267 gen_get_bit31_vec(struct gen_context
*gen
)
269 if (gen
->bit31_vec
< 0) {
270 gen
->bit31_vec
= ppc_allocate_vec_register(gen
->f
);
271 ppc_vspltisw(gen
->f
, gen
->bit31_vec
, -1);
272 ppc_vslw(gen
->f
, gen
->bit31_vec
, gen
->bit31_vec
, gen
->bit31_vec
);
274 return gen
->bit31_vec
;
279 * Register fetch. Return PPC vector register with result.
282 emit_fetch(struct gen_context
*gen
,
283 const struct tgsi_full_src_register
*reg
,
284 const unsigned chan_index
)
286 uint swizzle
= tgsi_util_get_full_src_register_swizzle(reg
, chan_index
);
294 switch (reg
->SrcRegister
.File
) {
295 case TGSI_FILE_INPUT
:
297 int offset
= (reg
->SrcRegister
.Index
* 4 + swizzle
) * 16;
298 int offset_reg
= emit_li_offset(gen
, offset
);
299 dst_vec
= ppc_allocate_vec_register(gen
->f
);
300 ppc_lvx(gen
->f
, dst_vec
, gen
->inputs_reg
, offset_reg
);
303 case TGSI_FILE_TEMPORARY
:
304 if (is_ppc_vec_temporary(reg
)) {
305 /* use PPC vec register */
306 dst_vec
= gen
->temps_map
[reg
->SrcRegister
.Index
][swizzle
];
309 /* use memory-based temp register "file" */
310 int offset
= (reg
->SrcRegister
.Index
* 4 + swizzle
) * 16;
311 int offset_reg
= emit_li_offset(gen
, offset
);
312 dst_vec
= ppc_allocate_vec_register(gen
->f
);
313 ppc_lvx(gen
->f
, dst_vec
, gen
->temps_reg
, offset_reg
);
316 case TGSI_FILE_IMMEDIATE
:
318 int offset
= (reg
->SrcRegister
.Index
* 4 + swizzle
) * 4;
319 int offset_reg
= emit_li_offset(gen
, offset
);
320 dst_vec
= ppc_allocate_vec_register(gen
->f
);
321 /* Load 4-byte word into vector register.
322 * The vector slot depends on the effective address we load from.
323 * We know that our immediates start at a 16-byte boundary so we
324 * know that 'swizzle' tells us which vector slot will have the
325 * loaded word. The other vector slots will be undefined.
327 ppc_lvewx(gen
->f
, dst_vec
, gen
->immed_reg
, offset_reg
);
328 /* splat word[swizzle] across the vector reg */
329 ppc_vspltw(gen
->f
, dst_vec
, dst_vec
, swizzle
);
332 case TGSI_FILE_CONSTANT
:
334 int offset
= (reg
->SrcRegister
.Index
* 4 + swizzle
) * 4;
335 int offset_reg
= emit_li_offset(gen
, offset
);
336 dst_vec
= ppc_allocate_vec_register(gen
->f
);
337 /* Load 4-byte word into vector register.
338 * The vector slot depends on the effective address we load from.
339 * We know that our constants start at a 16-byte boundary so we
340 * know that 'swizzle' tells us which vector slot will have the
341 * loaded word. The other vector slots will be undefined.
343 ppc_lvewx(gen
->f
, dst_vec
, gen
->const_reg
, offset_reg
);
344 /* splat word[swizzle] across the vector reg */
345 ppc_vspltw(gen
->f
, dst_vec
, dst_vec
, swizzle
);
356 assert(dst_vec
>= 0);
359 uint sign_op
= tgsi_util_get_full_src_register_sign_mode(reg
, chan_index
);
360 if (sign_op
!= TGSI_UTIL_SIGN_KEEP
) {
361 int bit31_vec
= gen_get_bit31_vec(gen
);
364 if (is_ppc_vec_temporary(reg
)) {
365 /* need to use a new temp */
366 dst_vec2
= ppc_allocate_vec_register(gen
->f
);
373 case TGSI_UTIL_SIGN_CLEAR
:
374 /* vec = vec & ~bit31 */
375 ppc_vandc(gen
->f
, dst_vec2
, dst_vec
, bit31_vec
);
377 case TGSI_UTIL_SIGN_SET
:
378 /* vec = vec | bit31 */
379 ppc_vor(gen
->f
, dst_vec2
, dst_vec
, bit31_vec
);
381 case TGSI_UTIL_SIGN_TOGGLE
:
382 /* vec = vec ^ bit31 */
383 ppc_vxor(gen
->f
, dst_vec2
, dst_vec
, bit31_vec
);
398 * Test if two TGSI src registers refer to the same memory location.
399 * We use this to avoid redundant register loads.
402 equal_src_locs(const struct tgsi_full_src_register
*a
, uint chan_a
,
403 const struct tgsi_full_src_register
*b
, uint chan_b
)
407 if (a
->SrcRegister
.File
!= b
->SrcRegister
.File
)
409 if (a
->SrcRegister
.Index
!= b
->SrcRegister
.Index
)
411 swz_a
= tgsi_util_get_full_src_register_swizzle(a
, chan_a
);
412 swz_b
= tgsi_util_get_full_src_register_swizzle(b
, chan_b
);
415 sign_a
= tgsi_util_get_full_src_register_sign_mode(a
, chan_a
);
416 sign_b
= tgsi_util_get_full_src_register_sign_mode(b
, chan_b
);
417 if (sign_a
!= sign_b
)
424 * Given a TGSI src register and channel index, return the PPC vector
425 * register containing the value. We use a cache to prevent re-loading
426 * the same register multiple times.
427 * \return index of PPC vector register with the desired src operand
430 get_src_vec(struct gen_context
*gen
,
431 struct tgsi_full_instruction
*inst
, int src_reg
, uint chan
)
433 const const struct tgsi_full_src_register
*src
=
434 &inst
->FullSrcRegisters
[src_reg
];
438 /* check the cache */
439 for (i
= 0; i
< gen
->num_regs
; i
++) {
440 if (equal_src_locs(&gen
->regs
[i
].src
, gen
->regs
[i
].chan
, src
, chan
)) {
442 assert(gen
->regs
[i
].vec
>= 0);
443 return gen
->regs
[i
].vec
;
447 /* cache miss: allocate new vec reg and emit fetch/load code */
448 vec
= emit_fetch(gen
, src
, chan
);
449 gen
->regs
[gen
->num_regs
].src
= *src
;
450 gen
->regs
[gen
->num_regs
].chan
= chan
;
451 gen
->regs
[gen
->num_regs
].vec
= vec
;
454 assert(gen
->num_regs
<= Elements(gen
->regs
));
463 * Clear the src operand cache. To be called at the end of each emit function.
466 release_src_vecs(struct gen_context
*gen
)
469 for (i
= 0; i
< gen
->num_regs
; i
++) {
470 const const struct tgsi_full_src_register src
= gen
->regs
[i
].src
;
471 if (!is_ppc_vec_temporary(&src
)) {
472 ppc_release_vec_register(gen
->f
, gen
->regs
[i
].vec
);
481 get_dst_vec(struct gen_context
*gen
,
482 const struct tgsi_full_instruction
*inst
,
485 const struct tgsi_full_dst_register
*reg
= &inst
->FullDstRegisters
[0];
487 if (is_ppc_vec_temporary_dst(reg
)) {
488 int vec
= gen
->temps_map
[reg
->DstRegister
.Index
][chan_index
];
492 return ppc_allocate_vec_register(gen
->f
);
498 * Register store. Store 'src_vec' at location indicated by 'reg'.
499 * \param free_vec Should the src_vec be released when done?
502 emit_store(struct gen_context
*gen
,
504 const struct tgsi_full_instruction
*inst
,
508 const struct tgsi_full_dst_register
*reg
= &inst
->FullDstRegisters
[0];
510 switch (reg
->DstRegister
.File
) {
511 case TGSI_FILE_OUTPUT
:
513 int offset
= (reg
->DstRegister
.Index
* 4 + chan_index
) * 16;
514 int offset_reg
= emit_li_offset(gen
, offset
);
515 ppc_stvx(gen
->f
, src_vec
, gen
->outputs_reg
, offset_reg
);
518 case TGSI_FILE_TEMPORARY
:
519 if (is_ppc_vec_temporary_dst(reg
)) {
521 int dst_vec
= gen
->temps_map
[reg
->DstRegister
.Index
][chan_index
];
522 if (dst_vec
!= src_vec
)
523 ppc_vmove(gen
->f
, dst_vec
, src_vec
);
528 int offset
= (reg
->DstRegister
.Index
* 4 + chan_index
) * 16;
529 int offset_reg
= emit_li_offset(gen
, offset
);
530 ppc_stvx(gen
->f
, src_vec
, gen
->temps_reg
, offset_reg
);
534 case TGSI_FILE_ADDRESS
:
538 reg
->DstRegister
.Index
,
547 switch( inst
->Instruction
.Saturate
) {
551 case TGSI_SAT_ZERO_ONE
:
555 case TGSI_SAT_MINUS_PLUS_ONE
:
562 ppc_release_vec_register(gen
->f
, src_vec
);
567 emit_scalar_unaryop(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
572 v0
= get_src_vec(gen
, inst
, 0, CHAN_X
);
573 v1
= ppc_allocate_vec_register(gen
->f
);
575 switch (inst
->Instruction
.Opcode
) {
576 case TGSI_OPCODE_RSQ
:
577 /* v1 = 1.0 / sqrt(v0) */
578 ppc_vrsqrtefp(gen
->f
, v1
, v0
);
580 case TGSI_OPCODE_RCP
:
582 ppc_vrefp(gen
->f
, v1
, v0
);
588 FOR_EACH_DST0_ENABLED_CHANNEL( *inst
, chan_index
) {
589 emit_store(gen
, v1
, inst
, chan_index
, FALSE
);
592 release_src_vecs(gen
);
593 ppc_release_vec_register(gen
->f
, v1
);
598 emit_unaryop(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
602 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan_index
) {
603 int v0
= get_src_vec(gen
, inst
, 0, chan_index
); /* v0 = srcreg[0] */
604 int v1
= get_dst_vec(gen
, inst
, chan_index
);
605 switch (inst
->Instruction
.Opcode
) {
606 case TGSI_OPCODE_ABS
:
607 /* turn off the most significant bit of each vector float word */
609 int bit31_vec
= gen_get_bit31_vec(gen
);
610 ppc_vandc(gen
->f
, v1
, v0
, bit31_vec
); /* v1 = v0 & ~bit31 */
613 case TGSI_OPCODE_FLR
:
614 ppc_vrfim(gen
->f
, v1
, v0
); /* v1 = floor(v0) */
616 case TGSI_OPCODE_FRC
:
617 ppc_vrfim(gen
->f
, v1
, v0
); /* tmp = floor(v0) */
618 ppc_vsubfp(gen
->f
, v1
, v0
, v1
); /* v1 = v0 - v1 */
620 case TGSI_OPCODE_EX2
:
621 ppc_vexptefp(gen
->f
, v1
, v0
); /* v1 = 2^v0 */
623 case TGSI_OPCODE_LG2
:
624 /* XXX this may be broken! */
625 ppc_vlogefp(gen
->f
, v1
, v0
); /* v1 = log2(v0) */
627 case TGSI_OPCODE_MOV
:
629 ppc_vmove(gen
->f
, v1
, v0
);
634 emit_store(gen
, v1
, inst
, chan_index
, TRUE
); /* store v0 */
637 release_src_vecs(gen
);
642 emit_binop(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
647 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_MUL
) {
648 zero_vec
= ppc_allocate_vec_register(gen
->f
);
649 ppc_vzero(gen
->f
, zero_vec
);
652 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan
) {
653 /* fetch src operands */
654 int v0
= get_src_vec(gen
, inst
, 0, chan
);
655 int v1
= get_src_vec(gen
, inst
, 1, chan
);
656 int v2
= get_dst_vec(gen
, inst
, chan
);
659 switch (inst
->Instruction
.Opcode
) {
660 case TGSI_OPCODE_ADD
:
661 ppc_vaddfp(gen
->f
, v2
, v0
, v1
);
663 case TGSI_OPCODE_SUB
:
664 ppc_vsubfp(gen
->f
, v2
, v0
, v1
);
666 case TGSI_OPCODE_MUL
:
667 ppc_vmaddfp(gen
->f
, v2
, v0
, v1
, zero_vec
);
669 case TGSI_OPCODE_MIN
:
670 ppc_vminfp(gen
->f
, v2
, v0
, v1
);
672 case TGSI_OPCODE_MAX
:
673 ppc_vmaxfp(gen
->f
, v2
, v0
, v1
);
680 emit_store(gen
, v2
, inst
, chan
, TRUE
);
683 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_MUL
)
684 ppc_release_vec_register(gen
->f
, zero_vec
);
686 release_src_vecs(gen
);
691 emit_triop(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
695 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan
) {
696 /* fetch src operands */
697 int v0
= get_src_vec(gen
, inst
, 0, chan
);
698 int v1
= get_src_vec(gen
, inst
, 1, chan
);
699 int v2
= get_src_vec(gen
, inst
, 2, chan
);
700 int v3
= get_dst_vec(gen
, inst
, chan
);
703 switch (inst
->Instruction
.Opcode
) {
704 case TGSI_OPCODE_MAD
:
705 ppc_vmaddfp(gen
->f
, v3
, v0
, v1
, v2
); /* v3 = v0 * v1 + v2 */
707 case TGSI_OPCODE_LRP
:
708 ppc_vsubfp(gen
->f
, v3
, v1
, v2
); /* v3 = v1 - v2 */
709 ppc_vmaddfp(gen
->f
, v3
, v0
, v3
, v2
); /* v3 = v0 * v3 + v2 */
716 emit_store(gen
, v3
, inst
, chan
, TRUE
);
719 release_src_vecs(gen
);
724 * Vector comparisons, resulting in 1.0 or 0.0 values.
727 emit_inequality(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
730 int one_vec
= gen_one_vec(gen
);
732 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan
) {
733 /* fetch src operands */
734 int v0
= get_src_vec(gen
, inst
, 0, chan
);
735 int v1
= get_src_vec(gen
, inst
, 1, chan
);
736 int v2
= get_dst_vec(gen
, inst
, chan
);
737 boolean complement
= FALSE
;
739 switch (inst
->Instruction
.Opcode
) {
740 case TGSI_OPCODE_SNE
:
743 case TGSI_OPCODE_SEQ
:
744 ppc_vcmpeqfpx(gen
->f
, v2
, v0
, v1
); /* v2 = v0 == v1 ? ~0 : 0 */
747 case TGSI_OPCODE_SGE
:
750 case TGSI_OPCODE_SLT
:
751 ppc_vcmpgtfpx(gen
->f
, v2
, v1
, v0
); /* v2 = v1 > v0 ? ~0 : 0 */
754 case TGSI_OPCODE_SLE
:
757 case TGSI_OPCODE_SGT
:
758 ppc_vcmpgtfpx(gen
->f
, v2
, v0
, v1
); /* v2 = v0 > v1 ? ~0 : 0 */
764 /* v2 is now {0,0,0,0} or {~0,~0,~0,~0} */
767 ppc_vandc(gen
->f
, v2
, one_vec
, v2
); /* v2 = one_vec & ~v2 */
769 ppc_vand(gen
->f
, v2
, one_vec
, v2
); /* v2 = one_vec & v2 */
772 emit_store(gen
, v2
, inst
, chan
, TRUE
);
775 release_src_vecs(gen
);
780 emit_dotprod(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
785 v2
= ppc_allocate_vec_register(gen
->f
);
787 ppc_vzero(gen
->f
, v2
); /* v2 = {0, 0, 0, 0} */
789 v0
= get_src_vec(gen
, inst
, 0, CHAN_X
); /* v0 = src0.XXXX */
790 v1
= get_src_vec(gen
, inst
, 1, CHAN_X
); /* v1 = src1.XXXX */
791 ppc_vmaddfp(gen
->f
, v2
, v0
, v1
, v2
); /* v2 = v0 * v1 + v2 */
793 v0
= get_src_vec(gen
, inst
, 0, CHAN_Y
); /* v0 = src0.YYYY */
794 v1
= get_src_vec(gen
, inst
, 1, CHAN_Y
); /* v1 = src1.YYYY */
795 ppc_vmaddfp(gen
->f
, v2
, v0
, v1
, v2
); /* v2 = v0 * v1 + v2 */
797 v0
= get_src_vec(gen
, inst
, 0, CHAN_Z
); /* v0 = src0.ZZZZ */
798 v1
= get_src_vec(gen
, inst
, 1, CHAN_Z
); /* v1 = src1.ZZZZ */
799 ppc_vmaddfp(gen
->f
, v2
, v0
, v1
, v2
); /* v2 = v0 * v1 + v2 */
801 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_DP4
) {
802 v0
= get_src_vec(gen
, inst
, 0, CHAN_W
); /* v0 = src0.WWWW */
803 v1
= get_src_vec(gen
, inst
, 1, CHAN_W
); /* v1 = src1.WWWW */
804 ppc_vmaddfp(gen
->f
, v2
, v0
, v1
, v2
); /* v2 = v0 * v1 + v2 */
806 else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_DPH
) {
807 v1
= get_src_vec(gen
, inst
, 1, CHAN_W
); /* v1 = src1.WWWW */
808 ppc_vaddfp(gen
->f
, v2
, v2
, v1
); /* v2 = v2 + v1 */
811 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan_index
) {
812 emit_store(gen
, v2
, inst
, chan_index
, FALSE
); /* store v2, free v2 later */
815 release_src_vecs(gen
);
817 ppc_release_vec_register(gen
->f
, v2
);
821 /** Approximation for vr = pow(va, vb) */
823 ppc_vec_pow(struct ppc_function
*f
, int vr
, int va
, int vb
)
825 /* pow(a,b) ~= exp2(log2(a) * b) */
826 int t_vec
= ppc_allocate_vec_register(f
);
827 int zero_vec
= ppc_allocate_vec_register(f
);
829 ppc_vzero(f
, zero_vec
);
831 ppc_vlogefp(f
, t_vec
, va
); /* t = log2(va) */
832 ppc_vmaddfp(f
, t_vec
, t_vec
, vb
, zero_vec
); /* t = t * vb + zero */
833 ppc_vexptefp(f
, vr
, t_vec
); /* vr = 2^t */
835 ppc_release_vec_register(f
, t_vec
);
836 ppc_release_vec_register(f
, zero_vec
);
841 emit_lit(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
843 int one_vec
= gen_one_vec(gen
);
846 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
847 emit_store(gen
, one_vec
, inst
, CHAN_X
, FALSE
);
851 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
) ||
852 IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
854 int zero_vec
= ppc_allocate_vec_register(gen
->f
);
856 x_vec
= get_src_vec(gen
, inst
, 0, CHAN_X
); /* x_vec = src[0].x */
858 ppc_vzero(gen
->f
, zero_vec
); /* zero = {0,0,0,0} */
859 ppc_vmaxfp(gen
->f
, x_vec
, x_vec
, zero_vec
); /* x_vec = max(x_vec, 0) */
861 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
862 emit_store(gen
, x_vec
, inst
, CHAN_Y
, FALSE
);
865 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
867 int z_vec
= ppc_allocate_vec_register(gen
->f
);
868 int pow_vec
= ppc_allocate_vec_register(gen
->f
);
869 int pos_vec
= ppc_allocate_vec_register(gen
->f
);
870 int p128_vec
= ppc_allocate_vec_register(gen
->f
);
871 int n128_vec
= ppc_allocate_vec_register(gen
->f
);
873 y_vec
= get_src_vec(gen
, inst
, 0, CHAN_Y
); /* y_vec = src[0].y */
874 ppc_vmaxfp(gen
->f
, y_vec
, y_vec
, zero_vec
); /* y_vec = max(y_vec, 0) */
876 w_vec
= get_src_vec(gen
, inst
, 0, CHAN_W
); /* w_vec = src[0].w */
878 /* clamp W to [-128, 128] */
879 load_constant_vec(gen
, p128_vec
, 128.0f
);
880 load_constant_vec(gen
, n128_vec
, -128.0f
);
881 ppc_vmaxfp(gen
->f
, w_vec
, w_vec
, n128_vec
); /* w = max(w, -128) */
882 ppc_vminfp(gen
->f
, w_vec
, w_vec
, p128_vec
); /* w = min(w, 128) */
885 * z = pow(tmp.y, tmp.w)
889 ppc_vec_pow(gen
->f
, pow_vec
, y_vec
, w_vec
); /* pow = pow(y, w) */
890 ppc_vcmpgtfpx(gen
->f
, pos_vec
, x_vec
, zero_vec
); /* pos = x > 0 */
891 ppc_vand(gen
->f
, z_vec
, pow_vec
, pos_vec
); /* z = pow & pos */
893 emit_store(gen
, z_vec
, inst
, CHAN_Z
, FALSE
);
895 ppc_release_vec_register(gen
->f
, z_vec
);
896 ppc_release_vec_register(gen
->f
, pow_vec
);
897 ppc_release_vec_register(gen
->f
, pos_vec
);
898 ppc_release_vec_register(gen
->f
, p128_vec
);
899 ppc_release_vec_register(gen
->f
, n128_vec
);
902 ppc_release_vec_register(gen
->f
, zero_vec
);
906 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
907 emit_store(gen
, one_vec
, inst
, CHAN_W
, FALSE
);
910 release_src_vecs(gen
);
915 emit_exp(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
917 const int one_vec
= gen_one_vec(gen
);
921 src_vec
= get_src_vec(gen
, inst
, 0, CHAN_X
);
923 /* Compute X = 2^floor(src) */
924 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
925 int dst_vec
= get_dst_vec(gen
, inst
, CHAN_X
);
926 int tmp_vec
= ppc_allocate_vec_register(gen
->f
);
927 ppc_vrfim(gen
->f
, tmp_vec
, src_vec
); /* tmp = floor(src); */
928 ppc_vexptefp(gen
->f
, dst_vec
, tmp_vec
); /* dst = 2 ^ tmp */
929 emit_store(gen
, dst_vec
, inst
, CHAN_X
, TRUE
);
930 ppc_release_vec_register(gen
->f
, tmp_vec
);
933 /* Compute Y = src - floor(src) */
934 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
935 int dst_vec
= get_dst_vec(gen
, inst
, CHAN_Y
);
936 int tmp_vec
= ppc_allocate_vec_register(gen
->f
);
937 ppc_vrfim(gen
->f
, tmp_vec
, src_vec
); /* tmp = floor(src); */
938 ppc_vsubfp(gen
->f
, dst_vec
, src_vec
, tmp_vec
); /* dst = src - tmp */
939 emit_store(gen
, dst_vec
, inst
, CHAN_Y
, TRUE
);
940 ppc_release_vec_register(gen
->f
, tmp_vec
);
943 /* Compute Z = RoughApprox2ToX(src) */
944 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
945 int dst_vec
= get_dst_vec(gen
, inst
, CHAN_Z
);
946 ppc_vexptefp(gen
->f
, dst_vec
, src_vec
); /* dst = 2 ^ src */
947 emit_store(gen
, dst_vec
, inst
, CHAN_Z
, TRUE
);
950 /* Compute W = 1.0 */
951 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
952 emit_store(gen
, one_vec
, inst
, CHAN_W
, FALSE
);
955 release_src_vecs(gen
);
960 emit_log(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
962 const int bit31_vec
= gen_get_bit31_vec(gen
);
963 const int one_vec
= gen_one_vec(gen
);
964 int src_vec
, abs_vec
;
967 src_vec
= get_src_vec(gen
, inst
, 0, CHAN_X
);
969 /* compute abs(src) */
970 abs_vec
= ppc_allocate_vec_register(gen
->f
);
971 ppc_vandc(gen
->f
, abs_vec
, src_vec
, bit31_vec
); /* abs = src & ~bit31 */
973 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
) &&
974 IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
976 /* compute tmp = floor(log2(abs)) */
977 int tmp_vec
= ppc_allocate_vec_register(gen
->f
);
978 ppc_vlogefp(gen
->f
, tmp_vec
, abs_vec
); /* tmp = log2(abs) */
979 ppc_vrfim(gen
->f
, tmp_vec
, tmp_vec
); /* tmp = floor(tmp); */
981 /* Compute X = tmp */
982 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
)) {
983 emit_store(gen
, tmp_vec
, inst
, CHAN_X
, FALSE
);
986 /* Compute Y = abs / 2^tmp */
987 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
988 const int zero_vec
= ppc_allocate_vec_register(gen
->f
);
989 ppc_vzero(gen
->f
, zero_vec
);
990 ppc_vexptefp(gen
->f
, tmp_vec
, tmp_vec
); /* tmp = 2 ^ tmp */
991 ppc_vrefp(gen
->f
, tmp_vec
, tmp_vec
); /* tmp = 1 / tmp */
992 /* tmp = abs * tmp + zero */
993 ppc_vmaddfp(gen
->f
, tmp_vec
, abs_vec
, tmp_vec
, zero_vec
);
994 emit_store(gen
, tmp_vec
, inst
, CHAN_Y
, FALSE
);
995 ppc_release_vec_register(gen
->f
, zero_vec
);
998 ppc_release_vec_register(gen
->f
, tmp_vec
);
1001 /* Compute Z = RoughApproxLog2(abs) */
1002 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
1003 int dst_vec
= get_dst_vec(gen
, inst
, CHAN_Z
);
1004 ppc_vlogefp(gen
->f
, dst_vec
, abs_vec
); /* dst = log2(abs) */
1005 emit_store(gen
, dst_vec
, inst
, CHAN_Z
, TRUE
);
1008 /* Compute W = 1.0 */
1009 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_W
)) {
1010 emit_store(gen
, one_vec
, inst
, CHAN_W
, FALSE
);
1013 ppc_release_vec_register(gen
->f
, abs_vec
);
1014 release_src_vecs(gen
);
1019 emit_pow(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
1021 int s0_vec
= get_src_vec(gen
, inst
, 0, CHAN_X
);
1022 int s1_vec
= get_src_vec(gen
, inst
, 1, CHAN_X
);
1023 int pow_vec
= ppc_allocate_vec_register(gen
->f
);
1026 ppc_vec_pow(gen
->f
, pow_vec
, s0_vec
, s1_vec
);
1028 FOR_EACH_DST0_ENABLED_CHANNEL(*inst
, chan
) {
1029 emit_store(gen
, pow_vec
, inst
, chan
, FALSE
);
1032 ppc_release_vec_register(gen
->f
, pow_vec
);
1034 release_src_vecs(gen
);
1039 emit_xpd(struct gen_context
*gen
, struct tgsi_full_instruction
*inst
)
1041 int x0_vec
, y0_vec
, z0_vec
;
1042 int x1_vec
, y1_vec
, z1_vec
;
1043 int zero_vec
, tmp_vec
;
1046 zero_vec
= ppc_allocate_vec_register(gen
->f
);
1047 ppc_vzero(gen
->f
, zero_vec
);
1049 tmp_vec
= ppc_allocate_vec_register(gen
->f
);
1050 tmp2_vec
= ppc_allocate_vec_register(gen
->f
);
1052 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
) ||
1053 IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
1054 x0_vec
= get_src_vec(gen
, inst
, 0, CHAN_X
);
1055 x1_vec
= get_src_vec(gen
, inst
, 1, CHAN_X
);
1057 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
) ||
1058 IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
)) {
1059 y0_vec
= get_src_vec(gen
, inst
, 0, CHAN_Y
);
1060 y1_vec
= get_src_vec(gen
, inst
, 1, CHAN_Y
);
1062 if (IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
) ||
1063 IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
)) {
1064 z0_vec
= get_src_vec(gen
, inst
, 0, CHAN_Z
);
1065 z1_vec
= get_src_vec(gen
, inst
, 1, CHAN_Z
);
1068 IF_IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_X
) {
1070 ppc_vmaddfp(gen
->f
, tmp_vec
, y0_vec
, z1_vec
, zero_vec
);
1071 /* tmp = tmp - z0 * y1*/
1072 ppc_vnmsubfp(gen
->f
, tmp_vec
, tmp_vec
, z0_vec
, y1_vec
);
1073 emit_store(gen
, tmp_vec
, inst
, CHAN_X
, FALSE
);
1075 IF_IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Y
) {
1077 ppc_vmaddfp(gen
->f
, tmp_vec
, z0_vec
, x1_vec
, zero_vec
);
1078 /* tmp = tmp - x0 * z1 */
1079 ppc_vnmsubfp(gen
->f
, tmp_vec
, tmp_vec
, x0_vec
, z1_vec
);
1080 emit_store(gen
, tmp_vec
, inst
, CHAN_Y
, FALSE
);
1082 IF_IS_DST0_CHANNEL_ENABLED(*inst
, CHAN_Z
) {
1084 ppc_vmaddfp(gen
->f
, tmp_vec
, x0_vec
, y1_vec
, zero_vec
);
1085 /* tmp = tmp - y0 * x1 */
1086 ppc_vnmsubfp(gen
->f
, tmp_vec
, tmp_vec
, y0_vec
, x1_vec
);
1087 emit_store(gen
, tmp_vec
, inst
, CHAN_Z
, FALSE
);
1089 /* W is undefined */
1091 ppc_release_vec_register(gen
->f
, tmp_vec
);
1092 ppc_release_vec_register(gen
->f
, zero_vec
);
1093 release_src_vecs(gen
);
1097 emit_instruction(struct gen_context
*gen
,
1098 struct tgsi_full_instruction
*inst
)
1101 /* we don't handle saturation/clamping yet */
1102 if (inst
->Instruction
.Saturate
!= TGSI_SAT_NONE
)
1105 /* need to use extra temps to fix SOA dependencies : */
1106 if (tgsi_check_soa_dependencies(inst
))
1109 switch (inst
->Instruction
.Opcode
) {
1110 case TGSI_OPCODE_MOV
:
1111 case TGSI_OPCODE_ABS
:
1112 case TGSI_OPCODE_FLR
:
1113 case TGSI_OPCODE_FRC
:
1114 case TGSI_OPCODE_EX2
:
1115 case TGSI_OPCODE_LG2
:
1116 emit_unaryop(gen
, inst
);
1118 case TGSI_OPCODE_RSQ
:
1119 case TGSI_OPCODE_RCP
:
1120 emit_scalar_unaryop(gen
, inst
);
1122 case TGSI_OPCODE_ADD
:
1123 case TGSI_OPCODE_SUB
:
1124 case TGSI_OPCODE_MUL
:
1125 case TGSI_OPCODE_MIN
:
1126 case TGSI_OPCODE_MAX
:
1127 emit_binop(gen
, inst
);
1129 case TGSI_OPCODE_SEQ
:
1130 case TGSI_OPCODE_SNE
:
1131 case TGSI_OPCODE_SLT
:
1132 case TGSI_OPCODE_SGT
:
1133 case TGSI_OPCODE_SLE
:
1134 case TGSI_OPCODE_SGE
:
1135 emit_inequality(gen
, inst
);
1137 case TGSI_OPCODE_MAD
:
1138 case TGSI_OPCODE_LRP
:
1139 emit_triop(gen
, inst
);
1141 case TGSI_OPCODE_DP3
:
1142 case TGSI_OPCODE_DP4
:
1143 case TGSI_OPCODE_DPH
:
1144 emit_dotprod(gen
, inst
);
1146 case TGSI_OPCODE_LIT
:
1147 emit_lit(gen
, inst
);
1149 case TGSI_OPCODE_LOG
:
1150 emit_log(gen
, inst
);
1152 case TGSI_OPCODE_EXP
:
1153 emit_exp(gen
, inst
);
1155 case TGSI_OPCODE_POW
:
1156 emit_pow(gen
, inst
);
1158 case TGSI_OPCODE_XPD
:
1159 emit_xpd(gen
, inst
);
1161 case TGSI_OPCODE_END
:
1173 struct ppc_function
*func
,
1174 struct tgsi_full_declaration
*decl
)
1176 if( decl
->Declaration
.File
== TGSI_FILE_INPUT
) {
1178 unsigned first
, last
, mask
;
1181 first
= decl
->DeclarationRange
.First
;
1182 last
= decl
->DeclarationRange
.Last
;
1183 mask
= decl
->Declaration
.UsageMask
;
1185 for( i
= first
; i
<= last
; i
++ ) {
1186 for( j
= 0; j
< NUM_CHANNELS
; j
++ ) {
1187 if( mask
& (1 << j
) ) {
1188 switch( decl
->Declaration
.Interpolate
) {
1189 case TGSI_INTERPOLATE_CONSTANT
:
1190 emit_coef_a0( func
, 0, i
, j
);
1191 emit_inputs( func
, 0, i
, j
);
1194 case TGSI_INTERPOLATE_LINEAR
:
1195 emit_tempf( func
, 0, 0, TGSI_SWIZZLE_X
);
1196 emit_coef_dadx( func
, 1, i
, j
);
1197 emit_tempf( func
, 2, 0, TGSI_SWIZZLE_Y
);
1198 emit_coef_dady( func
, 3, i
, j
);
1199 emit_mul( func
, 0, 1 ); /* x * dadx */
1200 emit_coef_a0( func
, 4, i
, j
);
1201 emit_mul( func
, 2, 3 ); /* y * dady */
1202 emit_add( func
, 0, 4 ); /* x * dadx + a0 */
1203 emit_add( func
, 0, 2 ); /* x * dadx + y * dady + a0 */
1204 emit_inputs( func
, 0, i
, j
);
1207 case TGSI_INTERPOLATE_PERSPECTIVE
:
1208 emit_tempf( func
, 0, 0, TGSI_SWIZZLE_X
);
1209 emit_coef_dadx( func
, 1, i
, j
);
1210 emit_tempf( func
, 2, 0, TGSI_SWIZZLE_Y
);
1211 emit_coef_dady( func
, 3, i
, j
);
1212 emit_mul( func
, 0, 1 ); /* x * dadx */
1213 emit_tempf( func
, 4, 0, TGSI_SWIZZLE_W
);
1214 emit_coef_a0( func
, 5, i
, j
);
1215 emit_rcp( func
, 4, 4 ); /* 1.0 / w */
1216 emit_mul( func
, 2, 3 ); /* y * dady */
1217 emit_add( func
, 0, 5 ); /* x * dadx + a0 */
1218 emit_add( func
, 0, 2 ); /* x * dadx + y * dady + a0 */
1219 emit_mul( func
, 0, 4 ); /* (x * dadx + y * dady + a0) / w */
1220 emit_inputs( func
, 0, i
, j
);
1237 emit_prologue(struct ppc_function
*func
)
1239 /* XXX set up stack frame */
1244 emit_epilogue(struct ppc_function
*func
)
1246 ppc_comment(func
, -4, "Epilogue:");
1248 /* XXX restore prev stack frame */
1250 debug_printf("PPC: Emitted %u instructions\n", func
->num_inst
);
1257 * Translate a TGSI vertex/fragment shader to PPC code.
1259 * \param tokens the TGSI input shader
1260 * \param func the output PPC code/function
1261 * \param immediates buffer to place immediates, later passed to PPC func
1262 * \return TRUE for success, FALSE if translation failed
1265 tgsi_emit_ppc(const struct tgsi_token
*tokens
,
1266 struct ppc_function
*func
,
1267 float (*immediates
)[4],
1268 boolean do_swizzles
)
1270 static int use_ppc_asm
= -1;
1271 struct tgsi_parse_context parse
;
1272 /*boolean instruction_phase = FALSE;*/
1274 uint num_immediates
= 0;
1275 struct gen_context gen
;
1278 if (use_ppc_asm
< 0) {
1279 /* If GALLIUM_NOPPC is set, don't use PPC codegen */
1280 use_ppc_asm
= !debug_get_bool_option("GALLIUM_NOPPC", FALSE
);
1286 debug_printf("\n********* TGSI->PPC ********\n");
1287 tgsi_dump(tokens
, 0);
1292 init_gen_context(&gen
, func
);
1294 emit_prologue(func
);
1296 tgsi_parse_init( &parse
, tokens
);
1298 while (!tgsi_parse_end_of_tokens(&parse
) && ok
) {
1299 tgsi_parse_token(&parse
);
1301 switch (parse
.FullToken
.Token
.Type
) {
1302 case TGSI_TOKEN_TYPE_DECLARATION
:
1303 if (parse
.FullHeader
.Processor
.Processor
== TGSI_PROCESSOR_FRAGMENT
) {
1304 emit_declaration(func
, &parse
.FullToken
.FullDeclaration
);
1308 case TGSI_TOKEN_TYPE_INSTRUCTION
:
1310 _debug_printf("# ");
1312 tgsi_dump_instruction(&parse
.FullToken
.FullInstruction
, ic
);
1315 ok
= emit_instruction(&gen
, &parse
.FullToken
.FullInstruction
);
1318 uint opcode
= parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
1319 debug_printf("failed to translate tgsi opcode %d (%s) to PPC (%s)\n",
1321 tgsi_get_opcode_name(opcode
),
1322 parse
.FullHeader
.Processor
.Processor
== TGSI_PROCESSOR_VERTEX
?
1323 "vertex shader" : "fragment shader");
1327 case TGSI_TOKEN_TYPE_IMMEDIATE
:
1328 /* splat each immediate component into a float[4] vector for SoA */
1330 const uint size
= parse
.FullToken
.FullImmediate
.Immediate
.NrTokens
- 1;
1333 assert(num_immediates
< TGSI_EXEC_NUM_IMMEDIATES
);
1334 for (i
= 0; i
< size
; i
++) {
1335 immediates
[num_immediates
][i
] =
1336 parse
.FullToken
.FullImmediate
.u
[i
].Float
;
1348 emit_epilogue(func
);
1350 tgsi_parse_free( &parse
);
1352 if (ppc_num_instructions(func
) == 0) {
1353 /* ran out of memory for instructions */
1358 debug_printf("TGSI->PPC translation failed\n");
1363 #endif /* PIPE_ARCH_PPC */