gen->one_reg = spe_allocate_available_register(gen->f);
spe_indent(gen->f, 4);
- spe_comment(gen->f, -4, "INIT CONSTANT 1.0:");
+ spe_comment(gen->f, -4, "init constant reg = 1.0:");
/* one = {1.0, 1.0, 1.0, 1.0} */
spe_load_float(gen->f, gen->one_reg, 1.0f);
gen->addr_reg = spe_allocate_available_register(gen->f);
spe_indent(gen->f, 4);
- spe_comment(gen->f, -4, "INIT CONSTANT 1.0:");
+ spe_comment(gen->f, -4, "init address reg = 0:");
/* init addr = {0, 0, 0, 0} */
spe_zero(gen->f, gen->addr_reg);
{
gen->frame_size = 1024; /* XXX temporary, should be dynamic */
- spe_comment(gen->f, -4, "Function prologue:");
+ spe_comment(gen->f, 0, "Function prologue:");
/* save $lr on stack # stqd $lr,16($sp) */
spe_stqd(gen->f, SPE_REG_RA, SPE_REG_SP, 16);
{
const int return_reg = 3;
- spe_comment(gen->f, -4, "Function epilogue:");
+ spe_comment(gen->f, 0, "Function epilogue:");
spe_comment(gen->f, 0, "return the killed mask");
if (gen->kill_mask_reg > 0) {
{
int ch = 0, src_reg, addr_reg;
- spe_comment(gen->f, -4, "ARL:");
-
src_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
addr_reg = get_address_reg(gen);
{
int ch, src_reg[4], dst_reg[4];
- spe_comment(gen->f, -4, "MOV:");
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
src_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
dst_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
{
int ch, s1_reg[4], s2_reg[4], d_reg[4];
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ADD:
- spe_comment(gen->f, -4, "ADD:");
- break;
- case TGSI_OPCODE_SUB:
- spe_comment(gen->f, -4, "SUB:");
- break;
- case TGSI_OPCODE_MUL:
- spe_comment(gen->f, -4, "MUL:");
- break;
- default:
- assert(0);
- }
-
/* Loop over Red/Green/Blue/Alpha channels, fetch src operands */
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4];
- spe_comment(gen->f, -4, "MAD:");
+
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
s2_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4], tmp_reg[4];
- spe_comment(gen->f, -4, "LERP:");
+
/* setup/get src/dst/temp regs */
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
{
int ch, s1_reg[4], d_reg[4], tmp_reg[4];
- if (inst->Instruction.Opcode == TGSI_OPCODE_RCP) {
- spe_comment(gen->f, -4, "RCP:");
- }
- else {
- assert(inst->Instruction.Opcode == TGSI_OPCODE_RSQ);
- spe_comment(gen->f, -4, "RSQ:");
- }
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
int ch, s1_reg[4], d_reg[4];
const int bit31mask_reg = get_itemp(gen);
- spe_comment(gen->f, -4, "ABS:");
-
/* mask with bit 31 set, the rest cleared */
spe_load_uint(gen->f, bit31mask_reg, (1 << 31));
int s2x_reg, s2y_reg, s2z_reg;
int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
- spe_comment(gen->f, -4, "DP3:");
-
s1x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
s2x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
s1y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
int s1x_reg, s1y_reg, s1z_reg, s1w_reg;
int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
- spe_comment(gen->f, -4, "DP4:");
-
s0x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
s1x_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
s0y_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
{
/* XXX rewrite this function to look more like DP3/DP4 */
int ch;
- spe_comment(gen->f, -4, "DPH:");
-
int s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
int s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
int tmp_reg = get_itemp(gen);
int src_reg[3];
int t0_reg = get_itemp(gen), t1_reg = get_itemp(gen);
- spe_comment(gen->f, -4, "NRM3:");
-
src_reg[0] = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
src_reg[1] = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
src_reg[2] = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
static boolean
emit_XPD(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
- spe_comment(gen->f, -4, "XPD:");
-
int s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
int s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
int tmp_reg = get_itemp(gen);
int ch, s1_reg[4], s2_reg[4], d_reg[4], one_reg;
bool complement = FALSE;
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_SGT:
- spe_comment(gen->f, -4, "SGT:");
- break;
- case TGSI_OPCODE_SLT:
- spe_comment(gen->f, -4, "SLT:");
- break;
- case TGSI_OPCODE_SGE:
- spe_comment(gen->f, -4, "SGE:");
- complement = TRUE;
- break;
- case TGSI_OPCODE_SLE:
- spe_comment(gen->f, -4, "SLE:");
- complement = TRUE;
- break;
- case TGSI_OPCODE_SEQ:
- spe_comment(gen->f, -4, "SEQ:");
- break;
- case TGSI_OPCODE_SNE:
- spe_comment(gen->f, -4, "SNE:");
- complement = TRUE;
- break;
- default:
- ;
- }
-
one_reg = get_const_one_reg(gen);
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
break;
case TGSI_OPCODE_SGE:
spe_fcgt(gen->f, d_reg[ch], s2_reg[ch], s1_reg[ch]);
+ complement = TRUE;
break;
case TGSI_OPCODE_SLE:
spe_fcgt(gen->f, d_reg[ch], s1_reg[ch], s2_reg[ch]);
+ complement = TRUE;
break;
case TGSI_OPCODE_SEQ:
spe_fceq(gen->f, d_reg[ch], s1_reg[ch], s2_reg[ch]);
break;
case TGSI_OPCODE_SNE:
spe_fceq(gen->f, d_reg[ch], s1_reg[ch], s2_reg[ch]);
+ complement = TRUE;
break;
default:
assert(0);
{
int ch;
- spe_comment(gen->f, -4, "CMP:");
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
{
int ch, s1_reg[4], d_reg[4];
- spe_comment(gen->f, -4, "TRUNC:");
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
d_reg[ch] = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
{
int ch, s1_reg[4], d_reg[4], tmp_reg[4], zero_reg, one_reg;
- spe_comment(gen->f, -4, "FLR:");
-
zero_reg = get_itemp(gen);
spe_zero(gen->f, zero_reg);
one_reg = get_const_one_reg(gen);
{
int ch, s1_reg[4], d_reg[4], tmp_reg[4], zero_reg, one_reg;
- spe_comment(gen->f, -4, "FRC:");
-
zero_reg = get_itemp(gen);
spe_zero(gen->f, zero_reg);
one_reg = get_const_one_reg(gen);
{
int ch, s0_reg[4], s1_reg[4], d_reg[4], tmp_reg[4];
- spe_comment(gen->f, -4, "MAX:");
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
s0_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
s1_reg[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
const int channel = 0;
int cond_reg;
- spe_comment(gen->f, -4, "IF:");
-
cond_reg = get_cond_mask_reg(gen);
/* XXX push cond exec mask */
{
const int cond_reg = get_cond_mask_reg(gen);
- spe_comment(gen->f, -4, "ELSE:");
-
spe_comment(gen->f, 0, "cond exec mask = !cond exec mask");
spe_complement(gen->f, cond_reg, cond_reg);
emit_update_exec_mask(gen);
static boolean
emit_ENDIF(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
- spe_comment(gen->f, -4, "ENDIF:");
-
/* XXX todo: pop cond exec mask */
gen->if_nesting--;
{
int exec_reg, loop_reg;
- spe_comment(gen->f, -4, "BGNLOOP:");
-
exec_reg = get_exec_mask_reg(gen);
loop_reg = get_loop_mask_reg(gen);
const int tmp_reg = get_itemp(gen);
int offset;
- spe_comment(gen->f, -4, "ENDLOOP:");
-
/* tmp_reg = exec[0] | exec[1] | exec[2] | exec[3] */
spe_orx(gen->f, tmp_reg, loop_reg);
const int exec_reg = get_exec_mask_reg(gen);
const int loop_reg = get_loop_mask_reg(gen);
- spe_comment(gen->f, -4, "BREAK:");
-
assert(gen->loop_nesting > 0);
spe_comment(gen->f, 0, "loop exec mask &= ~master exec mask");
static boolean
emit_CONT(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
- spe_comment(gen->f, -4, "CONT:");
-
assert(gen->loop_nesting > 0);
return TRUE;
{
int ch;
- spe_comment(gen->f, -4, ddx ? "DDX:" : "DDY:");
-
FOR_EACH_ENABLED_CHANNEL(inst, ch) {
int s_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
static boolean
emit_END(struct codegen *gen)
{
- spe_comment(gen->f, -4, "END:");
emit_epilogue(gen);
return TRUE;
}
assert(gen->num_imm < MAX_TEMPS);
- spe_comment(gen->f, -4, "IMMEDIATE:");
-
for (ch = 0; ch < 4; ch++) {
float val = immed->u.ImmediateFloat32[ch].Float;
sprintf(buf, "TGSI temp[%d] maps to SPU regs [$%d $%d $%d $%d]", i,
gen->temp_regs[i][0], gen->temp_regs[i][1],
gen->temp_regs[i][2], gen->temp_regs[i][3]);
- spe_comment(gen->f, -4, buf);
+ spe_comment(gen->f, 0, buf);
}
}
break;
{
struct tgsi_parse_context parse;
struct codegen gen;
+ uint ic = 0;
memset(&gen, 0, sizeof(gen));
gen.cell = cell;
if (cell->debug_flags & CELL_DEBUG_ASM) {
spe_print_code(f, TRUE);
- spe_indent(f, 8);
+ spe_indent(f, 2*8);
printf("Begin %s\n", __FUNCTION__);
tgsi_dump(tokens, 0);
}
switch (parse.FullToken.Token.Type) {
case TGSI_TOKEN_TYPE_IMMEDIATE:
+ if (f->print) {
+ _debug_printf(" # ");
+ tgsi_dump_immediate(&parse.FullToken.FullImmediate);
+ }
if (!emit_immediate(&gen, &parse.FullToken.FullImmediate))
gen.error = TRUE;
break;
case TGSI_TOKEN_TYPE_DECLARATION:
+ if (f->print) {
+ _debug_printf(" # ");
+ tgsi_dump_declaration(&parse.FullToken.FullDeclaration);
+ }
if (!emit_declaration(cell, &gen, &parse.FullToken.FullDeclaration))
gen.error = TRUE;
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
+ if (f->print) {
+ _debug_printf(" # ");
+ ic++;
+ tgsi_dump_instruction(&parse.FullToken.FullInstruction, ic);
+ }
if (!emit_instruction(&gen, &parse.FullToken.FullInstruction))
gen.error = TRUE;
break;