LLVM: lib/Frontend/HLSL/HLSLBinding.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
11
12using namespace llvm;
13using namespace hlsl;
14
15std::optional<uint32_t>
17 int32_t Size) {
20 return RS.findAvailableBinding(Size);
21}
22
25 for (auto It = Spaces.begin(), End = Spaces.end(); It != End; ++It) {
26 if (It->Space == Space)
27 return *It;
28 if (It->Space < Space)
29 continue;
30 return *Spaces.insert(It, Space);
31 }
32 return Spaces.emplace_back(Space);
33}
34
35std::optional<uint32_t>
38
40 return std::nullopt;
41
42
43 if (Size == -1) {
45 if (Last.UpperBound != ~0u)
46
47 return std::nullopt;
50 return RegSlot;
51 }
52
53
55
57 continue;
58 uint32_t RegSlot = R.LowerBound;
59
60
61
62 R.LowerBound += Size;
63 return RegSlot;
64 }
65
66 return std::nullopt;
67}
68
71 const Binding &Overlapping)>
72 ReportOverlap) {
73
75
76
78 if (NewEnd != Bindings.end())
79 Bindings.erase(NewEnd, Bindings.end());
80
82
83
84
85
88 for (const Binding &B : Bindings) {
90
91 BS = &Info.getBindingSpaces(B.RC);
92
94 ? &BS->Spaces.emplace_back(B.Space)
96 assert(S->Space <= B.Space && "bindings not sorted correctly?");
98
99 S = &BS->Spaces.emplace_back(B.Space);
100
101
102
103
105 ReportOverlap(*this, B);
106 continue;
107 }
108
110 if (LastFreeRange.LowerBound == B.LowerBound) {
111 if (B.UpperBound < ~0u)
112 LastFreeRange.LowerBound = B.UpperBound + 1;
113 else
115 } else if (LastFreeRange.LowerBound < B.LowerBound) {
116 LastFreeRange.UpperBound = B.LowerBound - 1;
117 if (B.UpperBound < ~0u)
118 S->FreeRanges.emplace_back(B.UpperBound + 1, ~0u);
119 } else {
120
121
122 ReportOverlap(*this, B);
123 if (B.UpperBound < ~0u)
125 std::max(LastFreeRange.LowerBound, B.UpperBound + 1);
126 else
128 }
129 }
130
131 return Info;
132}
133
140
141 llvm_unreachable("Searching for overlap for binding that does not overlap");
142}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
An efficient, type-erasing, non-owning reference to a callable.
Builder class for creating a /c BindingInfo.
LLVM_ABI const Binding & findOverlapping(const Binding &ReportedBinding) const
For use in the ReportOverlap callback of calculateBindingInfo - finds a binding that the ReportedBind...
Definition HLSLBinding.cpp:135
LLVM_ABI BindingInfo calculateBindingInfo(llvm::function_ref< void(const BindingInfoBuilder &Builder, const Binding &Overlapping)> ReportOverlap)
Calculate the binding info - ReportOverlap will be called once for each overlapping binding.
Definition HLSLBinding.cpp:69
BindingInfo represents the ranges of bindings and free space for each dxil::ResourceClass.
LLVM_ABI std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)
Definition HLSLBinding.cpp:16
BindingSpaces & getBindingSpaces(dxil::ResourceClass RC)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
auto unique(Range &&R, Predicate P)
LLVM_ABI RegisterSpace & getOrInsertSpace(uint32_t Space)
Definition HLSLBinding.cpp:24
llvm::SmallVector< RegisterSpace > Spaces
SmallVector< BindingRange > FreeRanges
LLVM_ABI std::optional< uint32_t > findAvailableBinding(int32_t Size)
Definition HLSLBinding.cpp:36