LLVM API Documentation
00001 //===- SparcV9StackSlots.cpp - Add empty stack slots to functions ---------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This pass adds 2 empty slots at the top of function stack. These two slots 00011 // are later used during code reoptimization for spilling the register values 00012 // when rewriting branches. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #include "SparcV9Internals.h" 00017 #include "llvm/Constant.h" 00018 #include "llvm/DerivedTypes.h" 00019 #include "llvm/Function.h" 00020 #include "llvm/CodeGen/MachineFunctionPass.h" 00021 #include "MachineFunctionInfo.h" 00022 using namespace llvm; 00023 00024 namespace { 00025 class StackSlots : public MachineFunctionPass { 00026 const TargetMachine &Target; 00027 public: 00028 StackSlots(const TargetMachine &T) : Target(T) {} 00029 00030 const char *getPassName() const { 00031 return "Stack Slot Insertion for profiling code"; 00032 } 00033 00034 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 00035 AU.setPreservesCFG(); 00036 } 00037 00038 bool runOnMachineFunction(MachineFunction &MF) { 00039 const Type *PtrInt = PointerType::get(Type::IntTy); 00040 unsigned Size = Target.getTargetData().getTypeSize(PtrInt); 00041 00042 Value *V = Constant::getNullValue(Type::IntTy); 00043 MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size); 00044 return true; 00045 } 00046 }; 00047 } 00048 00049 FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) { 00050 return new StackSlots(Target); 00051 } 00052