[clang] [llvm] [HLSL] Add support for user semantics (PR #153424)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 31 08:20:48 PDT 2025
================
@@ -818,6 +821,33 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
checkSemanticAnnotation(FD, D, A);
FD->addAttr(A);
+
+ unsigned Location = ActiveSemantic.Index.value_or(0);
+
+ const ConstantArrayType *AT = dyn_cast<ConstantArrayType>(D->getType());
+ unsigned ElementCount = AT ? AT->getZExtSize() : 1;
+ ActiveSemantic.Index = Location + ElementCount;
+
+ Twine BaseName = Twine(ActiveSemantic.Semantic->getAttrName()->getName());
+ for (unsigned I = 0; I < ElementCount; ++I) {
+ Twine VariableName = BaseName.concat(Twine(Location + I));
+
+ auto It = ActiveInputSemantics.find(FD);
+ if (It == ActiveInputSemantics.end()) {
+ llvm::StringSet<> Set({VariableName.str()});
+ auto Item = std::make_pair(FD, std::move(Set));
+ ActiveInputSemantics.insert(std::move(Item));
+ continue;
+ }
+
+ auto [_, Inserted] = ActiveInputSemantics[FD].insert(VariableName.str());
+ if (!Inserted) {
+ Diag(D->getLocation(), diag::err_hlsl_semantic_index_overlap)
+ << VariableName.str();
+ return false;
+ }
----------------
Keenuts wrote:
Removed the attribute
https://github.com/llvm/llvm-project/pull/153424
More information about the llvm-commits
mailing list