diff options
author | Chris Lattner <sabre@nondot.org> | 2007-01-18 01:12:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-01-18 01:12:56 +0000 |
commit | 393a8eea3c15de08eaf6953aa8a65a3961b76153 (patch) | |
tree | 8a3d3ca7b22f32e9c4b40826234539682dd0c42a | |
parent | a10dc506c0ea79a9689101edb37b2de6c36aa188 (diff) |
add new JumpTableSpecialLabelPrefix hook to asmprinter for jumptable emission.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33314 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Target/TargetAsmInfo.h | 7 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 10 | ||||
-rw-r--r-- | lib/Target/TargetAsmInfo.cpp | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index 1218330902..f58eb70906 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/include/llvm/Target/TargetAsmInfo.h @@ -78,6 +78,10 @@ namespace llvm { /// have names in the .o file. This is often "." or "L". const char *PrivateGlobalPrefix; // Defaults to "." + /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is + /// emitted before jump tables with the specified prefix. + const char *JumpTableSpecialLabelPrefix; // Default to null. + /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings /// will enclose any GlobalVariable (that isn't a function) /// @@ -343,6 +347,9 @@ namespace llvm { const char *getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; } + const char *getJumpTableSpecialLabelPrefix() const { + return JumpTableSpecialLabelPrefix; + } const char *getGlobalVarAddrPrefix() const { return GlobalVarAddrPrefix; } diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index caa9da0d2f..a9e720149e 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -244,6 +244,13 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI, if (EmittedSets.insert(JTBBs[ii]).second) printSetLabel(i, JTBBs[ii]); + // On some targets (e.g. darwin) we want to emit two consequtive labels + // before each jump table. The first label is never referenced, but tells + // the assembler and linker the extents of the jump table object. The + // second label is actually referenced by the code. + if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix()) + O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n"; + O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << i << ":\n"; @@ -259,7 +266,8 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI, << '_' << i << "_set_" << JTBBs[ii]->getNumber(); } else if (IsPic) { printBasicBlockLabel(JTBBs[ii], false, false); - //If the arch uses custom Jump Table directives, don't calc relative to JT + // If the arch uses custom Jump Table directives, don't calc relative to + // JT if (!HadJTEntryDirective) O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << i; diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp index 3afbddb89c..45ea0eed4d 100644 --- a/lib/Target/TargetAsmInfo.cpp +++ b/lib/Target/TargetAsmInfo.cpp @@ -28,6 +28,7 @@ TargetAsmInfo::TargetAsmInfo() : CommentString("#"), GlobalPrefix(""), PrivateGlobalPrefix("."), + JumpTableSpecialLabelPrefix(0), GlobalVarAddrPrefix(""), GlobalVarAddrSuffix(""), FunctionAddrPrefix(""), |