[Beignet] [PATCH 3/7] backend: Convert outputAssembly to C file I/O.

Manasi Navare manasi.d.navare at intel.com
Tue Aug 11 22:54:16 PDT 2015


From: Laura Ekstrand <laura.d.ekstrand at intel.com>

This unifies the printing of the Gen Assembly to C file I/O, eliminating the
use of iostream.  This is so that a single stream can be passed into the
function to receive all of the output.

Signed-off-by: Manasi Navare <manasi.d.navare at intel.com>
Signed-off-by: Laura Ekstrand <laura.d.ekstrand at intel.com>
---
 backend/src/backend/gen_context.cpp | 20 ++++++++++----------
 backend/src/backend/gen_context.hpp |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 9ca4d7e..c4c8cc6 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2292,7 +2292,7 @@ namespace gbe
     genKernel->insns = GBE_NEW_ARRAY_NO_ARG(GenInstruction, genKernel->insnNum);
     std::memcpy(genKernel->insns, &p->store[0], genKernel->insnNum * sizeof(GenInstruction));
     if (OCL_OUTPUT_ASM)
-      outputAssembly(std::cout, genKernel);
+      outputAssembly(stdout, genKernel);
 
     return true;
   }
@@ -2301,34 +2301,34 @@ namespace gbe
     return GBE_NEW(GenKernel, name, deviceID);
   }
 
-  void GenContext::outputAssembly(std::ostream& out, GenKernel* genKernel) {
-    out << genKernel->getName() << "'s disassemble begin:" << std::endl;
+  void GenContext::outputAssembly(FILE *file, GenKernel* genKernel) {
+    fprintf(file, "%s's disassemble begin:\n", genKernel->getName());
     ir::LabelIndex curLabel = (ir::LabelIndex)0;
     GenCompactInstruction * pCom = NULL;
     GenInstruction insn[2];
-    out << "  L0:" << std::endl;
+    fprintf(file, "  L0:\n");
     for (uint32_t insnID = 0; insnID < genKernel->insnNum; ) {
       if (labelPos.find((ir::LabelIndex)(curLabel + 1))->second == insnID &&
           curLabel < this->getFunction().labelNum()) {
-        out << "  L" << curLabel + 1 << ":" << std::endl;
+        fprintf(file, "  L%i:\n", curLabel + 1);
         curLabel = (ir::LabelIndex)(curLabel + 1);
         while(labelPos.find((ir::LabelIndex)(curLabel + 1))->second == insnID) {
-          out << "  L" << curLabel + 1 << ":" << std::endl;
+          fprintf(file, "  L%i:\n", curLabel + 1);
           curLabel = (ir::LabelIndex)(curLabel + 1);
         }
       }
-      out << "    (" << std::setw(8) << insnID << ")  ";
+      fprintf(file, "    (%8i)  ", insnID);
       pCom = (GenCompactInstruction*)&p->store[insnID];
       if(pCom->bits1.cmpt_control == 1) {
         decompactInstruction(pCom, &insn);
-        gen_disasm(stdout, &insn, deviceID, 1);
+        gen_disasm(file, &insn, deviceID, 1);
         insnID++;
       } else {
-        gen_disasm(stdout, &p->store[insnID], deviceID, 0);
+        gen_disasm(file, &p->store[insnID], deviceID, 0);
         insnID = insnID + 2;
       }
     }
-    out << genKernel->getName() << "'s disassemble end." << std::endl;
+    fprintf(file, "%s's disassemble end.\n", genKernel->getName());
   }
 
 } /* namespace gbe */
diff --git a/backend/src/backend/gen_context.hpp b/backend/src/backend/gen_context.hpp
index 29ec6d0..e9c6366 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -221,7 +221,7 @@ namespace gbe
     /*! Build the curbe patch list for the given kernel */
     void buildPatchList(void);
     /* Helper for printing the assembly */
-    void outputAssembly(std::ostream& out, GenKernel* genKernel);
+    void outputAssembly(FILE *file, GenKernel* genKernel);
     /*! Calc the group's slm offset from R0.0, to work around HSW SLM bug*/
     virtual void emitSLMOffset(void) { };
     /*! new selection of device */
-- 
1.9.1



More information about the Beignet mailing list