[clang] a2f488c - [clang][AVR] Implement '__flashN' for variables on different flash banks
Ben Shi via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 19 03:24:16 PST 2022
Author: Ben Shi
Date: 2022-01-19T11:24:01Z
New Revision: a2f488c6a5ce251426e4108fe3276f554f5bafac
URL: https://github.com/llvm/llvm-project/commit/a2f488c6a5ce251426e4108fe3276f554f5bafac
DIFF: https://github.com/llvm/llvm-project/commit/a2f488c6a5ce251426e4108fe3276f554f5bafac.diff
LOG: [clang][AVR] Implement '__flashN' for variables on different flash banks
Reviewed By: aykevl
Differential Revision: https://reviews.llvm.org/D115982
Added:
clang/test/Sema/avr-flash.c
Modified:
clang/lib/Basic/Targets/AVR.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/address-space-avr.c
clang/test/CodeGen/avr-flash.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index 50b0fc07b3118..6266ed72cd5c0 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -24,281 +24,282 @@ namespace targets {
struct LLVM_LIBRARY_VISIBILITY MCUInfo {
const char *Name;
const char *DefineName;
+ const int NumFlashBanks; // -1 means the device does not support LPM/ELPM.
};
// This list should be kept up-to-date with AVRDevices.td in LLVM.
static MCUInfo AVRMcus[] = {
- {"at90s1200", "__AVR_AT90S1200__"},
- {"attiny11", "__AVR_ATtiny11__"},
- {"attiny12", "__AVR_ATtiny12__"},
- {"attiny15", "__AVR_ATtiny15__"},
- {"attiny28", "__AVR_ATtiny28__"},
- {"at90s2313", "__AVR_AT90S2313__"},
- {"at90s2323", "__AVR_AT90S2323__"},
- {"at90s2333", "__AVR_AT90S2333__"},
- {"at90s2343", "__AVR_AT90S2343__"},
- {"attiny22", "__AVR_ATtiny22__"},
- {"attiny26", "__AVR_ATtiny26__"},
- {"at86rf401", "__AVR_AT86RF401__"},
- {"at90s4414", "__AVR_AT90S4414__"},
- {"at90s4433", "__AVR_AT90S4433__"},
- {"at90s4434", "__AVR_AT90S4434__"},
- {"at90s8515", "__AVR_AT90S8515__"},
- {"at90c8534", "__AVR_AT90c8534__"},
- {"at90s8535", "__AVR_AT90S8535__"},
- {"ata5272", "__AVR_ATA5272__"},
- {"attiny13", "__AVR_ATtiny13__"},
- {"attiny13a", "__AVR_ATtiny13A__"},
- {"attiny2313", "__AVR_ATtiny2313__"},
- {"attiny2313a", "__AVR_ATtiny2313A__"},
- {"attiny24", "__AVR_ATtiny24__"},
- {"attiny24a", "__AVR_ATtiny24A__"},
- {"attiny4313", "__AVR_ATtiny4313__"},
- {"attiny44", "__AVR_ATtiny44__"},
- {"attiny44a", "__AVR_ATtiny44A__"},
- {"attiny84", "__AVR_ATtiny84__"},
- {"attiny84a", "__AVR_ATtiny84A__"},
- {"attiny25", "__AVR_ATtiny25__"},
- {"attiny45", "__AVR_ATtiny45__"},
- {"attiny85", "__AVR_ATtiny85__"},
- {"attiny261", "__AVR_ATtiny261__"},
- {"attiny261a", "__AVR_ATtiny261A__"},
- {"attiny441", "__AVR_ATtiny441__"},
- {"attiny461", "__AVR_ATtiny461__"},
- {"attiny461a", "__AVR_ATtiny461A__"},
- {"attiny841", "__AVR_ATtiny841__"},
- {"attiny861", "__AVR_ATtiny861__"},
- {"attiny861a", "__AVR_ATtiny861A__"},
- {"attiny87", "__AVR_ATtiny87__"},
- {"attiny43u", "__AVR_ATtiny43U__"},
- {"attiny48", "__AVR_ATtiny48__"},
- {"attiny88", "__AVR_ATtiny88__"},
- {"attiny828", "__AVR_ATtiny828__"},
- {"at43usb355", "__AVR_AT43USB355__"},
- {"at76c711", "__AVR_AT76C711__"},
- {"atmega103", "__AVR_ATmega103__"},
- {"at43usb320", "__AVR_AT43USB320__"},
- {"attiny167", "__AVR_ATtiny167__"},
- {"at90usb82", "__AVR_AT90USB82__"},
- {"at90usb162", "__AVR_AT90USB162__"},
- {"ata5505", "__AVR_ATA5505__"},
- {"atmega8u2", "__AVR_ATmega8U2__"},
- {"atmega16u2", "__AVR_ATmega16U2__"},
- {"atmega32u2", "__AVR_ATmega32U2__"},
- {"attiny1634", "__AVR_ATtiny1634__"},
- {"atmega8", "__AVR_ATmega8__"},
- {"ata6289", "__AVR_ATA6289__"},
- {"atmega8a", "__AVR_ATmega8A__"},
- {"ata6285", "__AVR_ATA6285__"},
- {"ata6286", "__AVR_ATA6286__"},
- {"atmega48", "__AVR_ATmega48__"},
- {"atmega48a", "__AVR_ATmega48A__"},
- {"atmega48pa", "__AVR_ATmega48PA__"},
- {"atmega48pb", "__AVR_ATmega48PB__"},
- {"atmega48p", "__AVR_ATmega48P__"},
- {"atmega88", "__AVR_ATmega88__"},
- {"atmega88a", "__AVR_ATmega88A__"},
- {"atmega88p", "__AVR_ATmega88P__"},
- {"atmega88pa", "__AVR_ATmega88PA__"},
- {"atmega88pb", "__AVR_ATmega88PB__"},
- {"atmega8515", "__AVR_ATmega8515__"},
- {"atmega8535", "__AVR_ATmega8535__"},
- {"atmega8hva", "__AVR_ATmega8HVA__"},
- {"at90pwm1", "__AVR_AT90PWM1__"},
- {"at90pwm2", "__AVR_AT90PWM2__"},
- {"at90pwm2b", "__AVR_AT90PWM2B__"},
- {"at90pwm3", "__AVR_AT90PWM3__"},
- {"at90pwm3b", "__AVR_AT90PWM3B__"},
- {"at90pwm81", "__AVR_AT90PWM81__"},
- {"ata5790", "__AVR_ATA5790__"},
- {"ata5795", "__AVR_ATA5795__"},
- {"atmega16", "__AVR_ATmega16__"},
- {"atmega16a", "__AVR_ATmega16A__"},
- {"atmega161", "__AVR_ATmega161__"},
- {"atmega162", "__AVR_ATmega162__"},
- {"atmega163", "__AVR_ATmega163__"},
- {"atmega164a", "__AVR_ATmega164A__"},
- {"atmega164p", "__AVR_ATmega164P__"},
- {"atmega164pa", "__AVR_ATmega164PA__"},
- {"atmega165", "__AVR_ATmega165__"},
- {"atmega165a", "__AVR_ATmega165A__"},
- {"atmega165p", "__AVR_ATmega165P__"},
- {"atmega165pa", "__AVR_ATmega165PA__"},
- {"atmega168", "__AVR_ATmega168__"},
- {"atmega168a", "__AVR_ATmega168A__"},
- {"atmega168p", "__AVR_ATmega168P__"},
- {"atmega168pa", "__AVR_ATmega168PA__"},
- {"atmega168pb", "__AVR_ATmega168PB__"},
- {"atmega169", "__AVR_ATmega169__"},
- {"atmega169a", "__AVR_ATmega169A__"},
- {"atmega169p", "__AVR_ATmega169P__"},
- {"atmega169pa", "__AVR_ATmega169PA__"},
- {"atmega32", "__AVR_ATmega32__"},
- {"atmega32a", "__AVR_ATmega32A__"},
- {"atmega323", "__AVR_ATmega323__"},
- {"atmega324a", "__AVR_ATmega324A__"},
- {"atmega324p", "__AVR_ATmega324P__"},
- {"atmega324pa", "__AVR_ATmega324PA__"},
- {"atmega324pb", "__AVR_ATmega324PB__"},
- {"atmega325", "__AVR_ATmega325__"},
- {"atmega325a", "__AVR_ATmega325A__"},
- {"atmega325p", "__AVR_ATmega325P__"},
- {"atmega325pa", "__AVR_ATmega325PA__"},
- {"atmega3250", "__AVR_ATmega3250__"},
- {"atmega3250a", "__AVR_ATmega3250A__"},
- {"atmega3250p", "__AVR_ATmega3250P__"},
- {"atmega3250pa", "__AVR_ATmega3250PA__"},
- {"atmega328", "__AVR_ATmega328__"},
- {"atmega328p", "__AVR_ATmega328P__"},
- {"atmega328pb", "__AVR_ATmega328PB__"},
- {"atmega329", "__AVR_ATmega329__"},
- {"atmega329a", "__AVR_ATmega329A__"},
- {"atmega329p", "__AVR_ATmega329P__"},
- {"atmega329pa", "__AVR_ATmega329PA__"},
- {"atmega3290", "__AVR_ATmega3290__"},
- {"atmega3290a", "__AVR_ATmega3290A__"},
- {"atmega3290p", "__AVR_ATmega3290P__"},
- {"atmega3290pa", "__AVR_ATmega3290PA__"},
- {"atmega406", "__AVR_ATmega406__"},
- {"atmega64", "__AVR_ATmega64__"},
- {"atmega64a", "__AVR_ATmega64A__"},
- {"atmega640", "__AVR_ATmega640__"},
- {"atmega644", "__AVR_ATmega644__"},
- {"atmega644a", "__AVR_ATmega644A__"},
- {"atmega644p", "__AVR_ATmega644P__"},
- {"atmega644pa", "__AVR_ATmega644PA__"},
- {"atmega645", "__AVR_ATmega645__"},
- {"atmega645a", "__AVR_ATmega645A__"},
- {"atmega645p", "__AVR_ATmega645P__"},
- {"atmega649", "__AVR_ATmega649__"},
- {"atmega649a", "__AVR_ATmega649A__"},
- {"atmega649p", "__AVR_ATmega649P__"},
- {"atmega6450", "__AVR_ATmega6450__"},
- {"atmega6450a", "__AVR_ATmega6450A__"},
- {"atmega6450p", "__AVR_ATmega6450P__"},
- {"atmega6490", "__AVR_ATmega6490__"},
- {"atmega6490a", "__AVR_ATmega6490A__"},
- {"atmega6490p", "__AVR_ATmega6490P__"},
- {"atmega64rfr2", "__AVR_ATmega64RFR2__"},
- {"atmega644rfr2", "__AVR_ATmega644RFR2__"},
- {"atmega16hva", "__AVR_ATmega16HVA__"},
- {"atmega16hva2", "__AVR_ATmega16HVA2__"},
- {"atmega16hvb", "__AVR_ATmega16HVB__"},
- {"atmega16hvbrevb", "__AVR_ATmega16HVBREVB__"},
- {"atmega32hvb", "__AVR_ATmega32HVB__"},
- {"atmega32hvbrevb", "__AVR_ATmega32HVBREVB__"},
- {"atmega64hve", "__AVR_ATmega64HVE__"},
- {"at90can32", "__AVR_AT90CAN32__"},
- {"at90can64", "__AVR_AT90CAN64__"},
- {"at90pwm161", "__AVR_AT90PWM161__"},
- {"at90pwm216", "__AVR_AT90PWM216__"},
- {"at90pwm316", "__AVR_AT90PWM316__"},
- {"atmega32c1", "__AVR_ATmega32C1__"},
- {"atmega64c1", "__AVR_ATmega64C1__"},
- {"atmega16m1", "__AVR_ATmega16M1__"},
- {"atmega32m1", "__AVR_ATmega32M1__"},
- {"atmega64m1", "__AVR_ATmega64M1__"},
- {"atmega16u4", "__AVR_ATmega16U4__"},
- {"atmega32u4", "__AVR_ATmega32U4__"},
- {"atmega32u6", "__AVR_ATmega32U6__"},
- {"at90usb646", "__AVR_AT90USB646__"},
- {"at90usb647", "__AVR_AT90USB647__"},
- {"at90scr100", "__AVR_AT90SCR100__"},
- {"at94k", "__AVR_AT94K__"},
- {"m3000", "__AVR_AT000__"},
- {"atmega128", "__AVR_ATmega128__"},
- {"atmega128a", "__AVR_ATmega128A__"},
- {"atmega1280", "__AVR_ATmega1280__"},
- {"atmega1281", "__AVR_ATmega1281__"},
- {"atmega1284", "__AVR_ATmega1284__"},
- {"atmega1284p", "__AVR_ATmega1284P__"},
- {"atmega128rfa1", "__AVR_ATmega128RFA1__"},
- {"atmega128rfr2", "__AVR_ATmega128RFR2__"},
- {"atmega1284rfr2", "__AVR_ATmega1284RFR2__"},
- {"at90can128", "__AVR_AT90CAN128__"},
- {"at90usb1286", "__AVR_AT90USB1286__"},
- {"at90usb1287", "__AVR_AT90USB1287__"},
- {"atmega2560", "__AVR_ATmega2560__"},
- {"atmega2561", "__AVR_ATmega2561__"},
- {"atmega256rfr2", "__AVR_ATmega256RFR2__"},
- {"atmega2564rfr2", "__AVR_ATmega2564RFR2__"},
- {"atxmega16a4", "__AVR_ATxmega16A4__"},
- {"atxmega16a4u", "__AVR_ATxmega16A4U__"},
- {"atxmega16c4", "__AVR_ATxmega16C4__"},
- {"atxmega16d4", "__AVR_ATxmega16D4__"},
- {"atxmega32a4", "__AVR_ATxmega32A4__"},
- {"atxmega32a4u", "__AVR_ATxmega32A4U__"},
- {"atxmega32c4", "__AVR_ATxmega32C4__"},
- {"atxmega32d4", "__AVR_ATxmega32D4__"},
- {"atxmega32e5", "__AVR_ATxmega32E5__"},
- {"atxmega16e5", "__AVR_ATxmega16E5__"},
- {"atxmega8e5", "__AVR_ATxmega8E5__"},
- {"atxmega32x1", "__AVR_ATxmega32X1__"},
- {"atxmega64a3", "__AVR_ATxmega64A3__"},
- {"atxmega64a3u", "__AVR_ATxmega64A3U__"},
- {"atxmega64a4u", "__AVR_ATxmega64A4U__"},
- {"atxmega64b1", "__AVR_ATxmega64B1__"},
- {"atxmega64b3", "__AVR_ATxmega64B3__"},
- {"atxmega64c3", "__AVR_ATxmega64C3__"},
- {"atxmega64d3", "__AVR_ATxmega64D3__"},
- {"atxmega64d4", "__AVR_ATxmega64D4__"},
- {"atxmega64a1", "__AVR_ATxmega64A1__"},
- {"atxmega64a1u", "__AVR_ATxmega64A1U__"},
- {"atxmega128a3", "__AVR_ATxmega128A3__"},
- {"atxmega128a3u", "__AVR_ATxmega128A3U__"},
- {"atxmega128b1", "__AVR_ATxmega128B1__"},
- {"atxmega128b3", "__AVR_ATxmega128B3__"},
- {"atxmega128c3", "__AVR_ATxmega128C3__"},
- {"atxmega128d3", "__AVR_ATxmega128D3__"},
- {"atxmega128d4", "__AVR_ATxmega128D4__"},
- {"atxmega192a3", "__AVR_ATxmega192A3__"},
- {"atxmega192a3u", "__AVR_ATxmega192A3U__"},
- {"atxmega192c3", "__AVR_ATxmega192C3__"},
- {"atxmega192d3", "__AVR_ATxmega192D3__"},
- {"atxmega256a3", "__AVR_ATxmega256A3__"},
- {"atxmega256a3u", "__AVR_ATxmega256A3U__"},
- {"atxmega256a3b", "__AVR_ATxmega256A3B__"},
- {"atxmega256a3bu", "__AVR_ATxmega256A3BU__"},
- {"atxmega256c3", "__AVR_ATxmega256C3__"},
- {"atxmega256d3", "__AVR_ATxmega256D3__"},
- {"atxmega384c3", "__AVR_ATxmega384C3__"},
- {"atxmega384d3", "__AVR_ATxmega384D3__"},
- {"atxmega128a1", "__AVR_ATxmega128A1__"},
- {"atxmega128a1u", "__AVR_ATxmega128A1U__"},
- {"atxmega128a4u", "__AVR_ATxmega128A4U__"},
- {"attiny4", "__AVR_ATtiny4__"},
- {"attiny5", "__AVR_ATtiny5__"},
- {"attiny9", "__AVR_ATtiny9__"},
- {"attiny10", "__AVR_ATtiny10__"},
- {"attiny20", "__AVR_ATtiny20__"},
- {"attiny40", "__AVR_ATtiny40__"},
- {"attiny102", "__AVR_ATtiny102__"},
- {"attiny104", "__AVR_ATtiny104__"},
- {"attiny202", "__AVR_ATtiny202__"},
- {"attiny402", "__AVR_ATtiny402__"},
- {"attiny204", "__AVR_ATtiny204__"},
- {"attiny404", "__AVR_ATtiny404__"},
- {"attiny804", "__AVR_ATtiny804__"},
- {"attiny1604", "__AVR_ATtiny1604__"},
- {"attiny406", "__AVR_ATtiny406__"},
- {"attiny806", "__AVR_ATtiny806__"},
- {"attiny1606", "__AVR_ATtiny1606__"},
- {"attiny807", "__AVR_ATtiny807__"},
- {"attiny1607", "__AVR_ATtiny1607__"},
- {"attiny212", "__AVR_ATtiny212__"},
- {"attiny412", "__AVR_ATtiny412__"},
- {"attiny214", "__AVR_ATtiny214__"},
- {"attiny414", "__AVR_ATtiny414__"},
- {"attiny814", "__AVR_ATtiny814__"},
- {"attiny1614", "__AVR_ATtiny1614__"},
- {"attiny416", "__AVR_ATtiny416__"},
- {"attiny816", "__AVR_ATtiny816__"},
- {"attiny1616", "__AVR_ATtiny1616__"},
- {"attiny3216", "__AVR_ATtiny3216__"},
- {"attiny417", "__AVR_ATtiny417__"},
- {"attiny817", "__AVR_ATtiny817__"},
- {"attiny1617", "__AVR_ATtiny1617__"},
- {"attiny3217", "__AVR_ATtiny3217__"},
+ {"at90s1200", "__AVR_AT90S1200__", 0},
+ {"attiny11", "__AVR_ATtiny11__", 0},
+ {"attiny12", "__AVR_ATtiny12__", 0},
+ {"attiny15", "__AVR_ATtiny15__", 0},
+ {"attiny28", "__AVR_ATtiny28__", 0},
+ {"at90s2313", "__AVR_AT90S2313__", 1},
+ {"at90s2323", "__AVR_AT90S2323__", 1},
+ {"at90s2333", "__AVR_AT90S2333__", 1},
+ {"at90s2343", "__AVR_AT90S2343__", 1},
+ {"attiny22", "__AVR_ATtiny22__", 1},
+ {"attiny26", "__AVR_ATtiny26__", 1},
+ {"at86rf401", "__AVR_AT86RF401__", 1},
+ {"at90s4414", "__AVR_AT90S4414__", 1},
+ {"at90s4433", "__AVR_AT90S4433__", 1},
+ {"at90s4434", "__AVR_AT90S4434__", 1},
+ {"at90s8515", "__AVR_AT90S8515__", 1},
+ {"at90c8534", "__AVR_AT90c8534__", 1},
+ {"at90s8535", "__AVR_AT90S8535__", 1},
+ {"ata5272", "__AVR_ATA5272__", 1},
+ {"attiny13", "__AVR_ATtiny13__", 1},
+ {"attiny13a", "__AVR_ATtiny13A__", 1},
+ {"attiny2313", "__AVR_ATtiny2313__", 1},
+ {"attiny2313a", "__AVR_ATtiny2313A__", 1},
+ {"attiny24", "__AVR_ATtiny24__", 1},
+ {"attiny24a", "__AVR_ATtiny24A__", 1},
+ {"attiny4313", "__AVR_ATtiny4313__", 1},
+ {"attiny44", "__AVR_ATtiny44__", 1},
+ {"attiny44a", "__AVR_ATtiny44A__", 1},
+ {"attiny84", "__AVR_ATtiny84__", 1},
+ {"attiny84a", "__AVR_ATtiny84A__", 1},
+ {"attiny25", "__AVR_ATtiny25__", 1},
+ {"attiny45", "__AVR_ATtiny45__", 1},
+ {"attiny85", "__AVR_ATtiny85__", 1},
+ {"attiny261", "__AVR_ATtiny261__", 1},
+ {"attiny261a", "__AVR_ATtiny261A__", 1},
+ {"attiny441", "__AVR_ATtiny441__", 1},
+ {"attiny461", "__AVR_ATtiny461__", 1},
+ {"attiny461a", "__AVR_ATtiny461A__", 1},
+ {"attiny841", "__AVR_ATtiny841__", 1},
+ {"attiny861", "__AVR_ATtiny861__", 1},
+ {"attiny861a", "__AVR_ATtiny861A__", 1},
+ {"attiny87", "__AVR_ATtiny87__", 1},
+ {"attiny43u", "__AVR_ATtiny43U__", 1},
+ {"attiny48", "__AVR_ATtiny48__", 1},
+ {"attiny88", "__AVR_ATtiny88__", 1},
+ {"attiny828", "__AVR_ATtiny828__", 1},
+ {"at43usb355", "__AVR_AT43USB355__", 1},
+ {"at76c711", "__AVR_AT76C711__", 1},
+ {"atmega103", "__AVR_ATmega103__", 1},
+ {"at43usb320", "__AVR_AT43USB320__", 1},
+ {"attiny167", "__AVR_ATtiny167__", 1},
+ {"at90usb82", "__AVR_AT90USB82__", 1},
+ {"at90usb162", "__AVR_AT90USB162__", 1},
+ {"ata5505", "__AVR_ATA5505__", 1},
+ {"atmega8u2", "__AVR_ATmega8U2__", 1},
+ {"atmega16u2", "__AVR_ATmega16U2__", 1},
+ {"atmega32u2", "__AVR_ATmega32U2__", 1},
+ {"attiny1634", "__AVR_ATtiny1634__", 1},
+ {"atmega8", "__AVR_ATmega8__", 1},
+ {"ata6289", "__AVR_ATA6289__", 1},
+ {"atmega8a", "__AVR_ATmega8A__", 1},
+ {"ata6285", "__AVR_ATA6285__", 1},
+ {"ata6286", "__AVR_ATA6286__", 1},
+ {"atmega48", "__AVR_ATmega48__", 1},
+ {"atmega48a", "__AVR_ATmega48A__", 1},
+ {"atmega48pa", "__AVR_ATmega48PA__", 1},
+ {"atmega48pb", "__AVR_ATmega48PB__", 1},
+ {"atmega48p", "__AVR_ATmega48P__", 1},
+ {"atmega88", "__AVR_ATmega88__", 1},
+ {"atmega88a", "__AVR_ATmega88A__", 1},
+ {"atmega88p", "__AVR_ATmega88P__", 1},
+ {"atmega88pa", "__AVR_ATmega88PA__", 1},
+ {"atmega88pb", "__AVR_ATmega88PB__", 1},
+ {"atmega8515", "__AVR_ATmega8515__", 1},
+ {"atmega8535", "__AVR_ATmega8535__", 1},
+ {"atmega8hva", "__AVR_ATmega8HVA__", 1},
+ {"at90pwm1", "__AVR_AT90PWM1__", 1},
+ {"at90pwm2", "__AVR_AT90PWM2__", 1},
+ {"at90pwm2b", "__AVR_AT90PWM2B__", 1},
+ {"at90pwm3", "__AVR_AT90PWM3__", 1},
+ {"at90pwm3b", "__AVR_AT90PWM3B__", 1},
+ {"at90pwm81", "__AVR_AT90PWM81__", 1},
+ {"ata5790", "__AVR_ATA5790__", 1},
+ {"ata5795", "__AVR_ATA5795__", 1},
+ {"atmega16", "__AVR_ATmega16__", 1},
+ {"atmega16a", "__AVR_ATmega16A__", 1},
+ {"atmega161", "__AVR_ATmega161__", 1},
+ {"atmega162", "__AVR_ATmega162__", 1},
+ {"atmega163", "__AVR_ATmega163__", 1},
+ {"atmega164a", "__AVR_ATmega164A__", 1},
+ {"atmega164p", "__AVR_ATmega164P__", 1},
+ {"atmega164pa", "__AVR_ATmega164PA__", 1},
+ {"atmega165", "__AVR_ATmega165__", 1},
+ {"atmega165a", "__AVR_ATmega165A__", 1},
+ {"atmega165p", "__AVR_ATmega165P__", 1},
+ {"atmega165pa", "__AVR_ATmega165PA__", 1},
+ {"atmega168", "__AVR_ATmega168__", 1},
+ {"atmega168a", "__AVR_ATmega168A__", 1},
+ {"atmega168p", "__AVR_ATmega168P__", 1},
+ {"atmega168pa", "__AVR_ATmega168PA__", 1},
+ {"atmega168pb", "__AVR_ATmega168PB__", 1},
+ {"atmega169", "__AVR_ATmega169__", 1},
+ {"atmega169a", "__AVR_ATmega169A__", 1},
+ {"atmega169p", "__AVR_ATmega169P__", 1},
+ {"atmega169pa", "__AVR_ATmega169PA__", 1},
+ {"atmega32", "__AVR_ATmega32__", 1},
+ {"atmega32a", "__AVR_ATmega32A__", 1},
+ {"atmega323", "__AVR_ATmega323__", 1},
+ {"atmega324a", "__AVR_ATmega324A__", 1},
+ {"atmega324p", "__AVR_ATmega324P__", 1},
+ {"atmega324pa", "__AVR_ATmega324PA__", 1},
+ {"atmega324pb", "__AVR_ATmega324PB__", 1},
+ {"atmega325", "__AVR_ATmega325__", 1},
+ {"atmega325a", "__AVR_ATmega325A__", 1},
+ {"atmega325p", "__AVR_ATmega325P__", 1},
+ {"atmega325pa", "__AVR_ATmega325PA__", 1},
+ {"atmega3250", "__AVR_ATmega3250__", 1},
+ {"atmega3250a", "__AVR_ATmega3250A__", 1},
+ {"atmega3250p", "__AVR_ATmega3250P__", 1},
+ {"atmega3250pa", "__AVR_ATmega3250PA__", 1},
+ {"atmega328", "__AVR_ATmega328__", 1},
+ {"atmega328p", "__AVR_ATmega328P__", 1},
+ {"atmega328pb", "__AVR_ATmega328PB__", 1},
+ {"atmega329", "__AVR_ATmega329__", 1},
+ {"atmega329a", "__AVR_ATmega329A__", 1},
+ {"atmega329p", "__AVR_ATmega329P__", 1},
+ {"atmega329pa", "__AVR_ATmega329PA__", 1},
+ {"atmega3290", "__AVR_ATmega3290__", 1},
+ {"atmega3290a", "__AVR_ATmega3290A__", 1},
+ {"atmega3290p", "__AVR_ATmega3290P__", 1},
+ {"atmega3290pa", "__AVR_ATmega3290PA__", 1},
+ {"atmega406", "__AVR_ATmega406__", 1},
+ {"atmega64", "__AVR_ATmega64__", 1},
+ {"atmega64a", "__AVR_ATmega64A__", 1},
+ {"atmega640", "__AVR_ATmega640__", 1},
+ {"atmega644", "__AVR_ATmega644__", 1},
+ {"atmega644a", "__AVR_ATmega644A__", 1},
+ {"atmega644p", "__AVR_ATmega644P__", 1},
+ {"atmega644pa", "__AVR_ATmega644PA__", 1},
+ {"atmega645", "__AVR_ATmega645__", 1},
+ {"atmega645a", "__AVR_ATmega645A__", 1},
+ {"atmega645p", "__AVR_ATmega645P__", 1},
+ {"atmega649", "__AVR_ATmega649__", 1},
+ {"atmega649a", "__AVR_ATmega649A__", 1},
+ {"atmega649p", "__AVR_ATmega649P__", 1},
+ {"atmega6450", "__AVR_ATmega6450__", 1},
+ {"atmega6450a", "__AVR_ATmega6450A__", 1},
+ {"atmega6450p", "__AVR_ATmega6450P__", 1},
+ {"atmega6490", "__AVR_ATmega6490__", 1},
+ {"atmega6490a", "__AVR_ATmega6490A__", 1},
+ {"atmega6490p", "__AVR_ATmega6490P__", 1},
+ {"atmega64rfr2", "__AVR_ATmega64RFR2__", 1},
+ {"atmega644rfr2", "__AVR_ATmega644RFR2__", 1},
+ {"atmega16hva", "__AVR_ATmega16HVA__", 1},
+ {"atmega16hva2", "__AVR_ATmega16HVA2__", 1},
+ {"atmega16hvb", "__AVR_ATmega16HVB__", 1},
+ {"atmega16hvbrevb", "__AVR_ATmega16HVBREVB__", 1},
+ {"atmega32hvb", "__AVR_ATmega32HVB__", 1},
+ {"atmega32hvbrevb", "__AVR_ATmega32HVBREVB__", 1},
+ {"atmega64hve", "__AVR_ATmega64HVE__", 1},
+ {"at90can32", "__AVR_AT90CAN32__", 1},
+ {"at90can64", "__AVR_AT90CAN64__", 1},
+ {"at90pwm161", "__AVR_AT90PWM161__", 1},
+ {"at90pwm216", "__AVR_AT90PWM216__", 1},
+ {"at90pwm316", "__AVR_AT90PWM316__", 1},
+ {"atmega32c1", "__AVR_ATmega32C1__", 1},
+ {"atmega64c1", "__AVR_ATmega64C1__", 1},
+ {"atmega16m1", "__AVR_ATmega16M1__", 1},
+ {"atmega32m1", "__AVR_ATmega32M1__", 1},
+ {"atmega64m1", "__AVR_ATmega64M1__", 1},
+ {"atmega16u4", "__AVR_ATmega16U4__", 1},
+ {"atmega32u4", "__AVR_ATmega32U4__", 1},
+ {"atmega32u6", "__AVR_ATmega32U6__", 1},
+ {"at90usb646", "__AVR_AT90USB646__", 1},
+ {"at90usb647", "__AVR_AT90USB647__", 1},
+ {"at90scr100", "__AVR_AT90SCR100__", 1},
+ {"at94k", "__AVR_AT94K__", 1},
+ {"m3000", "__AVR_AT000__", 1},
+ {"atmega128", "__AVR_ATmega128__", 2},
+ {"atmega128a", "__AVR_ATmega128A__", 2},
+ {"atmega1280", "__AVR_ATmega1280__", 2},
+ {"atmega1281", "__AVR_ATmega1281__", 2},
+ {"atmega1284", "__AVR_ATmega1284__", 2},
+ {"atmega1284p", "__AVR_ATmega1284P__", 2},
+ {"atmega128rfa1", "__AVR_ATmega128RFA1__", 2},
+ {"atmega128rfr2", "__AVR_ATmega128RFR2__", 2},
+ {"atmega1284rfr2", "__AVR_ATmega1284RFR2__", 2},
+ {"at90can128", "__AVR_AT90CAN128__", 2},
+ {"at90usb1286", "__AVR_AT90USB1286__", 2},
+ {"at90usb1287", "__AVR_AT90USB1287__", 2},
+ {"atmega2560", "__AVR_ATmega2560__", 4},
+ {"atmega2561", "__AVR_ATmega2561__", 4},
+ {"atmega256rfr2", "__AVR_ATmega256RFR2__", 4},
+ {"atmega2564rfr2", "__AVR_ATmega2564RFR2__", 4},
+ {"atxmega16a4", "__AVR_ATxmega16A4__", 1},
+ {"atxmega16a4u", "__AVR_ATxmega16A4U__", 1},
+ {"atxmega16c4", "__AVR_ATxmega16C4__", 1},
+ {"atxmega16d4", "__AVR_ATxmega16D4__", 1},
+ {"atxmega32a4", "__AVR_ATxmega32A4__", 1},
+ {"atxmega32a4u", "__AVR_ATxmega32A4U__", 1},
+ {"atxmega32c4", "__AVR_ATxmega32C4__", 1},
+ {"atxmega32d4", "__AVR_ATxmega32D4__", 1},
+ {"atxmega32e5", "__AVR_ATxmega32E5__", 1},
+ {"atxmega16e5", "__AVR_ATxmega16E5__", 1},
+ {"atxmega8e5", "__AVR_ATxmega8E5__", 1},
+ {"atxmega32x1", "__AVR_ATxmega32X1__", 1},
+ {"atxmega64a3", "__AVR_ATxmega64A3__", 1},
+ {"atxmega64a3u", "__AVR_ATxmega64A3U__", 1},
+ {"atxmega64a4u", "__AVR_ATxmega64A4U__", 1},
+ {"atxmega64b1", "__AVR_ATxmega64B1__", 1},
+ {"atxmega64b3", "__AVR_ATxmega64B3__", 1},
+ {"atxmega64c3", "__AVR_ATxmega64C3__", 1},
+ {"atxmega64d3", "__AVR_ATxmega64D3__", 1},
+ {"atxmega64d4", "__AVR_ATxmega64D4__", 1},
+ {"atxmega64a1", "__AVR_ATxmega64A1__", 1},
+ {"atxmega64a1u", "__AVR_ATxmega64A1U__", 1},
+ {"atxmega128a3", "__AVR_ATxmega128A3__", 2},
+ {"atxmega128a3u", "__AVR_ATxmega128A3U__", 2},
+ {"atxmega128b1", "__AVR_ATxmega128B1__", 2},
+ {"atxmega128b3", "__AVR_ATxmega128B3__", 2},
+ {"atxmega128c3", "__AVR_ATxmega128C3__", 2},
+ {"atxmega128d3", "__AVR_ATxmega128D3__", 2},
+ {"atxmega128d4", "__AVR_ATxmega128D4__", 2},
+ {"atxmega192a3", "__AVR_ATxmega192A3__", 3},
+ {"atxmega192a3u", "__AVR_ATxmega192A3U__", 3},
+ {"atxmega192c3", "__AVR_ATxmega192C3__", 3},
+ {"atxmega192d3", "__AVR_ATxmega192D3__", 3},
+ {"atxmega256a3", "__AVR_ATxmega256A3__", 4},
+ {"atxmega256a3u", "__AVR_ATxmega256A3U__", 4},
+ {"atxmega256a3b", "__AVR_ATxmega256A3B__", 4},
+ {"atxmega256a3bu", "__AVR_ATxmega256A3BU__", 4},
+ {"atxmega256c3", "__AVR_ATxmega256C3__", 4},
+ {"atxmega256d3", "__AVR_ATxmega256D3__", 4},
+ {"atxmega384c3", "__AVR_ATxmega384C3__", 6},
+ {"atxmega384d3", "__AVR_ATxmega384D3__", 6},
+ {"atxmega128a1", "__AVR_ATxmega128A1__", 2},
+ {"atxmega128a1u", "__AVR_ATxmega128A1U__", 2},
+ {"atxmega128a4u", "__AVR_ATxmega128A4U__", 2},
+ {"attiny4", "__AVR_ATtiny4__", 0},
+ {"attiny5", "__AVR_ATtiny5__", 0},
+ {"attiny9", "__AVR_ATtiny9__", 0},
+ {"attiny10", "__AVR_ATtiny10__", 0},
+ {"attiny20", "__AVR_ATtiny20__", 0},
+ {"attiny40", "__AVR_ATtiny40__", 0},
+ {"attiny102", "__AVR_ATtiny102__", 0},
+ {"attiny104", "__AVR_ATtiny104__", 0},
+ {"attiny202", "__AVR_ATtiny202__", 1},
+ {"attiny402", "__AVR_ATtiny402__", 1},
+ {"attiny204", "__AVR_ATtiny204__", 1},
+ {"attiny404", "__AVR_ATtiny404__", 1},
+ {"attiny804", "__AVR_ATtiny804__", 1},
+ {"attiny1604", "__AVR_ATtiny1604__", 1},
+ {"attiny406", "__AVR_ATtiny406__", 1},
+ {"attiny806", "__AVR_ATtiny806__", 1},
+ {"attiny1606", "__AVR_ATtiny1606__", 1},
+ {"attiny807", "__AVR_ATtiny807__", 1},
+ {"attiny1607", "__AVR_ATtiny1607__", 1},
+ {"attiny212", "__AVR_ATtiny212__", 1},
+ {"attiny412", "__AVR_ATtiny412__", 1},
+ {"attiny214", "__AVR_ATtiny214__", 1},
+ {"attiny414", "__AVR_ATtiny414__", 1},
+ {"attiny814", "__AVR_ATtiny814__", 1},
+ {"attiny1614", "__AVR_ATtiny1614__", 1},
+ {"attiny416", "__AVR_ATtiny416__", 1},
+ {"attiny816", "__AVR_ATtiny816__", 1},
+ {"attiny1616", "__AVR_ATtiny1616__", 1},
+ {"attiny3216", "__AVR_ATtiny3216__", 1},
+ {"attiny417", "__AVR_ATtiny417__", 1},
+ {"attiny817", "__AVR_ATtiny817__", 1},
+ {"attiny1617", "__AVR_ATtiny1617__", 1},
+ {"attiny3217", "__AVR_ATtiny3217__", 1},
};
} // namespace targets
@@ -330,13 +331,25 @@ void AVRTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__AVR");
Builder.defineMacro("__AVR__");
Builder.defineMacro("__ELF__");
- Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
if (!this->CPU.empty()) {
auto It = llvm::find_if(
AVRMcus, [&](const MCUInfo &Info) { return Info.Name == this->CPU; });
- if (It != std::end(AVRMcus))
+ if (It != std::end(AVRMcus)) {
Builder.defineMacro(It->DefineName);
+ if (It->NumFlashBanks >= 1)
+ Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+ if (It->NumFlashBanks >= 2)
+ Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+ if (It->NumFlashBanks >= 3)
+ Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+ if (It->NumFlashBanks >= 4)
+ Builder.defineMacro("__flash3", "__attribute__((address_space(4)))");
+ if (It->NumFlashBanks >= 5)
+ Builder.defineMacro("__flash4", "__attribute__((address_space(5)))");
+ if (It->NumFlashBanks >= 6)
+ Builder.defineMacro("__flash5", "__attribute__((address_space(6)))");
+ }
}
}
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 220804f763fe2..ebe651b5a7184 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8282,14 +8282,15 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
const VarDecl *D) const override {
- // Check if a global/static variable is defined within address space 1
+ // Check if global/static variable is defined in address space
+ // 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
// but not constant.
LangAS AS = D->getType().getAddressSpace();
- if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
- !D->getType().isConstQualified())
+ if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+ toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
CGM.getDiags().Report(D->getLocation(),
diag::err_verify_nonconst_addrspace)
- << "__flash";
+ << "__flash*";
return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
}
diff --git a/clang/test/CodeGen/address-space-avr.c b/clang/test/CodeGen/address-space-avr.c
index ea78c895f63dc..0a37aff1cb857 100644
--- a/clang/test/CodeGen/address-space-avr.c
+++ b/clang/test/CodeGen/address-space-avr.c
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple avr -target-cpu atmega2560 -emit-llvm < %s | FileCheck %s
// CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var0 {{.*}} addrspace(4) constant [3 x i16]
// CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.f3var2 {{.*}} addrspace(4) constant [3 x i16]
// CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var1 {{.*}} addrspace(4) constant [3 x i16]
// CHECK: define{{.*}} void @bar() addrspace(1)
// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)
@@ -11,11 +14,16 @@
__flash const int var0[] = {999, 888, 777};
__flash static const int var1[] = {111, 222, 333};
+__flash3 const int f3var0[] = {12, 34, 56};
+__flash3 static const int f3var1[] = {52, 64, 96};
+
int i;
void foo();
void bar() {
static __flash const int var2[] = {555, 666, 777};
+ static __flash3 const int f3var2[] = {5555, 6666, 7787};
foo(var1[i]);
+ foo(f3var1[i]);
}
diff --git a/clang/test/CodeGen/avr-flash.c b/clang/test/CodeGen/avr-flash.c
index 99648137d0f18..4420afa9b9b8a 100644
--- a/clang/test/CodeGen/avr-flash.c
+++ b/clang/test/CodeGen/avr-flash.c
@@ -1,6 +1,11 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+// RUN: %clang_cc1 -triple avr -target-cpu atxmega384c3 -emit-llvm-only -verify %s
int foo(void) {
- static __flash int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash'}}
- return b[0];
+ static __flash int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ static __flash1 int c[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ static __flash2 int d[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ static __flash3 int e[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ static __flash4 int f[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ static __flash5 int g[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+ return b[0] + c[1];
}
diff --git a/clang/test/Sema/avr-flash.c b/clang/test/Sema/avr-flash.c
new file mode 100644
index 0000000000000..a008eb19b08e6
--- /dev/null
+++ b/clang/test/Sema/avr-flash.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple avr -target-cpu at90s8515 -fsyntax-only -verify
+
+int foo(int n) {
+ static __flash const int a0[] = {4, 6}; // OK
+ static __flash1 const int a1[] = {4, 6}; // expected-error {{unknown type name '__flash1'}}
+ static __flash2 const int a2[] = {4, 6}; // expected-error {{unknown type name '__flash2'}}
+ static __flash3 const int a3[] = {4, 6}; // expected-error {{unknown type name '__flash3'}}
+ static __flash4 const int a4[] = {4, 6}; // expected-error {{unknown type name '__flash4'}}
+ static __flash5 const int a5[] = {4, 6}; // expected-error {{unknown type name '__flash5'}}
+ // TODO: It would be better to report "'__flash5' is not supported on at908515".
+ return a0[n] + a1[n];
+}
More information about the cfe-commits
mailing list