[Beignet] [PATCH] GBE: support SLM bool load and store.

Zhigang Gong zhigang.gong at intel.com
Mon Jun 9 20:01:59 PDT 2014


The OCL spec does allow the use of a i1/BOOL SLM
variable, so we have to support the load and store of
it. To make things simple, I choose to use S16 to represent
i1 value.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 backend/src/backend/gen_insn_selection.cpp | 1 +
 backend/src/ir/instruction.cpp             | 1 -
 backend/src/llvm/llvm_passes.cpp           | 7 ++++++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 46d5846..a035982 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2682,6 +2682,7 @@ namespace gbe
       case TYPE_U32:
       case TYPE_S32:
         return GEN_BYTE_SCATTER_DWORD;
+      case TYPE_BOOL:
       case TYPE_U16:
       case TYPE_S16:
         return GEN_BYTE_SCATTER_WORD;
diff --git a/backend/src/ir/instruction.cpp b/backend/src/ir/instruction.cpp
index 2d2b34b..3dde2fd 100644
--- a/backend/src/ir/instruction.cpp
+++ b/backend/src/ir/instruction.cpp
@@ -938,7 +938,6 @@ namespace ir {
         if (UNLIKELY(checkRegisterData(family, regID, fn, whyNot) == false))
           return false;
       }
-      CHECK_TYPE(insn.type, allButBool);
       return true;
     }
 
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index d30a570..16d461d 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -171,7 +171,12 @@ namespace gbe
     switch (Ty->getTypeID()) {
       case Type::VoidTyID:    NOT_SUPPORTED;
       case Type::PointerTyID: return unit.getPointerSize();
-      case Type::IntegerTyID: return cast<IntegerType>(Ty)->getBitWidth();
+      case Type::IntegerTyID:
+      {
+        // use S16 to represent SLM bool variables.
+        int bitWidth = cast<IntegerType>(Ty)->getBitWidth();
+        return (bitWidth == 1) ? 16 : bitWidth;
+      }
       case Type::HalfTyID:    return 16;
       case Type::FloatTyID:   return 32;
       case Type::DoubleTyID:  return 64;
-- 
1.8.3.2



More information about the Beignet mailing list