// NOTE: This list has been synchronized with gcc-avr 5.4.0 and avr-libc 2.0.0.
static MCUInfo AVRMcus[] = {
+ {"avr1", NULL, 0, false},
{"at90s1200", "__AVR_AT90S1200__", 0, false},
{"attiny11", "__AVR_ATtiny11__", 0, false},
{"attiny12", "__AVR_ATtiny12__", 0, false},
{"attiny15", "__AVR_ATtiny15__", 0, false},
{"attiny28", "__AVR_ATtiny28__", 0, false},
+ {"avr2", NULL, 1, false},
{"at90s2313", "__AVR_AT90S2313__", 1, false},
{"at90s2323", "__AVR_AT90S2323__", 1, false},
{"at90s2333", "__AVR_AT90S2333__", 1, false},
{"at90s8515", "__AVR_AT90S8515__", 1, false},
{"at90c8534", "__AVR_AT90c8534__", 1, false},
{"at90s8535", "__AVR_AT90S8535__", 1, false},
+ {"avr25", NULL, 1, false},
{"ata5272", "__AVR_ATA5272__", 1, false},
{"ata6616c", "__AVR_ATA6616c__", 1, false},
{"attiny13", "__AVR_ATtiny13__", 1, false},
{"attiny48", "__AVR_ATtiny48__", 1, false},
{"attiny88", "__AVR_ATtiny88__", 1, false},
{"attiny828", "__AVR_ATtiny828__", 1, false},
+ {"avr3", NULL, 1, false},
{"at43usb355", "__AVR_AT43USB355__", 1, false},
{"at76c711", "__AVR_AT76C711__", 1, false},
+ {"avr31", NULL, 1, false},
{"atmega103", "__AVR_ATmega103__", 1, false},
{"at43usb320", "__AVR_AT43USB320__", 1, false},
+ {"avr35", NULL, 1, false},
{"attiny167", "__AVR_ATtiny167__", 1, false},
{"at90usb82", "__AVR_AT90USB82__", 1, false},
{"at90usb162", "__AVR_AT90USB162__", 1, false},
{"atmega16u2", "__AVR_ATmega16U2__", 1, false},
{"atmega32u2", "__AVR_ATmega32U2__", 1, false},
{"attiny1634", "__AVR_ATtiny1634__", 1, false},
+ {"avr4", NULL, 1, false},
{"atmega8", "__AVR_ATmega8__", 1, false},
{"ata6289", "__AVR_ATA6289__", 1, false},
{"atmega8a", "__AVR_ATmega8A__", 1, false},
{"at90pwm3", "__AVR_AT90PWM3__", 1, false},
{"at90pwm3b", "__AVR_AT90PWM3B__", 1, false},
{"at90pwm81", "__AVR_AT90PWM81__", 1, false},
+ {"avr5", NULL, 1, false},
{"ata5702m322", "__AVR_ATA5702M322__", 1, false},
{"ata5782", "__AVR_ATA5782__", 1, false},
{"ata5790", "__AVR_ATA5790__", 1, false},
{"at90scr100", "__AVR_AT90SCR100__", 1, false},
{"at94k", "__AVR_AT94K__", 1, false},
{"m3000", "__AVR_AT000__", 1, false},
+ {"avr51", NULL, 2, false},
{"atmega128", "__AVR_ATmega128__", 2, false},
{"atmega128a", "__AVR_ATmega128A__", 2, false},
{"atmega1280", "__AVR_ATmega1280__", 2, false},
{"at90can128", "__AVR_AT90CAN128__", 2, false},
{"at90usb1286", "__AVR_AT90USB1286__", 2, false},
{"at90usb1287", "__AVR_AT90USB1287__", 2, false},
+ {"avr6", NULL, 4, false},
{"atmega2560", "__AVR_ATmega2560__", 4, false},
{"atmega2561", "__AVR_ATmega2561__", 4, false},
{"atmega256rfr2", "__AVR_ATmega256RFR2__", 4, false},
{"atmega2564rfr2", "__AVR_ATmega2564RFR2__", 4, false},
+ {"avrxmega2", NULL, 1, false},
{"atxmega16a4", "__AVR_ATxmega16A4__", 1, false},
{"atxmega16a4u", "__AVR_ATxmega16A4U__", 1, false},
{"atxmega16c4", "__AVR_ATxmega16C4__", 1, false},
{"atxmega32e5", "__AVR_ATxmega32E5__", 1, false},
{"atxmega16e5", "__AVR_ATxmega16E5__", 1, false},
{"atxmega8e5", "__AVR_ATxmega8E5__", 1, false},
+ {"avrxmega4", NULL, 1, false},
{"atxmega64a3", "__AVR_ATxmega64A3__", 1, false},
{"atxmega64a3u", "__AVR_ATxmega64A3U__", 1, false},
{"atxmega64a4u", "__AVR_ATxmega64A4U__", 1, false},
{"atxmega64c3", "__AVR_ATxmega64C3__", 1, false},
{"atxmega64d3", "__AVR_ATxmega64D3__", 1, false},
{"atxmega64d4", "__AVR_ATxmega64D4__", 1, false},
+ {"avrxmega5", NULL, 1, false},
{"atxmega64a1", "__AVR_ATxmega64A1__", 1, false},
{"atxmega64a1u", "__AVR_ATxmega64A1U__", 1, false},
+ {"avrxmega6", NULL, 6, false},
{"atxmega128a3", "__AVR_ATxmega128A3__", 2, false},
{"atxmega128a3u", "__AVR_ATxmega128A3U__", 2, false},
{"atxmega128b1", "__AVR_ATxmega128B1__", 2, false},
{"atxmega256d3", "__AVR_ATxmega256D3__", 4, false},
{"atxmega384c3", "__AVR_ATxmega384C3__", 6, false},
{"atxmega384d3", "__AVR_ATxmega384D3__", 6, false},
+ {"avrxmega7", NULL, 2, false},
{"atxmega128a1", "__AVR_ATxmega128A1__", 2, false},
{"atxmega128a1u", "__AVR_ATxmega128A1U__", 2, false},
{"atxmega128a4u", "__AVR_ATxmega128A4U__", 2, false},
+ {"avrtiny", NULL, 0, true},
{"attiny4", "__AVR_ATtiny4__", 0, true},
{"attiny5", "__AVR_ATtiny5__", 0, true},
{"attiny9", "__AVR_ATtiny9__", 0, true},
{"attiny40", "__AVR_ATtiny40__", 0, true},
{"attiny102", "__AVR_ATtiny102__", 0, true},
{"attiny104", "__AVR_ATtiny104__", 0, true},
+ {"avrxmega3", NULL, 1, false},
{"attiny202", "__AVR_ATtiny202__", 1, false},
{"attiny402", "__AVR_ATtiny402__", 1, false},
{"attiny204", "__AVR_ATtiny204__", 1, false},
} // namespace targets
} // namespace clang
-static constexpr llvm::StringLiteral ValidFamilyNames[] = {
- "avr1", "avr2", "avr25", "avr3", "avr31",
- "avr35", "avr4", "avr5", "avr51", "avr6",
- "avrxmega1", "avrxmega2", "avrxmega3", "avrxmega4", "avrxmega5",
- "avrxmega6", "avrxmega7", "avrtiny"};
-
bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
- bool IsFamily = llvm::is_contained(ValidFamilyNames, Name);
-
- bool IsMCU = llvm::any_of(
+ return llvm::any_of(
AVRMcus, [&](const MCUInfo &Info) { return Info.Name == Name; });
- return IsFamily || IsMCU;
}
void AVRTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
- Values.append(std::begin(ValidFamilyNames), std::end(ValidFamilyNames));
for (const MCUInfo &Info : AVRMcus)
Values.push_back(Info.Name);
}
bool AVRTargetInfo::setCPU(const std::string &Name) {
- // Set the ABI and CPU fields if parameter Name is a family name.
- if (llvm::is_contained(ValidFamilyNames, Name)) {
- CPU = Name;
- ABI = Name == "avrtiny" ? "avrtiny" : "avr";
- return true;
- }
-
- // Set the ABI field if parameter Name is a device name.
+ // Set the ABI field based on the device or family name.
auto It = llvm::find_if(
AVRMcus, [&](const MCUInfo &Info) { return Info.Name == Name; });
if (It != std::end(AVRMcus)) {
CPU = Name;
ABI = It->IsTiny ? "avrtiny" : "avr";
+ DefineName = It->DefineName;
+ NumFlashBanks = It->NumFlashBanks;
return true;
}
if (ABI == "avrtiny")
Builder.defineMacro("__AVR_TINY__", "1");
- if (!this->CPU.empty()) {
- auto It = llvm::find_if(
- AVRMcus, [&](const MCUInfo &Info) { return Info.Name == this->CPU; });
+ if (DefineName.size() != 0)
+ Builder.defineMacro(DefineName);
- 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)))");
- }
- }
+ if (NumFlashBanks >= 1)
+ Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+ if (NumFlashBanks >= 2)
+ Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+ if (NumFlashBanks >= 3)
+ Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+ if (NumFlashBanks >= 4)
+ Builder.defineMacro("__flash3", "__attribute__((address_space(4)))");
+ if (NumFlashBanks >= 5)
+ Builder.defineMacro("__flash4", "__attribute__((address_space(5)))");
+ if (NumFlashBanks >= 6)
+ Builder.defineMacro("__flash5", "__attribute__((address_space(6)))");
}
// RUN: not %clang_cc1 -triple avr--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AVR
// AVR: error: unknown target CPU 'not-a-cpu'
-// AVR-NEXT: note: valid target CPU values are: avr1, avr2, avr25, avr3, avr31, avr35, avr4, avr5, avr51, avr6, avrxmega1, avrxmega2, avrxmega3, avrxmega4, avrxmega5, avrxmega6, avrxmega7, avrtiny, at90s1200, attiny11, attiny12, attiny15, attiny28, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, ata5272, ata6616c, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, at43usb355, at76c711, atmega103, at43usb320, attiny167, at90usb82, at90usb162, ata5505, ata6617c, ata664251, atmega8u2, atmega16u2, atmega32u2, attiny1634, atmega8, ata6289, atmega8a, ata6285, ata6286, ata6612c, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795, ata5831, ata6613c, ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161, atmega162, atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega32a, atmega323, atmega324a, atmega324p, atmega324pa, atmega324pb, atmega325, atmega325a, atmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328, atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa, atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, atmega640, atmega644, atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p, atmega649, atmega649a, atmega649p, atmega6450, atmega6450a, atmega6450p, atmega6490, atmega6490a, atmega6490p, atmega64rfr2, atmega644rfr2, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, atmega32hvb, atmega32hvbrevb, atmega64hve, atmega64hve2, at90can32, at90can64, at90pwm161, at90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, atmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at90scr100, at94k, m3000, atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286, at90usb1287, atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2, atxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega32a4, atxmega32a4u, atxmega32c3, atxmega32c4, atxmega32d3, atxmega32d4, atxmega32e5, atxmega16e5, atxmega8e5, atxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, atxmega64c3, atxmega64d3, atxmega64d4, atxmega64a1, atxmega64a1u, atxmega128a3, atxmega128a3u, atxmega128b1, atxmega128b3, atxmega128c3, atxmega128d3, atxmega128d4, atxmega192a3, atxmega192a3u, atxmega192c3, atxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, atxmega384d3, atxmega128a1, atxmega128a1u, atxmega128a4u, attiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102, attiny104, attiny202, attiny402, attiny204, attiny404, attiny804, attiny1604, attiny406, attiny806, attiny1606, attiny807, attiny1607, attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614, attiny416, attiny816, attiny1616, attiny3216, attiny417, attiny817, attiny1617, attiny3217, attiny1624, attiny1626, attiny1627, atmega808, atmega809, atmega1608, atmega1609, atmega3208, atmega3209, atmega4808, atmega4809
+// AVR-NEXT: note: valid target CPU values are: avr1, at90s1200, attiny11, attiny12, attiny15, attiny28, avr2, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, avr25, ata5272, ata6616c, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, avr3, at43usb355, at76c711, avr31, atmega103, at43usb320, avr35, attiny167, at90usb82, at90usb162, ata5505, ata6617c, ata664251, atmega8u2, atmega16u2, atmega32u2, attiny1634, avr4, atmega8, ata6289, atmega8a, ata6285, ata6286, ata6612c, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, avr5, ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795, ata5831, ata6613c, ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161, atmega162, atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega32a, atmega323, atmega324a, atmega324p, atmega324pa, atmega324pb, atmega325, atmega325a, atmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328, atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa, atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, atmega640, atmega644, atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p, atmega649, atmega649a, atmega649p, atmega6450, atmega6450a, atmega6450p, atmega6490, atmega6490a, atmega6490p, atmega64rfr2, atmega644rfr2, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, atmega32hvb, atmega32hvbrevb, atmega64hve, atmega64hve2, at90can32, at90can64, at90pwm161, at90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, atmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at90scr100, at94k, m3000, avr51, atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286, at90usb1287, avr6, atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2, avrxmega2, atxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega32a4, atxmega32a4u, atxmega32c3, atxmega32c4, atxmega32d3, atxmega32d4, atxmega32e5, atxmega16e5, atxmega8e5, avrxmega4, atxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, atxmega64c3, atxmega64d3, atxmega64d4, avrxmega5, atxmega64a1, atxmega64a1u, avrxmega6, atxmega128a3, atxmega128a3u, atxmega128b1, atxmega128b3, atxmega128c3, atxmega128d3, atxmega128d4, atxmega192a3, atxmega192a3u, atxmega192c3, atxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, atxmega384d3, avrxmega7, atxmega128a1, atxmega128a1u, atxmega128a4u, avrtiny, attiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102, attiny104, avrxmega3, attiny202, attiny402, attiny204, attiny404, attiny804, attiny1604, attiny406, attiny806, attiny1606, attiny807, attiny1607, attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614, attiny416, attiny816, attiny1616, attiny3216, attiny417, attiny817, attiny1617, attiny3217, attiny1624, attiny1626, attiny1627, atmega808, atmega809, atmega1608, atmega1609, atmega3208, atmega3209, atmega4808, atmega4809
// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
// RISCV32: error: unknown target CPU 'not-a-cpu'