Thanks to visit codestin.com
Credit goes to clang.llvm.org
clang
22.0.0git
include
clang
AST
HLSLResource.h
Go to the documentation of this file.
1
//===- HLSLResource.h - Routines for HLSL resources and bindings ----------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file provides shared routines to help analyze HLSL resources and
10
// theirs bindings during Sema and CodeGen.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_AST_HLSLRESOURCE_H
15
#define LLVM_CLANG_AST_HLSLRESOURCE_H
16
17
#include "
clang/AST/ASTContext.h
"
18
#include "
clang/AST/Attr.h
"
19
#include "clang/AST/Attrs.inc"
20
#include "
clang/AST/DeclBase.h
"
21
#include "
clang/Basic/TargetInfo.h
"
22
#include "
clang/Support/Compiler.h
"
23
#include "llvm/Support/raw_ostream.h"
24
25
namespace
clang
{
26
27
class
HLSLResourceBindingAttr;
28
class
HLSLRVkBindingAttr;
29
30
namespace
hlsl
{
31
32
struct
ResourceBindingAttrs
{
33
HLSLResourceBindingAttr *
RegBinding
;
34
HLSLVkBindingAttr *
VkBinding
;
35
36
ResourceBindingAttrs
(
const
Decl
*D) {
37
RegBinding
= D->
getAttr
<HLSLResourceBindingAttr>();
38
bool
IsSpirv = D->
getASTContext
().
getTargetInfo
().
getTriple
().isSPIRV();
39
VkBinding
= IsSpirv ? D->
getAttr
<HLSLVkBindingAttr>() :
nullptr
;
40
}
41
42
bool
hasBinding
()
const
{
return
RegBinding
||
VkBinding
; }
43
bool
isExplicit
()
const
{
44
return
(
RegBinding
&&
RegBinding
->hasRegisterSlot()) ||
VkBinding
;
45
}
46
47
unsigned
getSlot
()
const
{
48
assert(
isExplicit
() &&
"no explicit binding"
);
49
if
(
VkBinding
)
50
return
VkBinding
->getBinding();
51
if
(
RegBinding
&&
RegBinding
->hasRegisterSlot())
52
return
RegBinding
->getSlotNumber();
53
llvm_unreachable(
"no explicit binding"
);
54
}
55
56
unsigned
getSpace
()
const
{
57
if
(
VkBinding
)
58
return
VkBinding
->getSet();
59
if
(
RegBinding
)
60
return
RegBinding
->getSpaceNumber();
61
return
0;
62
}
63
64
bool
hasImplicitOrderID
()
const
{
65
return
RegBinding
&&
RegBinding
->hasImplicitBindingOrderID();
66
}
67
68
unsigned
getImplicitOrderID
()
const
{
69
assert(
hasImplicitOrderID
());
70
return
RegBinding
->getImplicitBindingOrderID();
71
}
72
};
73
74
}
// namespace hlsl
75
76
}
// namespace clang
77
78
#endif
// LLVM_CLANG_AST_HLSLRESOURCE_H
ASTContext.h
Defines the clang::ASTContext interface.
Attr.h
DeclBase.h
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition
ASTContext.h:891
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition
DeclBase.h:86
clang::Decl::getAttr
T * getAttr() const
Definition
DeclBase.h:573
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition
DeclBase.cpp:524
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition
TargetInfo.h:1292
TargetInfo.h
Defines the clang::TargetInfo interface.
Compiler.h
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
hlsl
Definition
hlsl_alias_intrinsics.h:12
clang::hlsl::ResourceBindingAttrs::isExplicit
bool isExplicit() const
Definition
HLSLResource.h:43
clang::hlsl::ResourceBindingAttrs::getImplicitOrderID
unsigned getImplicitOrderID() const
Definition
HLSLResource.h:68
clang::hlsl::ResourceBindingAttrs::getSpace
unsigned getSpace() const
Definition
HLSLResource.h:56
clang::hlsl::ResourceBindingAttrs::VkBinding
HLSLVkBindingAttr * VkBinding
Definition
HLSLResource.h:34
clang::hlsl::ResourceBindingAttrs::hasBinding
bool hasBinding() const
Definition
HLSLResource.h:42
clang::hlsl::ResourceBindingAttrs::ResourceBindingAttrs
ResourceBindingAttrs(const Decl *D)
Definition
HLSLResource.h:36
clang::hlsl::ResourceBindingAttrs::hasImplicitOrderID
bool hasImplicitOrderID() const
Definition
HLSLResource.h:64
clang::hlsl::ResourceBindingAttrs::getSlot
unsigned getSlot() const
Definition
HLSLResource.h:47
clang::hlsl::ResourceBindingAttrs::RegBinding
HLSLResourceBindingAttr * RegBinding
Definition
HLSLResource.h:33
Generated on
for clang by
1.14.0