From 6111a87b3aea006b2aee43ebe9cac0859b331f01 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Apr 2002 05:20:15 +0000 Subject: [PATCH] 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 --- include/llvm/CodeGen/InstrSelection.h | 8 -- lib/Target/SparcV9/SparcV9InstrSelection.cpp | 81 -------------------- 2 files changed, 89 deletions(-) diff --git a/include/llvm/CodeGen/InstrSelection.h b/include/llvm/CodeGen/InstrSelection.h index 91bc8f2a8cf..1a3023018d1 100644 --- a/include/llvm/CodeGen/InstrSelection.h +++ b/include/llvm/CodeGen/InstrSelection.h @@ -32,14 +32,6 @@ extern void GetInstructionsByRule (InstructionNode* subtreeRoot, TargetMachine &Target, vector& mvec); -extern unsigned GetInstructionsForProlog(BasicBlock* entryBB, - TargetMachine &Target, - MachineInstr** minstrVec); - -extern unsigned GetInstructionsForEpilog(BasicBlock* anExitBB, - TargetMachine &Target, - MachineInstr** minstrVec); - extern bool ThisIsAChainRule (int eruleno); diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 2094f6ec41c..a5c1a359c3f 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -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