From 7b3640bd1247ddf10a2615356904bed398720da1 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Thu, 25 Apr 2002 04:47:26 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2319 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineCodeForMethod.h | 31 ++++++++++----------- include/llvm/CodeGen/MachineFunction.h | 31 ++++++++++----------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/include/llvm/CodeGen/MachineCodeForMethod.h b/include/llvm/CodeGen/MachineCodeForMethod.h index 01c9fd9d24f..fb9eaf8fe92 100644 --- a/include/llvm/CodeGen/MachineCodeForMethod.h +++ b/include/llvm/CodeGen/MachineCodeForMethod.h @@ -21,17 +21,19 @@ class TargetMachine; class MachineCodeForMethod : private Annotation { - const Function* method; - bool compiledAsLeaf; + std::hash_set constantsForConstPool; + std::hash_map offsets; + const Function* method; unsigned staticStackSize; unsigned automaticVarsSize; unsigned regSpillsSize; - unsigned currentOptionalArgsSize; unsigned maxOptionalArgsSize; + unsigned maxOptionalNumArgs; unsigned currentTmpValuesSize; unsigned maxTmpValuesSize; - std::hash_set constantsForConstPool; - std::hash_map offsets; + bool compiledAsLeaf; + bool spillsAreaFrozen; + bool automaticVarsAreaFrozen; public: /*ctor*/ MachineCodeForMethod(const Function* function, @@ -57,8 +59,7 @@ public: inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; } inline unsigned getRegSpillsSize() const { return regSpillsSize; } inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;} - inline unsigned getCurrentOptionalArgsSize() const - { return currentOptionalArgsSize;} + inline unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;} inline const std::hash_set& getConstantPoolValues() const {return constantsForConstPool;} @@ -73,10 +74,9 @@ public: inline void markAsLeafMethod() { compiledAsLeaf = true; } int computeOffsetforLocalVar (const TargetMachine& target, - const Value* local, + const Value* local, unsigned int& getPaddedSize, unsigned int sizeToUse = 0); - int allocateLocalVar (const TargetMachine& target, const Value* local, unsigned int sizeToUse = 0); @@ -84,16 +84,14 @@ public: int allocateSpilledValue (const TargetMachine& target, const Type* type); - int allocateOptionalArg (const TargetMachine& target, - const Type* type); - - void resetOptionalArgs (const TargetMachine& target); - int pushTempValue (const TargetMachine& target, unsigned int size); void popAllTempValues (const TargetMachine& target); + void freezeSpillsArea () { spillsAreaFrozen = true; } + void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; } + int getOffset (const Value* val) const; // int getOffsetFromFP (const Value* val) const; @@ -120,9 +118,8 @@ private: inline void resetTmpAreaSize() { currentTmpValuesSize = 0; } - inline void incrementCurrentOptionalArgsSize(int incr) { - currentOptionalArgsSize+= incr; // stack size already includes this! - } + int allocateOptionalArg (const TargetMachine& target, + const Type* type); }; #endif diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 01c9fd9d24f..fb9eaf8fe92 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -21,17 +21,19 @@ class TargetMachine; class MachineCodeForMethod : private Annotation { - const Function* method; - bool compiledAsLeaf; + std::hash_set constantsForConstPool; + std::hash_map offsets; + const Function* method; unsigned staticStackSize; unsigned automaticVarsSize; unsigned regSpillsSize; - unsigned currentOptionalArgsSize; unsigned maxOptionalArgsSize; + unsigned maxOptionalNumArgs; unsigned currentTmpValuesSize; unsigned maxTmpValuesSize; - std::hash_set constantsForConstPool; - std::hash_map offsets; + bool compiledAsLeaf; + bool spillsAreaFrozen; + bool automaticVarsAreaFrozen; public: /*ctor*/ MachineCodeForMethod(const Function* function, @@ -57,8 +59,7 @@ public: inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; } inline unsigned getRegSpillsSize() const { return regSpillsSize; } inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;} - inline unsigned getCurrentOptionalArgsSize() const - { return currentOptionalArgsSize;} + inline unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;} inline const std::hash_set& getConstantPoolValues() const {return constantsForConstPool;} @@ -73,10 +74,9 @@ public: inline void markAsLeafMethod() { compiledAsLeaf = true; } int computeOffsetforLocalVar (const TargetMachine& target, - const Value* local, + const Value* local, unsigned int& getPaddedSize, unsigned int sizeToUse = 0); - int allocateLocalVar (const TargetMachine& target, const Value* local, unsigned int sizeToUse = 0); @@ -84,16 +84,14 @@ public: int allocateSpilledValue (const TargetMachine& target, const Type* type); - int allocateOptionalArg (const TargetMachine& target, - const Type* type); - - void resetOptionalArgs (const TargetMachine& target); - int pushTempValue (const TargetMachine& target, unsigned int size); void popAllTempValues (const TargetMachine& target); + void freezeSpillsArea () { spillsAreaFrozen = true; } + void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; } + int getOffset (const Value* val) const; // int getOffsetFromFP (const Value* val) const; @@ -120,9 +118,8 @@ private: inline void resetTmpAreaSize() { currentTmpValuesSize = 0; } - inline void incrementCurrentOptionalArgsSize(int incr) { - currentOptionalArgsSize+= incr; // stack size already includes this! - } + int allocateOptionalArg (const TargetMachine& target, + const Type* type); }; #endif