[clang][XCore] Define __xcore__ for XCore target.
authorNigel Perks <nigelp@xmos.com>
Wed, 21 Apr 2021 17:41:19 +0000 (18:41 +0100)
committerNigel Perks <nigelp@xmos.com>
Mon, 26 Apr 2021 14:06:04 +0000 (15:06 +0100)
The headers shipped with the XMOS XCore compiler expect __xcore__ to be defined.
The __XS1B__ macro, already defined, is for the default subtarget.

No other targets affected.

clang/lib/Basic/Targets/XCore.cpp
clang/test/Preprocessor/init.c

index da614f1..ba64f15 100644 (file)
@@ -28,6 +28,7 @@ const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
 
 void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
                                        MacroBuilder &Builder) const {
+  Builder.defineMacro("__xcore__");
   Builder.defineMacro("__XS1B__");
 }
 
index 0329453..be60eb6 100644 (file)
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+// XCORE:#define __xcore__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-unknown-unknown \
 // RUN:   < /dev/null \