[clang] [llvm] [DirectX] Validate registers are bound to root signature (PR #146785)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 25 07:46:36 PDT 2025
================
@@ -136,6 +136,51 @@ struct OverlappingRanges {
llvm::SmallVector<OverlappingRanges>
findOverlappingRanges(llvm::SmallVector<RangeInfo> &Infos);
+class RootSignatureBindingValidation {
+private:
+ llvm::SmallVector<RangeInfo, 16> Bindings;
+ struct TypeRange {
+ uint32_t Start;
+ uint32_t End;
+ };
+ std::unordered_map<dxil::ResourceClass, TypeRange> Ranges;
+
+public:
+ void addBinding(dxil::ResourceClass Type, const RangeInfo &Binding) {
+ auto It = Ranges.find(Type);
+
+ if (It == Ranges.end()) {
+ uint32_t InsertPos = Bindings.size();
+ Bindings.push_back(Binding);
+ Ranges[Type] = {InsertPos, InsertPos + 1};
+ } else {
----------------
llvm-beanz wrote:
nit: Instead of an `else` you could have an early return to avoid nesting.
https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
https://github.com/llvm/llvm-project/pull/146785
More information about the llvm-commits
mailing list