[Beignet] [PATCH 5/7] Backend: Refine selection IR output
Xiuli Pan
xiuli.pan at intel.com
Mon Nov 14 08:20:06 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Split the output IR into output instruction, thus we can dump each
selection instruction.
Also add ID and flag info in the sel IR to help debug.
Contributor: Ruiling Song <ruiling.song at intel.com>
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/backend/gen_insn_selection.hpp | 1 +
backend/src/backend/gen_insn_selection_output.cpp | 135 ++++++++++++----------
2 files changed, 75 insertions(+), 61 deletions(-)
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index bee35d2..57e60ad 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -211,6 +211,7 @@ namespace gbe
// Allocates (with a linear allocator) and owns SelectionInstruction
friend class Selection;
};
+ void outputSelectionInst(SelectionInstruction &insn);
/*! Instructions like sends require to make registers contiguous in GRF */
class SelectionVector : public NonCopyable, public intrusive_list_node
diff --git a/backend/src/backend/gen_insn_selection_output.cpp b/backend/src/backend/gen_insn_selection_output.cpp
index b683869..ae396f3 100644
--- a/backend/src/backend/gen_insn_selection_output.cpp
+++ b/backend/src/backend/gen_insn_selection_output.cpp
@@ -96,74 +96,87 @@ namespace gbe
}
#define OP_NAME_LENGTH 512
- void outputSelectionIR(GenContext &ctx, Selection* sel, const char* KernelName)
- {
- cout << KernelName <<"'s SELECTION IR begin:" << endl;
- cout << "WARNING: not completed yet, welcome for the FIX!" << endl;
- for (SelectionBlock &block : *sel->blockList) {
- for (SelectionInstruction &insn : block.insnList) {
- cout<<"["<<insn.ID<<"]";
- char opname[OP_NAME_LENGTH];
- if (insn.isLabel()) {
- cout << " L" << insn.index << ":" << endl;
- continue;
- } else {
- switch (insn.opcode) {
- #define DECL_SELECTION_IR(OP, FAMILY) case SEL_OP_##OP: sprintf(opname, "%s", #OP); break;
- #include "backend/gen_insn_selection.hxx"
- #undef DECL_SELECTION_IR
- }
- }
+ void outputSelectionInst(SelectionInstruction &insn) {
+ cout<<"["<<insn.ID<<"]";
+ if (insn.state.predicate != GEN_PREDICATE_NONE) {
+ if (insn.state.physicalFlag == 0)
+ cout << "(f" << insn.state.flagIndex << ")\t";
+ else
+ cout << "(f" << insn.state.flag << "." << insn.state.subFlag << ")\t";
+ }
+ else
+ cout << " \t";
- if (insn.opcode == SEL_OP_CMP) {
- switch (insn.extra.function) {
- case GEN_CONDITIONAL_LE:
- strcat(opname, ".le");
- break;
- case GEN_CONDITIONAL_L:
- strcat(opname, ".l");
- break;
- case GEN_CONDITIONAL_GE:
- strcat(opname, ".ge");
- break;
- case GEN_CONDITIONAL_G:
- strcat(opname, ".g");
- break;
- case GEN_CONDITIONAL_EQ:
- strcat(opname, ".eq");
- break;
- case GEN_CONDITIONAL_NEQ:
- strcat(opname, ".neq");
- break;
- }
- }
+ char opname[OP_NAME_LENGTH];
+ if (insn.isLabel()) {
+ cout << " L" << insn.index << ":" << endl;
+ return;
+ } else {
+ switch (insn.opcode) {
+ #define DECL_SELECTION_IR(OP, FAMILY) case SEL_OP_##OP: sprintf(opname, "%s", #OP); break;
+ #include "backend/gen_insn_selection.hxx"
+ #undef DECL_SELECTION_IR
+ }
+ }
- int n = strlen(opname);
- if(n >= OP_NAME_LENGTH - 20) {
- cout << "opname too long: " << opname << endl;
- return;
- }
+ if (insn.opcode == SEL_OP_CMP) {
+ switch (insn.extra.function) {
+ case GEN_CONDITIONAL_LE:
+ strcat(opname, ".le");
+ break;
+ case GEN_CONDITIONAL_L:
+ strcat(opname, ".l");
+ break;
+ case GEN_CONDITIONAL_GE:
+ strcat(opname, ".ge");
+ break;
+ case GEN_CONDITIONAL_G:
+ strcat(opname, ".g");
+ break;
+ case GEN_CONDITIONAL_EQ:
+ strcat(opname, ".eq");
+ break;
+ case GEN_CONDITIONAL_NEQ:
+ strcat(opname, ".neq");
+ break;
+ }
+ }
- sprintf(&opname[n], "(%d)", insn.state.execWidth);
- cout << " " << left << setw(20) << opname;
+ int n = strlen(opname);
+ if(n >= OP_NAME_LENGTH - 20) {
+ cout << "opname too long: " << opname << endl;
+ return;
+ }
- for (int i = 0; i < insn.dstNum; ++i)
- {
- GenRegister dst = insn.dst(i);
- outputGenReg(dst, true);
- cout << "\t";
- }
+ sprintf(&opname[n], "(%d)", insn.state.execWidth);
+ cout << left << setw(20) << opname;
- cout << ":\t";
+ for (int i = 0; i < insn.dstNum; ++i)
+ {
+ GenRegister dst = insn.dst(i);
+ outputGenReg(dst, true);
+ cout << "\t";
+ }
- for (int i = 0; i < insn.srcNum; ++i)
- {
- GenRegister src = insn.src(i);
- outputGenReg(src, false);
- cout << "\t";
- }
+ cout << ":\t";
+
+ for (int i = 0; i < insn.srcNum; ++i)
+ {
+ GenRegister src = insn.src(i);
+ outputGenReg(src, false);
+ cout << "\t";
+ }
- cout << endl;
+ cout << endl;
+ }
+
+ void outputSelectionIR(GenContext &ctx, Selection* sel, const char* KernelName)
+ {
+ cout << KernelName <<"'s SELECTION IR begin:" << endl;
+ cout << "WARNING: not completed yet, welcome for the FIX!" << endl;
+ for (SelectionBlock &block : *sel->blockList) {
+ for (SelectionInstruction &insn : block.insnList) {
+ outputSelectionInst(insn);
}
cout << endl;
}
--
2.7.4
More information about the Beignet
mailing list