2002-09-21 04:58:26 +00:00
|
|
|
//===- StackSlots.cpp - Specialize LLVM code for target machine ---------===//
|
|
|
|
//
|
2002-10-23 01:12:01 +00:00
|
|
|
// This pass adds 2 empty slots at the top of function stack. These two slots
|
|
|
|
// are later used during code reoptimization for spilling the register values
|
|
|
|
// when rewriting branches.
|
2002-09-21 04:58:26 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-10-23 01:12:01 +00:00
|
|
|
#include "llvm/CodeGen/StackSlots.h"
|
2002-09-21 04:58:26 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2002-10-23 01:12:01 +00:00
|
|
|
#include "llvm/Constant.h"
|
2002-09-21 04:58:26 +00:00
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
2003-01-14 22:00:31 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2002-12-28 20:42:56 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionInfo.h"
|
2002-09-21 04:58:26 +00:00
|
|
|
|
2002-12-28 20:42:56 +00:00
|
|
|
namespace {
|
2003-01-14 22:00:31 +00:00
|
|
|
class StackSlots : public MachineFunctionPass {
|
2002-12-28 20:42:56 +00:00
|
|
|
const TargetMachine &Target;
|
|
|
|
public:
|
|
|
|
StackSlots(const TargetMachine &T) : Target(T) {}
|
|
|
|
|
|
|
|
const char *getPassName() const {
|
|
|
|
return "Stack Slot Insertion for profiling code";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesCFG();
|
|
|
|
}
|
|
|
|
|
2003-01-14 22:00:31 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) {
|
2002-12-28 20:42:56 +00:00
|
|
|
const Type *PtrInt = PointerType::get(Type::IntTy);
|
|
|
|
unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
|
|
|
|
|
|
|
|
Value *V = Constant::getNullValue(Type::IntTy);
|
2003-01-14 22:00:31 +00:00
|
|
|
MF.getInfo()->allocateLocalVar(V, 2*Size);
|
2002-12-28 20:42:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2002-09-21 04:58:26 +00:00
|
|
|
|
2002-10-23 01:12:01 +00:00
|
|
|
Pass *createStackSlotsPass(const TargetMachine &Target) {
|
|
|
|
return new StackSlots(Target);
|
2002-09-21 04:58:26 +00:00
|
|
|
}
|