blob: 053d5013b00d3a3f9e5e9e46ef65f6b232f72a64 [file] [log] [blame]
Anand Shukla33db9ba2002-09-21 04:58:26 +00001//===- StackSlots.cpp - Specialize LLVM code for target machine ---------===//
2//
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.
6//
7//===----------------------------------------------------------------------===//
8
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"
16
17using std::map;
18using std::cerr;
19
20
21class StackSlots : public FunctionPass{
22private:
23 const TargetMachine ⌖
24public:
25 StackSlots (const TargetMachine &T): target(T) {}
26
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)));
32
33 return true;
34 }
35};
36
37
38Pass* createStackSlotsPass(TargetMachine &T){
39 return new StackSlots(T);
40}
41