13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
19#include "llvm/Support/Compiler.h"
20#include "llvm/TargetParser/Triple.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-i128:128-n32:64-S128";
33 else if (ABI ==
"n64")
34 Layout =
"m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
36 llvm_unreachable(
"Invalid ABI");
39 resetDataLayout((
"E-" + Layout).str());
41 resetDataLayout((
"e-" + Layout).str());
51 bool CanUseBSDABICalls;
52 enum MipsFloatABI { HardFloat, SoftFloat } FloatABI;
53 enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
56 bool UseIndirectJumpHazard;
67 IsNoABICalls(
false), CanUseBSDABICalls(
false), FloatABI(HardFloat),
68 DspRev(NoDSP), HasMSA(
false), DisableMadd4(
false),
69 UseIndirectJumpHazard(
false), FPMode(FPXX) {
70 TheCXXABI.set(TargetCXXABI::GenericMIPS);
72 if (Triple.isMIPS32())
74 else if (Triple.isABIN32())
79 CPU = ABI ==
"o32" ?
"mips32r2" :
"mips64r2";
81 CanUseBSDABICalls = Triple.isOSFreeBSD() ||
86 return CPU ==
"mips32r6" || CPU ==
"mips64r6";
90 if (CPU ==
"mips32r6" || ABI ==
"n32" || ABI ==
"n64" || ABI ==
"64")
92 else if (CPU ==
"mips1")
98 bool isNan2008()
const override {
return IsNan2008; }
100 bool processorSupportsGPR64()
const;
102 StringRef
getABI()
const override {
return ABI; }
104 bool setABI(
const std::string &Name)
override {
125 Int64Type = SignedLongLong;
126 IntMaxType = Int64Type;
127 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
128 LongDoubleWidth = LongDoubleAlign = 64;
129 LongWidth = LongAlign = 32;
130 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
131 PointerWidth = PointerAlign = 32;
132 PtrDiffType = SignedInt;
133 SizeType = UnsignedInt;
138 LongDoubleWidth = LongDoubleAlign = 128;
139 LongDoubleFormat = &llvm::APFloat::IEEEquad();
140 if (getTriple().isOSFreeBSD()) {
141 LongDoubleWidth = LongDoubleAlign = 64;
142 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
144 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
150 if (getTriple().isOSOpenBSD()) {
151 Int64Type = SignedLongLong;
153 Int64Type = SignedLong;
155 IntMaxType = Int64Type;
156 LongWidth = LongAlign = 64;
157 PointerWidth = PointerAlign = 64;
158 PtrDiffType = SignedLong;
159 SizeType = UnsignedLong;
164 Int64Type = SignedLongLong;
165 IntMaxType = Int64Type;
166 LongWidth = LongAlign = 32;
167 PointerWidth = PointerAlign = 32;
168 PtrDiffType = SignedInt;
169 SizeType = UnsignedInt;
172 bool isValidCPUName(StringRef Name)
const override;
175 bool setCPU(
const std::string &Name)
override {
177 return isValidCPUName(Name);
180 const std::string &
getCPU()
const {
return CPU; }
184 const std::vector<std::string> &FeaturesVec)
const override {
188 Features[
"mips64r2"] = Features[
"cnmips"] =
true;
189 else if (CPU ==
"octeon+")
190 Features[
"mips64r2"] = Features[
"cnmips"] = Features[
"cnmipsp"] =
true;
192 Features[CPU] =
true;
193 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
196 unsigned getISARev()
const;
203 bool hasFeature(StringRef Feature)
const override;
206 return TargetInfo::VoidPtrBuiltinVaList;
210 static const char *
const GCCRegNames[] = {
213 "$0",
"$1",
"$2",
"$3",
"$4",
"$5",
"$6",
"$7",
"$8",
"$9",
"$10",
214 "$11",
"$12",
"$13",
"$14",
"$15",
"$16",
"$17",
"$18",
"$19",
"$20",
215 "$21",
"$22",
"$23",
"$24",
"$25",
"$26",
"$27",
"$28",
"$29",
"$30",
218 "$f0",
"$f1",
"$f2",
"$f3",
"$f4",
"$f5",
"$f6",
"$f7",
"$f8",
"$f9",
219 "$f10",
"$f11",
"$f12",
"$f13",
"$f14",
"$f15",
"$f16",
"$f17",
"$f18",
220 "$f19",
"$f20",
"$f21",
"$f22",
"$f23",
"$f24",
"$f25",
"$f26",
"$f27",
221 "$f28",
"$f29",
"$f30",
"$f31",
223 "hi",
"lo",
"",
"$fcc0",
"$fcc1",
"$fcc2",
"$fcc3",
"$fcc4",
"$fcc5",
224 "$fcc6",
"$fcc7",
"$ac1hi",
"$ac1lo",
"$ac2hi",
"$ac2lo",
"$ac3hi",
227 "$w0",
"$w1",
"$w2",
"$w3",
"$w4",
"$w5",
"$w6",
"$w7",
"$w8",
"$w9",
228 "$w10",
"$w11",
"$w12",
"$w13",
"$w14",
"$w15",
"$w16",
"$w17",
"$w18",
229 "$w19",
"$w20",
"$w21",
"$w22",
"$w23",
"$w24",
"$w25",
"$w26",
"$w27",
230 "$w28",
"$w29",
"$w30",
"$w31",
232 "$msair",
"$msacsr",
"$msaaccess",
"$msasave",
"$msamodify",
233 "$msarequest",
"$msamap",
"$msaunmap"
253 return FloatABI != SoftFloat;
267 if (Name[1] ==
'C') {
278 switch (*Constraint) {
280 if (Constraint[1] ==
'C') {
281 R = std::string(
"^") + std::string(Constraint, 2);
287 return TargetInfo::convertConstraint(Constraint);
319 IsNan2008 = isIEEE754_2008Default();
320 IsAbs2008 = isIEEE754_2008Default();
321 IsSingleFloat =
false;
322 FloatABI = HardFloat;
325 FPMode = getDefaultFPMode();
326 bool OddSpregGiven =
false;
327 bool StrictAlign =
false;
328 bool FpGiven =
false;
330 for (
const auto &Feature : Features) {
331 if (Feature ==
"+single-float")
332 IsSingleFloat =
true;
333 else if (Feature ==
"+soft-float")
334 FloatABI = SoftFloat;
335 else if (Feature ==
"+mips16")
337 else if (Feature ==
"+micromips")
339 else if (Feature ==
"+mips32r6" || Feature ==
"+mips64r6")
340 HasUnalignedAccess =
true;
343 else if (Feature ==
"+strict-align")
345 else if (Feature ==
"+dsp")
346 DspRev = std::max(DspRev, DSP1);
347 else if (Feature ==
"+dspr2")
348 DspRev = std::max(DspRev, DSP2);
349 else if (Feature ==
"+msa")
351 else if (Feature ==
"+nomadd4")
353 else if (Feature ==
"+fp64") {
356 }
else if (Feature ==
"-fp64") {
359 }
else if (Feature ==
"+fpxx") {
362 }
else if (Feature ==
"+nan2008")
364 else if (Feature ==
"-nan2008")
366 else if (Feature ==
"+abs2008")
368 else if (Feature ==
"-abs2008")
370 else if (Feature ==
"+noabicalls")
372 else if (Feature ==
"+use-indirect-jump-hazard")
373 UseIndirectJumpHazard =
true;
374 else if (Feature ==
"+nooddspreg") {
376 OddSpregGiven =
false;
377 }
else if (Feature ==
"-nooddspreg") {
379 OddSpregGiven =
true;
383 if (FPMode == FPXX && !OddSpregGiven)
387 HasUnalignedAccess =
false;
389 if (HasMSA && !FpGiven) {
391 Features.push_back(
"+fp64");
411 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
412 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
413 {{
"a3"},
"$7"}, {{
"t0"},
"$8"}, {{
"t1"},
"$9"},
414 {{
"t2"},
"$10"}, {{
"t3"},
"$11"}, {{
"t4"},
"$12"},
415 {{
"t5"},
"$13"}, {{
"t6"},
"$14"}, {{
"t7"},
"$15"},
416 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
417 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
418 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
419 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
420 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
424 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
425 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
426 {{
"a3"},
"$7"}, {{
"a4"},
"$8"}, {{
"a5"},
"$9"},
427 {{
"a6"},
"$10"}, {{
"a7"},
"$11"}, {{
"t0"},
"$12"},
428 {{
"t1"},
"$13"}, {{
"t2"},
"$14"}, {{
"t3"},
"$15"},
429 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
430 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
431 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
432 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
433 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
442 return (ABI ==
"n32" || ABI ==
"n64") || getTargetOpts().ForceEnableInt128;
445 unsigned getUnwindWordWidth()
const override;
451 return std::make_pair(32, 32);
457 const llvm::Triple Triple;
462 void getVisualStudioDefines(
const LangOptions &Opts,
465 BuiltinVaListKind getBuiltinVaListKind()
const override;
467 CallingConvCheckResult checkCallingConvention(
CallingConv CC)
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
enum FPModeEnum getDefaultFPMode() const
std::pair< unsigned, unsigned > hardwareInterferenceSizes() const override
The first value in the pair is the minimum offset between two objects to avoid false sharing (destruc...
bool setABI(const std::string &Name) override
Use the specified ABI.
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
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 std::string & getCPU() const
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.