Mesa (master): intel/tools: Print c_literals 4 byte wide
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Feb 25 22:49:22 UTC 2020
Module: Mesa
Branch: master
Commit: 2f83daedb19d25744b2b89939713c9ca9e7ad29f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f83daedb19d25744b2b89939713c9ca9e7ad29f
Author: Sagar Ghuge <sagar.ghuge at intel.com>
Date: Fri Feb 7 14:36:12 2020 -0800
intel/tools: Print c_literals 4 byte wide
We already print hex value a byte wide, instead of printing c_literal
byte wide, we can print it 4 byte wide, which gives us 2 different
combinations.
v2: Fix the aliasing issue (Matt Turner)
Signed-off-by: Sagar Ghuge <sagar.ghuge at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3952>
---
src/intel/tools/i965_asm.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/intel/tools/i965_asm.c b/src/intel/tools/i965_asm.c
index 9479d6c2fbd..9fb0cdce0cc 100644
--- a/src/intel/tools/i965_asm.c
+++ b/src/intel/tools/i965_asm.c
@@ -56,6 +56,14 @@ print_help(const char *progname, FILE *file)
progname);
}
+static uint32_t
+get_dword(const brw_inst *inst, int idx)
+{
+ uint32_t dword;
+ memcpy(&dword, (char *)inst + 4 * idx, sizeof(dword));
+ return dword;
+}
+
static void
print_instruction(FILE *output, bool compact, const brw_inst *instruction)
{
@@ -73,11 +81,11 @@ print_instruction(FILE *output, bool compact, const brw_inst *instruction)
break;
}
case OPT_OUTPUT_C_LITERAL: {
- fprintf(output, "\t0x%02x,", ((unsigned char *)instruction)[0]);
+ fprintf(output, "\t0x%08x,", get_dword(instruction, 0));
+
+ for (unsigned i = 1; i < byte_limit / 4; i++)
+ fprintf(output, " 0x%08x,", get_dword(instruction, i));
- for (unsigned i = 1; i < byte_limit; i++) {
- fprintf(output, " 0x%02x,", ((unsigned char *)instruction)[i]);
- }
break;
}
case OPT_OUTPUT_BIN:
More information about the mesa-commit
mailing list