r188184 - [Mips] MSA frontend option support
Jack Carter
jack.carter at imgtec.com
Mon Aug 12 10:20:29 PDT 2013
Author: jacksprat
Date: Mon Aug 12 12:20:29 2013
New Revision: 188184
URL: http://llvm.org/viewvc/llvm-project?rev=188184&view=rev
Log:
[Mips] MSA frontend option support
This patch adds -mmsa and -mno-msa to the options supported by
clang to enable and disable support for MSA.
When MSA is enabled, a predefined macro '__mips_msa' is defined to 1.
Patch by Daniel Sanders
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-features.c
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=188184&r1=188183&r2=188184&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug 12 12:20:29 2013
@@ -1042,6 +1042,10 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group<m_Group>;
def msingle_float : Flag<["-"], "msingle-float">, Group<m_Group>;
def mdouble_float : Flag<["-"], "mdouble-float">, Group<m_Group>;
+def mmsa : Flag<["-"], "mmsa">, Group<m_Group>,
+ HelpText<"Enable MSA ASE on MIPS processors">, Flags<[HelpHidden]>;
+def mno_msa : Flag<["-"], "mno-msa">, Group<m_Group>,
+ HelpText<"Disable MSA ASE on MIPS processors">, Flags<[HelpHidden]>;
def mips32 : Flag<["-"], "mips32">, Group<mips_CPUs_Group>,
HelpText<"Equivalent to -march=mips32">, Flags<[HelpHidden]>;
def mips32r2 : Flag<["-"], "mips32r2">, Group<mips_CPUs_Group>,
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=188184&r1=188183&r2=188184&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Aug 12 12:20:29 2013
@@ -4530,6 +4530,7 @@ class MipsTargetInfoBase : public Target
enum DspRevEnum {
NoDSP, DSP1, DSP2
} DspRev;
+ bool HasMSA;
protected:
std::string ABI;
@@ -4538,7 +4539,8 @@ public:
MipsTargetInfoBase(const llvm::Triple &Triple, const std::string &ABIStr,
const std::string &CPUStr)
: TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false),
- IsSingleFloat(false), FloatABI(HardFloat), DspRev(NoDSP), ABI(ABIStr) {}
+ IsSingleFloat(false), FloatABI(HardFloat), DspRev(NoDSP),
+ HasMSA(false), ABI(ABIStr) {}
virtual const char *getABI() const { return ABI.c_str(); }
virtual bool setABI(const std::string &Name) = 0;
@@ -4589,6 +4591,9 @@ public:
break;
}
+ if (HasMSA)
+ Builder.defineMacro("__mips_msa", Twine(1));
+
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -4665,7 +4670,8 @@ public:
Name == "mips32" || Name == "mips32r2" ||
Name == "mips64" || Name == "mips64r2" ||
Name == "mips16" || Name == "micromips" ||
- Name == "dsp" || Name == "dspr2") {
+ Name == "dsp" || Name == "dspr2" ||
+ Name == "msa") {
Features[Name] = Enabled;
return true;
} else if (Name == "32") {
@@ -4699,6 +4705,8 @@ public:
DspRev = std::max(DspRev, DSP1);
else if (*it == "+dspr2")
DspRev = std::max(DspRev, DSP2);
+ else if (*it == "+msa")
+ HasMSA = true;
}
// Remove front-end specific option.
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=188184&r1=188183&r2=188184&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Aug 12 12:20:29 2013
@@ -1023,6 +1023,9 @@ void Clang::AddMIPSTargetArgs(const ArgL
AddTargetFeature(Args, CmdArgs,
options::OPT_mdspr2, options::OPT_mno_dspr2,
"dspr2");
+ AddTargetFeature(Args, CmdArgs,
+ options::OPT_mmsa, options::OPT_mno_msa,
+ "msa");
if (Arg *A = Args.getLastArg(options::OPT_mxgot, options::OPT_mno_xgot)) {
if (A->getOption().matches(options::OPT_mxgot)) {
Modified: cfe/trunk/test/Driver/mips-features.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=188184&r1=188183&r2=188184&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Mon Aug 12 12:20:29 2013
@@ -48,6 +48,18 @@
// RUN: | FileCheck --check-prefix=CHECK-NOMDSPR2 %s
// CHECK-NOMDSPR2: "-target-feature" "-dspr2"
//
+// -mmsa
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mno-msa -mmsa 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MMSA %s
+// CHECK-MMSA: "-target-feature" "+msa"
+//
+// -mno-msa
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mmsa -mno-msa 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOMMSA %s
+// CHECK-NOMMSA: "-target-feature" "-msa"
+//
// -mxgot
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -mno-xgot -mxgot 2>&1 \
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=188184&r1=188183&r2=188184&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Aug 12 12:20:29 2013
@@ -1224,6 +1224,11 @@
// MIPS-DSPR2:#define __mips_dsp_rev 2
// MIPS-DSPR2:#define __mips_dspr2 1
//
+// RUN: %clang_cc1 -target-feature +msa \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-MSA %s
+// MIPS-MSA:#define __mips_msa 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s
//
// MSP430:#define MSP430 1
More information about the cfe-commits
mailing list