//******************* 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