@@ -59,7 +59,6 @@ class BindingInfo {
5959 }
6060 // Size == -1 means unbounded array
6161 LLVM_ABI std::optional<uint32_t > findAvailableBinding (int32_t Size);
62- LLVM_ABI bool isBound (const BindingRange &Range) const ;
6362
6463 bool operator ==(const RegisterSpace &Other) const {
6564 return Space == Other.Space ;
@@ -103,94 +102,90 @@ class BindingInfo {
103102 // Size == -1 means unbounded array
104103 LLVM_ABI std::optional<uint32_t >
105104 findAvailableBinding (dxil::ResourceClass RC, uint32_t Space, int32_t Size);
106-
107- LLVM_ABI bool isBound (dxil::ResourceClass RC, uint32_t Space,
108- const BindingRange &Range) const ;
109-
110105 friend class BindingInfoBuilder ;
111106};
112- struct Binding {
113- dxil::ResourceClass RC;
114- uint32_t Space;
115- uint32_t LowerBound;
116- uint32_t UpperBound;
117- const void *Cookie;
118-
119- Binding (dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
120- uint32_t UpperBound, const void *Cookie)
121- : RC(RC), Space(Space), LowerBound(LowerBound), UpperBound(UpperBound),
122- Cookie (Cookie) {}
107+ struct Binding {
108+ dxil::ResourceClass RC;
109+ uint32_t Space;
110+ uint32_t LowerBound;
111+ uint32_t UpperBound;
112+ const void *Cookie;
113+
114+ Binding (dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
115+ uint32_t UpperBound, const void *Cookie)
116+ : RC(RC), Space(Space), LowerBound(LowerBound), UpperBound(UpperBound),
117+ Cookie (Cookie) {}
118+
119+ bool isUnbounded () const { return UpperBound == ~0U ; }
120+
121+ bool operator ==(const Binding &RHS) const {
122+ return std::tie (RC, Space, LowerBound, UpperBound, Cookie) ==
123+ std::tie (RHS.RC , RHS.Space , RHS.LowerBound , RHS.UpperBound ,
124+ RHS.Cookie );
125+ }
126+ bool operator !=(const Binding &RHS) const { return !(*this == RHS); }
123127
124- bool isUnbounded () const { return UpperBound == ~0U ; }
128+ bool operator <(const Binding &RHS) const {
129+ return std::tie (RC, Space, LowerBound) <
130+ std::tie (RHS.RC , RHS.Space , RHS.LowerBound );
131+ }
132+ };
133+ class BoundRegs {
134+ SmallVector<Binding> Bindings;
125135
126- bool operator ==(const Binding &RHS) const {
127- return std::tie (RC, Space, LowerBound, UpperBound, Cookie) ==
128- std::tie (RHS.RC , RHS.Space , RHS.LowerBound , RHS.UpperBound ,
129- RHS.Cookie );
130- }
131- bool operator !=(const Binding &RHS) const { return !(*this == RHS); }
136+ public:
137+ BoundRegs (SmallVector<Binding> &&Bindings)
138+ : Bindings(std::move(Bindings)) {}
139+
140+ bool isBound (dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
141+ uint32_t UpperBound) const {
142+ const Binding *It = llvm::upper_bound (
143+ Bindings, Binding{RC, Space, LowerBound, 0 , nullptr });
144+ if (It == Bindings.begin ())
145+ return false ;
146+ --It;
147+ return It->RC == RC && It->Space == Space &&
148+ It->LowerBound <= LowerBound && It->UpperBound >= UpperBound;
149+ }
150+ };
132151
133- bool operator <(const Binding &RHS) const {
134- return std::tie (RC, Space, LowerBound) <
135- std::tie (RHS.RC , RHS.Space , RHS.LowerBound );
136- }
137- };
138- class BoundRegs {
139- SmallVector<Binding> Bindings;
140-
141- public:
142- BoundRegs (SmallVector<Binding> &&Bindings)
143- : Bindings(std::move(Bindings)) {}
144-
145- bool isBound (dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
146- uint32_t UpperBound) const {
147- const Binding *It = llvm::upper_bound (
148- Bindings, Binding{RC, Space, LowerBound, 0 , nullptr });
149- if (It == Bindings.begin ())
150- return false ;
151- --It;
152- return It->RC == RC && It->Space == Space &&
153- It->LowerBound <= LowerBound && It->UpperBound >= UpperBound;
154- }
155- };
152+ // / Builder class for creating a /c BindingInfo.
153+ class BindingInfoBuilder {
154+ public:
155+ private:
156+ SmallVector<Binding> Bindings;
156157
157- // / Builder class for creating a /c BindingInfo.
158- class BindingInfoBuilder {
159- public:
160- private:
161- SmallVector<Binding> Bindings;
162-
163- public:
164- void trackBinding (dxil::ResourceClass RC, uint32_t Space,
165- uint32_t LowerBound, uint32_t UpperBound,
166- const void *Cookie) {
167- Bindings.emplace_back (RC, Space, LowerBound, UpperBound, Cookie);
168- }
169- // / Calculate the binding info - \c ReportOverlap will be called once for
170- // / each overlapping binding.
171- LLVM_ABI BindingInfo calculateBindingInfo (
172- llvm::function_ref<void (const BindingInfoBuilder &Builder,
173- const Binding &Overlapping)>
174- ReportOverlap);
175-
176- // / Calculate the binding info - \c HasOverlap will be set to indicate
177- // / whether there are any overlapping bindings.
178- BindingInfo calculateBindingInfo (bool &HasOverlap) {
179- HasOverlap = false ;
180- return calculateBindingInfo (
181- [&HasOverlap](auto , auto ) { HasOverlap = true ; });
182- }
158+ public:
159+ void trackBinding (dxil::ResourceClass RC, uint32_t Space,
160+ uint32_t LowerBound, uint32_t UpperBound,
161+ const void *Cookie) {
162+ Bindings.emplace_back (RC, Space, LowerBound, UpperBound, Cookie);
163+ }
164+ // / Calculate the binding info - \c ReportOverlap will be called once for
165+ // / each overlapping binding.
166+ LLVM_ABI BindingInfo calculateBindingInfo (
167+ llvm::function_ref<void (const BindingInfoBuilder &Builder,
168+ const Binding &Overlapping)>
169+ ReportOverlap);
170+
171+ // / Calculate the binding info - \c HasOverlap will be set to indicate
172+ // / whether there are any overlapping bindings.
173+ BindingInfo calculateBindingInfo (bool &HasOverlap) {
174+ HasOverlap = false ;
175+ return calculateBindingInfo (
176+ [&HasOverlap](auto , auto ) { HasOverlap = true ; });
177+ }
183178
184- BoundRegs calculateBoundRegs (
185- llvm::function_ref<void (const BindingInfoBuilder &Builder,
186- const Binding &Overlapping)>
187- ReportOverlap);
179+ BoundRegs calculateBoundRegs (
180+ llvm::function_ref<void (const BindingInfoBuilder &Builder,
181+ const Binding &Overlapping)>
182+ ReportOverlap);
188183
189- // / For use in the \c ReportOverlap callback of \c calculateBindingInfo -
190- // / finds a binding that the \c ReportedBinding overlaps with.
191- LLVM_ABI const Binding &
192- findOverlapping (const Binding &ReportedBinding) const ;
193- };
184+ // / For use in the \c ReportOverlap callback of \c calculateBindingInfo -
185+ // / finds a binding that the \c ReportedBinding overlaps with.
186+ LLVM_ABI const Binding &
187+ findOverlapping (const Binding &ReportedBinding) const ;
188+ };
194189
195190} // namespace hlsl
196191} // namespace llvm
0 commit comments