Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2051,6 +2051,12 @@ def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group, HelpText<"Do not assume that externally defined data is in the small data if" " it meets the -G threshold (MIPS)">; +def membedded_data : Flag<["-"], "membedded-data">, Group, + HelpText<"Place constants in the .rodata section instead of the .sdata " + "section even if they meet the -G threshold (MIPS)">; +def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, + HelpText<"Do not place constants in the .rodata section instead of the " + ".sdata if they meet the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/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: cfe/trunk/test/Driver/mips-features.c =================================================================== --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/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 \