[cfe-commits] r159753 - in /cfe/trunk: lib/Basic/Targets.cpp test/Preprocessor/init.c
Simon Atanasyan
satanasyan at mips.com
Thu Jul 5 09:06:06 PDT 2012
Author: atanasyan
Date: Thu Jul 5 11:06:06 2012
New Revision: 159753
URL: http://llvm.org/viewvc/llvm-project?rev=159753&view=rev
Log:
MIPS: Define __mips16 macro if -mips16 option is 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=159753&r1=159752&r2=159753&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul 5 11:06:06 2012
@@ -3599,6 +3599,7 @@
class MipsTargetInfoBase : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
std::string CPU;
+ bool IsMips16;
enum MipsFloatABI {
HardFloat, SingleFloat, SoftFloat
} FloatABI;
@@ -3612,6 +3613,7 @@
const std::string& CPUStr)
: TargetInfo(triple),
CPU(CPUStr),
+ IsMips16(false),
FloatABI(HardFloat),
ABI(ABIStr)
{}
@@ -3643,6 +3645,9 @@
break;
}
+ if (IsMips16)
+ Builder.defineMacro("__mips16", Twine(1));
+
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -3722,6 +3727,7 @@
}
virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
+ IsMips16 = false;
FloatABI = HardFloat;
for (std::vector<std::string>::iterator it = Features.begin(),
@@ -3730,6 +3736,8 @@
FloatABI = SingleFloat;
else if (*it == "+soft-float")
FloatABI = SoftFloat;
+ else if (*it == "+mips16")
+ IsMips16 = true;
}
// 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=159753&r1=159752&r2=159753&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Jul 5 11:06:06 2012
@@ -876,6 +876,18 @@
// MIPS-FABI-SINGLE:#define __mips_hard_float 1
// MIPS-FABI-SINGLE:#define __mips_single_float 1
//
+// Check MIPS features macros
+//
+// RUN: %clang_cc1 -target-feature +mips16 \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS16 %s
+// MIPS16:#define __mips16 1
+//
+// RUN: %clang_cc1 -target-feature -mips16 \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix NOMIPS16 %s
+// NOMIPS16-NOT:#define __mips16 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