[Beignet] [PATCH] Backend: Correct the wrong print for float type in disasm.

junyan.he at inbox.com junyan.he at inbox.com
Tue May 19 02:44:47 PDT 2015


From: Junyan He <junyan.he at linux.intel.com>

The GEN_BITS_FIELD always assigns the instruction subfields
to an integer. So when the instruction contains float imm,
the float value will be converted to integer in this assignment,
which cause the wrong print output for disasm.

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/backend/gen/gen_mesa_disasm.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/backend/src/backend/gen/gen_mesa_disasm.c b/backend/src/backend/gen/gen_mesa_disasm.c
index f8d89e0..14ce875 100644
--- a/backend/src/backend/gen/gen_mesa_disasm.c
+++ b/backend/src/backend/gen/gen_mesa_disasm.c
@@ -463,6 +463,17 @@ static int gen_version;
     bits;                                                       \
   })
 
+#define GEN_BITS_FIELD_WITH_TYPE(inst, gen, TYPE)               \
+  ({                                                            \
+    TYPE bits;                                                  \
+    if (gen_version < 80)                                       \
+      bits = ((const union Gen7NativeInstruction *)inst)->gen;	\
+    else                                                        \
+      bits = ((const union Gen8NativeInstruction *)inst)->gen;	\
+    bits;                                                       \
+  })
+
+
 #define GEN_BITS_FIELD2(inst, gen7, gen8)                       \
   ({                                                            \
     int bits;                                                   \
@@ -970,7 +981,7 @@ static int imm(FILE *file, uint32_t type, const void* inst)
       format(file, "0x%xV", GEN_BITS_FIELD(inst, bits3.ud));
       break;
     case GEN_TYPE_F:
-      format(file, "%-gF", GEN_BITS_FIELD(inst, bits3.f));
+      format(file, "%-gF", GEN_BITS_FIELD_WITH_TYPE(inst, bits3.f, float));
       break;
     case GEN_TYPE_UL:
       assert(!(gen_version < 80));
-- 
1.9.1



More information about the Beignet mailing list