aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-13 22:07:30 +0000
committerChris Lattner <sabre@nondot.org>2009-07-13 22:07:30 +0000
commit62c5c5099c1ba41985a7fc82692e4a5af7a9d93c (patch)
tree98a7d3a71a89250251499a1b700134cf957ee6ce /lib
parentf5074ec9634d51472bc6e2114deea0afb6677dd8 (diff)
downloadexternal_llvm-62c5c5099c1ba41985a7fc82692e4a5af7a9d93c.zip
external_llvm-62c5c5099c1ba41985a7fc82692e4a5af7a9d93c.tar.gz
external_llvm-62c5c5099c1ba41985a7fc82692e4a5af7a9d93c.tar.bz2
eliminate a bunch of code in print_pcrel_imm for printing symbols, using
printSymbolOperand instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp99
1 files changed, 26 insertions, 73 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index d8822e3..00a9a1e 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -346,12 +346,26 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
break;
}
case MachineOperand::MO_ExternalSymbol:
- /// NOTE: MO_ExternalSymbol in a non-pcrel_imm context is *only* generated
- /// by _GLOBAL_OFFSET_TABLE_ on X86-32. All others are call operands, which
- /// are pcrel_imm's.
- assert(!Subtarget->is64Bit());
- O << TAI->getGlobalPrefix();
- O << MO.getSymbolName();
+ bool needCloseParen = false;
+ std::string Name(TAI->getGlobalPrefix());
+ Name += MO.getSymbolName();
+
+ if (Name[0] == '$') {
+ // The name begins with a dollar-sign. In order to avoid having it look
+ // like an integer immediate to the assembler, enclose it in parens.
+ O << '(';
+ needCloseParen = true;
+ }
+
+ if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
+ FnStubs.insert(Name);
+ printSuffixedName(Name, "$stub");
+ } else {
+ O << Name;
+ }
+
+ if (needCloseParen)
+ O << ')';
break;
}
@@ -363,6 +377,7 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
case X86II::MO_DARWIN_NONLAZY:
case X86II::MO_DARWIN_HIDDEN_NONLAZY:
case X86II::MO_DLLIMPORT:
+ case X86II::MO_DARWIN_STUB:
// These affect the name of the symbol, not any suffix.
break;
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
@@ -384,6 +399,7 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
case X86II::MO_GOT: O << "@GOT"; break;
case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
+ case X86II::MO_PLT: O << "@PLT"; break;
}
}
@@ -400,76 +416,13 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
case MachineOperand::MO_MachineBasicBlock:
printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm);
return;
-
- case MachineOperand::MO_GlobalAddress: {
- const GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getValueName(GV);
- decorateName(Name, GV);
-
- bool needCloseParen = false;
- if (Name[0] == '$') {
- // The name begins with a dollar-sign. In order to avoid having it look
- // like an integer immediate to the assembler, enclose it in parens.
- O << '(';
- needCloseParen = true;
- }
-
- // Handle dllimport linkage.
- if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
- O << "__imp_" << Name;
- else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
- FnStubs.insert(Name);
- printSuffixedName(Name, "$stub");
- } else {
- O << Name;
- }
-
- if (needCloseParen)
- O << ')';
-
- // Assemble call via PLT for externally visible symbols.
- if (MO.getTargetFlags() == X86II::MO_PLT)
- O << "@PLT";
-
- printOffset(MO.getOffset());
-
+ case MachineOperand::MO_GlobalAddress:
+ printSymbolOperand(MO);
return;
- }
-
- case MachineOperand::MO_ExternalSymbol: {
- bool needCloseParen = false;
- std::string Name(TAI->getGlobalPrefix());
- Name += MO.getSymbolName();
-
- if (Name[0] == '$') {
- // The name begins with a dollar-sign. In order to avoid having it look
- // like an integer immediate to the assembler, enclose it in parens.
- O << '(';
- needCloseParen = true;
- }
-
- if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
- FnStubs.insert(Name);
- printSuffixedName(Name, "$stub");
- } else {
- O << Name;
- }
-
- if (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
- O << " + [.-";
- PrintPICBaseSymbol();
- O << ']';
- }
-
- if (MO.getTargetFlags() == X86II::MO_PLT)
- O << "@PLT";
-
- if (needCloseParen)
- O << ')';
-
+ case MachineOperand::MO_ExternalSymbol:
+ printSymbolOperand(MO);
return;
}
- }
}