freebsd-nq/contrib/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp

61 lines
1.9 KiB
C++
Raw Normal View History

2009-10-14 17:57:32 +00:00
//===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the definitions of the MachineFunctionAnalysis members.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/GCMetadata.h"
2009-10-14 17:57:32 +00:00
#include "llvm/CodeGen/MachineFunction.h"
2010-03-16 16:51:38 +00:00
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineFunctionInitializer.h"
2009-10-14 17:57:32 +00:00
using namespace llvm;
char MachineFunctionAnalysis::ID = 0;
MachineFunctionAnalysis::MachineFunctionAnalysis(
const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)
: FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) {
initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
2009-10-14 17:57:32 +00:00
}
MachineFunctionAnalysis::~MachineFunctionAnalysis() {
releaseMemory();
assert(!MF && "MachineFunctionAnalysis left initialized!");
}
2010-04-06 15:52:58 +00:00
void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
}
bool MachineFunctionAnalysis::doInitialization(Module &M) {
MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
assert(MMI && "MMI not around yet??");
MMI->setModule(&M);
2010-05-04 16:11:02 +00:00
NextFnNum = 0;
return false;
2010-04-06 15:52:58 +00:00
}
2009-10-14 17:57:32 +00:00
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
assert(!MF && "MachineFunctionAnalysis already initialized!");
2010-03-16 16:51:38 +00:00
MF = new MachineFunction(&F, TM, NextFnNum++,
getAnalysis<MachineModuleInfo>());
if (MFInitializer)
MFInitializer->initializeMachineFunction(*MF);
2009-10-14 17:57:32 +00:00
return false;
}
void MachineFunctionAnalysis::releaseMemory() {
delete MF;
MF = nullptr;
2009-10-14 17:57:32 +00:00
}