summaryrefslogtreecommitdiff
path: root/lib
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 /lib
parentb8da4ac698dbb219e093b3159e2b5519063b011c (diff)
downloadllvm-b84822fb7b64977c16e97b870891da1d6c9736fe.tar.gz
llvm-b84822fb7b64977c16e97b870891da1d6c9736fe.tar.bz2
llvm-b84822fb7b64977c16e97b870891da1d6c9736fe.tar.xz
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 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp10
-rw-r--r--lib/CodeGen/MachineFunction.cpp10
-rw-r--r--lib/CodeGen/MachineFunctionAnalysis.cpp2
-rw-r--r--lib/Target/X86/X86CodeEmitter.cpp2
4 files changed, 15 insertions, 9 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index fd6d182702..537993373a 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -64,7 +64,7 @@ static bool getVerboseAsm(bool VDef) {
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 @@ AsmPrinter::~AsmPrinter() {
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 @@ bool AsmPrinter::doFinalization(Module &M) {
}
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
+ this->MF = &MF;
// Get the function symbol.
CurrentFnSym = GetGlobalValueSymbol(MF.getFunction());
- IncrementFunctionNumber();
if (VerboseAsm)
LI = &getAnalysis<MachineLoopInfo>();
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index cf3b8f056a..faffe145e1 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -70,9 +70,9 @@ FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS,
return new Printer(OS, Banner);
}
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
// MachineFunction implementation
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
// Out of line virtual method.
MachineFunctionInfo::~MachineFunctionInfo() {}
@@ -81,8 +81,8 @@ void ilist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
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 @@ MachineFunction::MachineFunction(Function *F,
ConstantPool = new (Allocator.Allocate<MachineConstantPool>())
MachineConstantPool(TM.getTargetData());
Alignment = TM.getTargetLowering()->getFunctionAlignment(F);
-
+ FunctionNumber = FunctionNum;
JumpTableInfo = 0;
}
diff --git a/lib/CodeGen/MachineFunctionAnalysis.cpp b/lib/CodeGen/MachineFunctionAnalysis.cpp
index f5febc5a4c..8d87e3e4b1 100644
--- a/lib/CodeGen/MachineFunctionAnalysis.cpp
+++ b/lib/CodeGen/MachineFunctionAnalysis.cpp
@@ -36,7 +36,7 @@ MachineFunctionAnalysis::~MachineFunctionAnalysis() {
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
assert(!MF && "MachineFunctionAnalysis already initialized!");
- MF = new MachineFunction(&F, TM);
+ MF = new MachineFunction(&F, TM, NextFnNum++);
return false;
}
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index 828e872cac..e2c31395b2 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -921,7 +921,7 @@ public:
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();