[Beignet] [PATCH 3/7] backend: Convert outputAssembly to C file I/O.
Laura Ekstrand
laura.d.ekstrand at intel.com
Mon Jul 27 10:25:13 PDT 2015
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.
---
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 594a1eb..f10ecbe 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2288,7 +2288,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;
}
@@ -2297,34 +2297,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 d9b0cbe..6516316 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -220,7 +220,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 */
--
2.1.0
More information about the Beignet
mailing list