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/MachineFunctionPass.h"
21 #include "MachineFunctionInfo.h"
25 class StackSlots : public MachineFunctionPass {
26 const TargetMachine &Target;
28 StackSlots(const TargetMachine &T) : Target(T) {}
30 const char *getPassName() const {
31 return "Stack Slot Insertion for profiling code";
34 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
38 bool runOnMachineFunction(MachineFunction &MF) {
39 const Type *PtrInt = PointerType::get(Type::IntTy);
40 unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
42 Value *V = Constant::getNullValue(Type::IntTy);
43 MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size);
49 Pass *llvm::createStackSlotsPass(const TargetMachine &Target) {
50 return new StackSlots(Target);