Definitely helps when trying to understand and optimize a program.
static bool debug;
static void
-dump_from(struct qinst *inst)
+dump_from(struct vc4_compile *c, struct qinst *inst)
{
if (!debug)
return;
fprintf(stderr, "optimizing: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
static void
-dump_to(struct qinst *inst)
+dump_to(struct vc4_compile *c, struct qinst *inst)
{
if (!debug)
return;
fprintf(stderr, "to: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
/* Turn "dst = (sf == x) ? a : a)" into
* "dst = a"
*/
- dump_from(inst);
+ dump_from(c, inst);
inst->op = QOP_MOV;
inst->src[0] = inst->src[1];
inst->src[1] = c->undef;
progress = true;
- dump_to(inst);
+ dump_to(c, inst);
} else if (is_zero(c, defs, inst->src[1])) {
/* Replace references to a 0 uniform value
* with the SEL_X_0 equivalent.
*/
- dump_from(inst);
+ dump_from(c, inst);
inst->op -= (QOP_SEL_X_Y_ZS - QOP_SEL_X_0_ZS);
inst->src[1] = c->undef;
progress = true;
- dump_to(inst);
+ dump_to(c, inst);
}
break;
!reads_a_uniform))) {
if (debug) {
fprintf(stderr, "Copy propagate: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
if (debug) {
fprintf(stderr, "to: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
}
static struct qinst *
-vc4_find_cse(struct hash_table *ht, struct qinst *inst, uint32_t sf_count,
+vc4_find_cse(struct vc4_compile *c, struct hash_table *ht,
+ struct qinst *inst, uint32_t sf_count,
uint32_t r4_count)
{
if (inst->dst.file != QFILE_TEMP ||
fprintf(stderr, "CSE found match:\n");
fprintf(stderr, " Original inst: ");
- qir_dump_inst(entry->data);
+ qir_dump_inst(c, entry->data);
fprintf(stderr, "\n");
fprintf(stderr, " Our inst: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
if (debug) {
fprintf(stderr, "Added to CSE HT: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
if (debug) {
fprintf(stderr,
"Removing redundant SF: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
qir_remove_instruction(inst);
sf_count++;
}
} else {
- struct qinst *cse = vc4_find_cse(ht, inst,
+ struct qinst *cse = vc4_find_cse(c, ht, inst,
sf_count, r4_count);
if (cse) {
inst->src[0] = cse->dst;
if (debug) {
fprintf(stderr, " Turned into: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
}
!qir_has_side_effects(inst)) {
if (debug) {
fprintf(stderr, "Removing: ");
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
qir_remove_instruction(inst);
}
static void
-qir_print_reg(struct qreg reg)
+qir_print_reg(struct vc4_compile *c, struct qreg reg)
{
const char *files[] = {
[QFILE_TEMP] = "t",
fprintf(stderr, "null");
else
fprintf(stderr, "%s%d", files[reg.file], reg.index);
+
+ if (reg.file == QFILE_UNIF &&
+ c->uniform_contents[reg.index] == QUNIFORM_CONSTANT) {
+ fprintf(stderr, " (0x%08x / %f)",
+ c->uniform_data[reg.index],
+ uif(c->uniform_data[reg.index]));
+ }
}
void
-qir_dump_inst(struct qinst *inst)
+qir_dump_inst(struct vc4_compile *c, struct qinst *inst)
{
fprintf(stderr, "%s ", qir_get_op_name(inst->op));
- qir_print_reg(inst->dst);
+ qir_print_reg(c, inst->dst);
for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {
fprintf(stderr, ", ");
- qir_print_reg(inst->src[i]);
+ qir_print_reg(c, inst->src[i]);
}
}
foreach(node, &c->instructions) {
struct qinst *inst = (struct qinst *)node;
- qir_dump_inst(inst);
+ qir_dump_inst(c, inst);
fprintf(stderr, "\n");
}
}
bool qir_reads_r4(struct qinst *inst);
void qir_dump(struct vc4_compile *c);
-void qir_dump_inst(struct qinst *inst);
+void qir_dump_inst(struct vc4_compile *c, struct qinst *inst);
const char *qir_get_stage_name(enum qstage stage);
void qir_optimize(struct vc4_compile *c);