13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H
19#include "llvm/ADT/StringSwitch.h"
20#include "llvm/Support/Compiler.h"
21#include "llvm/TargetParser/Triple.h"
32 ArchDefineName = 1 << 0,
33 ArchDefinePpcgr = 1 << 1,
34 ArchDefinePpcsq = 1 << 2,
35 ArchDefine440 = 1 << 3,
36 ArchDefine603 = 1 << 4,
37 ArchDefine604 = 1 << 5,
38 ArchDefinePwr4 = 1 << 6,
39 ArchDefinePwr5 = 1 << 7,
40 ArchDefinePwr5x = 1 << 8,
41 ArchDefinePwr6 = 1 << 9,
42 ArchDefinePwr6x = 1 << 10,
43 ArchDefinePwr7 = 1 << 11,
44 ArchDefinePwr8 = 1 << 12,
45 ArchDefinePwr9 = 1 << 13,
46 ArchDefinePwr10 = 1 << 14,
47 ArchDefinePwr11 = 1 << 15,
48 ArchDefineFuture = 1 << 16,
49 ArchDefineA2 = 1 << 17,
50 ArchDefineE500 = 1 << 18
53 ArchDefineTypes ArchDefs = ArchDefineNone;
54 static const char *
const GCCRegNames[];
57 enum PPCFloatABI { HardFloat, SoftFloat } FloatABI;
60 bool HasAltivec =
false;
62 bool HasROPProtect =
false;
63 bool HasPrivileged =
false;
64 bool HasAIXSmallLocalExecTLS =
false;
65 bool HasAIXSmallLocalDynamicTLS =
false;
67 bool UseCRBits =
false;
68 bool HasP8Vector =
false;
69 bool HasP8Crypto =
false;
70 bool HasDirectMove =
false;
72 bool HasBPERMD =
false;
73 bool HasExtDiv =
false;
74 bool HasP9Vector =
false;
76 bool HasFrsqrte =
false;
77 bool HasFrsqrtes =
false;
78 bool PairedVectorMemops =
false;
79 bool HasP10Vector =
false;
80 bool HasPCRelativeMemops =
false;
81 bool HasPrefixInstrs =
false;
82 bool IsISA2_06 =
false;
83 bool IsISA2_07 =
false;
84 bool IsISA3_0 =
false;
85 bool IsISA3_1 =
false;
86 bool HasQuadwordAtomics =
false;
87 bool HasAIXShLibTLSModelOpt =
false;
88 bool UseLongCalls =
false;
97 LongDoubleWidth = LongDoubleAlign = 128;
98 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
101 HasUnalignedAccess =
true;
110 bool isValidCPUName(StringRef Name)
const override;
113 bool setCPU(
const std::string &Name)
override {
114 bool CPUKnown = isValidCPUName(Name);
120 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
121 .Case(
"440", ArchDefineName)
122 .Case(
"450", ArchDefineName | ArchDefine440)
123 .Case(
"601", ArchDefineName)
124 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
125 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
126 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
127 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
128 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
129 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
130 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
131 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
132 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
133 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
134 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
135 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
137 .Case(
"a2", ArchDefineA2)
138 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
139 .Cases(
"power4",
"pwr4",
140 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
141 .Cases(
"power5",
"pwr5",
142 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
144 .Cases(
"power5x",
"pwr5x",
145 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
146 ArchDefinePpcgr | ArchDefinePpcsq)
147 .Cases(
"power6",
"pwr6",
148 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
149 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
150 .Cases(
"power6x",
"pwr6x",
151 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
152 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
154 .Cases(
"power7",
"pwr7",
155 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
156 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
159 .Cases(
"power8",
"pwr8",
"ppc64le",
160 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
161 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
162 ArchDefinePpcgr | ArchDefinePpcsq)
163 .Cases(
"power9",
"pwr9",
164 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
165 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
166 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
167 .Cases(
"power10",
"pwr10",
168 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
169 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
170 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
172 .Cases(
"power11",
"pwr11",
173 ArchDefinePwr11 | ArchDefinePwr10 | ArchDefinePwr9 |
174 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
175 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
176 ArchDefinePpcgr | ArchDefinePpcsq)
178 ArchDefineFuture | ArchDefinePwr11 | ArchDefinePwr10 |
179 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
180 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
181 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
182 .Cases(
"8548",
"e500", ArchDefineE500)
183 .Default(ArchDefineNone);
188 StringRef
getABI()
const override {
return ABI; }
200 const std::vector<std::string> &FeaturesVec)
const override;
202 void addP10SpecificFeatures(llvm::StringMap<bool> &Features)
const;
203 void addP11SpecificFeatures(llvm::StringMap<bool> &Features)
const;
204 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
206 bool handleTargetFeatures(std::vector<std::string> &Features,
209 bool hasFeature(StringRef Feature)
const override;
211 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
212 bool Enabled)
const override;
231 if (FloatABI == SoftFloat)
244 if (FloatABI == SoftFloat)
338 switch (*Constraint) {
342 R = std::string(
"^") + std::string(Constraint, 2);
346 return TargetInfo::convertConstraint(Constraint);
363 if (LongDoubleWidth == 64)
365 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
375 return RegName ==
"r1" || RegName ==
"x1";
380 static constexpr int MINIMUM_AIX_OS_MAJOR = 7;
381 static constexpr int MINIMUM_AIX_OS_MINOR = 2;
383 llvm::Triple Triple = getTriple();
385 return Triple.isOSGlibc() ||
387 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
391 llvm::Triple Triple = getTriple();
393 return Triple.isOSGlibc() ||
395 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
397 bool validateCpuSupports(StringRef Feature)
const override;
398 bool validateCpuIs(StringRef Name)
const override;
405 if (Triple.isOSAIX())
406 resetDataLayout(
"E-m:a-p:32:32-Fi32-i64:64-n32");
407 else if (Triple.getArch() == llvm::Triple::ppcle)
408 resetDataLayout(
"e-m:e-p:32:32-Fn32-i64:64-n32");
410 resetDataLayout(
"E-m:e-p:32:32-Fn32-i64:64-n32");
412 switch (getTriple().getOS()) {
413 case llvm::Triple::Linux:
414 case llvm::Triple::FreeBSD:
415 case llvm::Triple::NetBSD:
416 SizeType = UnsignedInt;
417 PtrDiffType = SignedInt;
418 IntPtrType = SignedInt;
420 case llvm::Triple::AIX:
421 SizeType = UnsignedLong;
422 PtrDiffType = SignedLong;
423 IntPtrType = SignedLong;
424 LongDoubleWidth = 64;
425 LongDoubleAlign = DoubleAlign = 32;
426 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
432 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
434 LongDoubleWidth = LongDoubleAlign = 64;
435 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
439 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
444 return TargetInfo::PowerABIBuiltinVaList;
448 return std::make_pair(32, 32);
458 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
459 IntMaxType = SignedLong;
460 Int64Type = SignedLong;
461 std::string DataLayout;
463 if (Triple.isOSAIX()) {
465 DataLayout =
"E-m:a-Fi64-i64:64-i128:128-n32:64";
466 LongDoubleWidth = 64;
467 LongDoubleAlign = DoubleAlign = 32;
468 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
469 }
else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
470 DataLayout =
"e-m:e-Fn32-i64:64-i128:128-n32:64";
473 DataLayout =
"E-m:e";
474 if (Triple.isPPC64ELFv2ABI()) {
476 DataLayout +=
"-Fn32";
479 DataLayout +=
"-Fi64";
481 DataLayout +=
"-i64:64-i128:128-n32:64";
484 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
485 LongDoubleWidth = LongDoubleAlign = 64;
486 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
489 if (Triple.isOSAIX() || Triple.isOSLinux())
490 DataLayout +=
"-S128-v256:256:256-v512:512:512";
491 resetDataLayout(DataLayout);
494 MaxAtomicPromoteWidth = 128;
496 MaxAtomicInlineWidth = 64;
503 if (!getTriple().isOSAIX() &&
hasFeature(
"quadword-atomics"))
504 MaxAtomicInlineWidth = 128;
508 return TargetInfo::CharPtrBuiltinVaList;
512 bool setABI(
const std::string &Name)
override {
513 if (Name ==
"elfv1" || Name ==
"elfv2") {
532 return std::make_pair(128, 128);
539 using AIXTargetInfo::AIXTargetInfo;
541 return TargetInfo::CharPtrBuiltinVaList;
548 using AIXTargetInfo::AIXTargetInfo;
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.
BuiltinVaListKind getBuiltinVaListKind() const override
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...
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
PPC32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
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.
void setMaxAtomicWidth() override
Set the maximum inline or promote width lock-free atomic operation for the given target.
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
PPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
bool isSPRegName(StringRef RegName) const override
PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
bool supportsTargetAttributeTune() const override
Determine whether this TargetInfo supports tune in target attribute.
bool supportsCpuIs() const override
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
bool supportsCpuSupports() const override
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
std::string convertConstraint(const char *&Constraint) const override
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
const char * getIbm128Mangling() const override
Return the mangled code of __ibm128.
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
StringRef getABI() const override
Get the ABI currently in use.
bool setCPU(const std::string &Name) override
Target the specified CPU.
const char * getFloat128Mangling() const override
Return the mangled code of __float128.
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.