diff options
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/LazyLiveness.h | 1 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineFunction.h | 21 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineFunctionAnalysis.h | 49 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineFunctionPass.h | 16 | ||||
-rw-r--r-- | include/llvm/CodeGen/Passes.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGISel.h | 5 |
6 files changed, 67 insertions, 30 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); |