From: Simon Atanasyan Date: Fri, 18 Oct 2013 13:13:53 +0000 (+0000) Subject: [Mips] Define __mips_fpr and _MIPS_FPSET macros. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ddb2ad21d2c059b82e2ddbbb5eb8b325944b9970;p=clang [Mips] Define __mips_fpr and _MIPS_FPSET macros. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192969 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index a17bb03c86..2f90e98a39 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -4745,6 +4745,7 @@ class MipsTargetInfoBase : public TargetInfo { NoDSP, DSP1, DSP2 } DspRev; bool HasMSA; + bool HasFP64; protected: std::string ABI; @@ -4754,7 +4755,7 @@ public: const std::string &CPUStr) : TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false), IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat), - DspRev(NoDSP), HasMSA(false), ABI(ABIStr) {} + DspRev(NoDSP), HasMSA(false), HasFP64(false), ABI(ABIStr) {} virtual const char *getABI() const { return ABI.c_str(); } virtual bool setABI(const std::string &Name) = 0; @@ -4785,6 +4786,10 @@ public: if (IsSingleFloat) Builder.defineMacro("__mips_single_float", Twine(1)); + Builder.defineMacro("__mips_fpr", HasFP64 ? Twine(64) : Twine(32)); + Builder.defineMacro("_MIPS_FPSET", + Twine(32 / (HasFP64 || IsSingleFloat ? 1 : 2))); + if (IsMips16) Builder.defineMacro("__mips16", Twine(1)); @@ -4887,6 +4892,7 @@ public: IsSingleFloat = false; FloatABI = HardFloat; DspRev = NoDSP; + HasFP64 = ABI == "n32" || ABI == "n64" || ABI == "64"; for (std::vector::iterator it = Features.begin(), ie = Features.end(); it != ie; ++it) { @@ -4904,6 +4910,10 @@ public: DspRev = std::max(DspRev, DSP2); else if (*it == "+msa") HasMSA = true; + else if (*it == "+fp64") + HasFP64 = true; + else if (*it == "-fp64") + HasFP64 = false; else if (*it == "+nan2008") IsNan2008 = true; } diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index ce7ee09abe..1324733786 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -717,6 +717,7 @@ // MIPS32BE:#define _MIPSEB 1 // MIPS32BE:#define _MIPS_ARCH "mips32" // MIPS32BE:#define _MIPS_ARCH_MIPS32 1 +// MIPS32BE:#define _MIPS_FPSET 16 // MIPS32BE:#define _MIPS_SIM _ABIO32 // MIPS32BE:#define _MIPS_SZINT 32 // MIPS32BE:#define _MIPS_SZLONG 32 @@ -821,6 +822,7 @@ // MIPS32BE:#define __llvm__ 1 // MIPS32BE:#define __mips 1 // MIPS32BE:#define __mips__ 1 +// MIPS32BE:#define __mips_fpr 32 // MIPS32BE:#define __mips_hard_float 1 // MIPS32BE:#define __mips_o32 1 // MIPS32BE:#define _mips 1 @@ -834,6 +836,7 @@ // MIPS32EL:#define _MIPSEL 1 // MIPS32EL:#define _MIPS_ARCH "mips32" // MIPS32EL:#define _MIPS_ARCH_MIPS32 1 +// MIPS32EL:#define _MIPS_FPSET 16 // MIPS32EL:#define _MIPS_SIM _ABIO32 // MIPS32EL:#define _MIPS_SZINT 32 // MIPS32EL:#define _MIPS_SZLONG 32 @@ -935,6 +938,7 @@ // MIPS32EL:#define __llvm__ 1 // MIPS32EL:#define __mips 1 // MIPS32EL:#define __mips__ 1 +// MIPS32EL:#define __mips_fpr 32 // MIPS32EL:#define __mips_hard_float 1 // MIPS32EL:#define __mips_o32 1 // MIPS32EL:#define _mips 1 @@ -948,6 +952,7 @@ // MIPS64BE:#define _MIPSEB 1 // MIPS64BE:#define _MIPS_ARCH "mips64" // MIPS64BE:#define _MIPS_ARCH_MIPS64 1 +// MIPS64BE:#define _MIPS_FPSET 32 // MIPS64BE:#define _MIPS_SIM _ABI64 // MIPS64BE:#define _MIPS_SZINT 32 // MIPS64BE:#define _MIPS_SZLONG 64 @@ -1051,6 +1056,7 @@ // MIPS64BE:#define __mips64 1 // MIPS64BE:#define __mips64__ 1 // MIPS64BE:#define __mips__ 1 +// MIPS64BE:#define __mips_fpr 64 // MIPS64BE:#define __mips_hard_float 1 // MIPS64BE:#define __mips_n64 1 // MIPS64BE:#define _mips 1 @@ -1064,6 +1070,7 @@ // MIPS64EL:#define _MIPSEL 1 // MIPS64EL:#define _MIPS_ARCH "mips64" // MIPS64EL:#define _MIPS_ARCH_MIPS64 1 +// MIPS64EL:#define _MIPS_FPSET 32 // MIPS64EL:#define _MIPS_SIM _ABI64 // MIPS64EL:#define _MIPS_SZINT 32 // MIPS64EL:#define _MIPS_SZLONG 64 @@ -1167,6 +1174,7 @@ // MIPS64EL:#define __mips64 1 // MIPS64EL:#define __mips64__ 1 // MIPS64EL:#define __mips__ 1 +// MIPS64EL:#define __mips_fpr 64 // MIPS64EL:#define __mips_hard_float 1 // MIPS64EL:#define __mips_n64 1 // MIPS64EL:#define _mips 1 @@ -1242,6 +1250,36 @@ // RUN: | FileCheck -check-prefix MIPS-NAN2008 %s // MIPS-NAN2008:#define __mips_nan2008 1 // +// RUN: %clang_cc1 -target-feature -fp64 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS32-MFP32 %s +// MIPS32-MFP32:#define _MIPS_FPSET 16 +// MIPS32-MFP32:#define __mips_fpr 32 +// +// RUN: %clang_cc1 -target-feature +fp64 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS32-MFP64 %s +// MIPS32-MFP64:#define _MIPS_FPSET 32 +// MIPS32-MFP64:#define __mips_fpr 64 +// +// RUN: %clang_cc1 -target-feature +single-float \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS32-MFP32SF %s +// MIPS32-MFP32SF:#define _MIPS_FPSET 32 +// MIPS32-MFP32SF:#define __mips_fpr 32 +// +// RUN: %clang_cc1 -target-feature +fp64 \ +// RUN: -E -dM -triple=mips64-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS64-MFP64 %s +// MIPS64-MFP64:#define _MIPS_FPSET 32 +// MIPS64-MFP64:#define __mips_fpr 64 +// +// RUN: %clang_cc1 -target-feature -fp64 -target-feature +single-float \ +// RUN: -E -dM -triple=mips64-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS64-NOMFP64 %s +// MIPS64-NOMFP64:#define _MIPS_FPSET 32 +// MIPS64-NOMFP64:#define __mips_fpr 32 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s // // MSP430:#define MSP430 1