2004-04-25 09:04:49 +02:00
|
|
|
//===- SparcV9StackSlots.cpp - Add empty stack slots to functions ---------===//
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-09-21 06:58:26 +02:00
|
|
|
//
|
2002-10-23 03:12:01 +02:00
|
|
|
// This pass adds 2 empty slots at the top of function stack. These two slots
|
|
|
|
// are later used during code reoptimization for spilling the register values
|
|
|
|
// when rewriting branches.
|
2002-09-21 06:58:26 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-02-25 20:08:12 +01:00
|
|
|
#include "SparcV9Internals.h"
|
2002-10-23 03:12:01 +02:00
|
|
|
#include "llvm/Constant.h"
|
2002-09-21 06:58:26 +02:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2003-11-06 19:06:13 +01:00
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2004-08-16 23:55:02 +02:00
|
|
|
#include "MachineFunctionInfo.h"
|
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2002-12-28 21:42:56 +01:00
|
|
|
namespace {
|
2003-01-14 23:00:31 +01:00
|
|
|
class StackSlots : public MachineFunctionPass {
|
2002-12-28 21:42:56 +01:00
|
|
|
const TargetMachine &Target;
|
|
|
|
public:
|
|
|
|
StackSlots(const TargetMachine &T) : Target(T) {}
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-12-28 21:42:56 +01:00
|
|
|
const char *getPassName() const {
|
|
|
|
return "Stack Slot Insertion for profiling code";
|
|
|
|
}
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-12-28 21:42:56 +01:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesCFG();
|
|
|
|
}
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2003-01-14 23:00:31 +01:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) {
|
2002-12-28 21:42:56 +01:00
|
|
|
const Type *PtrInt = PointerType::get(Type::IntTy);
|
|
|
|
unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
|
2005-04-22 01:30:14 +02:00
|
|
|
|
2002-12-28 21:42:56 +01:00
|
|
|
Value *V = Constant::getNullValue(Type::IntTy);
|
2004-08-18 20:13:37 +02:00
|
|
|
MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size);
|
2002-12-28 21:42:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2002-09-21 06:58:26 +02:00
|
|
|
|
2004-09-20 06:48:05 +02:00
|
|
|
FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) {
|
2002-10-23 03:12:01 +02:00
|
|
|
return new StackSlots(Target);
|
2002-09-21 06:58:26 +02:00
|
|
|
}
|
2003-11-11 23:41:34 +01:00
|
|
|
|