mirror of https://github.com/microsoft/clang.git
Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174601 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f5a6aefa37
commit
21f18c4fda
|
@ -721,7 +721,7 @@ public:
|
|||
CanQualType OCLImage1dTy, OCLImage1dArrayTy, OCLImage1dBufferTy;
|
||||
CanQualType OCLImage2dTy, OCLImage2dArrayTy;
|
||||
CanQualType OCLImage3dTy;
|
||||
CanQualType OCLEventTy;
|
||||
CanQualType OCLSamplerTy, OCLEventTy;
|
||||
|
||||
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
|
||||
mutable QualType AutoDeductTy; // Deduction against 'auto'.
|
||||
|
|
|
@ -162,6 +162,9 @@ BUILTIN_TYPE(OCLImage2d, OCLImage2dTy)
|
|||
BUILTIN_TYPE(OCLImage2dArray, OCLImage2dArrayTy)
|
||||
BUILTIN_TYPE(OCLImage3d, OCLImage3dTy)
|
||||
|
||||
// OpenCL sampler_t.
|
||||
BUILTIN_TYPE(OCLSampler, OCLSamplerTy)
|
||||
|
||||
// OpenCL event_t.
|
||||
BUILTIN_TYPE(OCLEvent, OCLEventTy)
|
||||
|
||||
|
|
|
@ -1584,6 +1584,7 @@ public:
|
|||
|
||||
bool isImageType() const; // Any OpenCL image type
|
||||
|
||||
bool isSamplerT() const; // OpenCL sampler_t
|
||||
bool isEventT() const; // OpenCL event_t
|
||||
|
||||
bool isOpenCLSpecificType() const; // Any OpenCL specific type
|
||||
|
@ -4918,6 +4919,11 @@ inline bool Type::isImage2dArrayT() const {
|
|||
inline bool Type::isImage3dT() const {
|
||||
return isSpecificBuiltinType(BuiltinType::OCLImage3d);
|
||||
}
|
||||
|
||||
inline bool Type::isSamplerT() const {
|
||||
return isSpecificBuiltinType(BuiltinType::OCLSampler);
|
||||
}
|
||||
|
||||
inline bool Type::isEventT() const {
|
||||
return isSpecificBuiltinType(BuiltinType::OCLEvent);
|
||||
}
|
||||
|
@ -4929,7 +4935,7 @@ inline bool Type::isImageType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isOpenCLSpecificType() const {
|
||||
return isImageType() || isEventT();
|
||||
return isSamplerT() || isEventT() || isImageType();
|
||||
}
|
||||
|
||||
inline bool Type::isTemplateTypeParmType() const {
|
||||
|
|
|
@ -6139,6 +6139,10 @@ def err_event_t_addr_space_qual : Error<
|
|||
"the event_t type can only be used with __private address space qualifier">;
|
||||
def err_expected_kernel_void_return_type : Error<
|
||||
"kernel must have void return type">;
|
||||
def err_sampler_argument_required : Error<
|
||||
"sampler_t variable required - got %0">;
|
||||
def err_wrong_sampler_addressspace: Error<
|
||||
"sampler type cannot be used with the __local and __global address space qualifiers">;
|
||||
|
||||
} // end of sema category
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace clang {
|
|||
TST_image2d_t, // OpenCL image2d_t
|
||||
TST_image2d_array_t, // OpenCL image2d_array_t
|
||||
TST_image3d_t, // OpenCL image3d_t
|
||||
TST_sampler_t, // OpenCL sampler_t
|
||||
TST_event_t, // OpenCL event_t
|
||||
TST_error // erroneous type
|
||||
};
|
||||
|
|
|
@ -455,6 +455,7 @@ KEYWORD(image1d_buffer_t , KEYOPENCL)
|
|||
KEYWORD(image2d_t , KEYOPENCL)
|
||||
KEYWORD(image2d_array_t , KEYOPENCL)
|
||||
KEYWORD(image3d_t , KEYOPENCL)
|
||||
KEYWORD(sampler_t , KEYOPENCL)
|
||||
KEYWORD(event_t , KEYOPENCL)
|
||||
|
||||
// Borland Extensions.
|
||||
|
|
|
@ -282,6 +282,7 @@ public:
|
|||
static const TST TST_image2d_t = clang::TST_image2d_t;
|
||||
static const TST TST_image2d_array_t = clang::TST_image2d_array_t;
|
||||
static const TST TST_image3d_t = clang::TST_image3d_t;
|
||||
static const TST TST_sampler_t = clang::TST_sampler_t;
|
||||
static const TST TST_event_t = clang::TST_event_t;
|
||||
static const TST TST_error = clang::TST_error;
|
||||
|
||||
|
|
|
@ -625,6 +625,8 @@ public:
|
|||
SK_ProduceObjCObject,
|
||||
/// \brief Construct a std::initializer_list from an initializer list.
|
||||
SK_StdInitializerList,
|
||||
/// \brief Initialize an OpenCL sampler from an integer.
|
||||
SK_OCLSamplerInit,
|
||||
/// \brief Passing zero to a function where OpenCL event_t is expected.
|
||||
SK_OCLZeroEvent
|
||||
};
|
||||
|
@ -955,6 +957,10 @@ public:
|
|||
/// initializer list.
|
||||
void AddStdInitializerListConstructionStep(QualType T);
|
||||
|
||||
/// \brief Add a step to initialize an OpenCL sampler from an integer
|
||||
/// constant.
|
||||
void AddOCLSamplerInitStep(QualType T);
|
||||
|
||||
/// \brief Add a step to initialize an OpenCL event_t from a NULL
|
||||
/// constant.
|
||||
void AddOCLZeroEventStep(QualType T);
|
||||
|
|
|
@ -720,7 +720,10 @@ namespace clang {
|
|||
PREDEF_TYPE_IMAGE2D_ARR_ID = 42,
|
||||
/// \brief OpenCL 3d image type.
|
||||
PREDEF_TYPE_IMAGE3D_ID = 43,
|
||||
PREDEF_TYPE_EVENT_ID = 44
|
||||
/// \brief OpenCL event type.
|
||||
PREDEF_TYPE_EVENT_ID = 44,
|
||||
/// \brief OpenCL sampler type.
|
||||
PREDEF_TYPE_SAMPLER_ID = 45
|
||||
};
|
||||
|
||||
/// \brief The number of predefined type IDs that are reserved for
|
||||
|
|
|
@ -906,6 +906,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) {
|
|||
InitBuiltinType(OCLImage2dArrayTy, BuiltinType::OCLImage2dArray);
|
||||
InitBuiltinType(OCLImage3dTy, BuiltinType::OCLImage3d);
|
||||
|
||||
InitBuiltinType(OCLSamplerTy, BuiltinType::OCLSampler);
|
||||
InitBuiltinType(OCLEventTy, BuiltinType::OCLEvent);
|
||||
}
|
||||
|
||||
|
@ -1448,6 +1449,11 @@ ASTContext::getTypeInfoImpl(const Type *T) const {
|
|||
Width = Target->getPointerWidth(0);
|
||||
Align = Target->getPointerAlign(0);
|
||||
break;
|
||||
case BuiltinType::OCLSampler:
|
||||
// Samplers are modeled as integers.
|
||||
Width = Target->getIntWidth();
|
||||
Align = Target->getIntAlign();
|
||||
break;
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::OCLImage1d:
|
||||
case BuiltinType::OCLImage1dArray:
|
||||
|
@ -4923,6 +4929,7 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
|
|||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::Dependent:
|
||||
#define BUILTIN_TYPE(KIND, ID)
|
||||
#define PLACEHOLDER_TYPE(KIND, ID) \
|
||||
|
|
|
@ -1886,6 +1886,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
|
|||
case BuiltinType::OCLImage2d: Out << "11ocl_image2d"; break;
|
||||
case BuiltinType::OCLImage2dArray: Out << "16ocl_image2darray"; break;
|
||||
case BuiltinType::OCLImage3d: Out << "11ocl_image3d"; break;
|
||||
case BuiltinType::OCLSampler: Out << "11ocl_sampler"; break;
|
||||
case BuiltinType::OCLEvent: Out << "9ocl_event"; break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1060,6 +1060,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T,
|
|||
case BuiltinType::OCLImage2d: Out << "PAUocl_image2d@@"; break;
|
||||
case BuiltinType::OCLImage2dArray: Out << "PAUocl_image2darray@@"; break;
|
||||
case BuiltinType::OCLImage3d: Out << "PAUocl_image3d@@"; break;
|
||||
case BuiltinType::OCLSampler: Out << "PAUocl_sampler@@"; break;
|
||||
case BuiltinType::OCLEvent: Out << "PAUocl_event@@"; break;
|
||||
|
||||
case BuiltinType::NullPtr: Out << "$$T"; break;
|
||||
|
|
|
@ -351,6 +351,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
|
|||
case BuiltinType::OCLImage2d:
|
||||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::BoundMember:
|
||||
case BuiltinType::Dependent:
|
||||
|
|
|
@ -1518,6 +1518,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
|
|||
case OCLImage2d: return "image2d_t";
|
||||
case OCLImage2dArray: return "image2d_array_t";
|
||||
case OCLImage3d: return "image3d_t";
|
||||
case OCLSampler: return "sampler_t";
|
||||
case OCLEvent: return "event_t";
|
||||
}
|
||||
|
||||
|
|
|
@ -268,6 +268,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
|
|||
case BuiltinType::OCLImage2d:
|
||||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::BuiltinFn:
|
||||
return TST_unspecified;
|
||||
|
|
|
@ -426,6 +426,11 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) {
|
|||
case BuiltinType::OCLImage3d:
|
||||
return getOrCreateStructPtrType("opencl_image3d_t",
|
||||
OCLImage3dDITy);
|
||||
case BuiltinType::OCLSampler:
|
||||
return DBuilder.createBasicType("opencl_sampler_t",
|
||||
CGM.getContext().getTypeSize(BT),
|
||||
CGM.getContext().getTypeAlign(BT),
|
||||
llvm::dwarf::DW_ATE_unsigned);
|
||||
case BuiltinType::OCLEvent:
|
||||
return getOrCreateStructPtrType("opencl_event_t",
|
||||
OCLEventDITy);
|
||||
|
|
|
@ -55,6 +55,8 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) {
|
|||
case BuiltinType::OCLImage3d:
|
||||
return llvm::PointerType::get(llvm::StructType::create(
|
||||
CGM.getLLVMContext(), "opencl.image3d_t"), 0);
|
||||
case BuiltinType::OCLSampler:
|
||||
return llvm::IntegerType::get(CGM.getLLVMContext(),32);
|
||||
case BuiltinType::OCLEvent:
|
||||
return llvm::PointerType::get(llvm::StructType::create(
|
||||
CGM.getLLVMContext(), "opencl.event_t"), 0);
|
||||
|
|
|
@ -197,6 +197,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
|
|||
case BuiltinType::OCLImage2d:
|
||||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::OCLEvent:
|
||||
return true;
|
||||
|
||||
|
|
|
@ -378,6 +378,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
|||
case BuiltinType::OCLImage2d:
|
||||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLSampler:
|
||||
case BuiltinType::OCLEvent:
|
||||
ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
|
||||
break;
|
||||
|
|
|
@ -2781,6 +2781,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_image3d_t, Loc,
|
||||
PrevSpec, DiagID);
|
||||
break;
|
||||
case tok::kw_sampler_t:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_sampler_t, Loc,
|
||||
PrevSpec, DiagID);
|
||||
break;
|
||||
case tok::kw_event_t:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_event_t, Loc,
|
||||
PrevSpec, DiagID);
|
||||
|
@ -3635,6 +3639,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
|
|||
case tok::kw_image2d_t:
|
||||
case tok::kw_image2d_array_t:
|
||||
case tok::kw_image3d_t:
|
||||
case tok::kw_sampler_t:
|
||||
case tok::kw_event_t:
|
||||
|
||||
// struct-or-union-specifier (C99) or class-specifier (C++)
|
||||
|
@ -3716,6 +3721,7 @@ bool Parser::isTypeSpecifierQualifier() {
|
|||
case tok::kw_image2d_t:
|
||||
case tok::kw_image2d_array_t:
|
||||
case tok::kw_image3d_t:
|
||||
case tok::kw_sampler_t:
|
||||
case tok::kw_event_t:
|
||||
|
||||
// struct-or-union-specifier (C99) or class-specifier (C++)
|
||||
|
@ -3869,6 +3875,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
|
|||
case tok::kw_image2d_t:
|
||||
case tok::kw_image2d_array_t:
|
||||
case tok::kw_image3d_t:
|
||||
case tok::kw_sampler_t:
|
||||
case tok::kw_event_t:
|
||||
|
||||
// struct-or-union-specifier (C99) or class-specifier (C++)
|
||||
|
|
|
@ -1024,6 +1024,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
|
|||
case tok::kw_image2d_t:
|
||||
case tok::kw_image2d_array_t:
|
||||
case tok::kw_image3d_t:
|
||||
case tok::kw_sampler_t:
|
||||
case tok::kw_event_t: {
|
||||
if (!getLangOpts().CPlusPlus) {
|
||||
Diag(Tok, diag::err_expected_expression);
|
||||
|
|
|
@ -843,6 +843,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
|
|||
case tok::kw_image2d_t:
|
||||
case tok::kw_image2d_array_t:
|
||||
case tok::kw_image3d_t:
|
||||
case tok::kw_sampler_t:
|
||||
case tok::kw_event_t:
|
||||
case tok::kw___unknown_anytype:
|
||||
return TPResult::False();
|
||||
|
|
|
@ -286,6 +286,7 @@ bool Declarator::isDeclarationOfFunction() const {
|
|||
case TST_image2d_t:
|
||||
case TST_image2d_array_t:
|
||||
case TST_image3d_t:
|
||||
case TST_sampler_t:
|
||||
case TST_event_t:
|
||||
return false;
|
||||
|
||||
|
@ -428,6 +429,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T) {
|
|||
case DeclSpec::TST_image2d_t: return "image2d_t";
|
||||
case DeclSpec::TST_image2d_array_t: return "image2d_array_t";
|
||||
case DeclSpec::TST_image3d_t: return "image3d_t";
|
||||
case DeclSpec::TST_sampler_t: return "sampler_t";
|
||||
case DeclSpec::TST_event_t: return "event_t";
|
||||
case DeclSpec::TST_error: return "(error)";
|
||||
}
|
||||
|
|
|
@ -4483,6 +4483,14 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
SCAsWritten = SC_OpenCLWorkGroupLocal;
|
||||
}
|
||||
|
||||
// OpenCL v1.2 s6.9.b p4:
|
||||
// The sampler type cannot be used with the __local and __global address
|
||||
// space qualifiers.
|
||||
if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local ||
|
||||
R.getAddressSpace() == LangAS::opencl_global)) {
|
||||
Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
|
||||
}
|
||||
|
||||
// OpenCL 1.2 spec, p6.9 r:
|
||||
// The event type cannot be used to declare a program scope variable.
|
||||
// The event type cannot be used with the __local, __constant and __global
|
||||
|
|
|
@ -2424,6 +2424,7 @@ void InitializationSequence::Step::Destroy() {
|
|||
case SK_PassByIndirectRestore:
|
||||
case SK_ProduceObjCObject:
|
||||
case SK_StdInitializerList:
|
||||
case SK_OCLSamplerInit:
|
||||
case SK_OCLZeroEvent:
|
||||
break;
|
||||
|
||||
|
@ -2653,6 +2654,13 @@ void InitializationSequence::AddStdInitializerListConstructionStep(QualType T) {
|
|||
Steps.push_back(S);
|
||||
}
|
||||
|
||||
void InitializationSequence::AddOCLSamplerInitStep(QualType T) {
|
||||
Step S;
|
||||
S.Kind = SK_OCLSamplerInit;
|
||||
S.Type = T;
|
||||
Steps.push_back(S);
|
||||
}
|
||||
|
||||
void InitializationSequence::AddOCLZeroEventStep(QualType T) {
|
||||
Step S;
|
||||
S.Kind = SK_OCLZeroEvent;
|
||||
|
@ -4017,6 +4025,18 @@ static bool tryObjCWritebackConversion(Sema &S,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool TryOCLSamplerInitialization(Sema &S,
|
||||
InitializationSequence &Sequence,
|
||||
QualType DestType,
|
||||
Expr *Initializer) {
|
||||
if (!S.getLangOpts().OpenCL || !DestType->isSamplerT() ||
|
||||
!Initializer->isIntegerConstantExpr(S.getASTContext()))
|
||||
return false;
|
||||
|
||||
Sequence.AddOCLSamplerInitStep(DestType);
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// OpenCL 1.2 spec, s6.12.10
|
||||
//
|
||||
|
@ -4180,7 +4200,9 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (TryOCLSamplerInitialization(S, *this, DestType, Initializer))
|
||||
return;
|
||||
|
||||
if (TryOCLZeroEventInitialization(S, *this, DestType, Initializer))
|
||||
return;
|
||||
|
@ -4974,6 +4996,7 @@ InitializationSequence::Perform(Sema &S,
|
|||
case SK_PassByIndirectRestore:
|
||||
case SK_ProduceObjCObject:
|
||||
case SK_StdInitializerList:
|
||||
case SK_OCLSamplerInit:
|
||||
case SK_OCLZeroEvent: {
|
||||
assert(Args.size() == 1);
|
||||
CurInit = Args[0];
|
||||
|
@ -5490,6 +5513,23 @@ InitializationSequence::Perform(Sema &S,
|
|||
CurInit = S.Owned(Semantic);
|
||||
break;
|
||||
}
|
||||
case SK_OCLSamplerInit: {
|
||||
assert(Step->Type->isSamplerT() &&
|
||||
"Sampler initialization on non sampler type.");
|
||||
|
||||
QualType SourceType = CurInit.get()->getType();
|
||||
InitializedEntity::EntityKind EntityKind = Entity.getKind();
|
||||
|
||||
if (EntityKind == InitializedEntity::EK_Parameter) {
|
||||
if (!SourceType->isSamplerT())
|
||||
S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
|
||||
<< SourceType;
|
||||
} else if (EntityKind != InitializedEntity::EK_Variable) {
|
||||
llvm_unreachable("Invalid EntityKind!");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SK_OCLZeroEvent: {
|
||||
assert(Step->Type->isEventT() &&
|
||||
"Event initialization on non event type.");
|
||||
|
@ -6186,6 +6226,10 @@ void InitializationSequence::dump(raw_ostream &OS) const {
|
|||
OS << "std::initializer_list from initializer list";
|
||||
break;
|
||||
|
||||
case SK_OCLSamplerInit:
|
||||
OS << "OpenCL sampler_t from integer constant";
|
||||
break;
|
||||
|
||||
case SK_OCLZeroEvent:
|
||||
OS << "OpenCL event_t from zero";
|
||||
break;
|
||||
|
|
|
@ -1664,7 +1664,9 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
|
|||
== CanonTo.getLocalUnqualifiedType() &&
|
||||
(CanonFrom.getLocalCVRQualifiers() != CanonTo.getLocalCVRQualifiers()
|
||||
|| CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr()
|
||||
|| CanonFrom.getObjCLifetime() != CanonTo.getObjCLifetime())) {
|
||||
|| CanonFrom.getObjCLifetime() != CanonTo.getObjCLifetime()
|
||||
|| (CanonFrom->isSamplerT() &&
|
||||
CanonFrom.getAddressSpace() != CanonTo.getAddressSpace()))) {
|
||||
FromType = ToType;
|
||||
CanonFrom = CanonTo;
|
||||
}
|
||||
|
|
|
@ -737,6 +737,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
|
|||
case TST_image2d_t:
|
||||
case TST_image2d_array_t:
|
||||
case TST_image3d_t:
|
||||
case TST_sampler_t:
|
||||
case TST_event_t:
|
||||
case TST_error:
|
||||
break;
|
||||
|
|
|
@ -952,6 +952,10 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
|
|||
Result = Context.OCLImage3dTy;
|
||||
break;
|
||||
|
||||
case DeclSpec::TST_sampler_t:
|
||||
Result = Context.OCLSamplerTy;
|
||||
break;
|
||||
|
||||
case DeclSpec::TST_event_t:
|
||||
Result = Context.OCLEventTy;
|
||||
break;
|
||||
|
|
|
@ -67,6 +67,7 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
|
|||
case BuiltinType::OCLImage2d: ID = PREDEF_TYPE_IMAGE2D_ID; break;
|
||||
case BuiltinType::OCLImage2dArray: ID = PREDEF_TYPE_IMAGE2D_ARR_ID; break;
|
||||
case BuiltinType::OCLImage3d: ID = PREDEF_TYPE_IMAGE3D_ID; break;
|
||||
case BuiltinType::OCLSampler: ID = PREDEF_TYPE_SAMPLER_ID; break;
|
||||
case BuiltinType::OCLEvent: ID = PREDEF_TYPE_EVENT_ID; break;
|
||||
case BuiltinType::BuiltinFn:
|
||||
ID = PREDEF_TYPE_BUILTIN_FN; break;
|
||||
|
|
|
@ -4903,6 +4903,7 @@ QualType ASTReader::GetType(TypeID ID) {
|
|||
case PREDEF_TYPE_IMAGE2D_ID: T = Context.OCLImage2dTy; break;
|
||||
case PREDEF_TYPE_IMAGE2D_ARR_ID: T = Context.OCLImage2dArrayTy; break;
|
||||
case PREDEF_TYPE_IMAGE3D_ID: T = Context.OCLImage3dTy; break;
|
||||
case PREDEF_TYPE_SAMPLER_ID: T = Context.OCLSamplerTy; break;
|
||||
case PREDEF_TYPE_EVENT_ID: T = Context.OCLEventTy; break;
|
||||
case PREDEF_TYPE_AUTO_DEDUCT: T = Context.getAutoDeductType(); break;
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
|
||||
|
||||
constant sampler_t glb_smp = 7;
|
||||
// CHECK: global i32 7
|
||||
|
||||
void fnc1(image1d_t img) {}
|
||||
// CHECK: @fnc1(%opencl.image1d_t*
|
||||
|
||||
|
@ -18,7 +21,17 @@ void fnc2arr(image2d_array_t img) {}
|
|||
void fnc3(image3d_t img) {}
|
||||
// CHECK: @fnc3(%opencl.image3d_t*
|
||||
|
||||
void fnc4smp(sampler_t s) {}
|
||||
// CHECK: define void @fnc4smp(i32
|
||||
|
||||
kernel void foo(image1d_t img) {
|
||||
sampler_t smp = 5;
|
||||
// CHECK: alloca i32
|
||||
event_t evt;
|
||||
// CHECK: alloca %opencl.event_t*
|
||||
// CHECK: store i32 5,
|
||||
fnc4smp(smp);
|
||||
// CHECK: call void @fnc4smp(i32
|
||||
fnc4smp(glb_smp);
|
||||
// CHECK: call void @fnc4smp(i32
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ void foo5(img2darr_t img);
|
|||
|
||||
void foo6(img3d_t img);
|
||||
|
||||
void foo7(smp_t smp) {
|
||||
smp_t loc_smp;
|
||||
}
|
||||
|
||||
void foo8(evt_t evt) {
|
||||
evt_t loc_evt;
|
||||
}
|
||||
|
|
|
@ -18,5 +18,8 @@ typedef image2d_array_t img2darr_t;
|
|||
// image3d_t
|
||||
typedef image3d_t img3d_t;
|
||||
|
||||
// sampler_t
|
||||
typedef sampler_t smp_t;
|
||||
|
||||
// event_t
|
||||
typedef event_t evt_t;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
|
||||
|
||||
constant sampler_t glb_smp = 5;
|
||||
|
||||
void foo(sampler_t);
|
||||
|
||||
void kernel ker(sampler_t argsmp) {
|
||||
local sampler_t smp; // expected-error {{sampler type cannot be used with the __local and __global address space qualifiers}}
|
||||
const sampler_t const_smp = 7;
|
||||
foo(glb_smp);
|
||||
foo(const_smp);
|
||||
foo(5); // expected-error {{sampler_t variable required - got 'int'}}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// RUN: %clang_cc1 %s
|
||||
|
||||
void __attribute__((overloadable)) foo(sampler_t, read_only image1d_t);
|
||||
void __attribute__((overloadable)) foo(sampler_t, read_only image2d_t);
|
||||
|
||||
constant sampler_t glb_smp = 5;
|
||||
|
||||
void kernel ker(read_only image1d_t src1, read_only image2d_t src2) {
|
||||
const sampler_t smp = 10;
|
||||
foo(glb_smp, src1);
|
||||
foo(smp, src2);
|
||||
}
|
|
@ -596,6 +596,7 @@ void USRGenerator::VisitType(QualType T) {
|
|||
case BuiltinType::OCLImage2dArray:
|
||||
case BuiltinType::OCLImage3d:
|
||||
case BuiltinType::OCLEvent:
|
||||
case BuiltinType::OCLSampler:
|
||||
IgnoreResults = true;
|
||||
return;
|
||||
case BuiltinType::ObjCId:
|
||||
|
|
Loading…
Reference in New Issue