From 6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Tue, 11 Aug 2026 17:37:42 +0800 Subject: [MIR] Accept fixed-baseline LLVM syntax --- backend/lib/CodeGen/MachinePseudoExpansion.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'backend/lib/CodeGen/MachinePseudoExpansion.cpp') diff --git a/backend/lib/CodeGen/MachinePseudoExpansion.cpp b/backend/lib/CodeGen/MachinePseudoExpansion.cpp index 676804a..924c515 100644 --- a/backend/lib/CodeGen/MachinePseudoExpansion.cpp +++ b/backend/lib/CodeGen/MachinePseudoExpansion.cpp @@ -200,13 +200,20 @@ using BlockSizeSnapshot = std::vector layoutInstructions(MachineFunction &Function) { + std::vector Result; + for (MachineBasicBlock *Block = Function.firstBlock(); Block != nullptr; Block = Block->next()) + for (MachineInstr *Instruction = Block->firstInstruction(); Instruction != nullptr; + Instruction = Instruction->next()) + Result.push_back(Instruction); + return Result; +} + [[nodiscard]] Expected prepareImplementation(MachineFunction &Function, const TargetDescription &Target, const TargetPseudoExpansionInfo &Info, MachineActionReplay &Actions) { bool Changed = false; - for (MachineInstr *Instruction : Function.allInstructions()) { - if (Instruction == nullptr || Instruction->parent() == nullptr) - continue; + for (MachineInstr *Instruction : layoutInstructions(Function)) { const InstructionDescriptor *Descriptor = Target.instructionDescriptor(Instruction->opcode()); if (Descriptor == nullptr) return makeUnexpected(ErrorCode::VerificationError, @@ -255,10 +262,7 @@ expandImplementation(MachineFunction &Function, const TargetDescription &Target, SizesBefore = std::move(*Snapshot); } std::vector Worklist; - for (MachineInstr *Instruction : Function.allInstructions()) { - if (Instruction != nullptr && Instruction->parent() != nullptr) - Worklist.push_back(Instruction); - } + Worklist = layoutInstructions(Function); bool Changed = false; for (MachineInstr *Instruction : Worklist) { if (Instruction->parent() == nullptr) @@ -325,9 +329,7 @@ expandImplementation(MachineFunction &Function, const TargetDescription &Target, } } } - for (MachineInstr *Instruction : Function.allInstructions()) { - if (Instruction == nullptr || Instruction->parent() == nullptr) - continue; + for (MachineInstr *Instruction : layoutInstructions(Function)) { const InstructionDescriptor *Descriptor = Target.instructionDescriptor(Instruction->opcode()); if (Descriptor != nullptr && Descriptor->Flags.has(InstructionFlag::Pseudo) && Descriptor->Owner == ownerFor(Phase)) { -- cgit v1.2.3