// SPDX-License-Identifier: GPL-3.0-or-later #include "rcc/CodeGen/InstructionDescriptor.h" #include "rcc/CodeGen/MachineInstr.h" #include "rcc/CodeGen/MachineMemOperand.h" #include "rcc/CodeGen/MachineRegisterInfo.h" #include #include #include #include #include #include #include namespace rcc { namespace { [[nodiscard]] bool isRegisterOnly(const OperandKindSet &Kinds) noexcept { OperandKindSet RegisterKind{MachineOperand::Kind::Register}; return Kinds == RegisterKind; } [[nodiscard]] bool isDefRole(RegisterOperandRole Role) noexcept { return Role == RegisterOperandRole::Def || Role == RegisterOperandRole::DefUse; } [[nodiscard]] bool isUseRole(RegisterOperandRole Role) noexcept { return Role == RegisterOperandRole::Use || Role == RegisterOperandRole::DefUse; } [[nodiscard]] bool formsDefUsePair(RegisterOperandRole Left, RegisterOperandRole Right) noexcept { return (Left == RegisterOperandRole::Def && Right == RegisterOperandRole::Use) || (Left == RegisterOperandRole::Use && Right == RegisterOperandRole::Def); } [[nodiscard]] bool isPureDef(const MachineOperand &Operand) noexcept { return Operand.isRegister() && Operand.isDef() && !Operand.isUse(); } [[nodiscard]] bool isPureUse(const MachineOperand &Operand) noexcept { return Operand.isRegister() && Operand.isUse() && !Operand.isDef(); } [[nodiscard]] Expected validateDescriptorStructure(const InstructionDescriptor &Descriptor) { if (!Descriptor.InstructionOpcode.isValid()) return makeUnexpected(ErrorCode::InvalidArgument, "instruction descriptor opcode is invalid"); if (Descriptor.Name.empty()) return makeUnexpected(ErrorCode::InvalidArgument, "instruction descriptor name is empty"); if (Descriptor.NumExplicitDefs > Descriptor.Operands.size()) { return makeUnexpected(ErrorCode::InvalidArgument, "instruction descriptor explicit def count is out of range"); } bool SawOptional = false; for (std::size_t Index = 0; Index < Descriptor.Operands.size(); ++Index) { const OperandDescriptor &Operand = Descriptor.Operands[Index]; if (Operand.Kinds.empty()) { return makeUnexpected(ErrorCode::InvalidArgument, "operand descriptor must accept at least one operand kind"); } const bool IsRegister = Operand.Kinds.contains(MachineOperand::Kind::Register); if (IsRegister != (Operand.RegisterRole != RegisterOperandRole::None)) { return makeUnexpected(ErrorCode::InvalidArgument, "register-capable operand descriptor must declare a register role"); } if (isDefRole(Operand.RegisterRole) && !isRegisterOnly(Operand.Kinds)) { return makeUnexpected(ErrorCode::InvalidArgument, "register definition descriptor must accept only registers"); } if (!IsRegister && (Operand.RegClass || Operand.RegBank || Operand.EarlyClobber || Operand.AllowSubReg)) { return makeUnexpected(ErrorCode::InvalidArgument, "non-register operand descriptor has register constraints"); } if (Operand.EarlyClobber && !isDefRole(Operand.RegisterRole)) { return makeUnexpected(ErrorCode::InvalidArgument, "early-clobber operand descriptor must define a register"); } if (Index < Descriptor.NumExplicitDefs && !isDefRole(Operand.RegisterRole)) { return makeUnexpected(ErrorCode::InvalidArgument, "canonical explicit defs must precede instruction uses"); } if (Index >= Descriptor.NumExplicitDefs && isDefRole(Operand.RegisterRole)) { return makeUnexpected(ErrorCode::InvalidArgument, "register definition appears after the explicit def prefix"); } if (Descriptor.Variadic && Operand.Optional) { return makeUnexpected(ErrorCode::InvalidArgument, "variadic instruction descriptor cannot contain optional operands"); } if (Operand.Optional) SawOptional = true; else if (SawOptional && !Operand.VariadicGroup) { return makeUnexpected(ErrorCode::InvalidArgument, "optional operand descriptors must form a trailing suffix"); } if (Operand.VariadicGroup && (!Descriptor.Variadic || Index + 1 != Descriptor.Operands.size())) { return makeUnexpected(ErrorCode::InvalidArgument, "variadic operand group must be the final descriptor"); } if (Operand.VariadicGroup && (Operand.Optional || Operand.DefaultTiedOperand)) { return makeUnexpected(ErrorCode::InvalidArgument, "variadic operand descriptor cannot be optional or have a default tie"); } } if (Descriptor.Variadic && (Descriptor.Operands.empty() || !Descriptor.Operands.back().VariadicGroup)) { return makeUnexpected(ErrorCode::InvalidArgument, "variadic instruction descriptor requires a final variadic group"); } if (!Descriptor.Variadic && std::ranges::any_of(Descriptor.Operands, [](const OperandDescriptor &Operand) { return Operand.VariadicGroup; })) { return makeUnexpected(ErrorCode::InvalidArgument, "non-variadic instruction descriptor has a variadic group"); } for (std::size_t Index = 0; Index < Descriptor.Operands.size(); ++Index) { const OperandDescriptor &Operand = Descriptor.Operands[Index]; if (!Operand.DefaultTiedOperand) continue; const std::size_t OtherIndex = *Operand.DefaultTiedOperand; if (OtherIndex >= Descriptor.Operands.size() || OtherIndex == Index || Descriptor.Operands[OtherIndex].DefaultTiedOperand != Index) { return makeUnexpected(ErrorCode::InvalidArgument, "default operand tie must be reciprocal and in range"); } if (Operand.Optional || Descriptor.Operands[OtherIndex].Optional || !isRegisterOnly(Operand.Kinds) || !isRegisterOnly(Descriptor.Operands[OtherIndex].Kinds) || !formsDefUsePair(Operand.RegisterRole, Descriptor.Operands[OtherIndex].RegisterRole)) { return makeUnexpected(ErrorCode::InvalidArgument, "default operand tie must connect required register def and use"); } } std::unordered_set OperandNames; for (const OperandDescriptor &Operand : Descriptor.Operands) { if (Operand.Name && !OperandNames.insert(*Operand.Name).second) { return makeUnexpected(ErrorCode::InvalidArgument, "instruction descriptor has duplicate named operands"); } } std::unordered_set ImplicitDefs; for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitDefs) { if (!Implicit.Reg.isValid() || !ImplicitDefs.insert(Implicit.Reg).second) { return makeUnexpected(ErrorCode::InvalidArgument, "implicit definitions must name unique physical registers"); } } std::unordered_set ImplicitUses; for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitUses) { if (!Implicit.Reg.isValid() || Implicit.EarlyClobber || !ImplicitUses.insert(Implicit.Reg).second) { return makeUnexpected(ErrorCode::InvalidArgument, "implicit uses must name unique physical registers and cannot " "early-clobber"); } } const bool IsBranch = Descriptor.Flags.has(InstructionFlag::Branch); const bool IsTerminator = Descriptor.Flags.has(InstructionFlag::Terminator); if ((IsBranch || Descriptor.Flags.has(InstructionFlag::Return) || Descriptor.Flags.has(InstructionFlag::Barrier) || Descriptor.Flags.has(InstructionFlag::IndirectBranch)) && !IsTerminator) { return makeUnexpected(ErrorCode::InvalidArgument, "branch, return, and barrier descriptors must be terminators"); } if (Descriptor.Flags.has(InstructionFlag::IndirectBranch) && !IsBranch) { return makeUnexpected(ErrorCode::InvalidArgument, "indirect branch descriptor must also be a branch"); } const bool IsPseudo = Descriptor.Flags.has(InstructionFlag::Pseudo); const bool IsMeta = Descriptor.Flags.has(InstructionFlag::Meta); if (IsMeta && (!IsPseudo || Descriptor.Flags.has(InstructionFlag::ProducesCode))) { return makeUnexpected(ErrorCode::InvalidArgument, "meta instruction must be a non-emitting pseudo"); } if (!IsPseudo && Descriptor.Owner != PseudoOwner::None) { return makeUnexpected(ErrorCode::InvalidArgument, "non-pseudo instruction cannot have a pseudo owner"); } if (IsPseudo && !IsMeta && Descriptor.Owner == PseudoOwner::None) { return makeUnexpected(ErrorCode::InvalidArgument, "executable pseudo must declare its expansion owner"); } if (Descriptor.Flags.has(InstructionFlag::TerminalEmission) && (!IsPseudo || Descriptor.Owner != PseudoOwner::AsmPrinter || !Descriptor.Flags.has(InstructionFlag::ProducesCode))) { return makeUnexpected(ErrorCode::InvalidArgument, "terminal emission pseudo must produce code and be owned by AsmPrinter"); } if (Descriptor.RequiresMemoryOperands && !Descriptor.Flags.has(InstructionFlag::MayLoad) && !Descriptor.Flags.has(InstructionFlag::MayStore)) { return makeUnexpected(ErrorCode::InvalidArgument, "MMO requirement needs mayLoad or mayStore"); } return {}; } [[nodiscard]] const OperandDescriptor &descriptorForOperand(const InstructionDescriptor &Descriptor, std::size_t Index) { if (Index < Descriptor.Operands.size()) return Descriptor.Operands[Index]; return Descriptor.Operands.back(); } } // namespace OperandKindSet::OperandKindSet(std::initializer_list Kinds) noexcept { for (const MachineOperand::Kind Kind : Kinds) add(Kind); } InstructionFlags::InstructionFlags(std::initializer_list Flags) noexcept { for (const InstructionFlag Flag : Flags) set(Flag); } Expected InstructionSet::create(std::vector Descriptors, std::vector ImmediatePredicates) { if (Descriptors.empty()) { return makeUnexpected(ErrorCode::InvalidArgument, "instruction set requires at least one descriptor"); } InstructionSet Result(std::move(Descriptors), std::move(ImmediatePredicates)); std::unordered_set PredicateNames; for (std::size_t Index = 0; Index < Result.ImmediatePredicates.size(); ++Index) { const ImmediatePredicate &Predicate = Result.ImmediatePredicates[Index]; if (Predicate.Name.empty() || !Predicate.Predicate) { return makeUnexpected(ErrorCode::InvalidArgument, "immediate predicate requires a name and callable"); } if (!Result.PredicateToIndex.emplace(Predicate.ID, Index).second) { return makeUnexpected(ErrorCode::InvalidArgument, "duplicate immediate predicate ID"); } if (!PredicateNames.insert(Predicate.Name).second) { return makeUnexpected(ErrorCode::InvalidArgument, "duplicate immediate predicate name"); } } for (std::size_t Index = 0; Index < Result.Descriptors.size(); ++Index) { const InstructionDescriptor &Descriptor = Result.Descriptors[Index]; const auto Validation = validateDescriptorStructure(Descriptor); if (!Validation) return std::unexpected(Validation.error()); if (!Result.OpcodeToIndex.emplace(Descriptor.InstructionOpcode, Index).second) return makeUnexpected(ErrorCode::InvalidArgument, "duplicate instruction opcode"); if (!Result.NameToIndex.emplace(Descriptor.Name, Index).second) return makeUnexpected(ErrorCode::InvalidArgument, "duplicate instruction name"); for (const OperandDescriptor &Operand : Descriptor.Operands) { if (Operand.ImmediatePredicate && Result.immediatePredicate(*Operand.ImmediatePredicate) == nullptr) { return makeUnexpected(ErrorCode::InvalidArgument, "operand descriptor references an unknown immediate predicate"); } } } return Result; } const InstructionDescriptor *InstructionSet::descriptor(Opcode InstructionOpcode) const noexcept { const auto Position = OpcodeToIndex.find(InstructionOpcode); if (Position == OpcodeToIndex.end()) return nullptr; return &Descriptors[Position->second]; } const InstructionDescriptor *InstructionSet::descriptor(std::string_view Name) const noexcept { const auto Position = NameToIndex.find(std::string(Name)); if (Position == NameToIndex.end()) return nullptr; return &Descriptors[Position->second]; } Expected InstructionSet::validateExplicitOperands(const InstructionDescriptor &Descriptor, std::span Operands, const MachineRegisterInfo &RegInfo) const { std::size_t RequiredCount = Descriptor.Operands.size(); if (Descriptor.Variadic) --RequiredCount; else { while (RequiredCount != 0 && Descriptor.Operands[RequiredCount - 1].Optional) --RequiredCount; } if (Operands.size() < RequiredCount || (!Descriptor.Variadic && Operands.size() > Descriptor.Operands.size())) { return makeUnexpected(ErrorCode::VerificationError, "instruction has an invalid explicit operand count"); } for (std::size_t Index = 0; Index < Operands.size(); ++Index) { const MachineOperand &Operand = Operands[Index]; if (Operand.isImplicit()) { return makeUnexpected(ErrorCode::VerificationError, "explicit operand sequence contains an implicit register"); } const auto Validation = validateOperand(descriptorForOperand(Descriptor, Index), Operand, RegInfo); if (!Validation) return std::unexpected(Validation.error()); } return {}; } Expected InstructionSet::validateExplicitOperands(Opcode InstructionOpcode, std::span Operands, const MachineRegisterInfo &RegInfo) const { const InstructionDescriptor *Descriptor = descriptor(InstructionOpcode); if (Descriptor == nullptr) { return makeUnexpected(ErrorCode::VerificationError, "instruction opcode is not registered"); } return validateExplicitOperands(*Descriptor, Operands, RegInfo); } Expected InstructionSet::validateOperandTies(const InstructionDescriptor &Descriptor, std::span ExplicitOperands, std::span Ties) const { std::vector> Partners(ExplicitOperands.size()); for (const MachineOperandTie Tie : Ties) { if (Tie.DefOperand >= ExplicitOperands.size() || Tie.UseOperand >= ExplicitOperands.size() || Tie.DefOperand == Tie.UseOperand || !isPureDef(ExplicitOperands[Tie.DefOperand]) || !isPureUse(ExplicitOperands[Tie.UseOperand])) { return makeUnexpected(ErrorCode::VerificationError, "instruction tie must connect an in-range pure register def and use"); } if (Partners[Tie.DefOperand] || Partners[Tie.UseOperand]) { return makeUnexpected(ErrorCode::VerificationError, "instruction operand participates in duplicate or conflicting ties"); } Partners[Tie.DefOperand] = Tie.UseOperand; Partners[Tie.UseOperand] = Tie.DefOperand; } for (std::size_t Index = 0; Index < Descriptor.Operands.size(); ++Index) { const OperandDescriptor &Operand = Descriptor.Operands[Index]; if (Operand.DefaultTiedOperand && (Index >= Partners.size() || Partners[Index] != Operand.DefaultTiedOperand)) { return makeUnexpected(ErrorCode::VerificationError, "required descriptor tie is not materialized"); } } return {}; } Expected InstructionSet::validateOperandTies(Opcode InstructionOpcode, std::span ExplicitOperands, std::span Ties) const { const InstructionDescriptor *Descriptor = descriptor(InstructionOpcode); if (Descriptor == nullptr) { return makeUnexpected(ErrorCode::VerificationError, "instruction opcode is not registered"); } return validateOperandTies(*Descriptor, ExplicitOperands, Ties); } Expected InstructionSet::validateImplicitOperands( const InstructionDescriptor &Descriptor, std::span ImplicitOperands) const { const std::size_t DefaultCount = Descriptor.ImplicitDefs.size() + Descriptor.ImplicitUses.size(); if (ImplicitOperands.size() < DefaultCount || (!Descriptor.AllowExtraImplicitOperands && ImplicitOperands.size() != DefaultCount)) { return makeUnexpected(ErrorCode::VerificationError, "instruction implicit operand count does not match its descriptor"); } std::size_t Index = 0; auto ValidateDefault = [&](const ImplicitRegisterDescriptor &Implicit, bool IsDef) -> Expected { const MachineOperand *Operand = ImplicitOperands[Index++]; const Register *Reg = Operand == nullptr ? nullptr : Operand->getIf(); if (Reg == nullptr || Reg->physicalRegister() != Implicit.Reg || Operand->isDef() != IsDef || Operand->isUse() == IsDef || !Operand->isImplicit() || Operand->registerFlags().has(RegisterOperandFlag::EarlyClobber) != Implicit.EarlyClobber || Operand->registerFlags().has(RegisterOperandFlag::Renamable) != Implicit.Renamable) { return makeUnexpected(ErrorCode::VerificationError, "default implicit register operand does not match its descriptor"); } return {}; }; for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitDefs) { auto Validation = ValidateDefault(Implicit, true); if (!Validation) return std::unexpected(Validation.error()); } for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitUses) { auto Validation = ValidateDefault(Implicit, false); if (!Validation) return std::unexpected(Validation.error()); } for (; Index < ImplicitOperands.size(); ++Index) { const MachineOperand *Operand = ImplicitOperands[Index]; if (Operand == nullptr || !Operand->isRegister() || !Operand->isImplicit()) { return makeUnexpected(ErrorCode::VerificationError, "dynamic implicit operand must be an implicit register"); } } return {}; } Expected InstructionSet::validateImplicitOperands( Opcode InstructionOpcode, std::span ImplicitOperands) const { const InstructionDescriptor *Descriptor = descriptor(InstructionOpcode); if (Descriptor == nullptr) { return makeUnexpected(ErrorCode::VerificationError, "instruction opcode is not registered"); } return validateImplicitOperands(*Descriptor, ImplicitOperands); } Expected InstructionSet::validateMemOperands(const InstructionDescriptor &Descriptor, std::span MemOperands) const { const bool MayLoad = Descriptor.Flags.has(InstructionFlag::MayLoad); const bool MayStore = Descriptor.Flags.has(InstructionFlag::MayStore); if (Descriptor.RequiresMemoryOperands && MemOperands.empty()) { return makeUnexpected(ErrorCode::VerificationError, "memory instruction is missing MachineMemOperand"); } if (!MayLoad && !MayStore && !MemOperands.empty()) { return makeUnexpected(ErrorCode::VerificationError, "non-memory instruction carries MachineMemOperand"); } for (const MachineMemOperand *MemOperand : MemOperands) { if (MemOperand == nullptr || (MemOperand->isLoad() && !MayLoad) || (MemOperand->isStore() && !MayStore)) { return makeUnexpected(ErrorCode::VerificationError, "MachineMemOperand access conflicts with instruction descriptor"); } } return {}; } Expected InstructionSet::validateMemOperands(Opcode InstructionOpcode, std::span MemOperands) const { const InstructionDescriptor *Descriptor = descriptor(InstructionOpcode); if (Descriptor == nullptr) { return makeUnexpected(ErrorCode::VerificationError, "instruction opcode is not registered"); } return validateMemOperands(*Descriptor, MemOperands); } Expected InstructionSet::validateOperand(const OperandDescriptor &Descriptor, const MachineOperand &Operand, const MachineRegisterInfo &RegInfo) const { if (!Descriptor.Kinds.contains(Operand.kind())) { return makeUnexpected(ErrorCode::VerificationError, "instruction operand kind does not match its descriptor"); } if ((Operand.targetFlags() & ~Descriptor.AllowedTargetFlags) != 0) { return makeUnexpected(ErrorCode::VerificationError, "instruction operand uses unregistered target flags"); } if (Operand.isRegister()) { const bool IsDef = Operand.isDef(); const bool IsUse = Operand.isUse(); const bool ExpectedDef = isDefRole(Descriptor.RegisterRole); const bool ExpectedUse = isUseRole(Descriptor.RegisterRole); if (IsDef != ExpectedDef || IsUse != ExpectedUse) { return makeUnexpected(ErrorCode::VerificationError, "register operand def/use role does not match its descriptor"); } if (Operand.registerFlags().has(RegisterOperandFlag::EarlyClobber) != Descriptor.EarlyClobber) { return makeUnexpected(ErrorCode::VerificationError, "register operand early-clobber does not match its descriptor"); } if (!Descriptor.AllowSubReg && Operand.subReg().value() != 0) { return makeUnexpected(ErrorCode::VerificationError, "register operand has a disallowed subregister index"); } const Register *Reg = Operand.getIf(); if (Reg == nullptr) { return makeUnexpected(ErrorCode::InternalError, "register operand has inconsistent storage"); } if (Reg->isVirtual()) { auto Info = RegInfo.virtualRegisterInfo(*Reg); if (!Info) return std::unexpected(Info.error()); } } if (Descriptor.ImmediatePredicate) { const ImmediatePredicate *Predicate = immediatePredicate(*Descriptor.ImmediatePredicate); if (Predicate == nullptr || !Predicate->Predicate(Operand)) { return makeUnexpected(ErrorCode::VerificationError, "instruction operand fails its immediate predicate"); } } return {}; } Expected InstructionSet::validateInstruction(const MachineInstr &Instruction, const MachineRegisterInfo &RegInfo) const { const InstructionDescriptor *Descriptor = descriptor(Instruction.opcode()); if (Descriptor == nullptr) return makeUnexpected(ErrorCode::VerificationError, "instruction opcode is not registered"); const auto AllOperands = Instruction.operands(); std::size_t ExplicitCount = 0; while (ExplicitCount < AllOperands.size() && !AllOperands[ExplicitCount].isImplicit()) ++ExplicitCount; for (std::size_t Index = ExplicitCount; Index < AllOperands.size(); ++Index) { if (!AllOperands[Index].isImplicit()) { return makeUnexpected(ErrorCode::VerificationError, "explicit operand appears after implicit operands"); } } const auto ExplicitValidation = validateExplicitOperands(*Descriptor, AllOperands.first(ExplicitCount), RegInfo); if (!ExplicitValidation) return std::unexpected(ExplicitValidation.error()); std::vector Ties; for (std::size_t Index = 0; Index < ExplicitCount; ++Index) { const MachineOperand &Operand = AllOperands[Index]; if (!Operand.tiedOperandIndex()) continue; const std::size_t OtherIndex = *Operand.tiedOperandIndex(); if (OtherIndex >= ExplicitCount || AllOperands[OtherIndex].tiedOperandIndex() != Index) { return makeUnexpected(ErrorCode::VerificationError, "instruction operand tie is out of range or not reciprocal"); } if (Index > OtherIndex) continue; if (isPureUse(Operand) && isPureDef(AllOperands[OtherIndex])) Ties.push_back(MachineOperandTie{OtherIndex, Index}); else Ties.push_back(MachineOperandTie{Index, OtherIndex}); } auto TieValidation = validateOperandTies(*Descriptor, AllOperands.first(ExplicitCount), Ties); if (!TieValidation) return std::unexpected(TieValidation.error()); std::vector ImplicitOperands; ImplicitOperands.reserve(AllOperands.size() - ExplicitCount); for (std::size_t Index = ExplicitCount; Index < AllOperands.size(); ++Index) { if (AllOperands[Index].tiedOperandIndex()) { return makeUnexpected(ErrorCode::VerificationError, "implicit register operand cannot participate in a tie"); } ImplicitOperands.push_back(&AllOperands[Index]); } auto ImplicitValidation = validateImplicitOperands(*Descriptor, ImplicitOperands); if (!ImplicitValidation) return std::unexpected(ImplicitValidation.error()); return validateMemOperands(*Descriptor, Instruction.memOperands()); } Expected> InstructionSet::createDefaultImplicitOperands(const InstructionDescriptor &Descriptor) const { std::vector Result; Result.reserve(Descriptor.ImplicitDefs.size() + Descriptor.ImplicitUses.size()); auto AppendImplicit = [&Result](const ImplicitRegisterDescriptor &Implicit, bool IsDef) -> Expected { RegisterOperandFlags Flags{ IsDef ? RegisterOperandFlag::Define : RegisterOperandFlag::Use, RegisterOperandFlag::Implicit, }; if (Implicit.EarlyClobber) Flags.set(RegisterOperandFlag::EarlyClobber); if (Implicit.Renamable) Flags.set(RegisterOperandFlag::Renamable); auto Operand = MachineOperand::registerOperand(Register::fromPhysical(Implicit.Reg), Flags); if (!Operand) return std::unexpected(Operand.error()); Result.push_back(std::move(*Operand)); return {}; }; for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitDefs) { auto AppendResult = AppendImplicit(Implicit, true); if (!AppendResult) return std::unexpected(AppendResult.error()); } for (const ImplicitRegisterDescriptor &Implicit : Descriptor.ImplicitUses) { auto AppendResult = AppendImplicit(Implicit, false); if (!AppendResult) return std::unexpected(AppendResult.error()); } return Result; } const ImmediatePredicate * InstructionSet::immediatePredicate(ImmediatePredicateID ID) const noexcept { const auto Position = PredicateToIndex.find(ID); if (Position == PredicateToIndex.end()) return nullptr; return &ImmediatePredicates[Position->second]; } } // namespace rcc