Initial version: it adds 2 empty slots at the top of stack
[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.
4 // These two slots are later used during code reoptimization
5 // for spilling the resgiter values when rewriting branches. 
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/Target/TargetMachine.h"
10 #include "llvm/Target/MachineInstrInfo.h"
11 #include "llvm/Constants.h"
12 #include "llvm/Function.h"
13 #include "llvm/DerivedTypes.h"
14 #include "llvm/Pass.h"
15 #include "llvm/CodeGen/MachineCodeForMethod.h"
16
17 using std::map;
18 using std::cerr;
19
20
21 class StackSlots : public FunctionPass{
22 private:
23   const TargetMachine ⌖
24 public:
25   StackSlots (const TargetMachine &T): target(T) {}
26
27   bool runOnFunction(Function &F) {
28     Value *v = ConstantSInt::get(Type::IntTy,0);
29     MachineCodeForMethod &mcInfo = MachineCodeForMethod::get(&F);
30     mcInfo.allocateLocalVar
31       (target, v, 2*target.DataLayout.getTypeSize(PointerType::get(Type::IntTy)));
32     
33     return true;
34   }
35 };
36
37
38 Pass* createStackSlotsPass(TargetMachine &T){
39   return new StackSlots(T);
40 }
41