add a couple of predicates to test for "stub style pic in PIC mode" and "stub style pic in dynamic-no-pic" mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75273 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 11a7596..af4d405 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -1913,7 +1913,7 @@
getTargetMachine().getRelocationModel() == Reloc::PIC_ &&
GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
OpFlags = X86II::MO_PLT;
- } else if (Subtarget->isPICStyleStub() &&
+ } else if (Subtarget->isPICStyleStubAny() &&
(GV->isDeclaration() || GV->isWeakForLinker()) &&
Subtarget->getDarwinVers() < 9) {
// PC-relative references to external symbols should go through $stub,
@@ -1933,7 +1933,7 @@
if (Subtarget->isTargetELF() &&
getTargetMachine().getRelocationModel() == Reloc::PIC_) {
OpFlags = X86II::MO_PLT;
- } else if (Subtarget->isPICStyleStub() &&
+ } else if (Subtarget->isPICStyleStubAny() &&
Subtarget->getDarwinVers() < 9) {
// PC-relative references to external symbols should go through $stub,
// unless we're building with the leopard linker or later, which
@@ -4454,14 +4454,12 @@
unsigned WrapperKind = X86ISD::Wrapper;
if (Subtarget->is64Bit() &&
- getTargetMachine().getCodeModel() == CodeModel::Small) {
+ getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
- } else if (Subtarget->isPICStyleGOT()) {
+ else if (Subtarget->isPICStyleGOT())
OpFlag = X86II::MO_GOTOFF;
- } else if (Subtarget->isPICStyleStub() &&
- getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ else if (Subtarget->isPICStyleStubPIC(getTargetMachine()))
OpFlag = X86II::MO_PIC_BASE_OFFSET;
- }
SDValue Result = DAG.getTargetConstantPool(CP->getConstVal(), getPointerTy(),
CP->getAlignment(),
@@ -4487,14 +4485,13 @@
unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper;
- if (Subtarget->is64Bit()) {
+ if (Subtarget->is64Bit() &&
+ getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
- } else if (Subtarget->isPICStyleGOT()) {
+ else if (Subtarget->isPICStyleGOT())
OpFlag = X86II::MO_GOTOFF;
- } else if (Subtarget->isPICStyleStub() &&
- getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ else if (Subtarget->isPICStyleStubPIC(getTargetMachine()))
OpFlag = X86II::MO_PIC_BASE_OFFSET;
- }
SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), getPointerTy(),
OpFlag);
@@ -4520,14 +4517,13 @@
// global base reg.
unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper;
- if (Subtarget->is64Bit()) {
+ if (Subtarget->is64Bit() &&
+ getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
- } else if (Subtarget->isPICStyleGOT()) {
+ else if (Subtarget->isPICStyleGOT())
OpFlag = X86II::MO_GOTOFF;
- } else if (Subtarget->isPICStyleStub() &&
- getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ else if (Subtarget->isPICStyleStubPIC(getTargetMachine()))
OpFlag = X86II::MO_PIC_BASE_OFFSET;
- }
SDValue Result = DAG.getTargetExternalSymbol(Sym, getPointerTy(), OpFlag);