[cfe-commits] r159665 - in /cfe/trunk: lib/Basic/Targets.cpp test/Preprocessor/init.c
Hal Finkel
hfinkel at anl.gov
Tue Jul 3 09:51:05 PDT 2012
Author: hfinkel
Date: Tue Jul 3 11:51:04 2012
New Revision: 159665
URL: http://llvm.org/viewvc/llvm-project?rev=159665&view=rev
Log:
Add additional architecture defines for PPC targets.
Patch by Andy Gibbs.
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=159665&r1=159664&r2=159665&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jul 3 11:51:04 2012
@@ -582,6 +582,19 @@
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
}
+ /// \brief Flags for architecture specific defines.
+ typedef enum {
+ ArchDefineNone = 0,
+ ArchDefineName = 1 << 0, // <name> is substituted for arch name.
+ ArchDefinePpcgr = 1 << 1,
+ ArchDefinePpcsq = 1 << 2,
+ ArchDefine440 = 1 << 3,
+ ArchDefine603 = 1 << 4,
+ ArchDefine604 = 1 << 5,
+ ArchDefinePwr4 = 1 << 6,
+ ArchDefinePwr6 = 1 << 7
+ } ArchDefineTypes;
+
virtual bool setCPU(const std::string &Name) {
bool CPUKnown = llvm::StringSwitch<bool>(Name)
.Case("generic", true)
@@ -781,17 +794,44 @@
}
// CPU identification.
- if (CPU == "440") {
- Builder.defineMacro("_ARCH_440");
- } else if (CPU == "450") {
+ ArchDefineTypes defs = (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
+ .Case("440", ArchDefineName)
+ .Case("450", ArchDefineName | ArchDefine440)
+ .Case("601", ArchDefineName)
+ .Case("602", ArchDefineName | ArchDefinePpcgr)
+ .Case("603", ArchDefineName | ArchDefinePpcgr)
+ .Case("603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
+ .Case("603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
+ .Case("604", ArchDefineName | ArchDefinePpcgr)
+ .Case("604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
+ .Case("620", ArchDefineName | ArchDefinePpcgr)
+ .Case("7400", ArchDefineName | ArchDefinePpcgr)
+ .Case("7450", ArchDefineName | ArchDefinePpcgr)
+ .Case("750", ArchDefineName | ArchDefinePpcgr)
+ .Case("970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr
+ | ArchDefinePpcsq)
+ .Case("pwr6", ArchDefinePwr6 | ArchDefinePpcgr | ArchDefinePpcsq)
+ .Case("pwr7", ArchDefineName | ArchDefinePwr6 | ArchDefinePpcgr
+ | ArchDefinePpcsq)
+ .Default(ArchDefineNone);
+
+ if (defs & ArchDefineName)
+ Builder.defineMacro(Twine("_ARCH_", StringRef(CPU).upper()));
+ if (defs & ArchDefinePpcgr)
+ Builder.defineMacro("_ARCH_PPCGR");
+ if (defs & ArchDefinePpcsq)
+ Builder.defineMacro("_ARCH_PPCSQ");
+ if (defs & ArchDefine440)
Builder.defineMacro("_ARCH_440");
- Builder.defineMacro("_ARCH_450");
- } else if (CPU == "970") {
- Builder.defineMacro("_ARCH_970");
- } else if (CPU == "pwr6") {
+ if (defs & ArchDefine603)
+ Builder.defineMacro("_ARCH_603");
+ if (defs & ArchDefine604)
+ Builder.defineMacro("_ARCH_604");
+ if (defs & (ArchDefinePwr4 | ArchDefinePwr6))
+ Builder.defineMacro("_ARCH_PWR4");
+ if (defs & ArchDefinePwr6) {
+ Builder.defineMacro("_ARCH_PWR5");
Builder.defineMacro("_ARCH_PWR6");
- } else if (CPU == "pwr7") {
- Builder.defineMacro("_ARCH_PWR7");
}
}
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=159665&r1=159664&r2=159665&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Jul 3 11:51:04 2012
@@ -967,10 +967,116 @@
// MSP430:#define __WINT_WIDTH__ 16
// MSP430:#define __clang__ 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -target-cpu 603e < /dev/null | FileCheck -check-prefix PPC603E %s
+//
+// PPC603E:#define _ARCH_603 1
+// PPC603E:#define _ARCH_603E 1
+// PPC603E:#define _ARCH_PPC 1
+// PPC603E:#define _ARCH_PPCGR 1
+// PPC603E:#define _BIG_ENDIAN 1
+// PPC603E:#define __BIG_ENDIAN__ 1
+// PPC603E:#define __CHAR16_TYPE__ unsigned short
+// PPC603E:#define __CHAR32_TYPE__ unsigned int
+// PPC603E:#define __CHAR_BIT__ 8
+// PPC603E:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC603E:#define __DBL_DIG__ 15
+// PPC603E:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC603E:#define __DBL_HAS_DENORM__ 1
+// PPC603E:#define __DBL_HAS_INFINITY__ 1
+// PPC603E:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC603E:#define __DBL_MANT_DIG__ 53
+// PPC603E:#define __DBL_MAX_10_EXP__ 308
+// PPC603E:#define __DBL_MAX_EXP__ 1024
+// PPC603E:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC603E:#define __DBL_MIN_10_EXP__ (-307)
+// PPC603E:#define __DBL_MIN_EXP__ (-1021)
+// PPC603E:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC603E:#define __DECIMAL_DIG__ 33
+// PPC603E:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC603E:#define __FLT_DIG__ 6
+// PPC603E:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC603E:#define __FLT_EVAL_METHOD__ 0
+// PPC603E:#define __FLT_HAS_DENORM__ 1
+// PPC603E:#define __FLT_HAS_INFINITY__ 1
+// PPC603E:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC603E:#define __FLT_MANT_DIG__ 24
+// PPC603E:#define __FLT_MAX_10_EXP__ 38
+// PPC603E:#define __FLT_MAX_EXP__ 128
+// PPC603E:#define __FLT_MAX__ 3.40282347e+38F
+// PPC603E:#define __FLT_MIN_10_EXP__ (-37)
+// PPC603E:#define __FLT_MIN_EXP__ (-125)
+// PPC603E:#define __FLT_MIN__ 1.17549435e-38F
+// PPC603E:#define __FLT_RADIX__ 2
+// PPC603E:#define __INT16_TYPE__ short
+// PPC603E:#define __INT32_TYPE__ int
+// PPC603E:#define __INT64_C_SUFFIX__ LL
+// PPC603E:#define __INT64_TYPE__ long long int
+// PPC603E:#define __INT8_TYPE__ char
+// PPC603E:#define __INTMAX_MAX__ 9223372036854775807LL
+// PPC603E:#define __INTMAX_TYPE__ long long int
+// PPC603E:#define __INTMAX_WIDTH__ 64
+// PPC603E:#define __INTPTR_TYPE__ long int
+// PPC603E:#define __INTPTR_WIDTH__ 32
+// PPC603E:#define __INT_MAX__ 2147483647
+// PPC603E:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC603E:#define __LDBL_DIG__ 31
+// PPC603E:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC603E:#define __LDBL_HAS_DENORM__ 1
+// PPC603E:#define __LDBL_HAS_INFINITY__ 1
+// PPC603E:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC603E:#define __LDBL_MANT_DIG__ 106
+// PPC603E:#define __LDBL_MAX_10_EXP__ 308
+// PPC603E:#define __LDBL_MAX_EXP__ 1024
+// PPC603E:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC603E:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC603E:#define __LDBL_MIN_EXP__ (-968)
+// PPC603E:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC603E:#define __LONG_DOUBLE_128__ 1
+// PPC603E:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC603E:#define __LONG_MAX__ 2147483647L
+// PPC603E:#define __NATURAL_ALIGNMENT__ 1
+// PPC603E:#define __NO_INLINE__ 1
+// PPC603E:#define __POINTER_WIDTH__ 32
+// PPC603E:#define __POWERPC__ 1
+// PPC603E:#define __PTRDIFF_TYPE__ long int
+// PPC603E:#define __PTRDIFF_WIDTH__ 32
+// PPC603E:#define __REGISTER_PREFIX__
+// PPC603E:#define __SCHAR_MAX__ 127
+// PPC603E:#define __SHRT_MAX__ 32767
+// PPC603E:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC603E:#define __SIZEOF_DOUBLE__ 8
+// PPC603E:#define __SIZEOF_FLOAT__ 4
+// PPC603E:#define __SIZEOF_INT__ 4
+// PPC603E:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC603E:#define __SIZEOF_LONG_LONG__ 8
+// PPC603E:#define __SIZEOF_LONG__ 4
+// PPC603E:#define __SIZEOF_POINTER__ 4
+// PPC603E:#define __SIZEOF_PTRDIFF_T__ 4
+// PPC603E:#define __SIZEOF_SHORT__ 2
+// PPC603E:#define __SIZEOF_SIZE_T__ 4
+// PPC603E:#define __SIZEOF_WCHAR_T__ 4
+// PPC603E:#define __SIZEOF_WINT_T__ 4
+// PPC603E:#define __SIZE_TYPE__ long unsigned int
+// PPC603E:#define __SIZE_WIDTH__ 32
+// PPC603E:#define __UINTMAX_TYPE__ long long unsigned int
+// PPC603E:#define __USER_LABEL_PREFIX__ _
+// PPC603E:#define __WCHAR_MAX__ 2147483647
+// PPC603E:#define __WCHAR_TYPE__ int
+// PPC603E:#define __WCHAR_WIDTH__ 32
+// PPC603E:#define __WINT_TYPE__ int
+// PPC603E:#define __WINT_WIDTH__ 32
+// PPC603E:#define __powerpc__ 1
+// PPC603E:#define __ppc__ 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s
//
// PPC64:#define _ARCH_PPC 1
// PPC64:#define _ARCH_PPC64 1
+// PPC64:#define _ARCH_PPCGR 1
+// PPC64:#define _ARCH_PPCSQ 1
+// PPC64:#define _ARCH_PWR4 1
+// PPC64:#define _ARCH_PWR5 1
+// PPC64:#define _ARCH_PWR6 1
// PPC64:#define _ARCH_PWR7 1
// PPC64:#define _BIG_ENDIAN 1
// PPC64:#define _LP64 1
More information about the cfe-commits
mailing list