1 //===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the definitions of the MachineFunctionAnalysis members.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
19 // Register this pass with PassInfo directly to avoid having to define
20 // a default constructor.
22 X("Machine Function Analysis", "machine-function-analysis",
23 intptr_t(&MachineFunctionAnalysis::ID), 0,
24 /*CFGOnly=*/false, /*is_analysis=*/true);
26 char MachineFunctionAnalysis::ID = 0;
28 MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm,
29 CodeGenOpt::Level OL) :
30 FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) {
33 MachineFunctionAnalysis::~MachineFunctionAnalysis() {
35 assert(!MF && "MachineFunctionAnalysis left initialized!");
38 void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
40 AU.addRequired<MachineModuleInfo>();
43 bool MachineFunctionAnalysis::doInitialization(Module &M) {
44 MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
45 assert(MMI && "MMI not around yet??");
52 bool MachineFunctionAnalysis::runOnFunction(Function &F) {
53 assert(!MF && "MachineFunctionAnalysis already initialized!");
54 MF = new MachineFunction(&F, TM, NextFnNum++,
55 getAnalysis<MachineModuleInfo>());
59 void MachineFunctionAnalysis::releaseMemory() {