Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 901ea18

Browse files
committed
[mips] Pass "xgot" flag as a subtarget feature
We need "xgot" flag in the MipsAsmParser to implement correct expansion of some pseudo instructions in case of using 32-bit GOT (XGOT). MipsAsmParser does not have reference to MipsSubtarget but has a reference to "feature bit set". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372220 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d6489c1 commit 901ea18

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

lib/Target/Mips/Mips.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ def FeatureMT : SubtargetFeature<"mt", "HasMT", "true", "Mips MT ASE">;
209209
def FeatureLongCalls : SubtargetFeature<"long-calls", "UseLongCalls", "true",
210210
"Disable use of the jal instruction">;
211211

212+
def FeatureXGOT
213+
: SubtargetFeature<"xgot", "UseXGOT", "true", "Assume 32-bit GOT">;
214+
212215
def FeatureUseIndirectJumpsHazard : SubtargetFeature<"use-indirect-jump-hazard",
213216
"UseIndirectJumpsHazard",
214217
"true", "Use indirect jump"

lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ using namespace llvm;
8282

8383
STATISTIC(NumTailCalls, "Number of tail calls");
8484

85-
static cl::opt<bool>
86-
LargeGOT("mxgot", cl::Hidden,
87-
cl::desc("MIPS: Enable GOT larger than 64k."), cl::init(false));
88-
8985
static cl::opt<bool>
9086
NoZeroDivCheck("mno-check-zero-division", cl::Hidden,
9187
cl::desc("MIPS: Don't trap on integer division by zero."),
@@ -554,8 +550,9 @@ MipsTargetLowering::createFastISel(FunctionLoweringInfo &funcInfo,
554550
!Subtarget.inMicroMipsMode();
555551

556552
// Disable if either of the following is true:
557-
// We do not generate PIC, the ABI is not O32, LargeGOT is being used.
558-
if (!TM.isPositionIndependent() || !TM.getABI().IsO32() || LargeGOT)
553+
// We do not generate PIC, the ABI is not O32, XGOT is being used.
554+
if (!TM.isPositionIndependent() || !TM.getABI().IsO32() ||
555+
Subtarget.useXGOT())
559556
UseFastISel = false;
560557

561558
return UseFastISel ? Mips::createFastISel(funcInfo, libInfo) : nullptr;
@@ -1989,7 +1986,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
19891986
if (GV->hasLocalLinkage())
19901987
return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
19911988

1992-
if (LargeGOT)
1989+
if (Subtarget.useXGOT())
19931990
return getAddrGlobalLargeGOT(
19941991
N, SDLoc(N), Ty, DAG, MipsII::MO_GOT_HI16, MipsII::MO_GOT_LO16,
19951992
DAG.getEntryNode(),
@@ -3272,7 +3269,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
32723269

32733270
if (InternalLinkage)
32743271
Callee = getAddrLocal(G, DL, Ty, DAG, ABI.IsN32() || ABI.IsN64());
3275-
else if (LargeGOT) {
3272+
else if (Subtarget.useXGOT()) {
32763273
Callee = getAddrGlobalLargeGOT(G, DL, Ty, DAG, MipsII::MO_CALL_HI16,
32773274
MipsII::MO_CALL_LO16, Chain,
32783275
FuncInfo->callPtrInfo(Val));
@@ -3294,7 +3291,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
32943291
if (!IsPIC) // static
32953292
Callee = DAG.getTargetExternalSymbol(
32963293
Sym, getPointerTy(DAG.getDataLayout()), MipsII::MO_NO_FLAG);
3297-
else if (LargeGOT) {
3294+
else if (Subtarget.useXGOT()) {
32983295
Callee = getAddrGlobalLargeGOT(S, DL, Ty, DAG, MipsII::MO_CALL_HI16,
32993296
MipsII::MO_CALL_LO16, Chain,
33003297
FuncInfo->callPtrInfo(Sym));

lib/Target/Mips/MipsSubtarget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
189189
// Disable use of the `jal` instruction.
190190
bool UseLongCalls = false;
191191

192+
// Assume 32-bit GOT.
193+
bool UseXGOT = false;
194+
192195
/// The minimum alignment known to hold of the stack frame on
193196
/// entry to the function and which must be maintained by every function.
194197
unsigned stackAlignment;
@@ -323,6 +326,8 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
323326

324327
bool useLongCalls() const { return UseLongCalls; }
325328

329+
bool useXGOT() const { return UseXGOT; }
330+
326331
bool enableLongBranchPass() const {
327332
return hasStandardEncoding() || inMicroMipsMode() || allowMixed16_32();
328333
}

test/CodeGen/Mips/address-selection.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
; RUN: llc -march=mips < %s -debug 2>&1 | FileCheck %s --check-prefix=MIPS
2-
; RUN: llc -march=mips -relocation-model=pic -mxgot < %s -debug 2>&1 | FileCheck %s --check-prefix=MIPS-XGOT
2+
; RUN: llc -march=mips -relocation-model=pic -mattr=+xgot < %s \
3+
; RUN: -debug 2>&1 | FileCheck %s --check-prefix=MIPS-XGOT
34

45
; RUN: llc -march=mips -mattr=+micromips < %s -debug 2>&1 | FileCheck %s --check-prefix=MM
5-
; RUN: llc -march=mips -relocation-model=pic -mxgot -mattr=+micromips < %s -debug 2>&1 | FileCheck %s --check-prefix=MM-XGOT
6+
; RUN: llc -march=mips -relocation-model=pic -mattr=+xgot,+micromips < %s \
7+
; RUN: -debug 2>&1 | FileCheck %s --check-prefix=MM-XGOT
68

79
; REQUIRES: asserts
810

test/CodeGen/Mips/biggot.ll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
; RUN: llc -march=mipsel -mxgot -relocation-model=pic < %s | FileCheck %s -check-prefix=O32
2-
; RUN: llc -march=mips64el -mcpu=mips64r2 -mxgot -relocation-model=pic < %s | \
3-
; RUN: FileCheck %s -check-prefix=N64
4-
; RUN: llc -march=mipsel -mxgot -relocation-model=pic -fast-isel < %s | FileCheck %s -check-prefix=O32
5-
; RUN: llc -march=mips64el -mcpu=mips64r2 -mxgot -relocation-model=pic -fast-isel < %s | \
6-
; RUN: FileCheck %s -check-prefix=N64
1+
; RUN: llc -march=mipsel -mattr=+xgot \
2+
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=O32
3+
; RUN: llc -march=mips64el -mcpu=mips64r2 -mattr=+xgot \
4+
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=N64
5+
; RUN: llc -march=mipsel -mattr=+xgot -fast-isel \
6+
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=O32
7+
; RUN: llc -march=mips64el -mcpu=mips64r2 -mattr=+xgot -fast-isel \
8+
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=N64
79

810
@v0 = external global i32
911

test/CodeGen/Mips/mirparser/target-flags-pic-mxgot-tls.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RUN: llc -march=mips64 -target-abi n64 -start-before=finalize-isel \
2-
# RUN: -stop-after=finalize-isel -relocation-model=pic -mxgot \
2+
# RUN: -stop-after=finalize-isel -relocation-model=pic -mattr=+xgot \
33
# RUN: -o /dev/null %s
44

55
# A simple test to show that we can parse the target specific flags: gpoff-hi,

0 commit comments

Comments
 (0)