Move the InsertPrologEpilogCode class out of the Sparc.cpp file into the

new PrologEpilogCodeInserter.cpp file, and include the bodies of the
GetInstructionsFor(Prolog|Epilog) functions from SparcInstrSelection.cpp
into the class.  This eliminates the need for a static global vector of
instructions and a class of errors that is really unneccesary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2194 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-04-09 05:20:15 +00:00
parent bcd6cc8951
commit 6111a87b3a
2 changed files with 0 additions and 89 deletions

View File

@ -32,14 +32,6 @@ extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
TargetMachine &Target,
vector<MachineInstr*>& mvec);
extern unsigned GetInstructionsForProlog(BasicBlock* entryBB,
TargetMachine &Target,
MachineInstr** minstrVec);
extern unsigned GetInstructionsForEpilog(BasicBlock* anExitBB,
TargetMachine &Target,
MachineInstr** minstrVec);
extern bool ThisIsAChainRule (int eruleno);

View File

@ -1214,87 +1214,6 @@ CreateCopyInstructionsByType(const TargetMachine& target,
//******************* Externally Visible Functions *************************/
//------------------------------------------------------------------------
// External Function: GetInstructionsForProlog
// External Function: GetInstructionsForEpilog
//
// Purpose:
// Create prolog and epilog code for procedure entry and exit
//------------------------------------------------------------------------
extern unsigned
GetInstructionsForProlog(BasicBlock* entryBB,
TargetMachine &target,
MachineInstr** mvec)
{
MachineInstr* M;
const MachineFrameInfo& frameInfo = target.getFrameInfo();
unsigned int N = 0;
// The second operand is the stack size. If it does not fit in the
// immediate field, we have to use a free register to hold the size.
// We will assume that local register `l0' is unused since the SAVE
// instruction must be the first instruction in each procedure.
//
Function *F = entryBB->getParent();
MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(F);
unsigned int staticStackSize = mcInfo.getStaticStackSize();
if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize())
staticStackSize = (unsigned) frameInfo.getMinStackFrameSize();
if (unsigned padsz = (staticStackSize %
(unsigned) frameInfo.getStackFrameSizeAlignment()))
staticStackSize += frameInfo.getStackFrameSizeAlignment() - padsz;
if (target.getInstrInfo().constantFitsInImmedField(SAVE, staticStackSize))
{
M = new MachineInstr(SAVE);
M->SetMachineOperandReg(0, target.getRegInfo().getStackPointer());
M->SetMachineOperandConst(1, MachineOperand::MO_SignExtendedImmed,
- (int) staticStackSize);
M->SetMachineOperandReg(2, target.getRegInfo().getStackPointer());
mvec[N++] = M;
}
else
{
M = new MachineInstr(SETSW);
M->SetMachineOperandConst(0, MachineOperand::MO_SignExtendedImmed,
- (int) staticStackSize);
M->SetMachineOperandReg(1, MachineOperand::MO_MachineRegister,
target.getRegInfo().getUnifiedRegNum(
target.getRegInfo().getRegClassIDOfType(Type::IntTy),
SparcIntRegOrder::l0));
mvec[N++] = M;
M = new MachineInstr(SAVE);
M->SetMachineOperandReg(0, target.getRegInfo().getStackPointer());
M->SetMachineOperandReg(1, MachineOperand::MO_MachineRegister,
target.getRegInfo().getUnifiedRegNum(
target.getRegInfo().getRegClassIDOfType(Type::IntTy),
SparcIntRegOrder::l0));
M->SetMachineOperandReg(2, target.getRegInfo().getStackPointer());
mvec[N++] = M;
}
return N;
}
extern unsigned
GetInstructionsForEpilog(BasicBlock* anExitBB,
TargetMachine &target,
MachineInstr** mvec)
{
mvec[0] = new MachineInstr(RESTORE);
mvec[0]->SetMachineOperandReg(0, target.getRegInfo().getZeroRegNum());
mvec[0]->SetMachineOperandConst(1, MachineOperand::MO_SignExtendedImmed,
(int64_t)0);
mvec[0]->SetMachineOperandReg(2, target.getRegInfo().getZeroRegNum());
return 1;
}
//------------------------------------------------------------------------
// External Function: ThisIsAChainRule