aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-13 21:53:19 +0000
committerChris Lattner <sabre@nondot.org>2009-07-13 21:53:19 +0000
commitf666c094e99a3f5509ac8182622373ddde529ded (patch)
treef5c8a1d5152502e7a17e5461c0fe37c7eac068bb
parentc8d76d5afb023a1c6b439941be3b62789fcc0ed3 (diff)
downloadexternal_llvm-f666c094e99a3f5509ac8182622373ddde529ded.zip
external_llvm-f666c094e99a3f5509ac8182622373ddde529ded.tar.gz
external_llvm-f666c094e99a3f5509ac8182622373ddde529ded.tar.bz2
move a method and add a comment, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75520 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp175
1 files changed, 89 insertions, 86 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 887235c..d8822e3 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -287,92 +287,9 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
return false;
}
-/// print_pcrel_imm - This is used to print an immediate value that ends up
-/// being encoded as a pc-relative value. These print slightly differently, for
-/// example, a $ is not emitted.
-void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
- const MachineOperand &MO = MI->getOperand(OpNo);
- switch (MO.getType()) {
- default: LLVM_UNREACHABLE( "Unknown pcrel immediate operand");
- case MachineOperand::MO_Immediate:
- O << MO.getImm();
- return;
- 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());
-
- 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 << ')';
-
- return;
- }
- }
-}
-
-
+/// printSymbolOperand - Print a raw symbol reference operand. This handles
+/// jump tables, constant pools, global address and external symbols, all of
+/// which print to a label with various suffixes for relocation types etc.
void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
switch (MO.getType()) {
default: LLVM_UNREACHABLE("unknown symbol type!");
@@ -470,6 +387,92 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
}
}
+/// print_pcrel_imm - This is used to print an immediate value that ends up
+/// being encoded as a pc-relative value. These print slightly differently, for
+/// example, a $ is not emitted.
+void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
+ const MachineOperand &MO = MI->getOperand(OpNo);
+ switch (MO.getType()) {
+ default: LLVM_UNREACHABLE( "Unknown pcrel immediate operand");
+ case MachineOperand::MO_Immediate:
+ O << MO.getImm();
+ return;
+ 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());
+
+ 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 << ')';
+
+ return;
+ }
+ }
+}
+
+
void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
const char *Modifier) {