Skip to content

Commit

Permalink
pgmdump: add --expand to unroll rptN
Browse files Browse the repository at this point in the history
  • Loading branch information
robclark committed May 24, 2013
1 parent 0cf9757 commit 27b1dd3
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 17 deletions.
2 changes: 1 addition & 1 deletion includes/instr-a3xx.h
Expand Up @@ -232,7 +232,7 @@ typedef union PACKED {
/* normal gpr or const src register: */
struct PACKED {
uint32_t comp : 2;
uint32_t num : 9;
uint32_t num : 6;
};
/* for immediate val: */
int32_t iim_val : 11;
Expand Down
8 changes: 8 additions & 0 deletions run-cffdump.sh
Expand Up @@ -17,6 +17,10 @@ for f in $*; do
cffdump_args="$cffdump_args $f"
continue
fi
if [ $f = "--allregs" ]; then
cffdump_args="$cffdump_args $f"
continue
fi
if [ $f = "--verbose" ]; then
cffdump_args="$cffdump_args $f"
pgmdump_args="$pgmdump_args $f"
Expand All @@ -26,6 +30,10 @@ for f in $*; do
pgmdump_args="$pgmdump_args $f"
continue
fi
if [ $f = "--expand" ]; then
pgmdump_args="$pgmdump_args $f"
continue
fi

echo "$f"
if [ -x $dir/cffdump ]; then
Expand Down
35 changes: 34 additions & 1 deletion util/disasm-a3xx.c
Expand Up @@ -111,7 +111,7 @@ static void print_reg(reg_t reg, bool full, bool r, bool c, bool im,
* write-after-read (output.. but not 100%)..
*/

#define MAX_REG 128
#define MAX_REG 512

typedef struct {
uint8_t full[MAX_REG/8];
Expand Down Expand Up @@ -147,6 +147,14 @@ static unsigned regidx(reg_t reg)
return (4 * reg.num) + reg.comp;
}

static reg_t idxreg(unsigned idx)
{
return (reg_t){
.comp = idx & 0x3,
.num = idx >> 2,
};
}

static struct {
regmask_t used;
regmask_t rbw; /* read before write */
Expand Down Expand Up @@ -227,6 +235,8 @@ static bool last_dst_valid = false;

/* current instruction repeat flag: */
static unsigned repeat;
/* current instruction repeat indx/offset (for --expand): */
static unsigned repeatidx;

static void process_reg_dst(void)
{
Expand All @@ -253,6 +263,7 @@ static void print_reg_dst(reg_t reg, bool full, bool addr_rel)
last_dst_full = full;
last_dst_valid = true;
}
reg = idxreg(regidx(reg) + repeatidx);
print_reg(reg, full, false, false, false, false, false, addr_rel);
}

Expand Down Expand Up @@ -286,6 +297,9 @@ static void print_reg_src(reg_t reg, bool full, bool r, bool c, bool im,
}
}

if (r)
reg = idxreg(regidx(reg) + repeatidx);

print_reg(reg, full, r, c, im, neg, abs, addr_rel);
}

Expand Down Expand Up @@ -928,6 +942,25 @@ static bool print_instr(uint32_t *dwords, int level, int n)

process_reg_dst();

if ((instr->opc_cat <= 4) && (debug & EXPAND_REPEAT)) {
int i;
for (i = 0; i < instr->repeat; i++) {
repeatidx = i + 1;
printf("%s%04d[ ] ",
levels[level], n, dwords[1], dwords[0]);

if (name) {
printf("%s", name);
GETINFO(instr)->print(instr);
} else {
printf("unknown(%d,%d)", instr->opc_cat, opc);
}

printf("\n");
}
repeatidx = 0;
}

return (instr->opc_cat == 0) && (opc == OPC_END);
}

Expand Down
1 change: 1 addition & 0 deletions util/disasm.h
Expand Up @@ -34,6 +34,7 @@ enum shader_t {
enum debug_t {
PRINT_RAW = 0x1, /* dump raw hexdump */
PRINT_VERBOSE = 0x2,
EXPAND_REPEAT = 0x4,
};

int disasm_a2xx(uint32_t *dwords, int sizedwords, int level, enum shader_t type);
Expand Down
47 changes: 32 additions & 15 deletions util/pgmdump.c
Expand Up @@ -715,32 +715,49 @@ static int check_extension(const char *path, const char *ext)
int main(int argc, char **argv)
{
enum rd_sect_type type = RD_NONE;
enum debug_t debug = 0;
void *buf = NULL;
int fd, sz, i;

/* lame argument parsing: */
if ((argc > 1) && !strcmp(argv[1], "--verbose")) {
disasm_set_debug(PRINT_RAW | PRINT_VERBOSE);
argv++;
argc--;
}
if ((argc > 1) && !strcmp(argv[1], "--short")) {
/* only short dump, original shader, symbol table, and disassembly */
full_dump = 0;
argv++;
argc--;
}
if ((argc > 1) && !strcmp(argv[1], "--dump-shaders")) {
dump_shaders = 1;
argv++;
argc--;

while (1) {
if ((argc > 1) && !strcmp(argv[1], "--verbose")) {
debug |= PRINT_RAW | PRINT_VERBOSE;
argv++;
argc--;
continue;
}
if ((argc > 1) && !strcmp(argv[1], "--expand")) {
debug |= EXPAND_REPEAT;
argv++;
argc--;
continue;
}
if ((argc > 1) && !strcmp(argv[1], "--short")) {
/* only short dump, original shader, symbol table, and disassembly */
full_dump = 0;
argv++;
argc--;
continue;
}
if ((argc > 1) && !strcmp(argv[1], "--dump-shaders")) {
dump_shaders = 1;
argv++;
argc--;
continue;
}

break;
}

if (argc != 2) {
fprintf(stderr, "usage: pgmdump [--verbose] [--short] [--dump-shaders] testlog.rd\n");
return -1;
}

disasm_set_debug(debug);

infile = argv[1];

fd = open(infile, O_RDONLY);
Expand Down

0 comments on commit 27b1dd3

Please sign in to comment.