move handling of dllimport linkage in isel, not in asmprinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75086 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-07-09 00:58:53 +00:00
parent f4a9774e2b
commit 4aa21aa6d1
4 changed files with 27 additions and 17 deletions

View File

@ -351,10 +351,9 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
O << Name;
}
} else {
if (GV->hasDLLImportLinkage()) {
assert(MO.getTargetFlags() == 0);
// Handle dllimport linkage.
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
O << "__imp_";
}
O << Name;
if (shouldPrintPLT(TM, Subtarget)) {
@ -503,10 +502,9 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
PrintPICBaseSymbol();
}
} else {
if (GV->hasDLLImportLinkage()) {
// Handle dllimport linkage.
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
O << "__imp_";
assert(MO.getTargetFlags() == 0);
}
O << Name;
}
@ -533,7 +531,8 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
switch (MO.getTargetFlags()) {
default:
assert(0 && "Unknown target flag on GV operand");
case X86II::MO_NO_FLAG:
case X86II::MO_NO_FLAG: // No flag.
case X86II::MO_DLLIMPORT: // Prefix, not a suffix.
break;
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
O << " + [.-";

View File

@ -244,11 +244,13 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
decorateName(Name, GV);
if (!isMemOp) O << "OFFSET ";
if (GV->hasDLLImportLinkage()) {
// FIXME: This should be fixed with full support of stdcall & fastcall
// CC's
// Handle dllimport linkage.
// FIXME: This should be fixed with full support of stdcall & fastcall
// CC's
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
O << "__imp_";
}
O << Name;
printOffset(MO.getOffset());
return;
@ -278,11 +280,11 @@ void X86IntelAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo){
std::string Name = Mang->getValueName(GV);
decorateName(Name, GV);
if (GV->hasDLLImportLinkage()) {
// FIXME: This should be fixed with full support of stdcall & fastcall
// CC's
// Handle dllimport linkage.
// FIXME: This should be fixed with full support of stdcall & fastcall
// CC's
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
O << "__imp_";
}
O << Name;
printOffset(MO.getOffset());
return;

View File

@ -4547,13 +4547,16 @@ X86TargetLowering::LowerGlobalAddress(const GlobalValue *GV, DebugLoc dl,
// offset if it is legal.
SDValue Result;
if (!IsPic && !ExtraLoadRequired && isInt32(Offset)) {
// A direct static reference to a global.
Result = DAG.getTargetGlobalAddress(GV, getPointerTy(), Offset);
Offset = 0;
} else {
unsigned char OpFlags = 0;
if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getRelocationModel() != Reloc::Static) {
if (GV->hasDLLImportLinkage())
OpFlags = X86II::MO_DLLIMPORT;
else if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getRelocationModel() != Reloc::Static) {
if (ExtraLoadRequired)
OpFlags = X86II::MO_GOTPCREL;
} else if (Subtarget->isPICStyleGOT() &&

View File

@ -149,6 +149,12 @@ namespace X86II {
/// SYMBOL_LABEL @NTPOFF
MO_NTPOFF = 11,
/// MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the
/// reference is actually to the "__imp_FOO" symbol. This is used for
/// dllimport linkage on windows.
MO_DLLIMPORT = 12,
//===------------------------------------------------------------------===//
// Instruction encodings. These are the standard/most common forms for X86
// instructions.