[cfe-commits] r159774 - in /cfe/trunk: lib/Basic/Targets.cpp test/Preprocessor/init.c
Simon Atanasyan
satanasyan at mips.com
Thu Jul 5 13:16:22 PDT 2012
Author: atanasyan
Date: Thu Jul 5 15:16:22 2012
New Revision: 159774
URL: http://llvm.org/viewvc/llvm-project?rev=159774&view=rev
Log:
MIPS: Define __mips_dsp_rev / __mips_dspr2 / __mips_dsp macros
if -mdsp or -mdspr2 options are provided.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=159774&r1=159773&r2=159774&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul 5 15:16:22 2012
@@ -3603,6 +3603,9 @@
enum MipsFloatABI {
HardFloat, SingleFloat, SoftFloat
} FloatABI;
+ enum DspRevEnum {
+ NoDSP, DSP1, DSP2
+ } DspRev;
protected:
std::string ABI;
@@ -3615,6 +3618,7 @@
CPU(CPUStr),
IsMips16(false),
FloatABI(HardFloat),
+ DspRev(NoDSP),
ABI(ABIStr)
{}
@@ -3648,6 +3652,20 @@
if (IsMips16)
Builder.defineMacro("__mips16", Twine(1));
+ switch (DspRev) {
+ default:
+ break;
+ case DSP1:
+ Builder.defineMacro("__mips_dsp_rev", Twine(1));
+ Builder.defineMacro("__mips_dsp", Twine(1));
+ break;
+ case DSP2:
+ Builder.defineMacro("__mips_dsp_rev", Twine(2));
+ Builder.defineMacro("__mips_dspr2", Twine(1));
+ Builder.defineMacro("__mips_dsp", Twine(1));
+ break;
+ }
+
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -3729,6 +3747,7 @@
virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
IsMips16 = false;
FloatABI = HardFloat;
+ DspRev = NoDSP;
for (std::vector<std::string>::iterator it = Features.begin(),
ie = Features.end(); it != ie; ++it) {
@@ -3738,6 +3757,10 @@
FloatABI = SoftFloat;
else if (*it == "+mips16")
IsMips16 = true;
+ else if (*it == "+dsp")
+ DspRev = std::max(DspRev, DSP1);
+ else if (*it == "+dspr2")
+ DspRev = std::max(DspRev, DSP2);
}
// Remove front-end specific option.
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=159774&r1=159773&r2=159774&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Jul 5 15:16:22 2012
@@ -888,6 +888,20 @@
// RUN: | FileCheck -check-prefix NOMIPS16 %s
// NOMIPS16-NOT:#define __mips16 1
//
+// RUN: %clang_cc1 -target-feature +dsp \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-DSP %s
+// MIPS-DSP:#define __mips_dsp 1
+// MIPS-DSP:#define __mips_dsp_rev 1
+// MIPS-DSP-NOT:#define __mips_dspr2 1
+//
+// RUN: %clang_cc1 -target-feature +dspr2 \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-DSPR2 %s
+// MIPS-DSPR2:#define __mips_dsp 1
+// MIPS-DSPR2:#define __mips_dsp_rev 2
+// MIPS-DSPR2:#define __mips_dspr2 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