Minor changes
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9StackSlots.cpp
1 //===- StackSlots.cpp  - Specialize LLVM code for target machine ---------===//
2 //
3 // This pass adds 2 empty slots at the top of function stack.  These two slots
4 // are later used during code reoptimization for spilling the register values
5 // when rewriting branches.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/CodeGen/StackSlots.h"
10 #include "llvm/Target/TargetMachine.h"
11 #include "llvm/Constant.h"
12 #include "llvm/Function.h"
13 #include "llvm/DerivedTypes.h"
14 #include "llvm/CodeGen/MachineFunctionPass.h"
15 #include "llvm/CodeGen/MachineFunctionInfo.h"
16
17 namespace {
18   class StackSlots : public MachineFunctionPass {
19     const TargetMachine &Target;
20   public:
21     StackSlots(const TargetMachine &T) : Target(T) {}
22     
23     const char *getPassName() const {
24       return "Stack Slot Insertion for profiling code";
25     }
26     
27     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
28       AU.setPreservesCFG();
29     }
30     
31     bool runOnMachineFunction(MachineFunction &MF) {
32       const Type *PtrInt = PointerType::get(Type::IntTy);
33       unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
34       
35       Value *V = Constant::getNullValue(Type::IntTy);
36       MF.getInfo()->allocateLocalVar(V, 2*Size);
37       return true;
38     }
39   };
40 }
41
42 Pass *createStackSlotsPass(const TargetMachine &Target) {
43   return new StackSlots(Target);
44 }