[Beignet] [PATCH V2 4/5] GBE/DebugInfo: Pass debug info : SEL IR => GenInsn
Bai Yannan
yannan.bai at intel.com
Tue Nov 17 18:43:04 PST 2015
1. Add a structure DBGInfo in GenEncoder class, storing debug infomation for subsequentlt passing to GenInsn.
2. Add a vector<DebugInfo> in GenEncoder class, storing debug information corresponding to vector<GenInstruction>.
3. Pass debug information from SEL IR firstly to Gen Encoder, then add to vector when emitting, if OCL_DEBUGINFO is true.
Signed-off-by: Yannan Bai <yannan.bai at intel.com>
---
backend/src/backend/gen_context.cpp | 6 ++++++
backend/src/backend/gen_encoder.cpp | 13 +++++++++++++
backend/src/backend/gen_encoder.hpp | 3 +++
3 files changed, 22 insertions(+)
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 9868043..b3aacc9 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -92,6 +92,10 @@ namespace gbe
return i;
}
+ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
+#define SET_GENINSN_DBGINFO(I) \
+ if(OCL_DEBUGINFO) p->DBGInfo = I.DBGInfo;
+
void GenContext::emitInstructionStream(void) {
// Emit Gen ISA
for (auto &block : *sel->blockList)
@@ -101,6 +105,7 @@ namespace gbe
// no more virtual register here in that part of the code generation
GBE_ASSERT(insn.state.physicalFlag);
p->curr = insn.state;
+ SET_GENINSN_DBGINFO(insn);
switch (opcode) {
#define DECL_SELECTION_IR(OPCODE, FAMILY) \
case SEL_OP_##OPCODE: this->emit##FAMILY(insn); break;
@@ -114,6 +119,7 @@ namespace gbe
for(int i = 0; i < 8; i++)
p->NOP();
}
+#undef SET_GENINSN_DBGINFO
bool GenContext::patchBranches(void) {
using namespace ir;
diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index b153a2c..713b29f 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -591,11 +591,23 @@ namespace gbe
this->setSrc1(insn, bti);
}
}
+
+ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
+ void GenEncoder::setDBGInfo(DebugInfo in, bool hasHigh)
+ {
+ if(OCL_DEBUGINFO)
+ {
+ storedbg.push_back(in);
+ if(hasHigh) storedbg.push_back(in);
+ }
+ }
+
GenCompactInstruction *GenEncoder::nextCompact(uint32_t opcode) {
GenCompactInstruction insn;
std::memset(&insn, 0, sizeof(GenCompactInstruction));
insn.bits1.opcode = opcode;
this->store.push_back(insn.low);
+ setDBGInfo(DBGInfo, false);
return (GenCompactInstruction *)&this->store.back();
}
@@ -605,6 +617,7 @@ namespace gbe
insn.header.opcode = opcode;
this->store.push_back(insn.low);
this->store.push_back(insn.high);
+ setDBGInfo(DBGInfo, true);
return (GenNativeInstruction *)(&this->store.back()-1);
}
diff --git a/backend/src/backend/gen_encoder.hpp b/backend/src/backend/gen_encoder.hpp
index e9945e8..2fc0e5d 100644
--- a/backend/src/backend/gen_encoder.hpp
+++ b/backend/src/backend/gen_encoder.hpp
@@ -88,6 +88,9 @@ namespace gbe
uint32_t deviceID;
/*! simd width for this codegen */
uint32_t simdWidth;
+ DebugInfo DBGInfo;
+ vector<DebugInfo> storedbg;
+ void setDBGInfo(DebugInfo in, bool hasHigh);
////////////////////////////////////////////////////////////////////////
// Encoding functions
////////////////////////////////////////////////////////////////////////
--
1.9.1
More information about the Beignet
mailing list