1 //===- StackSlots.cpp - Specialize LLVM code for target machine ---------===//
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 "SparcInternals.h"
17 #include "llvm/Constant.h"
18 #include "llvm/Function.h"
19 #include "llvm/DerivedTypes.h"
20 #include "llvm/CodeGen/MachineFunctionPass.h"
21 #include "llvm/CodeGen/MachineFunctionInfo.h"
24 class StackSlots : public MachineFunctionPass {
25 const TargetMachine &Target;
27 StackSlots(const TargetMachine &T) : Target(T) {}
29 const char *getPassName() const {
30 return "Stack Slot Insertion for profiling code";
33 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
37 bool runOnMachineFunction(MachineFunction &MF) {
38 const Type *PtrInt = PointerType::get(Type::IntTy);
39 unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
41 Value *V = Constant::getNullValue(Type::IntTy);
42 MF.getInfo()->allocateLocalVar(V, 2*Size);
48 Pass *createStackSlotsPass(const TargetMachine &Target) {
49 return new StackSlots(Target);