[PATCH] D35914: [mips] Add support -m(no-)embedded-data option

Simon Dardis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 26 13:58:16 PDT 2017


sdardis created this revision.
Herald added a subscriber: arichardson.

Add support for the -membedded-data option which places constant data in
the .rodata section, rather than the .sdata section.


https://reviews.llvm.org/D35914

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===================================================================
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -65,6 +65,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
 // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
 //
+// -mno-abicalls -mgpopt -membedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-embedded-data -membedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s
+// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1"
+//
+// -mno-abicalls -mgpopt -mno-embedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -membedded-data -mno-embedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s
+// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
+// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:     -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1484,7 +1484,9 @@
     Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata,
                                       options::OPT_mno_local_sdata);
     Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata,
-                                      options::OPT_mno_extern_sdata);
+                                       options::OPT_mno_extern_sdata);
+    Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data,
+                                        options::OPT_mno_embedded_data);
     if (LocalSData) {
       CmdArgs.push_back("-mllvm");
       if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) {
@@ -1504,6 +1506,17 @@
       }
       ExternSData->claim();
     }
+
+    if (EmbeddedData) {
+      CmdArgs.push_back("-mllvm");
+      if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) {
+        CmdArgs.push_back("-membedded-data=1");
+      } else {
+        CmdArgs.push_back("-membedded-data=0");
+      }
+      EmbeddedData->claim();
+    }
+
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
     D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
 
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2051,6 +2051,12 @@
 def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group<m_Group>,
   HelpText<"Do not assume that externally defined data is in the small data if"
            " it meets the -G <size> threshold (MIPS)">;
+def membedded_data : Flag<["-"], "membedded-data">, Group<m_Group>,
+  HelpText<"Place constants in the .rodata section instead of the .sdata "
+           "section even if they meet the -G <size> threshold (MIPS)">;
+def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group<m_Group>,
+  HelpText<"Do not place constants in the .rodata section instead of the "
+           ".sdata if they meet the -G <size> threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group<m_Group>;
 def mabicalls : Flag<["-"], "mabicalls">, Group<m_Group>,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35914.108354.patch
Type: text/x-patch
Size: 3572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170726/db30b30c/attachment.bin>


More information about the cfe-commits mailing list