[llvm-branch-commits] [clang] [llvm] [HLSL] Add resource constructor with implicit binding for global resources (PR #138976)
Ashley Coleman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 12 15:49:58 PDT 2025
================
@@ -3269,27 +3285,42 @@ static bool initVarDeclWithCtor(Sema &S, VarDecl *VD,
return true;
}
-static bool initGlobalResourceDecl(Sema &S, VarDecl *VD) {
+bool SemaHLSL::initGlobalResourceDecl(VarDecl *VD) {
+ std::optional<uint32_t> RegisterSlot;
+ uint32_t SpaceNo = 0;
HLSLResourceBindingAttr *RBA = VD->getAttr<HLSLResourceBindingAttr>();
- if (!RBA || !RBA->hasRegisterSlot())
- // FIXME: add support for implicit binding (llvm/llvm-project#110722)
- return false;
+ if (RBA) {
+ if (RBA->hasRegisterSlot())
+ RegisterSlot = RBA->getSlotNumber();
+ SpaceNo = RBA->getSpaceNumber();
+ }
- ASTContext &AST = S.getASTContext();
+ ASTContext &AST = SemaRef.getASTContext();
uint64_t UIntTySize = AST.getTypeSize(AST.UnsignedIntTy);
uint64_t IntTySize = AST.getTypeSize(AST.IntTy);
- Expr *Args[] = {
- IntegerLiteral::Create(AST, llvm::APInt(UIntTySize, RBA->getSlotNumber()),
- AST.UnsignedIntTy, SourceLocation()),
- IntegerLiteral::Create(AST,
- llvm::APInt(UIntTySize, RBA->getSpaceNumber()),
- AST.UnsignedIntTy, SourceLocation()),
- IntegerLiteral::Create(AST, llvm::APInt(IntTySize, 1), AST.IntTy,
- SourceLocation()),
- IntegerLiteral::Create(AST, llvm::APInt(UIntTySize, 0), AST.UnsignedIntTy,
- SourceLocation())};
-
- return initVarDeclWithCtor(S, VD, Args);
+ IntegerLiteral *One = IntegerLiteral::Create(AST, llvm::APInt(IntTySize, 1),
+ AST.IntTy, SourceLocation());
+ IntegerLiteral *Zero = IntegerLiteral::Create(
+ AST, llvm::APInt(UIntTySize, 0), AST.UnsignedIntTy, SourceLocation());
+ IntegerLiteral *Space =
+ IntegerLiteral::Create(AST, llvm::APInt(UIntTySize, SpaceNo),
+ AST.UnsignedIntTy, SourceLocation());
+
+ // resource with explicit binding
----------------
V-FEXrt wrote:
This comment is duplicated here and 3318. Is that intentional?
https://github.com/llvm/llvm-project/pull/138976
More information about the llvm-branch-commits
mailing list