From: Simon Atanasyan Date: Wed, 18 Sep 2019 12:24:57 +0000 (+0000) Subject: [mips] Pass "xgot" flag as a subtarget feature X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dea5f9524dfcb55235c0a6469791b4dc84acac37;p=clang [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/cfe/trunk@372220 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Arch/Mips.cpp b/lib/Driver/ToolChains/Arch/Mips.cpp index b512ff64b0..384d3acedc 100644 --- a/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/lib/Driver/ToolChains/Arch/Mips.cpp @@ -267,6 +267,13 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple, D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1); } + if (Arg *A = Args.getLastArg(options::OPT_mxgot, options::OPT_mno_xgot)) { + if (A->getOption().matches(options::OPT_mxgot)) + Features.push_back("+xgot"); + else + Features.push_back("-xgot"); + } + mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args); if (FloatABI == mips::FloatABI::Soft) { // FIXME: Note, this is a hack. We need to pass the selected float diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index ac3f07df33..aa17efbee3 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -1675,13 +1675,6 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, CmdArgs.push_back("hard"); } - if (Arg *A = Args.getLastArg(options::OPT_mxgot, options::OPT_mno_xgot)) { - if (A->getOption().matches(options::OPT_mxgot)) { - CmdArgs.push_back("-mllvm"); - CmdArgs.push_back("-mxgot"); - } - } - if (Arg *A = Args.getLastArg(options::OPT_mldc1_sdc1, options::OPT_mno_ldc1_sdc1)) { if (A->getOption().matches(options::OPT_mno_ldc1_sdc1)) { diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c index 19725bc096..5ae5667749 100644 --- a/test/Driver/mips-features.c +++ b/test/Driver/mips-features.c @@ -268,13 +268,13 @@ // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-xgot -mxgot 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-XGOT %s -// CHECK-XGOT: "-mllvm" "-mxgot" +// CHECK-XGOT: "-target-feature" "+xgot" // // -mno-xgot // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mxgot -mno-xgot 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOXGOT %s -// CHECK-NOXGOT-NOT: "-mllvm" "-mxgot" +// CHECK-NOXGOT: "-target-feature" "-xgot" // // -mldc1-sdc1 // RUN: %clang -target mips-linux-gnu -### -c %s \ diff --git a/test/Driver/mips-integrated-as.s b/test/Driver/mips-integrated-as.s index 0e12877067..46ce5b6871 100644 --- a/test/Driver/mips-integrated-as.s +++ b/test/Driver/mips-integrated-as.s @@ -293,3 +293,13 @@ // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+single-float" // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+fpxx" // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+nooddspreg" + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -mxgot -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=XGOT %s +// XGOT: -cc1as +// XGOT: "-target-feature" "+xgot" + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -mno-xgot -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=NOXGOT %s +// NOXGOT: -cc1as +// NOXGOT: "-target-feature" "-xgot"