freedreno/a3xx: remove useless reg tracking in disasm-a3xx

Not really used for anything anymore.  So strip it out and avoid
conflicting symbols with upcoming new-compiler.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
Rob Clark 2014-01-29 16:13:54 -05:00
parent 1597788d12
commit f08d2b1c0f

View file

@ -107,189 +107,21 @@ static void print_reg(reg_t reg, bool full, bool r, bool c, bool im,
}
}
/* Tracking for registers used, read-before-write (input), and
* write-after-read (output.. but not 100%)..
*/
#define MAX_REG 4096
typedef struct {
uint8_t full[MAX_REG/8];
uint8_t half[MAX_REG/8];
} regmask_t;
static void regmask_set(regmask_t *regmask, unsigned num, bool full, unsigned val)
{
unsigned i = num / 8;
unsigned j = num % 8;
assert(num < MAX_REG);
if (full) {
regmask->full[i] = (regmask->full[i] & ~(1 << j)) | (val << j);
} else {
regmask->half[i] = (regmask->half[i] & ~(1 << j)) | (val << j);
}
}
static unsigned regmask_get(regmask_t *regmask, unsigned num, bool full)
{
unsigned i = num / 8;
unsigned j = num % 8;
assert(num < MAX_REG);
if (full) {
return (regmask->full[i] >> j) & 0x1;
} else {
return (regmask->half[i] >> j) & 0x1;
}
}
static unsigned regidx(reg_t reg)
{
return (4 * reg.num) + reg.comp;
}
static struct {
regmask_t used;
regmask_t rbw; /* read before write */
regmask_t war; /* write after read */
regmask_t cnst; /* used consts */
} regs;
static void print_regs(regmask_t *regmask, bool full)
{
int num, max = 0, cnt = 0;
int first, last;
void print_sequence(void)
{
if (first != MAX_REG) {
if (first == last) {
printf(" %d", first);
} else {
printf(" %d-%d", first, last);
}
}
}
first = last = MAX_REG;
for (num = 0; num < MAX_REG; num++) {
if (regmask_get(regmask, num, full)) {
if (num != (last + 1)) {
print_sequence();
first = num;
}
last = num;
max = num;
cnt++;
}
}
print_sequence();
printf(" (cnt=%d, max=%d)", cnt, max);
}
static void print_reg_stats(int level)
{
printf("%sRegister Stats:\n", levels[level]);
printf("%s- used (half):", levels[level]);
print_regs(&regs.used, false);
printf("\n");
printf("%s- used (full):", levels[level]);
print_regs(&regs.used, true);
printf("\n");
printf("%s- input (half):", levels[level]);
print_regs(&regs.rbw, false);
printf("\n");
printf("%s- input (full):", levels[level]);
print_regs(&regs.rbw, true);
printf("\n");
printf("%s- const (half):", levels[level]);
print_regs(&regs.cnst, false);
printf("\n");
printf("%s- const (full):", levels[level]);
print_regs(&regs.cnst, true);
printf("\n");
printf("%s- output (half):", levels[level]);
print_regs(&regs.war, false);
printf(" (estimated)\n");
printf("%s- output (full):", levels[level]);
print_regs(&regs.war, true);
printf(" (estimated)\n");
}
/* we have to process the dst register after src to avoid tripping up
* the read-before-write detection
*/
static unsigned last_dst;
static bool last_dst_full;
static bool last_dst_valid = false;
/* current instruction repeat flag: */
static unsigned repeat;
static void process_reg_dst(void)
{
int i;
if (!last_dst_valid)
return;
for (i = 0; i <= repeat; i++) {
unsigned dst = last_dst + i;
regmask_set(&regs.war, dst, last_dst_full, 1);
regmask_set(&regs.used, dst, last_dst_full, 1);
}
last_dst_valid = false;
}
static void print_reg_dst(reg_t reg, bool full, bool addr_rel)
{
/* presumably the special registers a0.c and p0.c don't count.. */
if (!(addr_rel || reg_special(reg))) {
last_dst = regidx(reg);
last_dst_full = full;
last_dst_valid = true;
}
print_reg(reg, full, false, false, false, false, false, addr_rel);
}
static void print_reg_src(reg_t reg, bool full, bool r, bool c, bool im,
bool neg, bool abs, bool addr_rel)
{
/* presumably the special registers a0.c and p0.c don't count.. */
if (!(addr_rel || c || im || reg_special(reg))) {
int i, num = regidx(reg);
for (i = 0; i <= repeat; i++) {
unsigned src = num + i;
if (!regmask_get(&regs.used, src, full))
regmask_set(&regs.rbw, src, full, 1);
regmask_set(&regs.war, src, full, 0);
regmask_set(&regs.used, src, full, 1);
if (!r)
break;
}
} else if (c) {
int i, num = regidx(reg);
for (i = 0; i <= repeat; i++) {
unsigned src = num + i;
regmask_set(&regs.cnst, src, full, 1);
if (!r)
break;
}
}
print_reg(reg, full, r, c, im, neg, abs, addr_rel);
}
static void print_instr_cat0(instr_t *instr)
{
instr_cat0_t *cat0 = &instr->cat0;
@ -978,8 +810,6 @@ static void print_instr(uint32_t *dwords, int level, int n)
}
printf("\n");
process_reg_dst();
}
int disasm_a3xx(uint32_t *dwords, int sizedwords, int level, enum shader_t type)
@ -988,12 +818,8 @@ int disasm_a3xx(uint32_t *dwords, int sizedwords, int level, enum shader_t type)
assert((sizedwords % 2) == 0);
memset(&regs, 0, sizeof(regs));
for (i = 0; i < sizedwords; i += 2)
print_instr(&dwords[i], level, i/2);
print_reg_stats(level);
return 0;
}