[llvm-commits] [llvm] r94509 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineFunction.h include/llvm/CodeGen/MachineFunctionAnalysis.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineFunctionAnalysis.cpp lib/Target/X86/X86CodeEmitter.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 25 20:35:27 PST 2010
Author: lattner
Date: Mon Jan 25 22:35:26 2010
New Revision: 94509
URL: http://llvm.org/viewvc/llvm-project?rev=94509&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/MachineFunction.cpp
llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Jan 25 22:35:26 2010
@@ -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 @@
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 @@
/// 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 @@
/// 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
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Mon Jan 25 22:35:26 2010
@@ -112,6 +112,11 @@
// 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 @@
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; }
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h Mon Jan 25 22:35:26 2010
@@ -28,7 +28,7 @@
const TargetMachine &TM;
CodeGenOpt::Level OptLevel;
MachineFunction *MF;
-
+ unsigned NextFnNum;
public:
static char ID;
explicit MachineFunctionAnalysis(const TargetMachine &tm,
@@ -39,6 +39,7 @@
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;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan 25 22:35:26 2010
@@ -64,7 +64,7 @@
char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
const MCAsmInfo *T, bool VDef)
- : MachineFunctionPass(&ID), FunctionNumber(0), O(o),
+ : MachineFunctionPass(&ID), O(o),
TM(tm), MAI(T), TRI(tm.getRegisterInfo()),
OutContext(*new MCContext()),
@@ -87,6 +87,12 @@
delete &OutContext;
}
+/// getFunctionNumber - Return a unique ID for the current function.
+///
+unsigned AsmPrinter::getFunctionNumber() const {
+ return MF->getFunctionNumber();
+}
+
TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const {
return TM.getTargetLowering()->getObjFileLowering();
}
@@ -359,9 +365,9 @@
}
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
+ this->MF = &MF;
// Get the function symbol.
CurrentFnSym = GetGlobalValueSymbol(MF.getFunction());
- IncrementFunctionNumber();
if (VerboseAsm)
LI = &getAnalysis<MachineLoopInfo>();
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Jan 25 22:35:26 2010
@@ -70,9 +70,9 @@
return new Printer(OS, Banner);
}
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
// MachineFunction implementation
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
// Out of line virtual method.
MachineFunctionInfo::~MachineFunctionInfo() {}
@@ -81,8 +81,8 @@
MBB->getParent()->DeleteMachineBasicBlock(MBB);
}
-MachineFunction::MachineFunction(Function *F,
- const TargetMachine &TM)
+MachineFunction::MachineFunction(Function *F, const TargetMachine &TM,
+ unsigned FunctionNum)
: Fn(F), Target(TM) {
if (TM.getRegisterInfo())
RegInfo = new (Allocator.Allocate<MachineRegisterInfo>())
@@ -95,7 +95,7 @@
ConstantPool = new (Allocator.Allocate<MachineConstantPool>())
MachineConstantPool(TM.getTargetData());
Alignment = TM.getTargetLowering()->getFunctionAlignment(F);
-
+ FunctionNumber = FunctionNum;
JumpTableInfo = 0;
}
Modified: llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp Mon Jan 25 22:35:26 2010
@@ -36,7 +36,7 @@
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
assert(!MF && "MachineFunctionAnalysis already initialized!");
- MF = new MachineFunction(&F, TM);
+ MF = new MachineFunction(&F, TM, NextFnNum++);
return false;
}
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=94509&r1=94508&r2=94509&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Jan 25 22:35:26 2010
@@ -921,7 +921,7 @@
FunctionType::get(llvm::Type::getVoidTy(getGlobalContext()), false);
DummyF = Function::Create(FTy, GlobalValue::InternalLinkage);
DummyTD = new TargetData("");
- DummyMF = new MachineFunction(DummyF, TM);
+ DummyMF = new MachineFunction(DummyF, TM, 0);
DummyMBB = DummyMF->CreateMachineBasicBlock();
InstrEmitter = new MCSingleInstructionCodeEmitter();
More information about the llvm-commits
mailing list