aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2013-04-14 14:07:51 +0000
committerSimon Atanasyan <simon@atanasyan.com>2013-04-14 14:07:51 +0000
commit321ae79aae228aa069795e78449a95fa35e2abfd (patch)
treeaa86070c2b9f7dad716972674a856346bb444eda
parenta8141614514634c7bd0ee4bc96e19fb3c10f72f2 (diff)
[Mips] Support -mmicromips / -mno-micromips command line options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179489 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/Options.td2
-rw-r--r--lib/Basic/Targets.cpp11
-rw-r--r--lib/Driver/Tools.cpp3
-rw-r--r--test/Driver/mips-features.c12
-rw-r--r--test/Preprocessor/init.c10
5 files changed, 37 insertions, 1 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 881353e386..8e23e265ce 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -957,6 +957,8 @@ def mprfchw : Flag<["-"], "mprfchw">, Group<m_x86_Features_Group>;
def mrdseed : Flag<["-"], "mrdseed">, Group<m_x86_Features_Group>;
def mips16 : Flag<["-"], "mips16">, Group<m_Group>;
def mno_mips16 : Flag<["-"], "mno-mips16">, Group<m_Group>;
+def mmicromips : Flag<["-"], "mmicromips">, Group<m_Group>;
+def mno_micromips : Flag<["-"], "mno-micromips">, Group<m_Group>;
def mxgot : Flag<["-"], "mxgot">, Group<m_Group>;
def mno_xgot : Flag<["-"], "mno-xgot">, Group<m_Group>;
def mdsp : Flag<["-"], "mdsp">, Group<m_Group>;
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 9689193869..95334e010a 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -4405,6 +4405,7 @@ class MipsTargetInfoBase : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
std::string CPU;
bool IsMips16;
+ bool IsMicromips;
bool IsSingleFloat;
enum MipsFloatABI {
HardFloat, SoftFloat
@@ -4423,6 +4424,7 @@ public:
: TargetInfo(triple),
CPU(CPUStr),
IsMips16(false),
+ IsMicromips(false),
IsSingleFloat(false),
FloatABI(HardFloat),
DspRev(NoDSP),
@@ -4461,6 +4463,9 @@ public:
if (IsMips16)
Builder.defineMacro("__mips16", Twine(1));
+ if (IsMicromips)
+ Builder.defineMacro("__mips_micromips", Twine(1));
+
switch (DspRev) {
default:
break;
@@ -4550,7 +4555,8 @@ public:
Name == "o32" || Name == "n32" || Name == "n64" || Name == "eabi" ||
Name == "mips32" || Name == "mips32r2" ||
Name == "mips64" || Name == "mips64r2" ||
- Name == "mips16" || Name == "dsp" || Name == "dspr2") {
+ Name == "mips16" || Name == "micromips" ||
+ Name == "dsp" || Name == "dspr2") {
Features[Name] = Enabled;
return true;
} else if (Name == "32") {
@@ -4565,6 +4571,7 @@ public:
virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
IsMips16 = false;
+ IsMicromips = false;
IsSingleFloat = false;
FloatABI = HardFloat;
DspRev = NoDSP;
@@ -4577,6 +4584,8 @@ public:
FloatABI = SoftFloat;
else if (*it == "+mips16")
IsMips16 = true;
+ else if (*it == "+micromips")
+ IsMicromips = true;
else if (*it == "+dsp")
DspRev = std::max(DspRev, DSP1);
else if (*it == "+dspr2")
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index e0fc74e05f..586a7ed76e 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -991,6 +991,9 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
options::OPT_mips16, options::OPT_mno_mips16,
"mips16");
AddTargetFeature(Args, CmdArgs,
+ options::OPT_mmicromips, options::OPT_mno_micromips,
+ "micromips");
+ AddTargetFeature(Args, CmdArgs,
options::OPT_mdsp, options::OPT_mno_dsp,
"dsp");
AddTargetFeature(Args, CmdArgs,
diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c
index 3bebffc11b..3f4730b863 100644
--- a/test/Driver/mips-features.c
+++ b/test/Driver/mips-features.c
@@ -14,6 +14,18 @@
// RUN: | FileCheck --check-prefix=CHECK-NOMIPS16 %s
// CHECK-NOMIPS16: "-target-feature" "-mips16"
//
+// -mmicromips
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mno-micromips -mmicromips 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MICROMIPS %s
+// CHECK-MICROMIPS: "-target-feature" "+micromips"
+//
+// -mno-micromips
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mmicromips -mno-micromips 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOMICROMIPS %s
+// CHECK-NOMICROMIPS: "-target-feature" "-micromips"
+//
// -mdsp
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -mno-dsp -mdsp 2>&1 \
diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c
index 8ab1439fa6..c1519a8a7f 100644
--- a/test/Preprocessor/init.c
+++ b/test/Preprocessor/init.c
@@ -1168,6 +1168,16 @@
// RUN: | FileCheck -check-prefix NOMIPS16 %s
// NOMIPS16-NOT:#define __mips16 1
//
+// RUN: %clang_cc1 -target-feature +micromips \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MICROMIPS %s
+// MICROMIPS:#define __mips_micromips 1
+//
+// RUN: %clang_cc1 -target-feature -micromips \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix NOMICROMIPS %s
+// NOMICROMIPS-NOT:#define __mips_micromips 1
+//
// RUN: %clang_cc1 -target-feature +dsp \
// RUN: -E -dM -triple=mips-none-none < /dev/null \
// RUN: | FileCheck -check-prefix MIPS-DSP %s