[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

Cassandra Beckley via cfe-commits cfe-commits at lists.llvm.org
Tue May 6 16:37:49 PDT 2025


================
@@ -5444,6 +5459,31 @@ QualType ASTContext::getHLSLAttributedResourceType(
 
   return QualType(Ty, 0);
 }
+
+QualType ASTContext::getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
+                                            uint32_t Alignment,
+                                            ArrayRef<SpirvOperand> Operands) {
+  llvm::FoldingSetNodeID ID;
+  HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
+
+  void *InsertPos = nullptr;
+  HLSLInlineSpirvType *Ty =
+      HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
+  if (Ty)
+    return QualType(Ty, 0);
+
+  unsigned size = sizeof(HLSLInlineSpirvType);
+  size += Operands.size() * sizeof(SpirvOperand);
+  void *mem = Allocate(size, alignof(HLSLInlineSpirvType));
+
+  Ty = new (mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
----------------
cassiebeckley wrote:

Done.

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


More information about the cfe-commits mailing list