[Beignet] [Patch V4 2/3] KBL: add kabylake backend support.

Yang Rong rong.r.yang at intel.com
Tue Aug 16 09:08:13 UTC 2016


Kabylake is almost same as skylake, derived it from GEN9.

v3: correct KBL disasm and bin generate.
v4: KBL is also gen9.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen9_context.cpp       |  4 ++++
 backend/src/backend/gen9_context.hpp       | 15 ++++++++++++++-
 backend/src/backend/gen_insn_selection.cpp | 10 ++++++++++
 backend/src/backend/gen_insn_selection.hpp |  7 +++++++
 backend/src/backend/gen_program.cpp        | 13 +++++++++++--
 5 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/backend/src/backend/gen9_context.cpp b/backend/src/backend/gen9_context.cpp
index 47b1496..dc05756 100644
--- a/backend/src/backend/gen9_context.cpp
+++ b/backend/src/backend/gen9_context.cpp
@@ -165,4 +165,8 @@ namespace gbe
     p->pop();
   }
 
+  void KblContext::newSelection(void) {
+    this->sel = GBE_NEW(SelectionKbl, *this);
+  }
+
 }
diff --git a/backend/src/backend/gen9_context.hpp b/backend/src/backend/gen9_context.hpp
index a2931cc..2f24b56 100644
--- a/backend/src/backend/gen9_context.hpp
+++ b/backend/src/backend/gen9_context.hpp
@@ -27,7 +27,7 @@
 
 namespace gbe
 {
-  /* This class is used to implement the HSW
+  /* This class is used to implement the skylake
      specific logic for context. */
   class Gen9Context : public Gen8Context
   {
@@ -68,5 +68,18 @@ namespace gbe
     virtual void calculateFullU64MUL(GenRegister src0, GenRegister src1, GenRegister dst_h,
                                            GenRegister dst_l, GenRegister s0l_s1h, GenRegister s0h_s1l);
   };
+  /* This class is used to implement the kabylake
+     specific logic for context. */
+  class KblContext : public Gen9Context
+  {
+    public:
+      virtual ~KblContext(void) { };
+      KblContext(const ir::Unit &unit, const std::string &name, uint32_t deviceID, bool relaxMath = false)
+        : Gen9Context(unit, name, deviceID, relaxMath) {
+        };
+
+    private:
+      virtual void newSelection(void);
+  };
 }
 #endif /* __GBE_GEN9_CONTEXT_HPP__ */
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index e342161..6ab8316 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2523,6 +2523,16 @@ extern bool OCL_DEBUGINFO; // first defined by calling BVAR in program.cpp
     opt_features = SIOF_LOGICAL_SRCMOD | SIOF_OP_MOV_LONG_REG_RESTRICT;
   }
 
+  SelectionKbl::SelectionKbl(GenContext &ctx) : Selection(ctx) {
+    this->opaque->setHas32X32Mul(true);
+    this->opaque->setHasLongType(true);
+    this->opaque->setHasDoubleType(true);
+    this->opaque->setLdMsgOrder(LD_MSG_ORDER_SKL);
+    this->opaque->setSlowByteGather(false);
+    this->opaque->setHasHalfType(true);
+    opt_features = SIOF_LOGICAL_SRCMOD;
+  }
+
   void Selection::Opaque::TYPED_WRITE(GenRegister *msgs, uint32_t msgNum,
                                       uint32_t bti, bool is3D) {
     uint32_t elemID = 0;
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index b481de8..5e28ec9 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -355,6 +355,13 @@ namespace gbe
       SelectionBxt(GenContext &ctx);
   };
 
+  class SelectionKbl : public Selection
+  {
+    public:
+      /*! Initialize internal structures used for the selection */
+      SelectionKbl(GenContext &ctx);
+  };
+
 } /* namespace gbe */
 
 #endif /*  __GEN_INSN_SELECTION_HPP__ */
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index ade0157..32f7794 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -186,6 +186,8 @@ namespace gbe {
       ctx = GBE_NEW(Gen9Context, unit, name, deviceID, relaxMath);
     } else if (IS_BROXTON(deviceID)) {
       ctx = GBE_NEW(BxtContext, unit, name, deviceID, relaxMath);
+    } else if (IS_KABYLAKE(deviceID)) {
+      ctx = GBE_NEW(KblContext, unit, name, deviceID, relaxMath);
     }
     GBE_ASSERTM(ctx != NULL, "Fail to create the gen context\n");
 
@@ -239,6 +241,7 @@ namespace gbe {
     GBHI_BDW = 4,
     GBHI_SKL = 5,
     GBHI_BXT = 6,
+    GBHI_KBL = 7,
     GBHI_MAX,
   };
 #define GEN_BINARY_VERSION  1
@@ -249,7 +252,8 @@ namespace gbe {
                                               {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'C', 'H', 'V'},
                                               {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'B', 'D', 'W'},
                                               {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'S', 'K', 'L'},
-                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'B', 'X', 'T'}
+                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'B', 'X', 'T'},
+                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'K', 'B', 'T'}
                                               };
 
 #define FILL_GEN_HEADER(binary, index)  do {int i = 0; do {*(binary+i) = gen_binary_header[index][i]; i++; }while(i < GEN_BINARY_HEADER_LENGTH);}while(0)
@@ -260,6 +264,7 @@ namespace gbe {
 #define FILL_BDW_HEADER(binary) FILL_GEN_HEADER(binary, GBHI_BDW)
 #define FILL_SKL_HEADER(binary) FILL_GEN_HEADER(binary, GBHI_SKL)
 #define FILL_BXT_HEADER(binary) FILL_GEN_HEADER(binary, GBHI_BXT)
+#define FILL_KBL_HEADER(binary) FILL_GEN_HEADER(binary, GBHI_KBL)
 
   static bool genHeaderCompare(const unsigned char *BufPtr, GEN_BINARY_HEADER_INDEX index)
   {
@@ -284,6 +289,7 @@ namespace gbe {
 #define MATCH_BDW_HEADER(binary) genHeaderCompare(binary, GBHI_BDW)
 #define MATCH_SKL_HEADER(binary) genHeaderCompare(binary, GBHI_SKL)
 #define MATCH_BXT_HEADER(binary) genHeaderCompare(binary, GBHI_BXT)
+#define MATCH_KBL_HEADER(binary) genHeaderCompare(binary, GBHI_KBL)
 
 #define MATCH_DEVICE(deviceID, binary) ((IS_IVYBRIDGE(deviceID) && MATCH_IVB_HEADER(binary)) ||  \
                                       (IS_IVYBRIDGE(deviceID) && MATCH_IVB_HEADER(binary)) ||  \
@@ -292,7 +298,8 @@ namespace gbe {
                                       (IS_BROADWELL(deviceID) && MATCH_BDW_HEADER(binary)) ||  \
                                       (IS_CHERRYVIEW(deviceID) && MATCH_CHV_HEADER(binary)) ||  \
                                       (IS_SKYLAKE(deviceID) && MATCH_SKL_HEADER(binary)) || \
-                                      (IS_BROXTON(deviceID) && MATCH_BXT_HEADER(binary)) \
+                                      (IS_BROXTON(deviceID) && MATCH_BXT_HEADER(binary)) || \
+                                      (IS_KABYLAKE(deviceID) && MATCH_KBL_HEADER(binary)) \
                                       )
 
   static gbe_program genProgramNewFromBinary(uint32_t deviceID, const char *binary, size_t size) {
@@ -392,6 +399,8 @@ namespace gbe {
         FILL_SKL_HEADER(*binary);
       }else if(IS_BROXTON(prog->deviceID)){
         FILL_BXT_HEADER(*binary);
+      }else if(IS_KABYLAKE(prog->deviceID)){
+        FILL_KBL_HEADER(*binary);
       }else {
         free(*binary);
         *binary = NULL;
-- 
2.1.4



More information about the Beignet mailing list