diff options
-rw-r--r-- | lib/Basic/Targets.cpp | 23 | ||||
-rw-r--r-- | test/Preprocessor/init.c | 14 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 42f5d63cc3..94d664d3b6 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3603,6 +3603,9 @@ class MipsTargetInfoBase : public TargetInfo { enum MipsFloatABI { HardFloat, SingleFloat, SoftFloat } FloatABI; + enum DspRevEnum { + NoDSP, DSP1, DSP2 + } DspRev; protected: std::string ABI; @@ -3615,6 +3618,7 @@ public: CPU(CPUStr), IsMips16(false), FloatABI(HardFloat), + DspRev(NoDSP), ABI(ABIStr) {} @@ -3648,6 +3652,20 @@ public: 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 @@ public: 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 @@ public: 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. diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 29ad682827..83028b7dac 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -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 |