Skip to content
Snippets Groups Projects
Commit 9a3478e0 authored by Chris Lattner's avatar Chris Lattner
Browse files

* 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.

llvm-svn: 10553
parent 299517dc
No related branches found
No related tags found
No related merge requests found
...@@ -26,55 +26,13 @@ ...@@ -26,55 +26,13 @@
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "Config/limits.h" using namespace llvm;
namespace llvm {
const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
static AnnotationID MF_AID( static AnnotationID MF_AID(
AnnotationManager::getID("CodeGen::MachineCodeForFunction")); AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
//===---------------------------------------------------------------------===//
// Code generation/destruction passes
//===---------------------------------------------------------------------===//
namespace { 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 { struct Printer : public FunctionPass {
const char *getPassName() const { return "MachineFunction Printer"; } const char *getPassName() const { return "MachineFunction Printer"; }
...@@ -89,15 +47,7 @@ namespace { ...@@ -89,15 +47,7 @@ namespace {
}; };
} }
FunctionPass *createMachineCodeConstructionPass(TargetMachine &Target) { FunctionPass *llvm::createMachineFunctionPrinterPass() {
return new ConstructMachineFunction(Target);
}
FunctionPass *createMachineCodeDestructionPass() {
return new DestroyMachineFunction();
}
FunctionPass *createMachineFunctionPrinterPass() {
return new Printer(); return new Printer();
} }
...@@ -341,24 +291,23 @@ MachineFunctionInfo::computeOffsetforLocalVar(const Value* val, ...@@ -341,24 +291,23 @@ MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
return aligned; return aligned;
} }
int
MachineFunctionInfo::allocateLocalVar(const Value* val, int MachineFunctionInfo::allocateLocalVar(const Value* val,
unsigned sizeToUse) unsigned sizeToUse) {
{
assert(! automaticVarsAreaFrozen && assert(! automaticVarsAreaFrozen &&
"Size of auto vars area has been used to compute an offset so " "Size of auto vars area has been used to compute an offset so "
"no more automatic vars should be allocated!"); "no more automatic vars should be allocated!");
// Check if we've allocated a stack slot for this value already // Check if we've allocated a stack slot for this value already
// //
int offset = getOffset(val); hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
if (offset == INVALID_FRAME_OFFSET) if (pair != offsets.end())
{ return pair->second;
unsigned getPaddedSize;
offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse); unsigned getPaddedSize;
offsets[val] = offset; unsigned offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
incrementAutomaticVarsSize(getPaddedSize); offsets[val] = offset;
} incrementAutomaticVarsSize(getPaddedSize);
return offset; return offset;
} }
...@@ -410,11 +359,3 @@ void MachineFunctionInfo::popAllTempValues() { ...@@ -410,11 +359,3 @@ void MachineFunctionInfo::popAllTempValues() {
resetTmpAreaSize(); // clear tmp area to reuse 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment