================ @@ -295,6 +297,105 @@ getRootSignature(RootSignatureBindingInfo &RSBI, return RootSigDesc; } +static void +reportOverlappingRegisters(Module &M, + llvm::hlsl::rootsig::OverlappingRanges Overlap) { + const llvm::hlsl::rootsig::RangeInfo *Info = Overlap.A; + const llvm::hlsl::rootsig::RangeInfo *OInfo = Overlap.B; + SmallString<128> Message; + raw_svector_ostream OS(Message); + OS << "register " << ResourceClassToString(Info->Class) + << " (space=" << Info->Space << ", register=" << Info->LowerBound << ")" + << " is overlapping with" + << " register " << ResourceClassToString(OInfo->Class) + << " (space=" << OInfo->Space << ", register=" << OInfo->LowerBound << ")" + << ", verify your root signature definition."; + + M.getContext().diagnose(DiagnosticInfoGeneric(Message)); +} + +static bool reportOverlappingRanges(Module &M, + const mcdxbc::RootSignatureDesc &RSD) { + using namespace llvm::hlsl::rootsig; + + llvm::SmallVector<RangeInfo> Infos; + + for (size_t I = 0; I < RSD.ParametersContainer.size(); I++) { + const auto &[Type, Loc] = + RSD.ParametersContainer.getTypeAndLocForParameter(I); + const auto &Header = RSD.ParametersContainer.getHeader(I); + switch (Type) { + case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): { ---------------- llvm-beanz wrote:
Rather than using `llvm::to_underlying` if you convert the int to the enum early (and handle the case where it doesn't match), the compiler will make sure you have full switch coverage. That's definitely the better pattern to use for cases like this. https://github.com/llvm/llvm-project/pull/148919 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits