[PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 10:17:21 PDT 2016


Anastasia added inline comments.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7868
@@ +7867,3 @@
+def warn_sampler_initializer_invalid_bits : Warning<
+  "Sampler initializer has invalid %0 bits">, InGroup<SpirCompat>;
+def err_sampler_initializer_not_constant : Error<
----------------
start in lower case as all other messages!

================
Comment at: lib/CodeGen/CGExprConstant.cpp:694
@@ +693,3 @@
+    case CK_IntToOCLSampler:
+      llvm_unreachable("global sampler variables are not generated");
+
----------------
Does this only apply to global variable samplers?

================
Comment at: lib/CodeGen/CodeGenModule.cpp:4309
@@ +4308,3 @@
+  // in SPIR spec v1.2 and also opencl-c.h
+  unsigned AddressingMode  = (0x0E & SamplerValue) >> 1;
+  unsigned FilterMode      = (0x30 & SamplerValue) >> 4;
----------------
Seems like this code is specific to SPIR and not OpenCL?

================
Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6906,3 +6907,1 @@
     case SK_OCLSamplerInit: {
-      assert(Step->Type->isSamplerT() && 
-             "Sampler initialization on non-sampler type.");
----------------
Is the assert no longer needed?

================
Comment at: lib/Sema/SemaInit.cpp:6909
@@ +6908,3 @@
+      Expr *Init = CurInit.get();
+      Init->dump();
+      QualType SourceType = Init->getType();
----------------
Debug output?

================
Comment at: test/CodeGenOpenCL/sampler.cl:23
@@ +22,3 @@
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
----------------
Why does the initialization  happen second time here?

================
Comment at: test/CodeGenOpenCL/sampler.cl:26
@@ +25,3 @@
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 35)
----------------
Could we check definition of global sampler variable in IR too?


http://reviews.llvm.org/D21567





More information about the cfe-commits mailing list