From 623710bf2f62389d5ee4d9987c620f72ded9db44 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Wed, 31 Mar 2004 20:58:37 +0000 Subject: [PATCH] Factor out getStaticStackSize from InsertPrologCode(), so that I can more easily steal it for a separate use in the reoptimizer. llvm-svn: 12568 --- .../SparcV9/SparcV9PrologEpilogInserter.cpp | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp index 8df8c6e09a99..48874e7369b0 100644 --- a/llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp +++ b/llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp @@ -51,6 +51,20 @@ namespace { // Create prolog and epilog code for procedure entry and exit //------------------------------------------------------------------------ +static unsigned getStaticStackSize (MachineFunction &MF) { + const TargetFrameInfo& frameInfo = MF.getTarget().getFrameInfo(); + + unsigned staticStackSize = MF.getInfo()->getStaticStackSize(); + + if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize()) + staticStackSize = (unsigned) frameInfo.getMinStackFrameSize(); + if (unsigned padsz = (staticStackSize % + (unsigned) frameInfo.getStackFrameSizeAlignment())) + staticStackSize += frameInfo.getStackFrameSizeAlignment() - padsz; + + return staticStackSize; +} + void InsertPrologEpilogCode::InsertPrologCode(MachineFunction &MF) { std::vector mvec; @@ -61,15 +75,7 @@ void InsertPrologEpilogCode::InsertPrologCode(MachineFunction &MF) // immediate field, we have to use a free register to hold the size. // See the comments below for the choice of this register. // - unsigned staticStackSize = MF.getInfo()->getStaticStackSize(); - - if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize()) - staticStackSize = (unsigned) frameInfo.getMinStackFrameSize(); - - if (unsigned padsz = (staticStackSize % - (unsigned) frameInfo.getStackFrameSizeAlignment())) - staticStackSize += frameInfo.getStackFrameSizeAlignment() - padsz; - + unsigned staticStackSize = getStaticStackSize (MF); int32_t C = - (int) staticStackSize; int SP = TM.getRegInfo().getStackPointer(); if (TM.getInstrInfo().constantFitsInImmedField(V9::SAVEi,staticStackSize)) {