aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-27 05:46:24 +0000
committerChris Lattner <sabre@nondot.org>2009-06-27 05:46:24 +0000
commit797a078ff8775712afd5d74069bb62828174ea53 (patch)
tree68cde6b617cd65fa03fb757543cfe942674d4b86 /lib
parent5bdaa52449b9a1687dbbce0e67a9e9d5561a864f (diff)
downloadexternal_llvm-797a078ff8775712afd5d74069bb62828174ea53.zip
external_llvm-797a078ff8775712afd5d74069bb62828174ea53.tar.gz
external_llvm-797a078ff8775712afd5d74069bb62828174ea53.tar.bz2
remove a bunch of fixmes (old checking code) and commonize all the
target-specific operand printing functionality. Yay. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp116
1 files changed, 29 insertions, 87 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index bb16e6a..e75cfc5 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -424,6 +424,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
const char *Modifier) {
const MachineOperand &MO = MI->getOperand(OpNo);
switch (MO.getType()) {
+ default: assert(0 && "unknown operand type!");
case MachineOperand::MO_Register: {
assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
"Virtual registers should not make it this far!");
@@ -450,29 +451,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
if (!isMemOp) O << '$';
O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
<< MO.getIndex();
-
- switch (MO.getTargetFlags()) {
- default:
- assert(0 && "Unknown target flag on jump table operand");
- case X86II::MO_NO_FLAG:
- // FIXME: REMOVE EVENTUALLY.
- if (TM.getRelocationModel() == Reloc::PIC_) {
- assert(!Subtarget->isPICStyleStub() &&
- !Subtarget->isPICStyleGOT() &&
- "Should have operand flag!");
- }
-
- break;
- case X86II::MO_PIC_BASE_OFFSET:
- O << '-';
- PrintPICBaseSymbol();
- break;
- case X86II::MO_GOTOFF:
- O << "@GOTOFF";
- break;
- }
-
- return;
+ break;
}
case MachineOperand::MO_ConstantPoolIndex: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
@@ -481,48 +460,16 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
<< MO.getIndex();
printOffset(MO.getOffset());
-
- switch (MO.getTargetFlags()) {
- default:
- assert(0 && "Unknown target flag on constant pool operand");
- case X86II::MO_NO_FLAG:
- // FIXME: REMOVE EVENTUALLY.
- if (TM.getRelocationModel() == Reloc::PIC_) {
- assert(!Subtarget->isPICStyleStub() &&
- !Subtarget->isPICStyleGOT() &&
- "Should have operand flag!");
- }
-
- break;
- case X86II::MO_PIC_BASE_OFFSET:
- O << '-';
- PrintPICBaseSymbol();
- break;
- case X86II::MO_GOTOFF:
- O << "@GOTOFF";
- break;
- }
-
- return;
+ break;
}
case MachineOperand::MO_GlobalAddress: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
- bool needCloseParen = false;
const GlobalValue *GV = MO.getGlobal();
- const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
- if (!GVar) {
- // If GV is an alias then use the aliasee for determining
- // thread-localness.
- if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
- GVar =dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
- }
-
- bool isThreadLocal = GVar && GVar->isThreadLocal();
-
std::string Name = Mang->getValueName(GV);
decorateName(Name, GV);
+ bool needCloseParen = false;
if (!isMemOp)
O << '$';
else if (Name[0] == '$') {
@@ -572,26 +519,9 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
if (needCloseParen)
O << ')';
- switch (MO.getTargetFlags()) {
- default:
- assert(0 && "Unknown target flag on GV operand");
- case X86II::MO_NO_FLAG:
- // FIXME: RIP THIS CHECKING CODE OUT EVENTUALLY.
- if (isThreadLocal)
- assert(0 && "Not lowered right");
- break;
- case X86II::MO_TLSGD: O << "@TLSGD"; break;
- case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
- case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
- case X86II::MO_TPOFF: O << "@TPOFF"; break;
- case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
- case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
- case X86II::MO_GOT: O << "@GOT"; break;
- case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
- }
- return;
+ break;
}
- case MachineOperand::MO_ExternalSymbol: {
+ 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.
@@ -602,19 +532,31 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
O << '$';
O << TAI->getGlobalPrefix();
O << MO.getSymbolName();
-
- if (MO.getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) {
- O << " + [.-";
- PrintPICBaseSymbol();
- O << ']';
- } else {
- assert(MO.getTargetFlags() == X86II::MO_NO_FLAG &&
- "Unknown operand flag for external symbol");
- }
- return;
+ break;
}
+
+ switch (MO.getTargetFlags()) {
default:
- O << "<unknown operand type>"; return;
+ assert(0 && "Unknown target flag on GV operand");
+ case X86II::MO_NO_FLAG:
+ break;
+ case X86II::MO_GOT_ABSOLUTE_ADDRESS:
+ O << " + [.-";
+ PrintPICBaseSymbol();
+ O << ']';
+ break;
+ case X86II::MO_PIC_BASE_OFFSET:
+ O << '-';
+ PrintPICBaseSymbol();
+ break;
+ case X86II::MO_TLSGD: O << "@TLSGD"; break;
+ case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
+ case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
+ case X86II::MO_TPOFF: O << "@TPOFF"; break;
+ case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
+ case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
+ case X86II::MO_GOT: O << "@GOT"; break;
+ case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
}
}