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: 2319
This commit is contained in:
parent
40221aa74c
commit
f0a992f0de
|
|
@ -21,17 +21,19 @@ class TargetMachine;
|
||||||
|
|
||||||
|
|
||||||
class MachineCodeForMethod : private Annotation {
|
class MachineCodeForMethod : private Annotation {
|
||||||
const Function* method;
|
std::hash_set<const Constant*> constantsForConstPool;
|
||||||
bool compiledAsLeaf;
|
std::hash_map<const Value*, int> offsets;
|
||||||
|
const Function* method;
|
||||||
unsigned staticStackSize;
|
unsigned staticStackSize;
|
||||||
unsigned automaticVarsSize;
|
unsigned automaticVarsSize;
|
||||||
unsigned regSpillsSize;
|
unsigned regSpillsSize;
|
||||||
unsigned currentOptionalArgsSize;
|
|
||||||
unsigned maxOptionalArgsSize;
|
unsigned maxOptionalArgsSize;
|
||||||
|
unsigned maxOptionalNumArgs;
|
||||||
unsigned currentTmpValuesSize;
|
unsigned currentTmpValuesSize;
|
||||||
unsigned maxTmpValuesSize;
|
unsigned maxTmpValuesSize;
|
||||||
std::hash_set<const Constant*> constantsForConstPool;
|
bool compiledAsLeaf;
|
||||||
std::hash_map<const Value*, int> offsets;
|
bool spillsAreaFrozen;
|
||||||
|
bool automaticVarsAreaFrozen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ MachineCodeForMethod(const Function* function,
|
/*ctor*/ MachineCodeForMethod(const Function* function,
|
||||||
|
|
@ -57,8 +59,7 @@ public:
|
||||||
inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
|
inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
|
||||||
inline unsigned getRegSpillsSize() const { return regSpillsSize; }
|
inline unsigned getRegSpillsSize() const { return regSpillsSize; }
|
||||||
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
||||||
inline unsigned getCurrentOptionalArgsSize() const
|
inline unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
|
||||||
{ return currentOptionalArgsSize;}
|
|
||||||
inline const std::hash_set<const Constant*>&
|
inline const std::hash_set<const Constant*>&
|
||||||
getConstantPoolValues() const {return constantsForConstPool;}
|
getConstantPoolValues() const {return constantsForConstPool;}
|
||||||
|
|
||||||
|
|
@ -73,10 +74,9 @@ public:
|
||||||
inline void markAsLeafMethod() { compiledAsLeaf = true; }
|
inline void markAsLeafMethod() { compiledAsLeaf = true; }
|
||||||
|
|
||||||
int computeOffsetforLocalVar (const TargetMachine& target,
|
int computeOffsetforLocalVar (const TargetMachine& target,
|
||||||
const Value* local,
|
const Value* local,
|
||||||
unsigned int& getPaddedSize,
|
unsigned int& getPaddedSize,
|
||||||
unsigned int sizeToUse = 0);
|
unsigned int sizeToUse = 0);
|
||||||
|
|
||||||
int allocateLocalVar (const TargetMachine& target,
|
int allocateLocalVar (const TargetMachine& target,
|
||||||
const Value* local,
|
const Value* local,
|
||||||
unsigned int sizeToUse = 0);
|
unsigned int sizeToUse = 0);
|
||||||
|
|
@ -84,16 +84,14 @@ public:
|
||||||
int allocateSpilledValue (const TargetMachine& target,
|
int allocateSpilledValue (const TargetMachine& target,
|
||||||
const Type* type);
|
const Type* type);
|
||||||
|
|
||||||
int allocateOptionalArg (const TargetMachine& target,
|
|
||||||
const Type* type);
|
|
||||||
|
|
||||||
void resetOptionalArgs (const TargetMachine& target);
|
|
||||||
|
|
||||||
int pushTempValue (const TargetMachine& target,
|
int pushTempValue (const TargetMachine& target,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
|
|
||||||
void popAllTempValues (const TargetMachine& target);
|
void popAllTempValues (const TargetMachine& target);
|
||||||
|
|
||||||
|
void freezeSpillsArea () { spillsAreaFrozen = true; }
|
||||||
|
void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
|
||||||
|
|
||||||
int getOffset (const Value* val) const;
|
int getOffset (const Value* val) const;
|
||||||
|
|
||||||
// int getOffsetFromFP (const Value* val) const;
|
// int getOffsetFromFP (const Value* val) const;
|
||||||
|
|
@ -120,9 +118,8 @@ private:
|
||||||
inline void resetTmpAreaSize() {
|
inline void resetTmpAreaSize() {
|
||||||
currentTmpValuesSize = 0;
|
currentTmpValuesSize = 0;
|
||||||
}
|
}
|
||||||
inline void incrementCurrentOptionalArgsSize(int incr) {
|
int allocateOptionalArg (const TargetMachine& target,
|
||||||
currentOptionalArgsSize+= incr; // stack size already includes this!
|
const Type* type);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,19 @@ class TargetMachine;
|
||||||
|
|
||||||
|
|
||||||
class MachineCodeForMethod : private Annotation {
|
class MachineCodeForMethod : private Annotation {
|
||||||
const Function* method;
|
std::hash_set<const Constant*> constantsForConstPool;
|
||||||
bool compiledAsLeaf;
|
std::hash_map<const Value*, int> offsets;
|
||||||
|
const Function* method;
|
||||||
unsigned staticStackSize;
|
unsigned staticStackSize;
|
||||||
unsigned automaticVarsSize;
|
unsigned automaticVarsSize;
|
||||||
unsigned regSpillsSize;
|
unsigned regSpillsSize;
|
||||||
unsigned currentOptionalArgsSize;
|
|
||||||
unsigned maxOptionalArgsSize;
|
unsigned maxOptionalArgsSize;
|
||||||
|
unsigned maxOptionalNumArgs;
|
||||||
unsigned currentTmpValuesSize;
|
unsigned currentTmpValuesSize;
|
||||||
unsigned maxTmpValuesSize;
|
unsigned maxTmpValuesSize;
|
||||||
std::hash_set<const Constant*> constantsForConstPool;
|
bool compiledAsLeaf;
|
||||||
std::hash_map<const Value*, int> offsets;
|
bool spillsAreaFrozen;
|
||||||
|
bool automaticVarsAreaFrozen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ MachineCodeForMethod(const Function* function,
|
/*ctor*/ MachineCodeForMethod(const Function* function,
|
||||||
|
|
@ -57,8 +59,7 @@ public:
|
||||||
inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
|
inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
|
||||||
inline unsigned getRegSpillsSize() const { return regSpillsSize; }
|
inline unsigned getRegSpillsSize() const { return regSpillsSize; }
|
||||||
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
||||||
inline unsigned getCurrentOptionalArgsSize() const
|
inline unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
|
||||||
{ return currentOptionalArgsSize;}
|
|
||||||
inline const std::hash_set<const Constant*>&
|
inline const std::hash_set<const Constant*>&
|
||||||
getConstantPoolValues() const {return constantsForConstPool;}
|
getConstantPoolValues() const {return constantsForConstPool;}
|
||||||
|
|
||||||
|
|
@ -73,10 +74,9 @@ public:
|
||||||
inline void markAsLeafMethod() { compiledAsLeaf = true; }
|
inline void markAsLeafMethod() { compiledAsLeaf = true; }
|
||||||
|
|
||||||
int computeOffsetforLocalVar (const TargetMachine& target,
|
int computeOffsetforLocalVar (const TargetMachine& target,
|
||||||
const Value* local,
|
const Value* local,
|
||||||
unsigned int& getPaddedSize,
|
unsigned int& getPaddedSize,
|
||||||
unsigned int sizeToUse = 0);
|
unsigned int sizeToUse = 0);
|
||||||
|
|
||||||
int allocateLocalVar (const TargetMachine& target,
|
int allocateLocalVar (const TargetMachine& target,
|
||||||
const Value* local,
|
const Value* local,
|
||||||
unsigned int sizeToUse = 0);
|
unsigned int sizeToUse = 0);
|
||||||
|
|
@ -84,16 +84,14 @@ public:
|
||||||
int allocateSpilledValue (const TargetMachine& target,
|
int allocateSpilledValue (const TargetMachine& target,
|
||||||
const Type* type);
|
const Type* type);
|
||||||
|
|
||||||
int allocateOptionalArg (const TargetMachine& target,
|
|
||||||
const Type* type);
|
|
||||||
|
|
||||||
void resetOptionalArgs (const TargetMachine& target);
|
|
||||||
|
|
||||||
int pushTempValue (const TargetMachine& target,
|
int pushTempValue (const TargetMachine& target,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
|
|
||||||
void popAllTempValues (const TargetMachine& target);
|
void popAllTempValues (const TargetMachine& target);
|
||||||
|
|
||||||
|
void freezeSpillsArea () { spillsAreaFrozen = true; }
|
||||||
|
void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
|
||||||
|
|
||||||
int getOffset (const Value* val) const;
|
int getOffset (const Value* val) const;
|
||||||
|
|
||||||
// int getOffsetFromFP (const Value* val) const;
|
// int getOffsetFromFP (const Value* val) const;
|
||||||
|
|
@ -120,9 +118,8 @@ private:
|
||||||
inline void resetTmpAreaSize() {
|
inline void resetTmpAreaSize() {
|
||||||
currentTmpValuesSize = 0;
|
currentTmpValuesSize = 0;
|
||||||
}
|
}
|
||||||
inline void incrementCurrentOptionalArgsSize(int incr) {
|
int allocateOptionalArg (const TargetMachine& target,
|
||||||
currentOptionalArgsSize+= incr; // stack size already includes this!
|
const Type* type);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue