#include <stdint.h>
#include <stdbool.h>
+#include "util/u_debug.h"
+
#include "instr-a3xx.h"
#include "disasm.h" /* TODO move 'enum shader_t' somewhere else.. */
{
if (instr->flags & IR3_INSTR_MARK)
return true; /* already visited */
- instr->flags ^= IR3_INSTR_MARK;
+ instr->flags |= IR3_INSTR_MARK;
return false;
}
static inline bool reg_gpr(struct ir3_register *r)
{
- if (r->flags & (IR3_REG_CONST | IR3_REG_IMMED | IR3_REG_RELATIV | IR3_REG_SSA | IR3_REG_ADDR))
+ if (r->flags & (IR3_REG_CONST | IR3_REG_IMMED | IR3_REG_RELATIV | IR3_REG_ADDR))
return false;
if ((reg_num(r) == REG_A0) || (reg_num(r) == REG_P0))
return false;
static inline unsigned regmask_idx(struct ir3_register *reg)
{
unsigned num = reg->num;
- assert(num < MAX_REG);
+ debug_assert(num < MAX_REG);
if (reg->flags & IR3_REG_HALF)
num += MAX_REG;
return num;
}
static void dump_reg_name(struct ir3_dump_ctx *ctx,
- struct ir3_register *reg)
+ struct ir3_register *reg, bool followssa)
{
if ((reg->flags & IR3_REG_ABS) && (reg->flags & IR3_REG_NEGATE))
fprintf(ctx->f, "(absneg)");
fprintf(ctx->f, "imm[%f,%d,0x%x]", reg->fim_val, reg->iim_val, reg->iim_val);
} else if (reg->flags & IR3_REG_SSA) {
if (ctx->verbose) {
- fprintf(ctx->f, "_[");
- dump_instr_name(ctx, reg->instr);
- fprintf(ctx->f, "]");
+ fprintf(ctx->f, "_");
+ if (followssa) {
+ fprintf(ctx->f, "[");
+ dump_instr_name(ctx, reg->instr);
+ fprintf(ctx->f, "]");
+ }
}
} else {
if (reg->flags & IR3_REG_HALF)
if (reg->flags & IR3_REG_SSA)
fprintf(ctx->f, "<src%u> ", (i - 1));
- dump_reg_name(ctx, reg);
+ dump_reg_name(ctx, reg, true);
}
fprintf(ctx->f, "}\"];\n");
for (i = 0; i < instr->regs_count; i++) {
struct ir3_register *reg = instr->regs[i];
printf(i ? ", " : " ");
- dump_reg_name(&ctx, reg);
+ dump_reg_name(&ctx, reg, !!i);
}
+
+ if (is_meta(instr) && (instr->opc == OPC_META_FO))
+ printf(", off=%d", instr->fo.off);
+
printf("\n");
}
void
ir3_dump_instr_list(struct ir3_instruction *instr)
{
+ struct ir3_block *block = instr->block;
unsigned n = 0;
while (instr) {
instr = instr->next;
}
printf("%u instructions\n", n);
+
+ for (n = 0; n < block->noutputs; n++) {
+ if (!block->outputs[n])
+ continue;
+ printf("out%d: ", n);
+ ir3_dump_instr_single(block->outputs[n]);
+ }
}
bool error;
};
+#define ra_debug 0
+
+#define ra_dump_list(msg, n) do { \
+ if (ra_debug) { \
+ debug_printf("-- " msg); \
+ ir3_dump_instr_list(n); \
+ } \
+ } while (0)
+
+#define ra_dump_instr(msg, n) do { \
+ if (ra_debug) { \
+ debug_printf(">> " msg); \
+ ir3_dump_instr_single(n); \
+ } \
+ } while (0)
+
/* sorta ugly way to retrofit half-precision support.. rather than
* passing extra param around, just OR in a high bit. All the low
* value arithmetic (ie. +/- offset within a contiguous vec4, etc)
/* check that the register exists, is a GPR and is not special (a0/p0) */
static struct ir3_register * reg_check(struct ir3_instruction *instr, unsigned n)
{
- if ((n < instr->regs_count) && reg_gpr(instr->regs[n]))
+ if ((n < instr->regs_count) && reg_gpr(instr->regs[n]) &&
+ !(instr->regs[n]->flags & IR3_REG_SSA))
return instr->regs[n];
return NULL;
}
{
struct ra_assign_visitor *a = ra_assign_visitor(v);
- if (is_flow(instr) && (instr->opc == OPC_KILL))
- return;
-
reg->flags &= ~IR3_REG_SSA;
reg->num = a->num & ~REG_HALF;
num = regid(REG_A0, 0) | REG_HALF;
} else {
/* predicate register (p0).. etc */
- return;
+ num = regid(REG_P0, 0);
+ debug_assert(dst->num == num);
}
ra_assign(ctx, instr, num);
{
struct ir3_instruction *n;
+ ra_dump_list("before:\n", block->head);
+
if (!block->parent) {
unsigned i, j;
int base, off = output_base(ctx);
}
}
+ ra_dump_list("after:\n", block->head);
+
/* then loop over instruction list and assign registers:
*/
- n = block->head;
- while (n) {
+ for (n = block->head; n; n = n->next) {
+ ra_dump_instr("ASSIGN: ", n);
ir3_instr_ra(ctx, n);
if (ctx->error)
return -1;
- n = n->next;
+ ra_dump_list("-------", block->head);
}
legalize(ctx, block);
bool half_precision, bool frag_coord, bool frag_face,
bool *has_samp, int *max_bary)
{
+ struct ir3_instruction *n;
struct ir3_ra_ctx ctx = {
.block = block,
.type = type,
};
int ret;
+ /* mark dst registers w/ SSA flag so we can see which
+ * have been assigned so far:
+ */
+ for (n = block->head; n; n = n->next)
+ if (n->regs_count > 0)
+ n->regs[0]->flags |= IR3_REG_SSA;
+
ir3_clear_mark(block->shader);
ret = block_ra(&ctx, block);
*has_samp = ctx.has_samp;