1 //===- StackSlots.cpp - Specialize LLVM code for target machine ---------===//
3 // This pass adds 2 empty slots at the top of function stack.
4 // These two slots are later used during code reoptimization
5 // for spilling the resgiter values when rewriting branches.
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Target/TargetMachine.h"
10 #include "llvm/Target/MachineInstrInfo.h"
11 #include "llvm/Constants.h"
12 #include "llvm/Function.h"
13 #include "llvm/DerivedTypes.h"
14 #include "llvm/Pass.h"
15 #include "llvm/CodeGen/MachineCodeForMethod.h"
21 class StackSlots : public FunctionPass{
23 const TargetMachine ⌖
25 StackSlots (const TargetMachine &T): target(T) {}
27 bool runOnFunction(Function &F) {
28 Value *v = ConstantSInt::get(Type::IntTy,0);
29 MachineCodeForMethod &mcInfo = MachineCodeForMethod::get(&F);
30 mcInfo.allocateLocalVar
31 (target, v, 2*target.DataLayout.getTypeSize(PointerType::get(Type::IntTy)));
38 Pass* createStackSlotsPass(TargetMachine &T){
39 return new StackSlots(T);