From c291e2f5780c3a8470113a2a58c1fa680cd54b20 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sun, 25 Sep 2011 19:21:35 +0000 Subject: Add target hook for pseudo instruction expansion. Many targets use pseudo instructions to help register allocation. Like the COPY instruction, these pseudos can be expanded after register allocation. The early expansion can make life easier for PEI and the post-ra scheduler. This patch adds a hook that is called for all remaining pseudo instructions from the ExpandPostRAPseudos pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140472 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/ExpandPostRAPseudos.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/ExpandPostRAPseudos.cpp b/lib/CodeGen/ExpandPostRAPseudos.cpp index 78382f548c..623b67ddcd 100644 --- a/lib/CodeGen/ExpandPostRAPseudos.cpp +++ b/lib/CodeGen/ExpandPostRAPseudos.cpp @@ -202,17 +202,26 @@ bool ExpandPostRA::runOnMachineFunction(MachineFunction &MF) { mbbi != mbbe; ++mbbi) { for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); mi != me;) { - MachineBasicBlock::iterator nmi = llvm::next(mi); MachineInstr *MI = mi; - assert(!MI->isInsertSubreg() && "INSERT_SUBREG should no longer appear"); - assert(MI->getOpcode() != TargetOpcode::EXTRACT_SUBREG && - "EXTRACT_SUBREG should no longer appear"); - if (MI->isSubregToReg()) { + // Advance iterator here because MI may be erased. + ++mi; + switch (MI->getOpcode()) { + case TargetOpcode::SUBREG_TO_REG: MadeChange |= LowerSubregToReg(MI); - } else if (MI->isCopy()) { + break; + case TargetOpcode::COPY: MadeChange |= LowerCopy(MI); + break; + case TargetOpcode::DBG_VALUE: + continue; + case TargetOpcode::INSERT_SUBREG: + case TargetOpcode::EXTRACT_SUBREG: + llvm_unreachable("Sub-register pseudos should have been eliminated."); + default: + if (MI->getDesc().isPseudo()) + MadeChange |= TII->expandPostRAPseudo(MI); + break; } - mi = nmi; } } -- cgit v1.2.3