================ @@ -0,0 +1,356 @@ +#include "C2000.h" +#include "Targets.h" +#include "clang/Basic/Builtins.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/MacroBuilder.h" +#include "clang/Basic/TargetBuiltins.h" + +using namespace clang; +using namespace clang::targets; + +const char *const C2000TargetInfo::GCCRegNames[] = { + "ACC", "XAR0", "XAR1", "XAR2", "XAR3", "XAR4", "XAR5", "XAR6", "XAR7"}; + +ArrayRef<const char *> C2000TargetInfo::getGCCRegNames() const { + return llvm::ArrayRef(GCCRegNames); +} + +bool C2000TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, + DiagnosticsEngine &Diags) { + + for (const auto &Feature : Features) { + if (Feature == "+eabi") { + eabi = true; + continue; + } + if (Feature == "+strict_ansi") { + strict = true; + continue; + } + if (Feature == "+cla_support") { + cla_support = true; + } + if (Feature == "+cla0") { + cla0 = true; + continue; + } + if (Feature == "+cla1") { + cla1 = true; + continue; + } + if (Feature == "+cla2") { + cla2 = true; + continue; + } + if (Feature == "+relaxed") { + relaxed = true; + continue; + } + if (Feature == "+fpu64") { + fpu64 = true; + continue; + } + if (Feature == "+fpu32") { + fpu32 = true; + continue; + } + if (Feature == "+tmu_support") { + tmu_support = true; + } + if (Feature == "+tmu1") { + tmu1 = true; + continue; + } + if (Feature == "+idiv0") { + idiv0 = true; + continue; + } + if (Feature == "+vcu_support") { + vcu_support = true; + } + if (Feature == "+vcu2") { + vcu2 = true; + continue; + } + if (Feature == "+vcrc") { + vcrc = true; + continue; + } + if (Feature == "+opt_level") { + opt = true; + continue; + } + } + return true; +} + +bool C2000TargetInfo::hasFeature(StringRef Feature) const { + return llvm::StringSwitch<bool>(Feature) + .Case("eabi", eabi) + .Case("strict_ansi", strict) + .Case("cla-support", cla_support) + .Case("cla0", cla0) + .Case("cla1", cla1) + .Case("cla2", cla2) + .Case("relaxed", relaxed) + .Case("fpu64", fpu64) + .Case("fpu32", fpu32) + .Case("tmu-support", tmu_support) + .Case("tmu1", tmu1) + .Case("vcu-support", vcu_support) + .Case("vcu2", vcu2) + .Case("vcrc", vcrc) + .Case("opt-level", opt) + .Default(false); +} + +void C2000TargetInfo::getTargetDefines(const LangOptions &Opts, + MacroBuilder &Builder) const { + Builder.undefineMacro("__CHAR_BIT__"); // FIXME: Implement 16-bit char + Builder.defineMacro("__CHAR_BIT__", "16"); + Builder.defineMacro("__TMS320C2000__"); ---------------- student433 wrote:
Actually, the defined macros without a feature condition are all dumped regardless of options. As you suggest that some of the macros are tied to options, It would be best to not declare them wrongly. But I would like to know what options affect macros like c99 complex enabled, large model, and others, since I could not find them documented in compiler manual. If there is uncertainty, those should be removed as you suggest https://github.com/llvm/llvm-project/pull/125663 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits