r372220 - [mips] Pass "xgot" flag as a subtarget feature

Simon Atanasyan via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 05:24:57 PDT 2019


Author: atanasyan
Date: Wed Sep 18 05:24:57 2019
New Revision: 372220

URL: http://llvm.org/viewvc/llvm-project?rev=372220&view=rev
Log:
[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".

Modified:
    cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/test/Driver/mips-features.c
    cfe/trunk/test/Driver/mips-integrated-as.s

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=372220&r1=372219&r2=372220&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Sep 18 05:24:57 2019
@@ -267,6 +267,13 @@ void mips::getMIPSTargetFeatures(const D
       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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=372220&r1=372219&r2=372220&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Sep 18 05:24:57 2019
@@ -1675,13 +1675,6 @@ void Clang::AddMIPSTargetArgs(const ArgL
     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)) {

Modified: cfe/trunk/test/Driver/mips-features.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=372220&r1=372219&r2=372220&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Wed Sep 18 05:24:57 2019
@@ -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 \

Modified: cfe/trunk/test/Driver/mips-integrated-as.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-integrated-as.s?rev=372220&r1=372219&r2=372220&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-integrated-as.s (original)
+++ cfe/trunk/test/Driver/mips-integrated-as.s Wed Sep 18 05:24:57 2019
@@ -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"




More information about the cfe-commits mailing list