[OpenCL] Enables passing sampler initializer to function argument

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: yaxunl, bader

Differential Revision: https://reviews.llvm.org/D31594

llvm-svn: 299524
This commit is contained in:
Egor Churaev 2017-04-05 09:02:56 +00:00
parent 2641a52ee4
commit a8d2451533
3 changed files with 8 additions and 3 deletions

View File

@ -7174,7 +7174,7 @@ InitializationSequence::Perform(Sema &S,
QualType SourceType = Init->getType();
// Case 1
if (Entity.isParameterKind()) {
if (!SourceType->isSamplerT()) {
if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
<< SourceType;
break;

View File

@ -54,4 +54,8 @@ kernel void foo(sampler_t smp_par) {
fnc4smp(smp_par);
// CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_par_ptr]]
// CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
fnc4smp(5);
// CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5)
// CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
}

View File

@ -30,7 +30,7 @@ constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant
constant sampler_t glb_smp9 = 0x100000000LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
void foo(sampler_t);
void foo(sampler_t); // expected-note{{passing argument to parameter here}}
constant struct sampler_s {
sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
@ -65,7 +65,8 @@ void kernel ker(sampler_t argsmp) {
foo(const_smp5);
foo(const_smp6);
foo(argsmp);
foo(5); // expected-error{{sampler_t variable required - got 'int'}}
foo(5);
foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible type 'sampler_t'}}
sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
foo(sa[0]);
foo(bad());