aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-26 04:35:26 +0000
committerChris Lattner <sabre@nondot.org>2010-01-26 04:35:26 +0000
commitb84822fb7b64977c16e97b870891da1d6c9736fe (patch)
treefb43db9cabf515f2751c5c0aeb5e362a63fbc017 /include/llvm/CodeGen
parentb8da4ac698dbb219e093b3159e2b5519063b011c (diff)
downloadexternal_llvm-b84822fb7b64977c16e97b870891da1d6c9736fe.tar.gz
external_llvm-b84822fb7b64977c16e97b870891da1d6c9736fe.tar.bz2
external_llvm-b84822fb7b64977c16e97b870891da1d6c9736fe.zip
make MachineFunction keep track of its ID and make
MachineFunctionAnalysis dole them out, instead of having AsmPrinter do both. Have the AsmPrinter::SetupMachineFunction method set the 'AsmPrinter::MF' variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h15
-rw-r--r--include/llvm/CodeGen/MachineFunction.h11
-rw-r--r--include/llvm/CodeGen/MachineFunctionAnalysis.h3
3 files changed, 13 insertions, 16 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 7432a83dc0..696b704851 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -19,7 +19,6 @@
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/DebugLoc.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/ADT/DenseMap.h"
namespace llvm {
class BlockAddress;
@@ -62,13 +61,6 @@ namespace llvm {
class AsmPrinter : public MachineFunctionPass {
static char ID;
- /// FunctionNumber - This provides a unique ID for each function emitted in
- /// this translation unit. It is autoincremented by SetupMachineFunction,
- /// and can be accessed with getFunctionNumber() and
- /// IncrementFunctionNumber().
- ///
- unsigned FunctionNumber;
-
// GCMetadataPrinters - The garbage collection metadata printer table.
typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type;
typedef gcp_map_type::iterator gcp_iterator;
@@ -168,7 +160,7 @@ namespace llvm {
/// getFunctionNumber - Return a unique ID for the current function.
///
- unsigned getFunctionNumber() const { return FunctionNumber; }
+ unsigned getFunctionNumber() const;
protected:
/// getAnalysisUsage - Record analysis usage.
@@ -219,11 +211,6 @@ namespace llvm {
/// is being processed from runOnMachineFunction.
void SetupMachineFunction(MachineFunction &MF);
- /// IncrementFunctionNumber - Increase Function Number. AsmPrinters should
- /// not normally call this, as the counter is automatically bumped by
- /// SetupMachineFunction.
- void IncrementFunctionNumber() { FunctionNumber++; }
-
/// EmitConstantPool - Print to the current output stream assembly
/// representations of the constants in the constant pool MCP. This is
/// used to print out constants which have been "spilled to memory" by
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index d2e89acc7c..85e4fb4e11 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -112,6 +112,11 @@ class MachineFunction {
// Tracks debug locations.
DebugLocTracker DebugLocInfo;
+ /// FunctionNumber - This provides a unique ID for each function emitted in
+ /// this translation unit.
+ ///
+ unsigned FunctionNumber;
+
// The alignment of the function.
unsigned Alignment;
@@ -119,13 +124,17 @@ class MachineFunction {
void operator=(const MachineFunction&); // intentionally unimplemented
public:
- MachineFunction(Function *Fn, const TargetMachine &TM);
+ MachineFunction(Function *Fn, const TargetMachine &TM, unsigned FunctionNum);
~MachineFunction();
/// getFunction - Return the LLVM function that this machine code represents
///
Function *getFunction() const { return Fn; }
+ /// getFunctionNumber - Return a unique ID for the current function.
+ ///
+ unsigned getFunctionNumber() const { return FunctionNumber; }
+
/// getTarget - Return the target machine this machine code is compiled with
///
const TargetMachine &getTarget() const { return Target; }
diff --git a/include/llvm/CodeGen/MachineFunctionAnalysis.h b/include/llvm/CodeGen/MachineFunctionAnalysis.h
index aa4cc9176b..ee2c6ddc81 100644
--- a/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -28,7 +28,7 @@ private:
const TargetMachine &TM;
CodeGenOpt::Level OptLevel;
MachineFunction *MF;
-
+ unsigned NextFnNum;
public:
static char ID;
explicit MachineFunctionAnalysis(const TargetMachine &tm,
@@ -39,6 +39,7 @@ public:
CodeGenOpt::Level getOptLevel() const { return OptLevel; }
private:
+ virtual bool doInitialization(Module &) { NextFnNum = 1; return false; }
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;