summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-04-25 04:30:43 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-04-25 04:30:43 +0000
commit709277247509f7ab0888291956e83ed35009397f (patch)
tree301677f518c90854ef16989e01f9244a3ffe6668 /llvm/lib/CodeGen/MachineFunction.cpp
parentd46bb6e933655be5d14f3e58bb2ebcda50090b81 (diff)
downloadbcm5719-llvm-709277247509f7ab0888291956e83ed35009397f.tar.gz
bcm5719-llvm-709277247509f7ab0888291956e83ed35009397f.zip
Optional args are no longer allocated as they are discovered.
(This can be improved to avoid making the initial pass over the method.) Also, ensure automatic vars and reg. spills areas are not extended if their sizes are used for computing some other offset. llvm-svn: 2310
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp73
1 files changed, 22 insertions, 51 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index bb52ef298e5..06e0666ec88 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -1,10 +1,10 @@
-//===-- MachineCodeForFunction.cpp ------------------------------------------=//
+//===-- MachineCodeForMethod.cpp -------------------------------------------=//
//
// Purpose:
// Collect native machine code information for a function.
// This allows target-specific information about the generated code
// to be stored with each function.
-//===----------------------------------------------------------------------===//
+//===---------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineCodeForMethod.h"
#include "llvm/CodeGen/MachineInstr.h" // For debug output
@@ -55,7 +55,8 @@ MachineCodeForMethod::get(const Function *F)
}
static unsigned
-ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F)
+ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
+ unsigned &maxOptionalNumArgs)
{
const MachineFrameInfo& frameInfo = target.getFrameInfo();
@@ -68,7 +69,7 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F)
if (CallInst *callInst = dyn_cast<CallInst>(*I))
{
unsigned int numOperands = callInst->getNumOperands() - 1;
- int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
+ int numExtra =(int)numOperands-frameInfo.getNumFixedOutgoingArgs();
if (numExtra <= 0)
continue;
@@ -91,6 +92,9 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F)
if (maxSize < sizeForThisCall)
maxSize = sizeForThisCall;
+
+ if (((int) maxOptionalNumArgs) < numExtra)
+ maxOptionalNumArgs = (unsigned) numExtra;
}
}
@@ -121,12 +125,14 @@ SizeToAlignment(unsigned int size, const TargetMachine& target)
MachineCodeForMethod::MachineCodeForMethod(const Function *F,
const TargetMachine& target)
: Annotation(MCFM_AID),
- method(F), compiledAsLeaf(false), staticStackSize(0),
+ method(F), staticStackSize(0),
automaticVarsSize(0), regSpillsSize(0),
- currentOptionalArgsSize(0), maxOptionalArgsSize(0),
- currentTmpValuesSize(0), maxTmpValuesSize(0)
+ maxOptionalArgsSize(0), maxOptionalNumArgs(0),
+ currentTmpValuesSize(0), maxTmpValuesSize(0), compiledAsLeaf(false),
+ spillsAreaFrozen(false), automaticVarsAreaFrozen(false)
{
- maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, method);
+ maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, method,
+ maxOptionalNumArgs);
staticStackSize = maxOptionalArgsSize
+ target.getFrameInfo().getMinStackFrameSize();
}
@@ -172,6 +178,10 @@ MachineCodeForMethod::allocateLocalVar(const TargetMachine& target,
const Value* val,
unsigned int sizeToUse = 0)
{
+ assert(! automaticVarsAreaFrozen &&
+ "Size of auto vars area has been used to compute an offset so "
+ "no more automatic vars should be allocated!");
+
// Check if we've allocated a stack slot for this value already
//
int offset = getOffset(val);
@@ -190,6 +200,10 @@ int
MachineCodeForMethod::allocateSpilledValue(const TargetMachine& target,
const Type* type)
{
+ assert(! spillsAreaFrozen &&
+ "Size of reg spills area has been used to compute an offset so "
+ "no more register spill slots should be allocated!");
+
unsigned int size = target.findOptimalStorageSize(type);
unsigned char align = target.DataLayout.getTypeAlignment(type);
@@ -215,49 +229,6 @@ MachineCodeForMethod::allocateSpilledValue(const TargetMachine& target,
}
int
-MachineCodeForMethod::allocateOptionalArg(const TargetMachine& target,
- const Type* type)
-{
- const MachineFrameInfo& frameInfo = target.getFrameInfo();
-
- int size = INT_MAX;
- if (frameInfo.argsOnStackHaveFixedSize())
- size = frameInfo.getSizeOfEachArgOnStack();
- else
- {
- size = target.findOptimalStorageSize(type);
- assert(0 && "UNTESTED CODE: Size per stack argument is not fixed on this architecture: use actual argument sizes for computing optional arg offsets");
- }
- unsigned char align = target.DataLayout.getTypeAlignment(type);
-
- bool growUp;
- int firstOffset = frameInfo.getFirstOptionalOutgoingArgOffset(*this, growUp);
-
- int offset = getCurrentOptionalArgsSize();
- if (! growUp)
- offset += size;
-
- if (unsigned int mod = offset % align)
- {
- offset += align - mod;
- size += align - mod;
- }
-
- offset = growUp? firstOffset + offset
- : firstOffset - offset;
-
- incrementCurrentOptionalArgsSize(size);
-
- return offset;
-}
-
-void
-MachineCodeForMethod::resetOptionalArgs(const TargetMachine& target)
-{
- currentOptionalArgsSize = 0;
-}
-
-int
MachineCodeForMethod::pushTempValue(const TargetMachine& target,
unsigned int size)
{
OpenPOWER on IntegriCloud