mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 01:46:14 +00:00
intel-gen4asm: add byte array style disasm
I previously added a byte array style output for intel-gen4asm, but there was no way to disassemble here. Well here that is.
This commit is contained in:
parent
cbfab5f415
commit
83a5c38e12
@ -40,7 +40,7 @@ read_program (FILE *input)
|
|||||||
struct brw_program_instruction *entry, **prev;
|
struct brw_program_instruction *entry, **prev;
|
||||||
int c;
|
int c;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
program = malloc (sizeof (struct brw_program));
|
program = malloc (sizeof (struct brw_program));
|
||||||
program->first = NULL;
|
program->first = NULL;
|
||||||
prev = &program->first;
|
prev = &program->first;
|
||||||
@ -62,9 +62,40 @@ read_program (FILE *input)
|
|||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct brw_program *
|
||||||
|
read_program_binary (FILE *input)
|
||||||
|
{
|
||||||
|
uint32_t temp;
|
||||||
|
uint8_t inst[16];
|
||||||
|
struct brw_program *program;
|
||||||
|
struct brw_program_instruction *entry, **prev;
|
||||||
|
int c;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
program = malloc (sizeof (struct brw_program));
|
||||||
|
program->first = NULL;
|
||||||
|
prev = &program->first;
|
||||||
|
while ((c = getc (input)) != EOF) {
|
||||||
|
if (c == '0') {
|
||||||
|
if (fscanf (input, "x%2x", &temp) == 1) {
|
||||||
|
inst[n++] = (uint8_t)temp;
|
||||||
|
if (n == 16) {
|
||||||
|
entry = malloc (sizeof (struct brw_program_instruction));
|
||||||
|
memcpy (&entry->instruction, inst, 16 * sizeof (uint8_t));
|
||||||
|
entry->next = NULL;
|
||||||
|
*prev = entry;
|
||||||
|
prev = &entry->next;
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: intel-gen4disasm [-o outputfile] inputfile\n");
|
fprintf(stderr, "usage: intel-gen4disasm [-o outputfile] [-b] inputfile\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -74,15 +105,19 @@ int main(int argc, char **argv)
|
|||||||
FILE *output = stdout;
|
FILE *output = stdout;
|
||||||
char *input_filename = NULL;
|
char *input_filename = NULL;
|
||||||
char *output_file = NULL;
|
char *output_file = NULL;
|
||||||
|
int byte_array_input = 0;
|
||||||
int o;
|
int o;
|
||||||
struct brw_program_instruction *inst;
|
struct brw_program_instruction *inst;
|
||||||
|
|
||||||
while ((o = getopt_long(argc, argv, "o:", longopts, NULL)) != -1) {
|
while ((o = getopt_long(argc, argv, "o:b", longopts, NULL)) != -1) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'o':
|
case 'o':
|
||||||
if (strcmp(optarg, "-") != 0)
|
if (strcmp(optarg, "-") != 0)
|
||||||
output_file = optarg;
|
output_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
byte_array_input = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -103,7 +138,10 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
program = read_program (input);
|
if (byte_array_input)
|
||||||
|
program = read_program_binary (input);
|
||||||
|
else
|
||||||
|
program = read_program (input);
|
||||||
if (!program)
|
if (!program)
|
||||||
exit (1);
|
exit (1);
|
||||||
if (output_file) {
|
if (output_file) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user