aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-26 06:28:43 +0000
committerChris Lattner <sabre@nondot.org>2010-01-26 06:28:43 +0000
commit589c6f620e8dcf3d59af1ae0e15372c934647c82 (patch)
tree416f671c04eaddff62cc5fa28c6842862157b44c /lib/CodeGen/MachineFunction.cpp
parentbeeb93e6ba48af2661eabc4872d8b159fb43e5db (diff)
Move getJTISymbol from MachineJumpTableInfo to MachineFunction,
which is more convenient, and change getPICJumpTableRelocBaseExpr to take a MachineFunction to match. Next, move the X86 code that create a PICBase symbol to X86TargetLowering::getPICBaseSymbol from X86MCInstLower::GetPICBaseSymbol, which was an asmprinter specific library. This eliminates a 'gross hack', and allows us to implement X86ISelLowering::getPICJumpTableRelocBaseExpr which now calls it. This in turn allows us to eliminate the X86AsmPrinter::printPICJumpTableSetLabel method, which was the only overload of printPICJumpTableSetLabel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
-rw-r--r--lib/CodeGen/MachineFunction.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index deb639d542..511f4aed4c 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -445,6 +445,27 @@ DILocation MachineFunction::getDILocation(DebugLoc DL) const {
return DILocation(DebugLocInfo.DebugLocations[Idx]);
}
+
+/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
+/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
+/// normal 'L' label is returned.
+MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
+ bool isLinkerPrivate) const {
+ assert(JumpTableInfo && "No jump tables");
+
+ const std::vector<MachineJumpTableEntry> &JTs =JumpTableInfo->getJumpTables();
+ assert(JTI < JTs.size() && "Invalid JTI!");
+ const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
+
+ const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
+ MAI.getPrivateGlobalPrefix();
+ SmallString<60> Name;
+ raw_svector_ostream(Name)
+ << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
+ return Ctx.GetOrCreateSymbol(Name.str());
+}
+
+
//===----------------------------------------------------------------------===//
// MachineFrameInfo implementation
//===----------------------------------------------------------------------===//
@@ -581,24 +602,6 @@ unsigned MachineJumpTableInfo::getJumpTableIndex(
return JumpTables.size()-1;
}
-/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
-/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
-/// normal 'L' label is returned.
-MCSymbol *MachineJumpTableInfo::getJTISymbol(unsigned JTI, MCContext &Ctx,
- bool isLinkerPrivate) const {
- assert(JTI < JumpTables.size() && !JumpTables[JTI].MBBs.empty() &&
- "Invalid JTI!");
- const MachineFunction *MF = JumpTables[JTI].MBBs[0]->getParent();
- const MCAsmInfo &MAI = *MF->getTarget().getMCAsmInfo();
-
- const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
- MAI.getPrivateGlobalPrefix();
- SmallString<60> Name;
- raw_svector_ostream(Name)
- << Prefix << "JTI" << MF->getFunctionNumber() << '_' << JTI;
- return Ctx.GetOrCreateSymbol(Name.str());
-}
-
/// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update
/// the jump tables to branch to New instead.