aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-20 09:17:07 +0000
committerChris Lattner <sabre@nondot.org>2003-12-20 09:17:07 +0000
commit07f32d48f1e16bcdc621985549548a5849215238 (patch)
treebe0afd969a4e7f43d72497d6487e8ad113f15732 /lib/CodeGen/MachineFunction.cpp
parent73c1366ee2197dd2226546f5c10431d625e464ce (diff)
* Finegrainify namespacification
* Move sparc specific code out of generic code * Eliminate the getOffset() method which made INVALID_FRAME_OFFSET necessary, which made pulling in MAX_INT as a sentinal necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
-rw-r--r--lib/CodeGen/MachineFunction.cpp85
1 files changed, 13 insertions, 72 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 790859bc87..66497d964a 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -26,55 +26,13 @@
#include "llvm/Function.h"
#include "llvm/iOther.h"
#include "llvm/Pass.h"
-#include "Config/limits.h"
-
-namespace llvm {
-
-const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
+using namespace llvm;
static AnnotationID MF_AID(
AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
-//===---------------------------------------------------------------------===//
-// Code generation/destruction passes
-//===---------------------------------------------------------------------===//
-
namespace {
- class ConstructMachineFunction : public FunctionPass {
- TargetMachine &Target;
- public:
- ConstructMachineFunction(TargetMachine &T) : Target(T) {}
-
- const char *getPassName() const {
- return "ConstructMachineFunction";
- }
-
- bool runOnFunction(Function &F) {
- MachineFunction::construct(&F, Target).getInfo()->CalculateArgSize();
- return false;
- }
- };
-
- struct DestroyMachineFunction : public FunctionPass {
- const char *getPassName() const { return "FreeMachineFunction"; }
-
- static void freeMachineCode(Instruction &I) {
- MachineCodeForInstruction::destroy(&I);
- }
-
- bool runOnFunction(Function &F) {
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
- for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E; ++I)
- MachineCodeForInstruction::get(I).dropAllReferences();
-
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
- for_each(FI->begin(), FI->end(), freeMachineCode);
-
- return false;
- }
- };
-
struct Printer : public FunctionPass {
const char *getPassName() const { return "MachineFunction Printer"; }
@@ -89,15 +47,7 @@ namespace {
};
}
-FunctionPass *createMachineCodeConstructionPass(TargetMachine &Target) {
- return new ConstructMachineFunction(Target);
-}
-
-FunctionPass *createMachineCodeDestructionPass() {
- return new DestroyMachineFunction();
-}
-
-FunctionPass *createMachineFunctionPrinterPass() {
+FunctionPass *llvm::createMachineFunctionPrinterPass() {
return new Printer();
}
@@ -341,24 +291,23 @@ MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
return aligned;
}
-int
-MachineFunctionInfo::allocateLocalVar(const Value* val,
- unsigned sizeToUse)
-{
+
+int MachineFunctionInfo::allocateLocalVar(const Value* val,
+ unsigned sizeToUse) {
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);
- if (offset == INVALID_FRAME_OFFSET)
- {
- unsigned getPaddedSize;
- offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
- offsets[val] = offset;
- incrementAutomaticVarsSize(getPaddedSize);
- }
+ hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
+ if (pair != offsets.end())
+ return pair->second;
+
+ unsigned getPaddedSize;
+ unsigned offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
+ offsets[val] = offset;
+ incrementAutomaticVarsSize(getPaddedSize);
return offset;
}
@@ -410,11 +359,3 @@ void MachineFunctionInfo::popAllTempValues() {
resetTmpAreaSize(); // clear tmp area to reuse
}
-int
-MachineFunctionInfo::getOffset(const Value* val) const
-{
- hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
- return (pair == offsets.end()) ? INVALID_FRAME_OFFSET : pair->second;
-}
-
-} // End llvm namespace