1 //===- SparcV9StackSlots.cpp - Add empty stack slots to functions ---------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
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"
26 class StackSlots : public MachineFunctionPass {
27 const TargetMachine &Target;
29 StackSlots(const TargetMachine &T) : Target(T) {}
31 const char *getPassName() const {
32 return "Stack Slot Insertion for profiling code";
35 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
39 bool runOnMachineFunction(MachineFunction &MF) {
40 const Type *PtrInt = PointerType::get(Type::IntTy);
41 unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
43 Value *V = Constant::getNullValue(Type::IntTy);
44 MF.getInfo()->allocateLocalVar(V, 2*Size);
50 Pass *createStackSlotsPass(const TargetMachine &Target) {
51 return new StackSlots(Target);
54 } // End llvm namespace