[Beignet] [PATCH 2/3] Backend: Add ID for sel ir

Xiuli Pan xiuli.pan at intel.com
Fri Sep 30 07:32:28 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

We now make each sel ir instruction with ID of step 2.

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 backend/src/backend/gen_context.cpp                 |  1 +
 backend/src/backend/gen_insn_selection.hpp          |  2 ++
 backend/src/backend/gen_insn_selection_optimize.cpp | 10 ++++++++++
 backend/src/backend/gen_insn_selection_output.cpp   |  1 +
 4 files changed, 14 insertions(+)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 439b868..7360f6c 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -3840,6 +3840,7 @@ namespace gbe
     sel->select();
     if (OCL_OPTIMIZE_SEL_IR)
       sel->optimize();
+    sel->addID();
     if (OCL_OUTPUT_SEL_IR)
       outputSelectionIR(*this, this->sel, genKernel->getName());
     schedulePreRegAllocation(*this, *this->sel);
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index 14ac05f..814b449 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -314,6 +314,8 @@ namespace gbe
     void optimize(void);
     uint32_t opt_features;
 
+    /* Add insn ID for sel IR */
+    void addID(void);
     const GenContext &getCtx();
 
     /*! Use custom allocators */
diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp b/backend/src/backend/gen_insn_selection_optimize.cpp
index b8aa776..cc283d7 100644
--- a/backend/src/backend/gen_insn_selection_optimize.cpp
+++ b/backend/src/backend/gen_insn_selection_optimize.cpp
@@ -285,4 +285,14 @@ namespace gbe
     //do global optimization
 
   }
+
+  void Selection::addID()
+  {
+    uint32_t insnID = 0;
+    for (auto &block : *blockList)
+      for (auto &insn : block.insnList) {
+        insn.ID  = insnID;
+        insnID += 2;
+      }
+  }
 } /* namespace gbe */
diff --git a/backend/src/backend/gen_insn_selection_output.cpp b/backend/src/backend/gen_insn_selection_output.cpp
index 7bdd8fd..b683869 100644
--- a/backend/src/backend/gen_insn_selection_output.cpp
+++ b/backend/src/backend/gen_insn_selection_output.cpp
@@ -102,6 +102,7 @@ namespace gbe
     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;
-- 
2.7.4



More information about the Beignet mailing list