Great renaming part II: Sparc --> SparcV9 (also includes command-line options and...
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9StackSlots.cpp
1 //===- StackSlots.cpp  - Specialize LLVM code for target machine ----------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass adds 2 empty slots at the top of function stack.  These two slots
11 // are later used during code reoptimization for spilling the register values
12 // when rewriting branches.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "SparcV9Internals.h"
17 #include "llvm/Constant.h"
18 #include "llvm/DerivedTypes.h"
19 #include "llvm/Function.h"
20 #include "llvm/CodeGen/MachineFunctionInfo.h"
21 #include "llvm/CodeGen/MachineFunctionPass.h"
22
23 namespace llvm {
24
25 namespace {
26   class StackSlots : public MachineFunctionPass {
27     const TargetMachine &Target;
28   public:
29     StackSlots(const TargetMachine &T) : Target(T) {}
30     
31     const char *getPassName() const {
32       return "Stack Slot Insertion for profiling code";
33     }
34     
35     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
36       AU.setPreservesCFG();
37     }
38     
39     bool runOnMachineFunction(MachineFunction &MF) {
40       const Type *PtrInt = PointerType::get(Type::IntTy);
41       unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
42       
43       Value *V = Constant::getNullValue(Type::IntTy);
44       MF.getInfo()->allocateLocalVar(V, 2*Size);
45       return true;
46     }
47   };
48 }
49
50 Pass *createStackSlotsPass(const TargetMachine &Target) {
51   return new StackSlots(Target);
52 }
53
54 } // End llvm namespace