diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 19:03:08 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 19:03:08 +0800 |
| commit | 1ecaa5028a39cdfd9b9590053d802e8049d346d5 (patch) | |
| tree | 48729f14d438c7bf9b8c764a0807b3fbd3fe1a8b /backend/lib/CodeGen/MIRParser/MIParser.cpp | |
| parent | 5794302adc3ce94c69318965b1bbef7a895d5d41 (diff) | |
| download | rcc-project-1ecaa5028a39cdfd9b9590053d802e8049d346d5.tar.gz rcc-project-1ecaa5028a39cdfd9b9590053d802e8049d346d5.tar.xz | |
[MIR] Omit predictable successors in simplified output
Diffstat (limited to 'backend/lib/CodeGen/MIRParser/MIParser.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MIRParser/MIParser.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/backend/lib/CodeGen/MIRParser/MIParser.cpp b/backend/lib/CodeGen/MIRParser/MIParser.cpp index 0015b02..5932111 100644 --- a/backend/lib/CodeGen/MIRParser/MIParser.cpp +++ b/backend/lib/CodeGen/MIRParser/MIParser.cpp @@ -7,6 +7,7 @@ #include "rcc/CodeGen/GenericOpcodes.h" #include "rcc/CodeGen/InlineAsm.h" #include "rcc/CodeGen/InstructionDescriptor.h" +#include "rcc/CodeGen/MIRPrinter.h" #include "rcc/CodeGen/MIRYamlMapping.h" #include "rcc/CodeGen/MachineBasicBlock.h" #include "rcc/CodeGen/MachineCFGUpdater.h" @@ -2860,25 +2861,11 @@ bool MIParser::Impl::inferSuccessors() { if (ExplicitSuccessorBlocks.contains(Block)) continue; - bool BlocksFallthrough = true; std::vector<MachineBasicBlock *> Successors; - for (MachineInstr *Instruction = Block->firstInstruction(); Instruction != nullptr; - Instruction = Instruction->next()) { - const InstructionDescriptor *Descriptor = - Target.instructions().descriptor(Instruction->opcode()); - if (Descriptor == nullptr) - return fail("instruction has no target descriptor while inferring successors"); - if (Descriptor->Flags.has(InstructionFlag::Branch)) { - for (const MachineOperand &Operand : Instruction->operands()) { - if (const BasicBlockOperand *TargetBlock = Operand.getIf<BasicBlockOperand>()) { - if (std::ranges::find(Successors, TargetBlock->Block) == Successors.end()) - Successors.push_back(TargetBlock->Block); - } - } - } - if (Descriptor->Flags.has(InstructionFlag::Barrier)) - BlocksFallthrough = false; - } + bool BlocksFallthrough = false; + auto Guessed = guessSuccessors(*Block, Target, Successors, BlocksFallthrough); + if (!Guessed) + return importError(token(), Guessed.error()); if (BlocksFallthrough && Block->next() != nullptr && std::ranges::find(Successors, Block->next()) == Successors.end()) Successors.push_back(Block->next()); |
