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"
33 bool CanUseBSDABICalls;
34 enum MipsFloatABI { HardFloat, SoftFloat } FloatABI;
35 enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
38 bool UseIndirectJumpHazard;
43 unsigned ISALevel = 0;
56 IsNoABICalls(
false), CanUseBSDABICalls(
false), FloatABI(HardFloat),
57 DspRev(NoDSP), HasMSA(
false), DisableMadd4(
false),
61 if (Triple.isMIPS32())
63 else if (Triple.isABIN32())
68 CPU =
ABI ==
"o32" ?
"mips32r2" :
"mips64r2";
70 CanUseBSDABICalls = Triple.isOSFreeBSD() ||
77 if ((ISALevel == 32 && ISARev == 6) ||
ABI ==
"n32" ||
ABI ==
"n64" ||
80 else if (ISALevel == 1)
86 bool isNan2008()
const override {
return IsNan2008; }
89 return ISALevel == 64 || (ISALevel >= 3 && ISALevel <= 5);
94 bool setABI(
const std::string &Name)
override {
162 bool isValidCPUName(StringRef Name)
const override;
170 const std::string &
getCPU()
const {
return CPU; }
174 const std::vector<std::string> &FeaturesVec)
const override {
178 Features[
"mips64r2"] = Features[
"cnmips"] =
true;
179 else if (CPU ==
"octeon+")
180 Features[
"mips64r2"] = Features[
"cnmips"] = Features[
"cnmipsp"] =
true;
182 Features[CPU] =
true;
186 void setISAFromFeatures(
const std::vector<std::string> &Features);
203 "$0",
"$1",
"$2",
"$3",
"$4",
"$5",
"$6",
"$7",
"$8",
"$9",
"$10",
204 "$11",
"$12",
"$13",
"$14",
"$15",
"$16",
"$17",
"$18",
"$19",
"$20",
205 "$21",
"$22",
"$23",
"$24",
"$25",
"$26",
"$27",
"$28",
"$29",
"$30",
208 "$f0",
"$f1",
"$f2",
"$f3",
"$f4",
"$f5",
"$f6",
"$f7",
"$f8",
"$f9",
209 "$f10",
"$f11",
"$f12",
"$f13",
"$f14",
"$f15",
"$f16",
"$f17",
"$f18",
210 "$f19",
"$f20",
"$f21",
"$f22",
"$f23",
"$f24",
"$f25",
"$f26",
"$f27",
211 "$f28",
"$f29",
"$f30",
"$f31",
213 "hi",
"lo",
"",
"$fcc0",
"$fcc1",
"$fcc2",
"$fcc3",
"$fcc4",
"$fcc5",
214 "$fcc6",
"$fcc7",
"$ac1hi",
"$ac1lo",
"$ac2hi",
"$ac2lo",
"$ac3hi",
217 "$w0",
"$w1",
"$w2",
"$w3",
"$w4",
"$w5",
"$w6",
"$w7",
"$w8",
"$w9",
218 "$w10",
"$w11",
"$w12",
"$w13",
"$w14",
"$w15",
"$w16",
"$w17",
"$w18",
219 "$w19",
"$w20",
"$w21",
"$w22",
"$w23",
"$w24",
"$w25",
"$w26",
"$w27",
220 "$w28",
"$w29",
"$w30",
"$w31",
222 "$msair",
"$msacsr",
"$msaaccess",
"$msasave",
"$msamodify",
223 "$msarequest",
"$msamap",
"$msaunmap"
243 return FloatABI != SoftFloat;
257 if (Name[1] ==
'C') {
268 switch (*Constraint) {
270 if (Constraint[1] ==
'C') {
271 R = std::string(
"^") + std::string(Constraint, 2);
313 IsSingleFloat =
false;
314 FloatABI = HardFloat;
318 bool OddSpregGiven =
false;
319 bool StrictAlign =
false;
320 bool FpGiven =
false;
321 bool IsR5900 =
false;
323 for (
const auto &
Feature : Features) {
324 if (
Feature ==
"+single-float")
325 IsSingleFloat =
true;
326 else if (
Feature ==
"+soft-float")
327 FloatABI = SoftFloat;
330 else if (
Feature ==
"+micromips")
336 else if (
Feature ==
"+strict-align")
339 DspRev = std::max(DspRev, DSP1);
341 DspRev = std::max(DspRev, DSP2);
344 else if (
Feature ==
"+nomadd4")
349 }
else if (
Feature ==
"-fp64") {
352 }
else if (
Feature ==
"+fpxx") {
355 }
else if (
Feature ==
"+nan2008")
357 else if (
Feature ==
"-nan2008")
359 else if (
Feature ==
"+abs2008")
361 else if (
Feature ==
"-abs2008")
363 else if (
Feature ==
"+noabicalls")
365 else if (
Feature ==
"+use-indirect-jump-hazard")
366 UseIndirectJumpHazard =
true;
369 else if (
Feature ==
"+nooddspreg") {
371 OddSpregGiven =
false;
372 }
else if (
Feature ==
"-nooddspreg") {
374 OddSpregGiven =
true;
384 if (HasMSA && !FpGiven) {
386 Features.push_back(
"+fp64");
393 if (
ABI ==
"o32" && ISALevel < 32 &&
FPMode !=
FP64 && !IsR5900 &&
394 !OddSpregGiven && !NoOddSpreg) {
396 Features.push_back(
"+nooddspreg");
400 HasLLSC = ISALevel != 1 && !IsR5900;
421 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
422 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
423 {{
"a3"},
"$7"}, {{
"t0"},
"$8"}, {{
"t1"},
"$9"},
424 {{
"t2"},
"$10"}, {{
"t3"},
"$11"}, {{
"t4"},
"$12"},
425 {{
"t5"},
"$13"}, {{
"t6"},
"$14"}, {{
"t7"},
"$15"},
426 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
427 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
428 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
429 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
430 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
434 {{
"at"},
"$1"}, {{
"v0"},
"$2"}, {{
"v1"},
"$3"},
435 {{
"a0"},
"$4"}, {{
"a1"},
"$5"}, {{
"a2"},
"$6"},
436 {{
"a3"},
"$7"}, {{
"a4"},
"$8"}, {{
"a5"},
"$9"},
437 {{
"a6"},
"$10"}, {{
"a7"},
"$11"}, {{
"t0"},
"$12"},
438 {{
"t1"},
"$13"}, {{
"t2"},
"$14"}, {{
"t3"},
"$15"},
439 {{
"s0"},
"$16"}, {{
"s1"},
"$17"}, {{
"s2"},
"$18"},
440 {{
"s3"},
"$19"}, {{
"s4"},
"$20"}, {{
"s5"},
"$21"},
441 {{
"s6"},
"$22"}, {{
"s7"},
"$23"}, {{
"t8"},
"$24"},
442 {{
"t9"},
"$25"}, {{
"k0"},
"$26"}, {{
"k1"},
"$27"},
443 {{
"gp"},
"$28"}, {{
"sp",
"$sp"},
"$29"}, {{
"fp",
"$fp"},
"$30"},
455 unsigned getUnwindWordWidth()
const override;
461 return std::make_pair(32, 32);
467 const llvm::Triple Triple;
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.
static StringRef getTriple(const Command &Job)
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...
TargetOptions & getTargetOpts() const
Retrieve the target options.
TargetInfo(const llvm::Triple &T)
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
unsigned HasUnalignedAccess
unsigned char MaxAtomicPromoteWidth
void resetDataLayout(StringRef DL)
Set the data layout to the given string.
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 ...
virtual std::string convertConstraint(const char *&Constraint) const
unsigned char MaxAtomicInlineWidth
Options for controlling the target.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
MicrosoftMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
MinGWMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
enum clang::targets::MipsTargetInfo::FPModeEnum FPMode
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 ...
StringRef getABI() const override
Get the ABI currently in use.
ArrayRef< const char * > getGCCRegNames() const override
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
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
bool processorSupportsGPR64() const
bool setCPU(StringRef Name) override
Target the specified CPU.
void setISAFromFeatures(const std::vector< std::string > &Features)
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
void getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const
WindowsMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
WindowsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Defines the clang::TargetInfo interface.
static const char *const GCCRegNames[]
Top level wrappers for InstallAPI frontend operations.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
unsigned short SuitableAlign
unsigned char PointerWidth
const llvm::fltSemantics * LongDoubleFormat
unsigned char PointerAlign
unsigned char LongDoubleAlign
unsigned char LongDoubleWidth