Move the InsertPrologEpilogCode class out of the Sparc.cpp file into the
authorChris Lattner <sabre@nondot.org>
Tue, 9 Apr 2002 05:20:15 +0000 (05:20 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 9 Apr 2002 05:20:15 +0000 (05:20 +0000)
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

include/llvm/CodeGen/InstrSelection.h
lib/Target/SparcV9/SparcV9InstrSelection.cpp

index 91bc8f2a8cf616f50b3f1df07d67963700062dd4..1a3023018d13033026c0fdc204210e6f5f005f64 100644 (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);
 
 
index 2094f6ec41c8ecbf804ac0eb03e9af54775855bf..a5c1a359c3fee3c6a0300dfa87461b716b512203 100644 (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