2004-04-25 15:04:49 +08:00
|
|
|
//===- SparcV9StackSlots.cpp - Add empty stack slots to functions ---------===//
|
2005-04-22 07:30:14 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08: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 07:30:14 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-09-21 12:58:26 +08:00
|
|
|
//
|
2002-10-23 09:12:01 +08: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 12:58:26 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-02-26 03:08:12 +08:00
|
|
|
#include "SparcV9Internals.h"
|
2002-10-23 09:12:01 +08:00
|
|
|
#include "llvm/Constant.h"
|
2002-09-21 12:58:26 +08:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2003-11-07 02:06:13 +08:00
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2004-08-17 05:55:02 +08:00
|
|
|
#include "MachineFunctionInfo.h"
|
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2002-12-29 04:42:56 +08:00
|
|
|
namespace {
|
2003-01-15 06:00:31 +08:00
|
|
|
class StackSlots : public MachineFunctionPass {
|
2002-12-29 04:42:56 +08:00
|
|
|
const TargetMachine &Target;
|
|
|
|
public:
|
|
|
|
StackSlots(const TargetMachine &T) : Target(T) {}
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2002-12-29 04:42:56 +08:00
|
|
|
const char *getPassName() const {
|
|
|
|
return "Stack Slot Insertion for profiling code";
|
|
|
|
}
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2002-12-29 04:42:56 +08:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesCFG();
|
|
|
|
}
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2003-01-15 06:00:31 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) {
|
2002-12-29 04:42:56 +08:00
|
|
|
const Type *PtrInt = PointerType::get(Type::IntTy);
|
|
|
|
unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
|
2005-04-22 07:30:14 +08:00
|
|
|
|
2002-12-29 04:42:56 +08:00
|
|
|
Value *V = Constant::getNullValue(Type::IntTy);
|
2004-08-19 02:13:37 +08:00
|
|
|
MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size);
|
2002-12-29 04:42:56 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2002-09-21 12:58:26 +08:00
|
|
|
|
2004-09-20 12:48:05 +08:00
|
|
|
FunctionPass *llvm::createStackSlotsPass(const TargetMachine &Target) {
|
2002-10-23 09:12:01 +08:00
|
|
|
return new StackSlots(Target);
|
2002-09-21 12:58:26 +08:00
|
|
|
}
|
2003-11-12 06:41:34 +08:00
|
|
|
|