================ @@ -3228,6 +3228,62 @@ static QualType builtinCommonTypeImpl(Sema &S, TemplateName BaseTemplate, } } +static bool isInVkNamespace(const RecordType *RT) { + DeclContext *DC = RT->getDecl()->getDeclContext(); + if (!DC) + return false; + + NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC); + if (!ND) + return false; + + return ND->getQualifiedNameAsString() == "hlsl::vk"; +} + +static SpirvOperand checkHLSLSpirvTypeOperand(Sema &SemaRef, + QualType OperandArg, + SourceLocation Loc) { + if (auto *RT = OperandArg->getAs<RecordType>()) { + bool Literal = false; + SourceLocation LiteralLoc; + if (isInVkNamespace(RT) && RT->getDecl()->getName() == "Literal") { + auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl()); + assert(SpecDecl); + + const TemplateArgumentList &LiteralArgs = SpecDecl->getTemplateArgs(); + QualType ConstantType = LiteralArgs[0].getAsType(); + RT = ConstantType->getAs<RecordType>(); + Literal = true; + LiteralLoc = SpecDecl->getSourceRange().getBegin(); + } + + if (RT && isInVkNamespace(RT) && + RT->getDecl()->getName() == "integral_constant") { + auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl()); + assert(SpecDecl); + + const TemplateArgumentList &ConstantArgs = SpecDecl->getTemplateArgs(); + + QualType ConstantType = ConstantArgs[0].getAsType(); + llvm::APInt Value = ConstantArgs[1].getAsIntegral(); + + if (Literal) { + return SpirvOperand::createLiteral(Value); + } else { + return SpirvOperand::createConstant(ConstantType, Value); + } ---------------- llvm-beanz wrote:
nit: [braces](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements) & [else](https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return) ```suggestion if (Literal) return SpirvOperand::createLiteral(Value); return SpirvOperand::createConstant(ConstantType, Value); ``` https://github.com/llvm/llvm-project/pull/134034 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits