[clang] [CIR][CUDA] Support host-side texture registration (PR #236849)
David Rivera via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 13:50:07 PDT 2026
================
@@ -18,9 +39,45 @@ struct __attribute__((device_builtin_texture_type)) texture
: public textureReference {};
texture<float, 2, NormalizedFloat> tex;
+texture<float, 1, ElementType> tex_element;
+
+//===----------------------------------------------------------------------===//
+// Device-side checks
+//===----------------------------------------------------------------------===//
// CIR-DEVICE: cir.global external target_address_space(1) @tex = #cir.undef : !cir.cuda_texture
+// CIR-DEVICE: cir.global external target_address_space(1) @tex_element = #cir.undef : !cir.cuda_texture
// CIR now matches OG CodeGen and emits undef for CUDA shadow variables.
// LLVM-DEVICE: @tex ={{.*}} addrspace(1) externally_initialized global i64 undef
+// LLVM-DEVICE: @tex_element ={{.*}} addrspace(1) externally_initialized global i64 undef
+
// OGCG-DEVICE: @tex ={{.*}} addrspace(1) externally_initialized global i64 undef
+// OGCG-DEVICE: @tex_element ={{.*}} addrspace(1) externally_initialized global i64 undef
+
+//===----------------------------------------------------------------------===//
+// Host-side checks
+//===----------------------------------------------------------------------===//
+
+// Check the CUDA texture registration runtime declaration.
+// CIR-HOST: cir.func private @__cudaRegisterTexture(!cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void>, !cir.ptr<!void>, !cir.ptr<!void>, !s32i, !s32i, !s32i)
+
+// Check texture registration metadata.
+// CIR-HOST-DAG: @tex = {{.*}}cu.var_registration = #cir.cu.var_registration<tex, Texture, texture_type = 2, normalized>
+// CIR-HOST-DAG: @tex_element = {{.*}}cu.var_registration = #cir.cu.var_registration<tex_element, Texture, texture_type = 1>
----------------
RiverDave wrote:
nit: Similar to your other checks down below, make sure you record `cir.call` for `__cudaRegisterTexture`
https://github.com/llvm/llvm-project/pull/236849
More information about the cfe-commits
mailing list