summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-31 18:16:33 +0000
committerDan Gohman <gohman@apple.com>2009-07-31 18:16:33 +0000
commitad2afc2a421a0e41603d5eee412d4d8c77e9bc1c (patch)
treef06c032e6c95e27a621685fb4a2a2f07469ca076 /include/llvm
parent56594f98848ac6d1885662644b5652c04c0d0831 (diff)
downloadllvm-ad2afc2a421a0e41603d5eee412d4d8c77e9bc1c.tar.gz
llvm-ad2afc2a421a0e41603d5eee412d4d8c77e9bc1c.tar.bz2
llvm-ad2afc2a421a0e41603d5eee412d4d8c77e9bc1c.tar.xz
Reapply r77654 with a fix: MachineFunctionPass's getAnalysisUsage
shouldn't do AU.setPreservesCFG(), because even though CodeGen passes don't modify the LLVM IR CFG, they may modify the MachineFunction CFG, and passes like MachineLoop are registered with isCFGOnly set to true. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/CodeGen/LazyLiveness.h1
-rw-r--r--include/llvm/CodeGen/MachineFunction.h21
-rw-r--r--include/llvm/CodeGen/MachineFunctionAnalysis.h49
-rw-r--r--include/llvm/CodeGen/MachineFunctionPass.h16
-rw-r--r--include/llvm/CodeGen/Passes.h5
-rw-r--r--include/llvm/CodeGen/SelectionDAGISel.h5
-rw-r--r--include/llvm/Function.h3
7 files changed, 68 insertions, 32 deletions
diff --git a/include/llvm/CodeGen/LazyLiveness.h b/include/llvm/CodeGen/LazyLiveness.h
index 82e4a153d5..388b638109 100644
--- a/include/llvm/CodeGen/LazyLiveness.h
+++ b/include/llvm/CodeGen/LazyLiveness.h
@@ -34,6 +34,7 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<MachineDominatorTree>();
+ MachineFunctionPass::getAnalysisUsage(AU);
}
bool runOnMachineFunction(MachineFunction &mf);
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index ea6a384d22..b306583a5a 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -67,7 +67,7 @@ struct MachineFunctionInfo {
};
class MachineFunction : private Annotation {
- const Function *Fn;
+ Function *Fn;
const TargetMachine &Target;
// RegInfo - Information about each register in use in the function.
@@ -115,12 +115,12 @@ class MachineFunction : private Annotation {
unsigned Alignment;
public:
- MachineFunction(const Function *Fn, const TargetMachine &TM);
+ MachineFunction(Function *Fn, const TargetMachine &TM);
~MachineFunction();
/// getFunction - Return the LLVM function that this machine code represents
///
- const Function *getFunction() const { return Fn; }
+ Function *getFunction() const { return Fn; }
/// getTarget - Return the target machine this machine code is compiled with
///
@@ -229,21 +229,6 @@ public:
///
void dump() const;
- /// construct - Allocate and initialize a MachineFunction for a given Function
- /// and Target
- ///
- static MachineFunction& construct(const Function *F, const TargetMachine &TM);
-
- /// destruct - Destroy the MachineFunction corresponding to a given Function
- ///
- static void destruct(const Function *F);
-
- /// get - Return a handle to a MachineFunction corresponding to the given
- /// Function. This should not be called before "construct()" for a given
- /// Function.
- ///
- static MachineFunction& get(const Function *F);
-
// Provide accessors for the MachineBasicBlock list...
typedef BasicBlockListType::iterator iterator;
typedef BasicBlockListType::const_iterator const_iterator;
diff --git a/include/llvm/CodeGen/MachineFunctionAnalysis.h b/include/llvm/CodeGen/MachineFunctionAnalysis.h
new file mode 100644
index 0000000000..5f1ff56af9
--- /dev/null
+++ b/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -0,0 +1,49 @@
+//===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the MachineFunctionAnalysis class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
+#define LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
+
+#include "llvm/Pass.h"
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+
+class MachineFunction;
+
+/// MachineFunctionAnalysis - This class is a Pass that manages a
+/// MachineFunction object.
+struct MachineFunctionAnalysis : public FunctionPass {
+private:
+ const TargetMachine &TM;
+ CodeGenOpt::Level OptLevel;
+ MachineFunction *MF;
+
+public:
+ static char ID;
+ explicit MachineFunctionAnalysis(TargetMachine &tm,
+ CodeGenOpt::Level OL = CodeGenOpt::Default);
+
+
+ MachineFunction &getMF() const { return *MF; }
+ CodeGenOpt::Level getOptLevel() const { return OptLevel; }
+
+private:
+ virtual bool runOnFunction(Function &F);
+ virtual void releaseMemory();
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+};
+
+} // End llvm namespace
+
+#endif
diff --git a/include/llvm/CodeGen/MachineFunctionPass.h b/include/llvm/CodeGen/MachineFunctionPass.h
index 6b5e64abc4..6f7c216382 100644
--- a/include/llvm/CodeGen/MachineFunctionPass.h
+++ b/include/llvm/CodeGen/MachineFunctionPass.h
@@ -24,19 +24,25 @@
namespace llvm {
- // FIXME: This pass should declare that the pass does not invalidate any LLVM
- // passes.
-struct MachineFunctionPass : public FunctionPass {
+/// MachineFunctionPass - This class adapts the FunctionPass interface to
+/// allow convenient creation of passes that operate on the MachineFunction
+/// representation. Instead of overriding runOnFunction, subclasses
+/// override runOnMachineFunction.
+class MachineFunctionPass : public FunctionPass {
+protected:
explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
-protected:
/// runOnMachineFunction - This method must be overloaded to perform the
/// desired machine code transformation or analysis.
///
virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
-public:
+ /// getAnalysisUsage - Subclasses that override getAnalysisUsage
+ /// must call this.
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+
+private:
bool runOnFunction(Function &F);
};
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index e0ac416978..fa570b5855 100644
--- a/include/llvm/CodeGen/Passes.h
+++ b/include/llvm/CodeGen/Passes.h
@@ -146,11 +146,6 @@ namespace llvm {
/// by seeing if the labels map to the same reduced label.
FunctionPass *createDebugLabelFoldingPass();
- /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
- /// the current function, which should happen after the function has been
- /// emitted to a .s file or to memory.
- FunctionPass *createMachineCodeDeleter();
-
/// getRegisterAllocator - This creates an instance of the register allocator
/// for the Sparc.
FunctionPass *getRegisterAllocator(TargetMachine &T);
diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h
index d2c0dc420f..51f90acba4 100644
--- a/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/include/llvm/CodeGen/SelectionDAGISel.h
@@ -19,6 +19,7 @@
#include "llvm/Pass.h"
#include "llvm/Constant.h"
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
namespace llvm {
class FastISel;
@@ -39,7 +40,7 @@ namespace llvm {
/// SelectionDAGISel - This is the common base class used for SelectionDAG-based
/// pattern-matching instruction selectors.
-class SelectionDAGISel : public FunctionPass {
+class SelectionDAGISel : public MachineFunctionPass {
public:
const TargetMachine &TM;
TargetLowering &TLI;
@@ -62,7 +63,7 @@ public:
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
- virtual bool runOnFunction(Function &Fn);
+ virtual bool runOnMachineFunction(MachineFunction &MF);
unsigned MakeReg(MVT VT);
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 57ebfb10a5..90d9b0ee46 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -21,7 +21,6 @@
#include "llvm/GlobalValue.h"
#include "llvm/BasicBlock.h"
#include "llvm/Argument.h"
-#include "llvm/Support/Annotation.h"
#include "llvm/Attributes.h"
namespace llvm {
@@ -66,7 +65,7 @@ private:
mutable ilist_node<Argument> Sentinel;
};
-class Function : public GlobalValue, public Annotable,
+class Function : public GlobalValue,
public ilist_node<Function> {
public:
typedef iplist<Argument> ArgumentListType;