Rename the redundant MachineOperand::getOperandType() to MachineOperand::getType()
[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/Target/MachineInstrInfo.h"
12 #include "llvm/Constant.h"
13 #include "llvm/Function.h"
14 #include "llvm/DerivedTypes.h"
15 #include "llvm/Pass.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17
18 class StackSlots : public FunctionPass {
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 runOnFunction(Function &F) {
32     const Type *PtrInt = PointerType::get(Type::IntTy);
33     unsigned Size = Target.DataLayout.getTypeSize(PtrInt);
34
35     MachineFunction &mcInfo = MachineFunction::get(&F);
36     Value *V = Constant::getNullValue(Type::IntTy);
37     mcInfo.allocateLocalVar(Target, V, 2*Size);
38     return true;
39   }
40 };
41
42 Pass *createStackSlotsPass(const TargetMachine &Target) {
43   return new StackSlots(Target);
44 }