GBE: support SLM bool load and store.
authorZhigang Gong <zhigang.gong@intel.com>
Tue, 10 Jun 2014 02:45:56 +0000 (10:45 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 11 Jun 2014 03:03:23 +0000 (11:03 +0800)
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@intel.com>
Reviewed-by: Ruiling Song <ruiling.song@intel.com>
backend/src/backend/gen_insn_selection.cpp
backend/src/ir/instruction.cpp
backend/src/llvm/llvm_passes.cpp

index 46d5846..a035982 100644 (file)
@@ -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;
index 2d2b34b..3dde2fd 100644 (file)
@@ -938,7 +938,6 @@ namespace ir {
         if (UNLIKELY(checkRegisterData(family, regID, fn, whyNot) == false))
           return false;
       }
-      CHECK_TYPE(insn.type, allButBool);
       return true;
     }
 
index d30a570..16d461d 100644 (file)
@@ -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;