From cd055541b83297f06fba6bf0a770c3751efb026f Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Tue, 10 Jun 2014 10:45:56 +0800 Subject: [PATCH] GBE: support SLM bool load and store. 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 Reviewed-by: Ruiling Song --- 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(Ty)->getBitWidth(); + case Type::IntegerTyID: + { + // use S16 to represent SLM bool variables. + int bitWidth = cast(Ty)->getBitWidth(); + return (bitWidth == 1) ? 16 : bitWidth; + } case Type::HalfTyID: return 16; case Type::FloatTyID: return 32; case Type::DoubleTyID: return 64; -- 2.7.4