18#include "llvm/ADT/StringSwitch.h"
24#define BUILTIN(ID, TYPE, ATTRS) \
25 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
26#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
27 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
28#include "clang/Basic/BuiltinsMips.def"
32 return llvm::StringSwitch<bool>(CPU)
37 .Case(
"mips64r2",
true)
38 .Case(
"mips64r3",
true)
39 .Case(
"mips64r5",
true)
40 .Case(
"mips64r6",
true)
42 .Case(
"octeon+",
true)
47 {
"mips1"}, {
"mips2"}, {
"mips3"}, {
"mips4"}, {
"mips5"},
48 {
"mips32"}, {
"mips32r2"}, {
"mips32r3"}, {
"mips32r5"}, {
"mips32r6"},
49 {
"mips64"}, {
"mips64r2"}, {
"mips64r3"}, {
"mips64r5"}, {
"mips64r6"},
50 {
"octeon"}, {
"octeon+"}, {
"p5600"}};
62 return llvm::StringSwitch<unsigned>(
getCPU())
63 .Cases(
"mips32",
"mips64", 1)
64 .Cases(
"mips32r2",
"mips64r2",
"octeon",
"octeon+", 2)
65 .Cases(
"mips32r3",
"mips64r3", 3)
66 .Cases(
"mips32r5",
"mips64r5", 5)
67 .Cases(
"mips32r6",
"mips64r6", 6)
75 Builder.defineMacro(
"_MIPSEB");
78 Builder.defineMacro(
"_MIPSEL");
81 Builder.defineMacro(
"__mips__");
82 Builder.defineMacro(
"_mips");
84 Builder.defineMacro(
"mips");
87 Builder.defineMacro(
"__mips",
"32");
88 Builder.defineMacro(
"_MIPS_ISA",
"_MIPS_ISA_MIPS32");
90 Builder.defineMacro(
"__mips",
"64");
91 Builder.defineMacro(
"__mips64");
92 Builder.defineMacro(
"__mips64__");
93 Builder.defineMacro(
"_MIPS_ISA",
"_MIPS_ISA_MIPS64");
96 const std::string ISARev = std::to_string(
getISARev());
99 Builder.defineMacro(
"__mips_isa_rev", ISARev);
102 Builder.defineMacro(
"__mips_o32");
103 Builder.defineMacro(
"_ABIO32",
"1");
104 Builder.defineMacro(
"_MIPS_SIM",
"_ABIO32");
105 }
else if (
ABI ==
"n32") {
106 Builder.defineMacro(
"__mips_n32");
107 Builder.defineMacro(
"_ABIN32",
"2");
108 Builder.defineMacro(
"_MIPS_SIM",
"_ABIN32");
109 }
else if (
ABI ==
"n64") {
110 Builder.defineMacro(
"__mips_n64");
111 Builder.defineMacro(
"_ABI64",
"3");
112 Builder.defineMacro(
"_MIPS_SIM",
"_ABI64");
114 llvm_unreachable(
"Invalid ABI.");
117 Builder.defineMacro(
"__mips_abicalls");
118 if (CanUseBSDABICalls)
119 Builder.defineMacro(
"__ABICALLS__");
122 Builder.defineMacro(
"__REGISTER_PREFIX__",
"");
126 Builder.defineMacro(
"__mips_hard_float", Twine(1));
129 Builder.defineMacro(
"__mips_soft_float", Twine(1));
134 Builder.defineMacro(
"__mips_single_float", Twine(1));
138 Builder.defineMacro(
"__mips_fpr", Twine(0));
141 Builder.defineMacro(
"__mips_fpr", Twine(32));
144 Builder.defineMacro(
"__mips_fpr", Twine(64));
149 Builder.defineMacro(
"_MIPS_FPSET", Twine(32));
151 Builder.defineMacro(
"_MIPS_FPSET", Twine(16));
153 Builder.defineMacro(
"_MIPS_SPFPSET", Twine(16));
155 Builder.defineMacro(
"_MIPS_SPFPSET", Twine(32));
158 Builder.defineMacro(
"__mips16", Twine(1));
161 Builder.defineMacro(
"__mips_micromips", Twine(1));
164 Builder.defineMacro(
"__mips_nan2008", Twine(1));
167 Builder.defineMacro(
"__mips_abs2008", Twine(1));
173 Builder.defineMacro(
"__mips_dsp_rev", Twine(1));
174 Builder.defineMacro(
"__mips_dsp", Twine(1));
177 Builder.defineMacro(
"__mips_dsp_rev", Twine(2));
178 Builder.defineMacro(
"__mips_dspr2", Twine(1));
179 Builder.defineMacro(
"__mips_dsp", Twine(1));
184 Builder.defineMacro(
"__mips_msa", Twine(1));
187 Builder.defineMacro(
"__mips_no_madd4", Twine(1));
190 Builder.defineMacro(
"_MIPS_SZINT", Twine(
getIntWidth()));
191 Builder.defineMacro(
"_MIPS_SZLONG", Twine(
getLongWidth()));
193 Builder.defineMacro(
"_MIPS_ARCH",
"\"" + CPU +
"\"");
194 if (CPU ==
"octeon+")
195 Builder.defineMacro(
"_MIPS_ARCH_OCTEONP");
197 Builder.defineMacro(
"_MIPS_ARCH_" + StringRef(CPU).upper());
199 if (StringRef(CPU).starts_with(
"octeon"))
200 Builder.defineMacro(
"__OCTEON__");
202 if (CPU !=
"mips1") {
203 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
204 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
205 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
212 if (
ABI ==
"n32" ||
ABI ==
"n64")
213 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
217 return llvm::StringSwitch<bool>(Feature)
219 .Case(
"dsp", DspRev >= DSP1)
220 .Case(
"dspr2", DspRev >= DSP2)
232 return llvm::StringSwitch<unsigned>(
ABI)
241 if (
getTriple().isMIPS64() && IsMicromips && (
ABI ==
"n32" ||
ABI ==
"n64")) {
242 Diags.
Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
248 Diags.
Report(diag::err_target_unsupported_abi) <<
ABI << CPU;
254 Diags.
Report(diag::err_unsupported_abi_for_opt) <<
"-mfpxx" <<
"o32";
260 (
ABI ==
"n32" ||
ABI ==
"n64")) {
261 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfpxx" << CPU;
266 CPU ==
"mips64r6")) {
267 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfp32" << CPU;
271 if (
FPMode ==
FP64 && (CPU ==
"mips1" || CPU ==
"mips2" ||
273 Diags.
Report(diag::err_mips_fp64_req) <<
"-mfp64";
278 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfpxx" << CPU;
282 if (FloatABI == SoftFloat && HasMSA) {
283 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-msoft-float"
288 if (HasMSA && (CPU ==
"mips1" || CPU ==
"mips2" ||
getISARev() < 2) &&
290 Diags.
Report(diag::err_mips_fp64_req) <<
"-mmsa";
295 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfpxx"
300 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfp32"
Defines the Diagnostic-related interfaces.
static constexpr llvm::StringLiteral ValidCPUNames[]
static constexpr Builtin::Info BuiltinInfo[]
static constexpr Builtin::Info BuiltinInfo[]
Defines the clang::MacroBuilder utility class.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
enum clang::targets::MipsTargetInfo::FPModeEnum FPMode
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
bool processorSupportsGPR64() const
unsigned getUnwindWordWidth() const override
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
unsigned getISARev() const
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
bool validateTarget(DiagnosticsEngine &Diags) const override
Check the target is valid after it is fully initialized.
const std::string & getCPU() const
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
The JSON file list parser is used to communicate input to InstallAPI.