13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
18#include "llvm/Support/Compiler.h"
19#include "llvm/TargetParser/Triple.h"
25 void setDataLayout() {
29 Layout =
"m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
30 else if (ABI ==
"n32")
31 Layout =
"m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
32 else if (ABI ==
"n64")
33 Layout =
"m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
35 llvm_unreachable(
"Invalid ABI");
38 resetDataLayout((
"E-" + Layout).str());
40 resetDataLayout((
"e-" + Layout).str());
50 bool CanUseBSDABICalls;
51 enum MipsFloatABI { HardFloat, SoftFloat } FloatABI;
52 enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
55 bool UseIndirectJumpHazard;
65 IsNoABICalls(
false), CanUseBSDABICalls(
false), FloatABI(HardFloat),
66 DspRev(NoDSP), HasMSA(
false), DisableMadd4(
false),
67 UseIndirectJumpHazard(
false), FPMode(FPXX) {
68 TheCXXABI.set(TargetCXXABI::GenericMIPS);
70 if (Triple.isMIPS32())
72 else if (Triple.getEnvironment() == llvm::Triple::GNUABIN32)
77 CPU = ABI ==
"o32" ?
"mips32r2" :
"mips64r2";
79 CanUseBSDABICalls = Triple.isOSFreeBSD() ||
84 return CPU ==
"mips32r6" || CPU ==
"mips64r6";
88 return CPU ==
"mips32r6" || ABI ==
"n32" || ABI ==
"n64" || ABI ==
"64";
91 bool isNan2008()
const override {
return IsNan2008; }
93 bool processorSupportsGPR64()
const;
95 StringRef
getABI()
const override {
return ABI; }
97 bool setABI(
const std::string &Name)
override {
118 Int64Type = SignedLongLong;
119 IntMaxType = Int64Type;
120 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
121 LongDoubleWidth = LongDoubleAlign = 64;
122 LongWidth = LongAlign = 32;
123 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
124 PointerWidth = PointerAlign = 32;
125 PtrDiffType = SignedInt;
126 SizeType = UnsignedInt;
131 LongDoubleWidth = LongDoubleAlign = 128;
132 LongDoubleFormat = &llvm::APFloat::IEEEquad();
133 if (getTriple().isOSFreeBSD()) {
134 LongDoubleWidth = LongDoubleAlign = 64;
135 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
137 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
143 if (getTriple().isOSOpenBSD()) {
144 Int64Type = SignedLongLong;
146 Int64Type = SignedLong;
148 IntMaxType = Int64Type;
149 LongWidth = LongAlign = 64;
150 PointerWidth = PointerAlign = 64;
151 PtrDiffType = SignedLong;
152 SizeType = UnsignedLong;
157 Int64Type = SignedLongLong;
158 IntMaxType = Int64Type;
159 LongWidth = LongAlign = 32;
160 PointerWidth = PointerAlign = 32;
161 PtrDiffType = SignedInt;
162 SizeType = UnsignedInt;
165 bool isValidCPUName(StringRef Name)
const override;
168 bool setCPU(
const std::string &Name)
override {
170 return isValidCPUName(Name);
173 const std::string &
getCPU()
const {
return CPU; }
177 const std::vector<std::string> &FeaturesVec)
const override {
181 Features[
"mips64r2"] = Features[
"cnmips"] =
true;
182 else if (CPU ==
"octeon+")
183 Features[
"mips64r2"] = Features[
"cnmips"] = Features[
"cnmipsp"] =
true;
185 Features[CPU] =
true;
186 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
189 unsigned getISARev()
const;
196 bool hasFeature(StringRef Feature)
const override;
199 return TargetInfo::VoidPtrBuiltinVaList;
203 static const char *
const GCCRegNames[] = {
206 "$0",
"$1",
"$2",
"$3",
"$4",
"$5",
"$6",
"$7",
"$8",
"$9",
"$10",
207 "$11",
"$12",
"$13",
"$14",
"$15",
"$16",
"$17",
"$18",
"$19",
"$20",
208 "$21",
"$22",
"$23",
"$24",
"$25",
"$26",
"$27",
"$28",
"$29",
"$30",
211 "$f0",
"$f1",
"$f2",
"$f3",
"$f4",
"$f5",
"$f6",
"$f7",
"$f8",
"$f9",
212 "$f10",
"$f11",
"$f12",
"$f13",
"$f14",
"$f15",
"$f16",
"$f17",
"$f18",
213 "$f19",
"$f20",
"$f21",
"$f22",
"$f23",
"$f24",
"$f25",
"$f26",
"$f27",
214 "$f28",
"$f29",
"$f30",
"$f31",
216 "hi",
"lo",
"",
"$fcc0",
"$fcc1",
"$fcc2",
"$fcc3",
"$fcc4",
"$fcc5",
217 "$fcc6",
"$fcc7",
"$ac1hi",
"$ac1lo",
"$ac2hi",
"$ac2lo",
"$ac3hi",
220 "$w0",
"$w1",
"$w2",
"$w3",
"$w4",
"$w5",
"$w6",
"$w7",
"$w8",
"$w9",
221 "$w10",
"$w11",
"$w12",
"$w13",
"$w14",
"$w15",
"$w16",
"$w17",
"$w18",
222 "$w19",
"$w20",
"$w21",
"$w22",
"$w23",
"$w24",
"$w25",
"$w26",
"$w27",
223 "$w28",
"$w29",
"$w30",
"$w31",
225 "$msair",
"$msacsr",
"$msaaccess",
"$msasave",
"$msamodify",
226 "$msarequest",
"$msamap",
"$msaunmap"
258 if (Name[1] ==
'C') {
269 switch (*Constraint) {
271 if (Constraint[1] ==
'C') {
272 R = std::string(
"^") + std::string(Constraint, 2);
278 return TargetInfo::convertConstraint(Constraint);
310 IsNan2008 = isIEEE754_2008Default();
311 IsAbs2008 = isIEEE754_2008Default();
312 IsSingleFloat =
false;
313 FloatABI = HardFloat;
315 FPMode = isFP64Default() ? FP64 : FPXX;
317 for (
const auto &Feature : Features) {
318 if (Feature ==
"+single-float")
319 IsSingleFloat =
true;
320 else if (Feature ==
"+soft-float")
321 FloatABI = SoftFloat;
322 else if (Feature ==
"+mips16")
324 else if (Feature ==
"+micromips")
326 else if (Feature ==
"+dsp")
327 DspRev = std::max(DspRev, DSP1);
328 else if (Feature ==
"+dspr2")
329 DspRev = std::max(DspRev, DSP2);
330 else if (Feature ==
"+msa")
332 else if (Feature ==
"+nomadd4")
334 else if (Feature ==
"+fp64")
336 else if (Feature ==
"-fp64")
338 else if (Feature ==
"+fpxx")
340 else if (Feature ==
"+nan2008")
342 else if (Feature ==
"-nan2008")
344 else if (Feature ==
"+abs2008")
346 else if (Feature ==
"-abs2008")
348 else if (Feature ==
"+noabicalls")
350 else if (Feature ==
"+use-indirect-jump-hazard")
351 UseIndirectJumpHazard =
true;
371 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
372 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
373 {{
"a3"},
"$7"}, {{
"t0"},
"$8"}, {{
"t1"},
"$9"},
374 {{
"t2"},
"$10"}, {{
"t3"},
"$11"}, {{
"t4"},
"$12"},
375 {{
"t5"},
"$13"}, {{
"t6"},
"$14"}, {{
"t7"},
"$15"},
376 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
377 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
378 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
379 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
380 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
384 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
385 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
386 {{
"a3"},
"$7"}, {{
"a4"},
"$8"}, {{
"a5"},
"$9"},
387 {{
"a6"},
"$10"}, {{
"a7"},
"$11"}, {{
"t0"},
"$12"},
388 {{
"t1"},
"$13"}, {{
"t2"},
"$14"}, {{
"t3"},
"$15"},
389 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
390 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
391 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
392 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
393 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
402 return (ABI ==
"n32" || ABI ==
"n64") || getTargetOpts().ForceEnableInt128;
405 unsigned getUnwindWordWidth()
const override;
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Exposes information about the current target.
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Options for controlling the target.
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...
bool setCPU(const std::string &Name) override
Target the specified CPU.
StringRef getABI() const override
Get the ABI currently in use.
ArrayRef< const char * > getGCCRegNames() const override
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
bool isIEEE754_2008Default() const
bool isFP64Default() const
bool setABI(const std::string &Name) override
Use the specified ABI.
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
std::string convertConstraint(const char *&Constraint) const override
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
bool isNan2008() const override
Returns true if NaN encoding is IEEE 754-2008.
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
const std::string & getCPU() const
Defines the clang::TargetInfo interface.