[PATCH] D124157: [clang][preprocessor] Add more macros to target AVR
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 21 02:43:43 PDT 2022
benshi001 created this revision.
benshi001 added reviewers: aykevl, dylanmckay.
Herald added a subscriber: Jim.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124157
Files:
clang/lib/Basic/Targets/AVR.cpp
clang/test/Preprocessor/avr-common.c
Index: clang/test/Preprocessor/avr-common.c
===================================================================
--- clang/test/Preprocessor/avr-common.c
+++ clang/test/Preprocessor/avr-common.c
@@ -1,6 +1,10 @@
// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny4 /dev/null | FileCheck -match-full-lines %s --check-prefix TINY
// CHECK: #define AVR 1
// CHECK: #define __AVR 1
// CHECK: #define __AVR__ 1
// CHECK: #define __ELF__ 1
+// CHECK-NOT: __AVR_TINY__
+
+// TINY: #define __AVR_TINY__ 1
Index: clang/lib/Basic/Targets/AVR.cpp
===================================================================
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -384,6 +384,9 @@
auto It = llvm::find_if(
AVRMcus, [&](const MCUInfo &Info) { return Info.Name == this->CPU; });
+ if (It->IsTiny)
+ Builder.defineMacro("__AVR_TINY__", "1");
+
if (It != std::end(AVRMcus)) {
Builder.defineMacro(It->DefineName);
if (It->NumFlashBanks >= 1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124157.424133.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220421/525cf2fe/attachment-0001.bin>
More information about the cfe-commits
mailing list