avr-llvm / clang

[MERGED UPSTREAM] Clang frontend supporting AVR
Other
11 stars 1 forks source link

Process #define's for all MCUs #6

Open dylanmckay opened 9 years ago

dylanmckay commented 9 years ago

in lib/Basic/Targets.cpp inside class AVRTargetInfo, we currently handle a few different MCUs and set the processor defines appropriately.

if (CPU == "atmega328") {
    Builder.defineMacro("__AVR_ATmega328__");
} else if (CPU == "atmega328p") {
    Builder.defineMacro("__AVR_ATmega328P__");
} else if (CPU == "atmega168") {
    Builder.defineMacro("__AVR_ATmega168__");
} else if (CPU == "atmega168p") {
...

This should be rewritten as a StringSwitch, and the entire set of supported CPUs should be added, Ideally, a warning would also be emitted along the lines of "unknown MCU" if we don't recognise this.

A goal might be to allow MCUs to be specified inside a TableGen file - perhaps AVRMCUs.def, and have all information in one centralized place.