MIPS: Define __mips_dsp_rev / __mips_dspr2 / __mips_dsp macros

if -mdsp or -mdspr2 options are provided.

llvm-svn: 159774
This commit is contained in:
Simon Atanasyan 2012-07-05 20:16:22 +00:00
parent 8de7955f35
commit 9780e4a2bb
2 changed files with 37 additions and 0 deletions

View File

@ -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.

View File

@ -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