18 #include "llvm/ADT/StringSwitch.h" 20 using namespace clang;
24 #define BUILTIN(ID, TYPE, ATTRS) \ 25 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 26 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ 27 {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, 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)
48 {
"mips1"}, {
"mips2"}, {
"mips3"}, {
"mips4"}, {
"mips5"},
49 {
"mips32"}, {
"mips32r2"}, {
"mips32r3"}, {
"mips32r5"}, {
"mips32r6"},
50 {
"mips64"}, {
"mips64r2"}, {
"mips64r3"}, {
"mips64r5"}, {
"mips64r6"},
51 {
"octeon"}, {
"octeon+"}, {
"p5600"}};
63 return llvm::StringSwitch<unsigned>(
getCPU())
64 .Cases(
"mips32",
"mips64", 1)
65 .Cases(
"mips32r2",
"mips64r2",
"octeon",
"octeon+", 2)
66 .Cases(
"mips32r3",
"mips64r3", 3)
67 .Cases(
"mips32r5",
"mips64r5", 5)
68 .Cases(
"mips32r6",
"mips64r6", 6)
89 Builder.
defineMacro(
"_MIPS_ISA",
"_MIPS_ISA_MIPS32");
94 Builder.
defineMacro(
"_MIPS_ISA",
"_MIPS_ISA_MIPS64");
97 const std::string ISARev = std::to_string(
getISARev());
106 }
else if (
ABI ==
"n32") {
110 }
else if (
ABI ==
"n64") {
115 llvm_unreachable(
"Invalid ABI.");
119 if (CanUseBSDABICalls)
127 Builder.
defineMacro(
"__mips_hard_float", Twine(1));
130 Builder.
defineMacro(
"__mips_soft_float", Twine(1));
135 Builder.
defineMacro(
"__mips_single_float", Twine(1));
190 Builder.
defineMacro(
"_MIPS_ARCH",
"\"" + CPU +
"\"");
191 if (CPU ==
"octeon+")
194 Builder.
defineMacro(
"_MIPS_ARCH_" + StringRef(CPU).upper());
196 if (StringRef(CPU).startswith(
"octeon"))
201 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
202 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
203 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
209 if (
ABI ==
"n32" ||
ABI ==
"n64")
210 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
214 return llvm::StringSwitch<bool>(Feature)
216 .Case(
"dsp", DspRev >= DSP1)
217 .Case(
"dspr2", DspRev >= DSP2)
229 return llvm::StringSwitch<unsigned>(
ABI)
238 if (
getTriple().isMIPS64() && IsMicromips && (
ABI ==
"n32" ||
ABI ==
"n64")) {
239 Diags.
Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
245 Diags.
Report(diag::err_target_unsupported_abi) <<
ABI << CPU;
251 Diags.
Report(diag::err_target_unsupported_abi) <<
ABI << CPU;
259 Diags.
Report(diag::err_target_unsupported_abi_for_triple)
268 Diags.
Report(diag::err_target_unsupported_abi_for_triple)
275 Diags.
Report(diag::err_unsupported_abi_for_opt) <<
"-mfpxx" <<
"o32";
281 (
ABI ==
"n32" ||
ABI ==
"n64")) {
282 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfpxx" << CPU;
287 CPU ==
"mips64r6")) {
288 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfp32" << CPU;
292 if (
FPMode ==
FP64 && (CPU ==
"mips1" || CPU ==
"mips2" ||
294 Diags.
Report(diag::err_mips_fp64_req) <<
"-mfp64";
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
Defines the clang::MacroBuilder utility class.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
unsigned getUnwindWordWidth() const override
bool validateTarget(DiagnosticsEngine &Diags) const override
Check the target is valid after it is fully initialized.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
Enumerates target-specific builtins in their own namespaces within namespace clang.
unsigned getISARev() const
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
const std::string & getCPU() const
Dataflow Directional Tag Classes.
bool processorSupportsGPR64() const
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
enum clang::targets::MipsTargetInfo::FPModeEnum FPMode
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
static constexpr llvm::StringLiteral ValidCPUNames[]
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".