From: Evan Cheng Date: Wed, 29 Nov 2006 23:48:14 +0000 (+0000) Subject: In PIC mode, GV not requiring an extra load can be used as address immediate. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c8306bde15c37592084602e28308fc5a2cd14ef8;p=oota-llvm.git In PIC mode, GV not requiring an extra load can be used as address immediate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32028 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 67effad7976..1e3530f21f6 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4994,21 +4994,14 @@ bool X86TargetLowering::isLegalAddressImmediate(int64_t V) const { } bool X86TargetLowering::isLegalAddressImmediate(GlobalValue *GV) const { - // GV is 64-bit but displacement field is 32-bit unless we are in small code - // model. Mac OS X happens to support only small PIC code model. - // FIXME: better support for other OS's. - if (Subtarget->is64Bit() && !Subtarget->isTargetDarwin()) + // In 64-bit mode, GV is 64-bit so it won't fit in the 32-bit displacement + // field unless we are in small code model. + if (Subtarget->is64Bit() && + getTargetMachine().getCodeModel() != CodeModel::Small) return false; - if (Subtarget->isTargetDarwin()) { - Reloc::Model RModel = getTargetMachine().getRelocationModel(); - if (RModel == Reloc::Static) - return true; - else if (RModel == Reloc::DynamicNoPIC) - return !(Subtarget->GVRequiresExtraLoad(GV, false)); - else - return false; - } else - return true; + Reloc::Model RModel = getTargetMachine().getRelocationModel(); + return (RModel == Reloc::Static) || + !Subtarget->GVRequiresExtraLoad(GV, false); } /// isShuffleMaskLegal - Targets can use this to indicate that they only