[PATCH] D124157: [clang][preprocessor] Add more macros to target AVR

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 1 21:39:25 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42fa5bae7afc: [clang][preprocessor] Add more macros to target AVR (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124157/new/

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,11 @@
-// 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 attiny13 /dev/null | FileCheck -match-full-lines --check-prefixes=CHECK,AVR %s
+// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny4 /dev/null | FileCheck -match-full-lines --check-prefixes=CHECK,TINY %s
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
+
+// TINY: #define __AVR_TINY__ 1
+// AVR-NOT: __AVR_TINY__
+
 // CHECK: #define __AVR__ 1
 // CHECK: #define __ELF__ 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.426329.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/5f54bac7/attachment.bin>


More information about the cfe-commits mailing list