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

Submitted by Manasi Navare on Aug. 12, 2015, 5:54 a.m.

Details

Message ID 1439358860-6874-4-git-send-email-manasi.d.navare@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Manasi Navare Aug. 12, 2015, 5:54 a.m.
From: Laura Ekstrand <laura.d.ekstrand@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@intel.com>
Signed-off-by: Laura Ekstrand <laura.d.ekstrand@intel.com>
---
 backend/src/backend/gen_context.cpp | 20 ++++++++++----------
 backend/src/backend/gen_context.hpp |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

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 */