Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 1 | //===-- 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" |
| 16 | using namespace llvm; |
| 17 | |
| 18 | // Register this pass with PassInfo directly to avoid having to define |
| 19 | // a default constructor. |
| 20 | static PassInfo |
| 21 | X("Machine Function Analysis", "machine-function-analysis", |
| 22 | intptr_t(&MachineFunctionAnalysis::ID), 0, |
| 23 | /*CFGOnly=*/false, /*is_analysis=*/true); |
| 24 | |
| 25 | char MachineFunctionAnalysis::ID = 0; |
| 26 | |
Dan Gohman | 28a4c78 | 2009-11-09 18:18:49 +0000 | [diff] [blame^] | 27 | MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm, |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 28 | CodeGenOpt::Level OL) : |
| 29 | FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) { |
| 30 | } |
| 31 | |
Dan Gohman | f940833 | 2009-08-01 04:19:43 +0000 | [diff] [blame] | 32 | MachineFunctionAnalysis::~MachineFunctionAnalysis() { |
Chris Lattner | f5e1613 | 2009-10-12 04:22:44 +0000 | [diff] [blame] | 33 | releaseMemory(); |
Dan Gohman | f940833 | 2009-08-01 04:19:43 +0000 | [diff] [blame] | 34 | assert(!MF && "MachineFunctionAnalysis left initialized!"); |
| 35 | } |
| 36 | |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 37 | bool MachineFunctionAnalysis::runOnFunction(Function &F) { |
| 38 | assert(!MF && "MachineFunctionAnalysis already initialized!"); |
| 39 | MF = new MachineFunction(&F, TM); |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | void MachineFunctionAnalysis::releaseMemory() { |
| 44 | delete MF; |
| 45 | MF = 0; |
| 46 | } |
| 47 | |
| 48 | void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { |
| 49 | AU.setPreservesAll(); |
| 50 | } |