14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H 15 #define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H 19 #include "llvm/ADT/Triple.h" 20 #include "llvm/Support/Compiler.h" 26 void setDataLayout() {
30 Layout =
"m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
31 else if (ABI ==
"n32")
32 Layout =
"m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
33 else if (ABI ==
"n64")
34 Layout =
"m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
36 llvm_unreachable(
"Invalid ABI");
39 resetDataLayout((
"E-" + Layout).str());
41 resetDataLayout((
"e-" + Layout).str());
52 bool CanUseBSDABICalls;
53 enum MipsFloatABI { HardFloat, SoftFloat }
FloatABI;
54 enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
57 bool UseIndirectJumpHazard;
67 IsNoABICalls(
false), CanUseBSDABICalls(
false), FloatABI(HardFloat),
68 DspRev(NoDSP), HasMSA(
false), DisableMadd4(
false),
72 setABI(getTriple().isMIPS32() ?
"o32" :
"n64");
74 CPU = ABI ==
"o32" ?
"mips32r2" :
"mips64r2";
76 CanUseBSDABICalls = Triple.getOS() == llvm::Triple::FreeBSD ||
77 Triple.getOS() == llvm::Triple::OpenBSD;
81 return CPU ==
"mips32r6" || CPU ==
"mips64r6";
85 return CPU ==
"mips32r6" || ABI ==
"n32" || ABI ==
"n64" || ABI ==
"64";
88 bool isNan2008()
const override {
return IsNan2008; }
90 bool processorSupportsGPR64()
const;
92 StringRef
getABI()
const override {
return ABI; }
94 bool setABI(
const std::string &Name)
override {
115 Int64Type = SignedLongLong;
116 IntMaxType = Int64Type;
117 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
118 LongDoubleWidth = LongDoubleAlign = 64;
119 LongWidth = LongAlign = 32;
120 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
121 PointerWidth = PointerAlign = 32;
122 PtrDiffType = SignedInt;
123 SizeType = UnsignedInt;
128 LongDoubleWidth = LongDoubleAlign = 128;
129 LongDoubleFormat = &llvm::APFloat::IEEEquad();
130 if (getTriple().getOS() == llvm::Triple::FreeBSD) {
131 LongDoubleWidth = LongDoubleAlign = 64;
132 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
134 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
140 if (getTriple().getOS() == llvm::Triple::OpenBSD) {
141 Int64Type = SignedLongLong;
143 Int64Type = SignedLong;
145 IntMaxType = Int64Type;
146 LongWidth = LongAlign = 64;
147 PointerWidth = PointerAlign = 64;
148 PtrDiffType = SignedLong;
149 SizeType = UnsignedLong;
154 Int64Type = SignedLongLong;
155 IntMaxType = Int64Type;
156 LongWidth = LongAlign = 32;
157 PointerWidth = PointerAlign = 32;
158 PtrDiffType = SignedInt;
159 SizeType = UnsignedInt;
162 bool isValidCPUName(StringRef Name)
const override;
165 bool setCPU(
const std::string &Name)
override {
167 return isValidCPUName(Name);
170 const std::string &
getCPU()
const {
return CPU; }
174 const std::vector<std::string> &FeaturesVec)
const override {
178 Features[
"mips64r2"] = Features[
"cnmips"] =
true;
180 Features[CPU] =
true;
189 bool hasFeature(StringRef Feature)
const override;
199 "$0",
"$1",
"$2",
"$3",
"$4",
"$5",
"$6",
"$7",
"$8",
"$9",
"$10",
200 "$11",
"$12",
"$13",
"$14",
"$15",
"$16",
"$17",
"$18",
"$19",
"$20",
201 "$21",
"$22",
"$23",
"$24",
"$25",
"$26",
"$27",
"$28",
"$29",
"$30",
204 "$f0",
"$f1",
"$f2",
"$f3",
"$f4",
"$f5",
"$f6",
"$f7",
"$f8",
"$f9",
205 "$f10",
"$f11",
"$f12",
"$f13",
"$f14",
"$f15",
"$f16",
"$f17",
"$f18",
206 "$f19",
"$f20",
"$f21",
"$f22",
"$f23",
"$f24",
"$f25",
"$f26",
"$f27",
207 "$f28",
"$f29",
"$f30",
"$f31",
209 "hi",
"lo",
"",
"$fcc0",
"$fcc1",
"$fcc2",
"$fcc3",
"$fcc4",
"$fcc5",
210 "$fcc6",
"$fcc7",
"$ac1hi",
"$ac1lo",
"$ac2hi",
"$ac2lo",
"$ac3hi",
213 "$w0",
"$w1",
"$w2",
"$w3",
"$w4",
"$w5",
"$w6",
"$w7",
"$w8",
"$w9",
214 "$w10",
"$w11",
"$w12",
"$w13",
"$w14",
"$w15",
"$w16",
"$w17",
"$w18",
215 "$w19",
"$w20",
"$w21",
"$w22",
"$w23",
"$w24",
"$w25",
"$w26",
"$w27",
216 "$w28",
"$w29",
"$w30",
"$w31",
218 "$msair",
"$msacsr",
"$msaaccess",
"$msasave",
"$msamodify",
219 "$msarequest",
"$msamap",
"$msaunmap" 221 return llvm::makeArrayRef(GCCRegNames);
251 if (Name[1] ==
'C') {
262 switch (*Constraint) {
264 if (Constraint[1] ==
'C') {
265 R = std::string(
"^") + std::string(Constraint, 2);
303 IsNan2008 = isIEEE754_2008Default();
304 IsAbs2008 = isIEEE754_2008Default();
305 IsSingleFloat =
false;
306 FloatABI = HardFloat;
308 HasFP64 = isFP64Default();
310 for (
const auto &Feature : Features) {
311 if (Feature ==
"+single-float")
312 IsSingleFloat =
true;
313 else if (Feature ==
"+soft-float")
314 FloatABI = SoftFloat;
315 else if (Feature ==
"+mips16")
317 else if (Feature ==
"+micromips")
319 else if (Feature ==
"+dsp")
321 else if (Feature ==
"+dspr2")
323 else if (Feature ==
"+msa")
325 else if (Feature ==
"+nomadd4")
327 else if (Feature ==
"+fp64")
329 else if (Feature ==
"-fp64")
331 else if (Feature ==
"+nan2008")
333 else if (Feature ==
"-nan2008")
335 else if (Feature ==
"+abs2008")
337 else if (Feature ==
"-abs2008")
339 else if (Feature ==
"+noabicalls")
341 else if (Feature ==
"+use-indirect-jump-hazard")
342 UseIndirectJumpHazard =
true;
362 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
363 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
364 {{
"a3"},
"$7"}, {{
"t0"},
"$8"}, {{
"t1"},
"$9"},
365 {{
"t2"},
"$10"}, {{
"t3"},
"$11"}, {{
"t4"},
"$12"},
366 {{
"t5"},
"$13"}, {{
"t6"},
"$14"}, {{
"t7"},
"$15"},
367 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
368 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
369 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
370 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
371 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
375 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
376 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
377 {{
"a3"},
"$7"}, {{
"a4"},
"$8"}, {{
"a5"},
"$9"},
378 {{
"a6"},
"$10"}, {{
"a7"},
"$11"}, {{
"t0"},
"$12"},
379 {{
"t1"},
"$13"}, {{
"t2"},
"$14"}, {{
"t3"},
"$15"},
380 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
381 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
382 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
383 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
384 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
388 return llvm::makeArrayRef(O32RegAliases);
389 return llvm::makeArrayRef(NewABIRegAliases);
393 return (ABI ==
"n32" || ABI ==
"n64") || getTargetOpts().ForceEnableInt128;
401 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H std::string convertConstraint(const char *&Constraint) const override
ArrayRef< const char * > getGCCRegNames() const override
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
static const Builtin::Info BuiltinInfo[]
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...
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Options for controlling the target.
The generic Mips ABI is a modified version of the Itanium ABI.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
Concrete class used by the front-end to report problems and issues.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
static const char *const GCCRegNames[]
typedef void* __builtin_va_list;
Exposes information about the current target.
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
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.
bool isFP64Default() const
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
bool isIEEE754_2008Default() const
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 isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
Defines the clang::TargetOptions class.
StringRef getABI() const override
Get the ABI currently in use.
const std::string & getCPU() const
Dataflow Directional Tag Classes.
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
bool isNan2008() const override
Returns true if NaN encoding is IEEE 754-2008.
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
bool setABI(const std::string &Name) override
Use the specified ABI.
Defines the clang::TargetInfo interface.
__DEVICE__ int max(int __a, int __b)
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
virtual std::string convertConstraint(const char *&Constraint) const