Index: clang/lib/Driver/ToolChains/AVR.cpp =================================================================== --- clang/lib/Driver/ToolChains/AVR.cpp +++ clang/lib/Driver/ToolChains/AVR.cpp @@ -29,310 +29,333 @@ namespace { // NOTE: This list has been synchronized with gcc-avr 7.3.0 and avr-libc 2.0.0. +// Refer to https://www.alldatasheet.com/ for more device information. constexpr struct { StringRef Name; StringRef SubPath; StringRef Family; unsigned DataAddr; + unsigned FlashSize; + unsigned SRAMSize; + unsigned EEPROMSize; } MCUInfo[] = { - {"at90s1200", "", "avr1", 0}, - {"attiny11", "", "avr1", 0}, - {"attiny12", "", "avr1", 0}, - {"attiny15", "", "avr1", 0}, - {"attiny28", "", "avr1", 0}, - {"at90s2313", "tiny-stack", "avr2", 0x800060}, - {"at90s2323", "tiny-stack", "avr2", 0x800060}, - {"at90s2333", "tiny-stack", "avr2", 0x800060}, - {"at90s2343", "tiny-stack", "avr2", 0x800060}, - {"at90s4433", "tiny-stack", "avr2", 0x800060}, - {"attiny22", "tiny-stack", "avr2", 0x800060}, - {"attiny26", "tiny-stack", "avr2", 0x800060}, - {"at90s4414", "", "avr2", 0x800060}, - {"at90s4434", "", "avr2", 0x800060}, - {"at90s8515", "", "avr2", 0x800060}, - {"at90c8534", "", "avr2", 0x800060}, - {"at90s8535", "", "avr2", 0x800060}, - {"attiny13", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny13a", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny2313", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny2313a", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny24", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny24a", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny25", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny261", "avr25/tiny-stack", "avr25", 0x800060}, - {"attiny261a", "avr25/tiny-stack", "avr25", 0x800060}, - {"at86rf401", "avr25", "avr25", 0x800060}, + {"at90s1200", "", "avr1", 0, 1024, 0, 64}, + {"attiny11", "", "avr1", 0, 1024, 0, 64}, + {"attiny12", "", "avr1", 0, 1024, 0, 64}, + {"attiny15", "", "avr1", 0, 1024, 0, 64}, + {"attiny28", "", "avr1", 0, 2048, 0, 64}, + {"at90s2313", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"at90s2323", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"at90s2333", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"at90s2343", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"at90s4433", "tiny-stack", "avr2", 0x800060, 4096, 128, 256}, + {"attiny22", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"attiny26", "tiny-stack", "avr2", 0x800060, 2048, 128, 128}, + {"at90s4414", "", "avr2", 0x800060, 4096, 256, 256}, + {"at90s4434", "", "avr2", 0x800060, 4096, 256, 256}, + {"at90s8515", "", "avr2", 0x800060, 8192, 512, 512}, + {"at90c8534", "", "avr2", 0x800060, 8192, 512, 512}, + {"at90s8535", "", "avr2", 0x800060, 8192, 512, 512}, + {"attiny13", "avr25/tiny-stack", "avr25", 0x800060, 1024, 64, 64}, + {"attiny13a", "avr25/tiny-stack", "avr25", 0x800060, 1024, 64, 64}, + {"attiny2313", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny2313a", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny24", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny24a", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny25", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny261", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"attiny261a", "avr25/tiny-stack", "avr25", 0x800060, 2048, 128, 128}, + {"at86rf401", "avr25", "avr25", 0x800060, 2048, 128, 128}, {"ata5272", "avr25", "avr25", 0x800100}, {"ata6616c", "avr25", "avr25", 0x800100}, - {"attiny4313", "avr25", "avr25", 0x800060}, - {"attiny44", "avr25", "avr25", 0x800060}, - {"attiny44a", "avr25", "avr25", 0x800060}, - {"attiny84", "avr25", "avr25", 0x800060}, - {"attiny84a", "avr25", "avr25", 0x800060}, - {"attiny45", "avr25", "avr25", 0x800060}, - {"attiny85", "avr25", "avr25", 0x800060}, - {"attiny441", "avr25", "avr25", 0x800100}, - {"attiny461", "avr25", "avr25", 0x800060}, - {"attiny461a", "avr25", "avr25", 0x800060}, - {"attiny841", "avr25", "avr25", 0x800100}, - {"attiny861", "avr25", "avr25", 0x800060}, - {"attiny861a", "avr25", "avr25", 0x800060}, - {"attiny87", "avr25", "avr25", 0x800100}, - {"attiny43u", "avr25", "avr25", 0x800060}, - {"attiny48", "avr25", "avr25", 0x800100}, - {"attiny88", "avr25", "avr25", 0x800100}, - {"attiny828", "avr25", "avr25", 0x800100}, - {"at43usb355", "avr3", "avr3", 0x800100}, + {"attiny4313", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny44", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny44a", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny84", "avr25", "avr25", 0x800060, 8192, 512, 512}, + {"attiny84a", "avr25", "avr25", 0x800060, 8192, 512, 512}, + {"attiny45", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny85", "avr25", "avr25", 0x800060, 8192, 512, 512}, + {"attiny441", "avr25", "avr25", 0x800100, 4096, 256, 256}, + {"attiny461", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny461a", "avr25", "avr25", 0x800060, 4096, 256, 256}, + {"attiny841", "avr25", "avr25", 0x800100, 8192, 512, 512}, + {"attiny861", "avr25", "avr25", 0x800060, 8192, 512, 512}, + {"attiny861a", "avr25", "avr25", 0x800060, 8192, 512, 512}, + {"attiny87", "avr25", "avr25", 0x800100, 8192, 512, 512}, + {"attiny43u", "avr25", "avr25", 0x800060, 4096, 256, 64}, + {"attiny48", "avr25", "avr25", 0x800100, 4096, 256, 64}, + {"attiny88", "avr25", "avr25", 0x800100, 8192, 512, 64}, + {"attiny828", "avr25", "avr25", 0x800100, 8192, 512, 256}, + {"at43usb355", "avr3", "avr3", 0x800100, 24576, 1024, 0}, {"at76c711", "avr3", "avr3", 0x800060}, - {"atmega103", "avr31", "avr31", 0x800060}, + {"atmega103", "avr31", "avr31", 0x800060, 65536, 4096, 4096}, {"at43usb320", "avr31", "avr31", 0x800060}, - {"attiny167", "avr35", "avr35", 0x800100}, - {"at90usb82", "avr35", "avr35", 0x800100}, - {"at90usb162", "avr35", "avr35", 0x800100}, - {"ata5505", "avr35", "avr35", 0x800100}, + {"attiny167", "avr35", "avr35", 0x800100, 16384, 512, 512}, + {"at90usb82", "avr35", "avr35", 0x800100, 8192, 512, 512}, + {"at90usb162", "avr35", "avr35", 0x800100, 16384, 512, 512}, + {"ata5505", "avr35", "avr35", 0x800100, 16384, 512, 512}, {"ata6617c", "avr35", "avr35", 0x800100}, {"ata664251", "avr35", "avr35", 0x800100}, - {"atmega8u2", "avr35", "avr35", 0x800100}, - {"atmega16u2", "avr35", "avr35", 0x800100}, - {"atmega32u2", "avr35", "avr35", 0x800100}, - {"attiny1634", "avr35", "avr35", 0x800100}, - {"atmega8", "avr4", "avr4", 0x800060}, + {"atmega8u2", "avr35", "avr35", 0x800100, 8192, 512, 512}, + {"atmega16u2", "avr35", "avr35", 0x800100, 16384, 512, 512}, + {"atmega32u2", "avr35", "avr35", 0x800100, 32768, 1024, 1024}, + {"attiny1634", "avr35", "avr35", 0x800100, 16384, 1024, 256}, + {"atmega8", "avr4", "avr4", 0x800060, 8192, 1024, 512}, {"ata6289", "avr4", "avr4", 0x800100}, - {"atmega8a", "avr4", "avr4", 0x800060}, - {"ata6285", "avr4", "avr4", 0x800100}, - {"ata6286", "avr4", "avr4", 0x800100}, - {"ata6612c", "avr4", "avr4", 0x800100}, - {"atmega48", "avr4", "avr4", 0x800100}, - {"atmega48a", "avr4", "avr4", 0x800100}, - {"atmega48pa", "avr4", "avr4", 0x800100}, - {"atmega48pb", "avr4", "avr4", 0x800100}, - {"atmega48p", "avr4", "avr4", 0x800100}, - {"atmega88", "avr4", "avr4", 0x800100}, - {"atmega88a", "avr4", "avr4", 0x800100}, - {"atmega88p", "avr4", "avr4", 0x800100}, - {"atmega88pa", "avr4", "avr4", 0x800100}, - {"atmega88pb", "avr4", "avr4", 0x800100}, - {"atmega8515", "avr4", "avr4", 0x800060}, - {"atmega8535", "avr4", "avr4", 0x800060}, - {"atmega8hva", "avr4", "avr4", 0x800100}, - {"at90pwm1", "avr4", "avr4", 0x800100}, - {"at90pwm2", "avr4", "avr4", 0x800100}, - {"at90pwm2b", "avr4", "avr4", 0x800100}, - {"at90pwm3", "avr4", "avr4", 0x800100}, - {"at90pwm3b", "avr4", "avr4", 0x800100}, - {"at90pwm81", "avr4", "avr4", 0x800100}, + {"atmega8a", "avr4", "avr4", 0x800060, 8192, 1024, 512}, + {"ata6285", "avr4", "avr4", 0x800100, 8192, 512, 256}, + {"ata6286", "avr4", "avr4", 0x800100, 8192, 512, 256}, + {"ata6612c", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"atmega48", "avr4", "avr4", 0x800100, 4096, 512, 256}, + {"atmega48a", "avr4", "avr4", 0x800100, 4096, 512, 256}, + {"atmega48pa", "avr4", "avr4", 0x800100, 4096, 512, 256}, + {"atmega48pb", "avr4", "avr4", 0x800100, 4096, 512, 256}, + {"atmega48p", "avr4", "avr4", 0x800100, 4096, 512, 256}, + {"atmega88", "avr4", "avr4", 0x800100, 8192, 1024, 512}, + {"atmega88a", "avr4", "avr4", 0x800100, 8192, 1024, 512}, + {"atmega88p", "avr4", "avr4", 0x800100, 8192, 1024, 512}, + {"atmega88pa", "avr4", "avr4", 0x800100, 8192, 1024, 512}, + {"atmega88pb", "avr4", "avr4", 0x800100, 8192, 1024, 512}, + {"atmega8515", "avr4", "avr4", 0x800060, 8192, 512, 512}, + {"atmega8535", "avr4", "avr4", 0x800060, 8192, 512, 512}, + {"atmega8hva", "avr4", "avr4", 0x800100, 8192, 512, 256}, + {"at90pwm1", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"at90pwm2", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"at90pwm2b", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"at90pwm3", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"at90pwm3b", "avr4", "avr4", 0x800100, 8192, 512, 512}, + {"at90pwm81", "avr4", "avr4", 0x800100, 8192, 256, 512}, {"ata5702m322", "avr5", "avr5", 0x800200}, - {"ata5782", "avr5", "avr5", 0x800200}, - {"ata5790", "avr5", "avr5", 0x800100}, - {"ata5790n", "avr5", "avr5", 0x800100}, - {"ata5791", "avr5", "avr5", 0x800100}, - {"ata5795", "avr5", "avr5", 0x800100}, - {"ata5831", "avr5", "avr5", 0x800200}, - {"ata6613c", "avr5", "avr5", 0x800100}, - {"ata6614q", "avr5", "avr5", 0x800100}, - {"ata8210", "avr5", "avr5", 0x800200}, - {"ata8510", "avr5", "avr5", 0x800200}, - {"atmega16", "avr5", "avr5", 0x800060}, - {"atmega16a", "avr5", "avr5", 0x800060}, - {"atmega161", "avr5", "avr5", 0x800060}, - {"atmega162", "avr5", "avr5", 0x800100}, - {"atmega163", "avr5", "avr5", 0x800060}, - {"atmega164a", "avr5", "avr5", 0x800100}, - {"atmega164p", "avr5", "avr5", 0x800100}, - {"atmega164pa", "avr5", "avr5", 0x800100}, - {"atmega165", "avr5", "avr5", 0x800100}, - {"atmega165a", "avr5", "avr5", 0x800100}, - {"atmega165p", "avr5", "avr5", 0x800100}, - {"atmega165pa", "avr5", "avr5", 0x800100}, - {"atmega168", "avr5", "avr5", 0x800100}, - {"atmega168a", "avr5", "avr5", 0x800100}, - {"atmega168p", "avr5", "avr5", 0x800100}, - {"atmega168pa", "avr5", "avr5", 0x800100}, - {"atmega168pb", "avr5", "avr5", 0x800100}, - {"atmega169", "avr5", "avr5", 0x800100}, - {"atmega169a", "avr5", "avr5", 0x800100}, - {"atmega169p", "avr5", "avr5", 0x800100}, - {"atmega169pa", "avr5", "avr5", 0x800100}, - {"atmega32", "avr5", "avr5", 0x800060}, - {"atmega32a", "avr5", "avr5", 0x800060}, - {"atmega323", "avr5", "avr5", 0x800060}, - {"atmega324a", "avr5", "avr5", 0x800100}, - {"atmega324p", "avr5", "avr5", 0x800100}, - {"atmega324pa", "avr5", "avr5", 0x800100}, - {"atmega324pb", "avr5", "avr5", 0x800100}, - {"atmega325", "avr5", "avr5", 0x800100}, - {"atmega325a", "avr5", "avr5", 0x800100}, - {"atmega325p", "avr5", "avr5", 0x800100}, - {"atmega325pa", "avr5", "avr5", 0x800100}, - {"atmega3250", "avr5", "avr5", 0x800100}, - {"atmega3250a", "avr5", "avr5", 0x800100}, - {"atmega3250p", "avr5", "avr5", 0x800100}, - {"atmega3250pa", "avr5", "avr5", 0x800100}, - {"atmega328", "avr5", "avr5", 0x800100}, - {"atmega328p", "avr5", "avr5", 0x800100}, - {"atmega328pb", "avr5", "avr5", 0x800100}, - {"atmega329", "avr5", "avr5", 0x800100}, - {"atmega329a", "avr5", "avr5", 0x800100}, - {"atmega329p", "avr5", "avr5", 0x800100}, - {"atmega329pa", "avr5", "avr5", 0x800100}, - {"atmega3290", "avr5", "avr5", 0x800100}, - {"atmega3290a", "avr5", "avr5", 0x800100}, - {"atmega3290p", "avr5", "avr5", 0x800100}, - {"atmega3290pa", "avr5", "avr5", 0x800100}, - {"atmega406", "avr5", "avr5", 0x800100}, - {"atmega64", "avr5", "avr5", 0x800100}, - {"atmega64a", "avr5", "avr5", 0x800100}, - {"atmega640", "avr5", "avr5", 0x800200}, - {"atmega644", "avr5", "avr5", 0x800100}, - {"atmega644a", "avr5", "avr5", 0x800100}, - {"atmega644p", "avr5", "avr5", 0x800100}, - {"atmega644pa", "avr5", "avr5", 0x800100}, - {"atmega645", "avr5", "avr5", 0x800100}, - {"atmega645a", "avr5", "avr5", 0x800100}, - {"atmega645p", "avr5", "avr5", 0x800100}, - {"atmega649", "avr5", "avr5", 0x800100}, - {"atmega649a", "avr5", "avr5", 0x800100}, - {"atmega649p", "avr5", "avr5", 0x800100}, - {"atmega6450", "avr5", "avr5", 0x800100}, - {"atmega6450a", "avr5", "avr5", 0x800100}, - {"atmega6450p", "avr5", "avr5", 0x800100}, - {"atmega6490", "avr5", "avr5", 0x800100}, - {"atmega6490a", "avr5", "avr5", 0x800100}, - {"atmega6490p", "avr5", "avr5", 0x800100}, - {"atmega64rfr2", "avr5", "avr5", 0x800200}, - {"atmega644rfr2", "avr5", "avr5", 0x800200}, - {"atmega16hva", "avr5", "avr5", 0x800100}, - {"atmega16hva2", "avr5", "avr5", 0x800100}, - {"atmega16hvb", "avr5", "avr5", 0x800100}, - {"atmega16hvbrevb", "avr5", "avr5", 0x800100}, - {"atmega32hvb", "avr5", "avr5", 0x800100}, - {"atmega32hvbrevb", "avr5", "avr5", 0x800100}, - {"atmega64hve", "avr5", "avr5", 0x800100}, - {"atmega64hve2", "avr5", "avr5", 0x800100}, - {"at90can32", "avr5", "avr5", 0x800100}, - {"at90can64", "avr5", "avr5", 0x800100}, - {"at90pwm161", "avr5", "avr5", 0x800100}, - {"at90pwm216", "avr5", "avr5", 0x800100}, - {"at90pwm316", "avr5", "avr5", 0x800100}, - {"atmega32c1", "avr5", "avr5", 0x800100}, - {"atmega64c1", "avr5", "avr5", 0x800100}, - {"atmega16m1", "avr5", "avr5", 0x800100}, - {"atmega32m1", "avr5", "avr5", 0x800100}, - {"atmega64m1", "avr5", "avr5", 0x800100}, - {"atmega16u4", "avr5", "avr5", 0x800100}, - {"atmega32u4", "avr5", "avr5", 0x800100}, - {"atmega32u6", "avr5", "avr5", 0x800100}, - {"at90usb646", "avr5", "avr5", 0x800100}, - {"at90usb647", "avr5", "avr5", 0x800100}, - {"at90scr100", "avr5", "avr5", 0x800100}, + {"ata5782", "avr5", "avr5", 0x800200, 16384, 1024, 1024}, + {"ata5790", "avr5", "avr5", 0x800100, 16384, 512, 2048}, + {"ata5790n", "avr5", "avr5", 0x800100, 16384, 512, 2048}, + {"ata5791", "avr5", "avr5", 0x800100, 16384, 512, 2048}, + {"ata5795", "avr5", "avr5", 0x800100, 8192, 512, 2048}, + {"ata5831", "avr5", "avr5", 0x800200, 16384, 1024, 1024}, + {"ata6613c", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"ata6614q", "avr5", "avr5", 0x800100, 32768, 2048, 512}, + {"ata8210", "avr5", "avr5", 0x800200, 16384, 1024, 1024}, + {"ata8510", "avr5", "avr5", 0x800200, 16384, 1024, 1024}, + {"atmega16", "avr5", "avr5", 0x800060, 16384, 1024, 512}, + {"atmega16a", "avr5", "avr5", 0x800060, 16384, 1024, 512}, + {"atmega161", "avr5", "avr5", 0x800060, 16384, 1024, 512}, + {"atmega162", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega163", "avr5", "avr5", 0x800060, 16384, 1024, 512}, + {"atmega164a", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega164p", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega164pa", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega165", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega165a", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega165p", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega165pa", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega168", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega168a", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega168p", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega168pa", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega168pb", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega169", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega169a", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega169p", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega169pa", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega32", "avr5", "avr5", 0x800060, 32768, 2048, 1024}, + {"atmega32a", "avr5", "avr5", 0x800060, 32768, 2048, 1024}, + {"atmega323", "avr5", "avr5", 0x800060, 32768, 2048, 1024}, + {"atmega324a", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega324p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega324pa", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega324pb", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega325", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega325a", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega325p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega325pa", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3250", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3250a", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3250p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3250pa", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega328", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega328p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega328pb", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega329", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega329a", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega329p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega329pa", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3290", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3290a", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3290p", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega3290pa", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega406", "avr5", "avr5", 0x800100, 32768, 2048, 512}, + {"atmega64", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega64a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega640", "avr5", "avr5", 0x800200, 65536, 4096, 2048}, + {"atmega644", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega644a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega644p", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega644pa", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega645", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega645a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega645p", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega649", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega649a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega649p", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6450", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6450a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6450p", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6490", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6490a", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega6490p", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega64rfr2", "avr5", "avr5", 0x800200, 65536, 8192, 2048}, + {"atmega644rfr2", "avr5", "avr5", 0x800200, 65536, 8192, 2048}, + {"atmega16hva", "avr5", "avr5", 0x800100, 16384, 512, 256}, + {"atmega16hva2", "avr5", "avr5", 0x800100, 16384, 512, 256}, + {"atmega16hvb", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega16hvbrevb", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega32hvb", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega32hvbrevb", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega64hve", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega64hve2", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"at90can32", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"at90can64", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"at90pwm161", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"at90pwm216", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"at90pwm316", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega32c1", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega64c1", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega16m1", "avr5", "avr5", 0x800100, 8192, 1024, 512}, + {"atmega32m1", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega64m1", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"atmega16u4", "avr5", "avr5", 0x800100, 16384, 1024, 512}, + {"atmega32u4", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"atmega32u6", "avr5", "avr5", 0x800100, 32768, 2048, 1024}, + {"at90usb646", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"at90usb647", "avr5", "avr5", 0x800100, 65536, 4096, 2048}, + {"at90scr100", "avr5", "avr5", 0x800100, 65536, 4096, 4096}, {"at94k", "avr5", "avr5", 0x800060}, {"m3000", "avr5", "avr5", 0x800060}, - {"atmega128", "avr51", "avr51", 0x800100}, - {"atmega128a", "avr51", "avr51", 0x800100}, - {"atmega1280", "avr51", "avr51", 0x800200}, - {"atmega1281", "avr51", "avr51", 0x800200}, - {"atmega1284", "avr51", "avr51", 0x800100}, - {"atmega1284p", "avr51", "avr51", 0x800100}, - {"atmega128rfa1", "avr51", "avr51", 0x800200}, - {"atmega128rfr2", "avr51", "avr51", 0x800200}, - {"atmega1284rfr2", "avr51", "avr51", 0x800200}, - {"at90can128", "avr51", "avr51", 0x800200}, - {"at90usb1286", "avr51", "avr51", 0x800200}, - {"at90usb1287", "avr51", "avr51", 0x800200}, - {"atmega2560", "avr6", "avr6", 0x800200}, - {"atmega2561", "avr6", "avr6", 0x800200}, - {"atmega256rfr2", "avr6", "avr6", 0x800200}, - {"atmega2564rfr2", "avr6", "avr6", 0x800200}, - {"attiny4", "avrtiny", "avrtiny", 0x800040}, - {"attiny5", "avrtiny", "avrtiny", 0x800040}, - {"attiny9", "avrtiny", "avrtiny", 0x800040}, - {"attiny10", "avrtiny", "avrtiny", 0x800040}, - {"attiny20", "avrtiny", "avrtiny", 0x800040}, - {"attiny40", "avrtiny", "avrtiny", 0x800040}, - {"attiny102", "avrtiny", "avrtiny", 0x800040}, - {"attiny104", "avrtiny", "avrtiny", 0x800040}, - {"atxmega16a4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega16a4u", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega16c4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega16d4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32a4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32a4u", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32c3", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32c4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32d3", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32d4", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega32e5", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega16e5", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega8e5", "avrxmega2", "avrxmega2", 0x802000}, - {"atxmega64a3", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64a3u", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64a4u", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64b1", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64b3", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64c3", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64d3", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64d4", "avrxmega4", "avrxmega4", 0x802000}, - {"atxmega64a1", "avrxmega5", "avrxmega5", 0x802000}, - {"atxmega64a1u", "avrxmega5", "avrxmega5", 0x802000}, - {"atxmega128a3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128a3u", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128b1", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128b3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128c3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128d3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128d4", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega192a3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega192a3u", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega192c3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega192d3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256a3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256a3u", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256a3b", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256a3bu", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256c3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega256d3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega384c3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega384d3", "avrxmega6", "avrxmega6", 0x802000}, - {"atxmega128a1", "avrxmega7", "avrxmega7", 0x802000}, - {"atxmega128a1u", "avrxmega7", "avrxmega7", 0x802000}, - {"atxmega128a4u", "avrxmega7", "avrxmega7", 0x802000}, - {"attiny202", "avrxmega3/short-calls", "avrxmega3", 0x803F80}, - {"attiny204", "avrxmega3/short-calls", "avrxmega3", 0x803F80}, - {"attiny212", "avrxmega3/short-calls", "avrxmega3", 0x803F80}, - {"attiny214", "avrxmega3/short-calls", "avrxmega3", 0x803F80}, - {"attiny402", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny404", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny406", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny412", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny414", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny416", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny417", "avrxmega3/short-calls", "avrxmega3", 0x803F00}, - {"attiny804", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"attiny806", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"attiny807", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"attiny814", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"attiny816", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"attiny817", "avrxmega3/short-calls", "avrxmega3", 0x803E00}, - {"atmega808", "avrxmega3/short-calls", "avrxmega3", 0x803C00}, - {"atmega809", "avrxmega3/short-calls", "avrxmega3", 0x803C00}, - {"atmega1608", "avrxmega3", "avrxmega3", 0x803800}, - {"atmega1609", "avrxmega3", "avrxmega3", 0x803800}, - {"atmega3208", "avrxmega3", "avrxmega3", 0x803000}, - {"atmega3209", "avrxmega3", "avrxmega3", 0x803000}, - {"atmega4808", "avrxmega3", "avrxmega3", 0x802800}, - {"atmega4809", "avrxmega3", "avrxmega3", 0x802800}, - {"attiny1604", "avrxmega3", "avrxmega3", 0x803C00}, - {"attiny1606", "avrxmega3", "avrxmega3", 0x803C00}, - {"attiny1607", "avrxmega3", "avrxmega3", 0x803C00}, - {"attiny1614", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny1616", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny1617", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny1624", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny1626", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny1627", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny3216", "avrxmega3", "avrxmega3", 0x803800}, - {"attiny3217", "avrxmega3", "avrxmega3", 0x803800}, -}; + {"atmega128", "avr51", "avr51", 0x800100, 131072, 4096, 4096}, + {"atmega128a", "avr51", "avr51", 0x800100, 131072, 4096, 4096}, + {"atmega1280", "avr51", "avr51", 0x800200, 131072, 8192, 4096}, + {"atmega1281", "avr51", "avr51", 0x800200, 131072, 8192, 4096}, + {"atmega1284", "avr51", "avr51", 0x800100, 131072, 16384, 4096}, + {"atmega1284p", "avr51", "avr51", 0x800100, 131072, 16384, 4096}, + {"atmega128rfa1", "avr51", "avr51", 0x800200, 131072, 16384, 4096}, + {"atmega128rfr2", "avr51", "avr51", 0x800200, 131072, 16384, 4096}, + {"atmega1284rfr2", "avr51", "avr51", 0x800200, 131072, 16384, 4096}, + {"at90can128", "avr51", "avr51", 0x800200, 131072, 4096, 4096}, + {"at90usb1286", "avr51", "avr51", 0x800200, 131072, 8192, 4096}, + {"at90usb1287", "avr51", "avr51", 0x800200, 131072, 8192, 4096}, + {"atmega2560", "avr6", "avr6", 0x800200, 262144, 8192, 4096}, + {"atmega2561", "avr6", "avr6", 0x800200, 262144, 8192, 4096}, + {"atmega256rfr2", "avr6", "avr6", 0x800200, 262144, 32768, 8192}, + {"atmega2564rfr2", "avr6", "avr6", 0x800200, 262144, 32768, 8192}, + {"attiny4", "avrtiny", "avrtiny", 0x800040, 512, 32, 0}, + {"attiny5", "avrtiny", "avrtiny", 0x800040, 512, 32, 0}, + {"attiny9", "avrtiny", "avrtiny", 0x800040, 1024, 32, 0}, + {"attiny10", "avrtiny", "avrtiny", 0x800040, 1024, 32, 0}, + {"attiny20", "avrtiny", "avrtiny", 0x800040, 2048, 128, 0}, + {"attiny40", "avrtiny", "avrtiny", 0x800040, 4096, 256, 0}, + {"attiny102", "avrtiny", "avrtiny", 0x800040, 1024, 32, 0}, + {"attiny104", "avrtiny", "avrtiny", 0x800040, 1024, 32, 0}, + {"atxmega16a4", "avrxmega2", "avrxmega2", 0x802000, 16384, 2048, 1024}, + {"atxmega16a4u", "avrxmega2", "avrxmega2", 0x802000, 16384, 2048, 1024}, + {"atxmega16c4", "avrxmega2", "avrxmega2", 0x802000, 16384, 2048, 1024}, + {"atxmega16d4", "avrxmega2", "avrxmega2", 0x802000, 16384, 2048, 1024}, + {"atxmega32a4", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 2048}, + {"atxmega32a4u", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 2048}, + {"atxmega32c3", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 2048}, + {"atxmega32c4", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 2048}, + {"atxmega32d3", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 1024}, + {"atxmega32d4", "avrxmega2", "avrxmega2", 0x802000, 32768, 4096, 1024}, + {"atxmega32e5", "avrxmega2", "avrxmega2", 0x802000, 32768, 2048, 512}, + {"atxmega16e5", "avrxmega2", "avrxmega2", 0x802000, 16384, 2048, 512}, + {"atxmega8e5", "avrxmega2", "avrxmega2", 0x802000, 8192, 1024, 512}, + {"atxmega64a3", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64a3u", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64a4u", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64b1", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64b3", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64c3", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64d3", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64d4", "avrxmega4", "avrxmega4", 0x802000, 65536, 4096, 2048}, + {"atxmega64a1", "avrxmega5", "avrxmega5", 0x802000, 65536, 4096, 2048}, + {"atxmega64a1u", "avrxmega5", "avrxmega5", 0x802000, 65536, 4096, 2048}, + {"atxmega128a3", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128a3u", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128b1", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128b3", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128c3", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128d3", "avrxmega6", "avrxmega6", 0x802000, 131072, 8192, 2048}, + {"atxmega128d4", "avrxmega6", "avrxmega6", 0x802000, 196608, 8192, 2048}, + {"atxmega192a3", "avrxmega6", "avrxmega6", 0x802000, 196608, 16384, 4096}, + {"atxmega192a3u", "avrxmega6", "avrxmega6", 0x802000, 196608, 16384, 4096}, + {"atxmega192c3", "avrxmega6", "avrxmega6", 0x802000, 196608, 16384, 2048}, + {"atxmega192d3", "avrxmega6", "avrxmega6", 0x802000, 196608, 16384, 2048}, + {"atxmega256a3", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega256a3u", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega256a3b", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega256a3bu", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega256c3", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega256d3", "avrxmega6", "avrxmega6", 0x802000, 262144, 16384, 4096}, + {"atxmega384c3", "avrxmega6", "avrxmega6", 0x802000, 393216, 32768, 4096}, + {"atxmega384d3", "avrxmega6", "avrxmega6", 0x802000, 393216, 32768, 4096}, + {"atxmega128a1", "avrxmega7", "avrxmega7", 0x802000, 131072, 8192, 2048}, + {"atxmega128a1u", "avrxmega7", "avrxmega7", 0x802000, 131072, 8192, 2048}, + {"atxmega128a4u", "avrxmega7", "avrxmega7", 0x802000, 131072, 8192, 2048}, + {"attiny202", "avrxmega3/short-calls", "avrxmega3", 0x803F80, 2048, 128, + 64}, + {"attiny204", "avrxmega3/short-calls", "avrxmega3", 0x803F80, 2048, 128, + 64}, + {"attiny212", "avrxmega3/short-calls", "avrxmega3", 0x803F80, 2048, 128, + 64}, + {"attiny214", "avrxmega3/short-calls", "avrxmega3", 0x803F80, 2048, 128, + 64}, + {"attiny402", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny404", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny406", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny412", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny414", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny416", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny417", "avrxmega3/short-calls", "avrxmega3", 0x803F00, 4096, 256, + 128}, + {"attiny804", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"attiny806", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"attiny807", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"attiny814", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"attiny816", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"attiny817", "avrxmega3/short-calls", "avrxmega3", 0x803E00, 8192, 512, + 128}, + {"atmega808", "avrxmega3/short-calls", "avrxmega3", 0x803C00, 8192, 1024, + 256}, + {"atmega809", "avrxmega3/short-calls", "avrxmega3", 0x803C00, 8192, 1024, + 256}, + {"atmega1608", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"atmega1609", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"atmega3208", "avrxmega3", "avrxmega3", 0x803000, 32768, 4096, 256}, + {"atmega3209", "avrxmega3", "avrxmega3", 0x803000, 32768, 4096, 256}, + {"atmega4808", "avrxmega3", "avrxmega3", 0x802800, 49152, 6126, 256}, + {"atmega4809", "avrxmega3", "avrxmega3", 0x802800, 49152, 6126, 256}, + {"attiny1604", "avrxmega3", "avrxmega3", 0x803C00, 16384, 1024, 256}, + {"attiny1606", "avrxmega3", "avrxmega3", 0x803C00, 16384, 1024, 256}, + {"attiny1607", "avrxmega3", "avrxmega3", 0x803C00, 16384, 1024, 256}, + {"attiny1614", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny1616", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny1617", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny1624", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny1626", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny1627", "avrxmega3", "avrxmega3", 0x803800, 16384, 2048, 256}, + {"attiny3216", "avrxmega3", "avrxmega3", 0x803800, 32768, 2048, 256}, + {"attiny3217", "avrxmega3", "avrxmega3", 0x803800, 32768, 2048, 256}, +}; // namespace std::string GetMCUSubPath(StringRef MCUName) { for (const auto &MCU : MCUInfo) @@ -355,6 +378,27 @@ return Optional(); } +unsigned GetMCUFlashSize(StringRef MCUName) { + for (const auto &MCU : MCUInfo) + if (MCU.Name == MCUName) + return MCU.FlashSize; + return 0; +} + +unsigned GetMCUSRAMSize(StringRef MCUName) { + for (const auto &MCU : MCUInfo) + if (MCU.Name == MCUName) + return MCU.SRAMSize; + return 0; +} + +unsigned GetMCUEEPROMSize(StringRef MCUName) { + for (const auto &MCU : MCUInfo) + if (MCU.Name == MCUName) + return MCU.EEPROMSize; + return 0; +} + const StringRef PossibleAVRLibcLocations[] = { "/avr", "/usr/avr", @@ -375,8 +419,7 @@ // Only add default libraries if the user hasn't explicitly opted out. if (!Args.hasArg(options::OPT_nostdlib) && - !Args.hasArg(options::OPT_nodefaultlibs) && - GCCInstallation.isValid()) { + !Args.hasArg(options::OPT_nodefaultlibs) && GCCInstallation.isValid()) { GCCInstallPath = GCCInstallation.getInstallPath(); std::string GCCParentPath(GCCInstallation.getParentLibPath()); getProgramPaths().push_back(GCCParentPath + "/../bin"); @@ -433,7 +476,7 @@ llvm::Optional SectionAddressData = GetMCUSectionAddressData(CPU); // Compute the linker program path, and use GNU "avr-ld" as default. - const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ); + const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ); std::string Linker(A ? A->getValue() : getShortName()); if (!llvm::sys::fs::can_execute(Linker)) { std::string FullPath = getToolChain().GetProgramPath(Linker.c_str()); @@ -533,6 +576,18 @@ CmdArgs.push_back(Args.MakeArgString(Prefix + *FamilyName + ".x")); } } + // We must explicitly define __TEXT_REGION_LENGTH__, + // __DATA_REGION_LENGTH__, and __EEPROM_REGION_LENGTH__ according to + // current MCU. + CmdArgs.push_back( + Args.MakeArgString(std::string("--defsym=__TEXT_REGION_LENGTH__=") + + std::to_string(GetMCUFlashSize(CPU)))); + CmdArgs.push_back( + Args.MakeArgString(std::string("--defsym=__DATA_REGION_LENGTH__=") + + std::to_string(GetMCUSRAMSize(CPU)))); + CmdArgs.push_back( + Args.MakeArgString(std::string("--defsym=__EEPROM_REGION_LENGTH__=") + + std::to_string(GetMCUEEPROMSize(CPU)))); } } Index: clang/test/Driver/avr-toolchain.c =================================================================== --- clang/test/Driver/avr-toolchain.c +++ clang/test/Driver/avr-toolchain.c @@ -64,5 +64,8 @@ // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 %s -fuse-ld=ld.lld 2>&1 | FileCheck --check-prefix=LLD %s // LLD: {{".*lld"}} {{.*}} "-e" "__vectors" "-T" {{".*avr5.x"}} +// LLD-SAME: "--defsym=__TEXT_REGION_LENGTH__=32768" +// LLD-SAME: "--defsym=__DATA_REGION_LENGTH__=2048" +// LLD-SAME: "--defsym=__EEPROM_REGION_LENGTH__=1024" // LLD-NOT: "avr-ld" // LLD-NOT: "-mavr5"