blob: d3f1d8296daad7029d48cfd5f37a10473dd75dc2 [file] [log] [blame]
Dan Gohmanad2afc22009-07-31 18:16:33 +00001//===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the definitions of the MachineFunctionAnalysis members.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/CodeGen/MachineFunctionAnalysis.h"
15#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner11d53c12010-03-13 20:55:24 +000016#include "llvm/CodeGen/MachineModuleInfo.h"
Dan Gohmanad2afc22009-07-31 18:16:33 +000017using namespace llvm;
18
19// Register this pass with PassInfo directly to avoid having to define
20// a default constructor.
21static PassInfo
22X("Machine Function Analysis", "machine-function-analysis",
23 intptr_t(&MachineFunctionAnalysis::ID), 0,
24 /*CFGOnly=*/false, /*is_analysis=*/true);
25
26char MachineFunctionAnalysis::ID = 0;
27
Dan Gohman28a4c782009-11-09 18:18:49 +000028MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm,
Dan Gohmanad2afc22009-07-31 18:16:33 +000029 CodeGenOpt::Level OL) :
30 FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) {
31}
32
Dan Gohmanf9408332009-08-01 04:19:43 +000033MachineFunctionAnalysis::~MachineFunctionAnalysis() {
Chris Lattnerf5e16132009-10-12 04:22:44 +000034 releaseMemory();
Dan Gohmanf9408332009-08-01 04:19:43 +000035 assert(!MF && "MachineFunctionAnalysis left initialized!");
36}
37
Dan Gohmanad2afc22009-07-31 18:16:33 +000038bool MachineFunctionAnalysis::runOnFunction(Function &F) {
39 assert(!MF && "MachineFunctionAnalysis already initialized!");
Chris Lattner11d53c12010-03-13 20:55:24 +000040 MF = new MachineFunction(&F, TM, NextFnNum++,
41 getAnalysis<MachineModuleInfo>().getContext());
Dan Gohmanad2afc22009-07-31 18:16:33 +000042 return false;
43}
44
45void MachineFunctionAnalysis::releaseMemory() {
46 delete MF;
47 MF = 0;
48}
49
50void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
51 AU.setPreservesAll();
Chris Lattner11d53c12010-03-13 20:55:24 +000052 AU.addRequired<MachineModuleInfo>();
Dan Gohmanad2afc22009-07-31 18:16:33 +000053}