[Beignet] [PATCH 1/5] Avoid use GenNativeInstruction directly out of GenEncode and gen_insn_compact.

Yang Rong rong.r.yang at intel.com
Sun Sep 28 22:37:15 PDT 2014


Use the void* instead of when do instruction compact/decompact.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen_context.cpp      | 2 +-
 backend/src/backend/gen_insn_compact.cpp | 3 ++-
 backend/src/backend/gen_program.cpp      | 6 +++---
 backend/src/backend/gen_program.hpp      | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 8844233..78f21ad 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -1903,7 +1903,7 @@ namespace gbe
       std::cout << genKernel->getName() << "'s disassemble begin:" << std::endl;
       ir::LabelIndex curLabel = (ir::LabelIndex)0;
       GenCompactInstruction * pCom = NULL;
-      GenNativeInstruction insn;
+      GenInstruction insn[2];
       std::cout << "  L0:" << std::endl;
       for (uint32_t insnID = 0; insnID < genKernel->insnNum; ) {
         if (labelPos.find((ir::LabelIndex)(curLabel + 1))->second == insnID &&
diff --git a/backend/src/backend/gen_insn_compact.cpp b/backend/src/backend/gen_insn_compact.cpp
index f19c364..17b3e55 100644
--- a/backend/src/backend/gen_insn_compact.cpp
+++ b/backend/src/backend/gen_insn_compact.cpp
@@ -260,7 +260,8 @@ namespace gbe {
     uint32_t data;
   };
 
-  void decompactInstruction(GenCompactInstruction * p, GenNativeInstruction *pOut) {
+  void decompactInstruction(GenCompactInstruction * p, void *insn) {
+    GenNativeInstruction *pOut = (union GenNativeInstruction *) insn;
 
     memset(pOut, 0, sizeof(GenNativeInstruction));
     union ControlBits control_bits;
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index d2ad07d..44f7e33 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -89,13 +89,13 @@ namespace gbe {
     char *buf = new char[4096];
     setbuffer(f, buf, 4096);
     GenCompactInstruction * pCom = NULL;
-    GenNativeInstruction nativeInsn;
+    GenInstruction insn[2];
 
     for (uint32_t i = 0; i < insnNum;) {
       pCom = (GenCompactInstruction*)(insns+i);
       if(pCom->bits1.cmpt_control == 1) {
-        decompactInstruction(pCom, &nativeInsn);
-        gen_disasm(f, &nativeInsn, deviceID, 1);
+        decompactInstruction(pCom, &insn);
+        gen_disasm(f, &insn, deviceID, 1);
         i++;
       } else {
         gen_disasm(f, insns+i, deviceID, 0);
diff --git a/backend/src/backend/gen_program.hpp b/backend/src/backend/gen_program.hpp
index 8e8989b..f22e2d0 100644
--- a/backend/src/backend/gen_program.hpp
+++ b/backend/src/backend/gen_program.hpp
@@ -79,7 +79,7 @@ namespace gbe
     GBE_CLASS(GenProgram);
   };
   /*! decompact GEN ASM if it is in compacted format */
-  extern void decompactInstruction(union GenCompactInstruction *p, union GenNativeInstruction *pOut);
+  extern void decompactInstruction(union GenCompactInstruction *p, void *insn);
 } /* namespace gbe */
 
 #endif /* __GBE_GEN_PROGRAM_HPP__ */
-- 
1.8.3.2



More information about the Beignet mailing list