[clang] [llvm] [HLSL] Add SPIR-V target type for StructuredBuffers (PR #132027)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 21 08:08:14 PDT 2025


================
@@ -386,13 +386,29 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
     if (ContainedTy.isNull())
       return nullptr;
 
-    assert(!ResAttrs.RawBuffer &&
-           "Raw buffers handles are not implemented for SPIR-V yet");
     assert(!ResAttrs.IsROV &&
            "Rasterizer order views not implemented for SPIR-V yet");
 
-    // convert element type
     llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
+    if (ResAttrs.RawBuffer) {
+      // TODO: Handle types with layout information.
+      assert((ElemType->isIntegerTy() || ElemType->isFloatingPointTy() ||
+              ElemType->isVectorTy()) &&
+             "The element type for a SPIR-V resource must be a types that does "
+             "not require layout information.");
+      llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
+
+      uint32_t StorageClass = /* StorageBuffer storage class */ 12;
----------------
Keenuts wrote:

There is `SPIRV::StorageClass::StorageBuffer` defined, and the TD files has the value 12 associated, so might be a way to extract the int from this enum

https://github.com/llvm/llvm-project/pull/132027


More information about the llvm-commits mailing list