//===-- PrologEpilogCodeInserter.cpp - Insert Prolog & Epilog code for fn -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// Insert SAVE/RESTORE instructions for the function
//
#include "llvm/DerivedTypes.h"
#include "llvm/Intrinsics.h"
+namespace llvm {
+
namespace {
struct InsertPrologEpilogCode : public MachineFunctionPass {
const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; }
M->setOperandLo32(1);
mvec.push_back(M);
- M = BuildMI(V9::SRAi6, 3).addMReg(uregNum).addZImm(0)
+ M = BuildMI(V9::SRAi5, 3).addMReg(uregNum).addZImm(0)
.addMReg(uregNum, MOTy::Def);
mvec.push_back(M);
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
MachineBasicBlock &MBB = *I;
- BasicBlock &BB = *I->getBasicBlock();
- Instruction *TermInst = (Instruction*)BB.getTerminator();
+ const BasicBlock &BB = *I->getBasicBlock();
+ const Instruction *TermInst = (Instruction*)BB.getTerminator();
if (TermInst->getOpcode() == Instruction::Ret)
{
int ZR = TM.getRegInfo().getZeroRegNum();
// Remove the NOPs in the delay slots of the return instruction
unsigned numNOPs = 0;
- while (termMvec.back()->getOpCode() == V9::NOP)
+ while (termMvec.back()->getOpcode() == V9::NOP)
{
- assert( termMvec.back() == MBB.back());
- delete MBB.pop_back();
+ assert( termMvec.back() == &MBB.back());
termMvec.pop_back();
+ MBB.erase(&MBB.back());
++numNOPs;
}
- assert(termMvec.back() == MBB.back());
+ assert(termMvec.back() == &MBB.back());
// Check that we found the right number of NOPs and have the right
// number of instructions to replace them.
- unsigned ndelays = MII.getNumDelaySlots(termMvec.back()->getOpCode());
+ unsigned ndelays = MII.getNumDelaySlots(termMvec.back()->getOpcode());
assert(numNOPs == ndelays && "Missing NOPs in delay slots?");
assert(ndelays == 1 && "Cannot use epilog code for delay slots?");
}
}
-Pass* UltraSparc::getPrologEpilogInsertionPass() {
+FunctionPass *createPrologEpilogInsertionPass() {
return new InsertPrologEpilogCode();
}
+
+} // End llvm namespace