[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 21 15:27:41 PDT 2025
================
@@ -3332,6 +3388,39 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD,
}
return HasNoTypeMember;
}
+
+ case BTK__hlsl_spirv_type: {
+ assert(Converted.size() == 4);
+
+ if (!Context.getTargetInfo().getTriple().isSPIRV()) {
+ SemaRef.Diag(TemplateLoc, diag::err_hlsl_spirv_only)
+ << "__hlsl_spirv_type";
+ }
+
+ if (llvm::any_of(Converted, [](auto &C) { return C.isDependent(); }))
+ return Context.getCanonicalTemplateSpecializationType(TemplateName(BTD),
+ Converted);
+
+ uint64_t Opcode = Converted[0].getAsIntegral().getZExtValue();
+ uint64_t Size = Converted[1].getAsIntegral().getZExtValue();
+ uint64_t Alignment = Converted[2].getAsIntegral().getZExtValue();
+
+ ArrayRef<TemplateArgument> OperandArgs = Converted[3].getPackAsArray();
+
+ llvm::SmallVector<SpirvOperand> Operands;
+
+ for (auto &OperandTA : OperandArgs) {
+ QualType OperandArg = OperandTA.getAsType();
+ auto Operand = checkHLSLSpirvTypeOperand(SemaRef, OperandArg,
+ TemplateArgs[3].getLocation());
+ if (!Operand.isValid()) {
+ return QualType();
+ }
----------------
llvm-beanz wrote:
nit: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
```suggestion
if (!Operand.isValid())
return QualType();
```
https://github.com/llvm/llvm-project/pull/134034
More information about the cfe-commits
mailing list