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 PairedVectorMemops =
false;
77 bool HasP10Vector =
false;
78 bool HasPCRelativeMemops =
false;
79 bool HasPrefixInstrs =
false;
80 bool IsISA2_06 =
false;
81 bool IsISA2_07 =
false;
82 bool IsISA3_0 =
false;
83 bool IsISA3_1 =
false;
84 bool HasQuadwordAtomics =
false;
85 bool HasAIXShLibTLSModelOpt =
false;
86 bool UseLongCalls =
false;
95 LongDoubleWidth = LongDoubleAlign = 128;
96 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
99 HasUnalignedAccess =
true;
108 bool isValidCPUName(StringRef Name)
const override;
111 bool setCPU(
const std::string &Name)
override {
112 bool CPUKnown = isValidCPUName(Name);
118 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
119 .Case(
"440", ArchDefineName)
120 .Case(
"450", ArchDefineName | ArchDefine440)
121 .Case(
"601", ArchDefineName)
122 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
123 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
124 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
125 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
126 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
127 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
128 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
129 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
130 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
131 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
132 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
133 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
135 .Case(
"a2", ArchDefineA2)
136 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
137 .Cases(
"power4",
"pwr4",
138 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
139 .Cases(
"power5",
"pwr5",
140 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
142 .Cases(
"power5x",
"pwr5x",
143 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
144 ArchDefinePpcgr | ArchDefinePpcsq)
145 .Cases(
"power6",
"pwr6",
146 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
147 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
148 .Cases(
"power6x",
"pwr6x",
149 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
150 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
152 .Cases(
"power7",
"pwr7",
153 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
154 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
157 .Cases(
"power8",
"pwr8",
"ppc64le",
158 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
159 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
160 ArchDefinePpcgr | ArchDefinePpcsq)
161 .Cases(
"power9",
"pwr9",
162 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
163 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
164 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
165 .Cases(
"power10",
"pwr10",
166 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
167 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
168 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
170 .Cases(
"power11",
"pwr11",
171 ArchDefinePwr11 | ArchDefinePwr10 | ArchDefinePwr9 |
172 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
173 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
174 ArchDefinePpcgr | ArchDefinePpcsq)
176 ArchDefineFuture | ArchDefinePwr11 | ArchDefinePwr10 |
177 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
178 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
179 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
180 .Cases(
"8548",
"e500", ArchDefineE500)
181 .Default(ArchDefineNone);
186 StringRef
getABI()
const override {
return ABI; }
198 const std::vector<std::string> &FeaturesVec)
const override;
200 void addP10SpecificFeatures(llvm::StringMap<bool> &Features)
const;
201 void addP11SpecificFeatures(llvm::StringMap<bool> &Features)
const;
202 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
204 bool handleTargetFeatures(std::vector<std::string> &Features,
207 bool hasFeature(StringRef Feature)
const override;
209 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
210 bool Enabled)
const override;
229 if (FloatABI == SoftFloat)
242 if (FloatABI == SoftFloat)
336 switch (*Constraint) {
340 R = std::string(
"^") + std::string(Constraint, 2);
344 return TargetInfo::convertConstraint(Constraint);
361 if (LongDoubleWidth == 64)
363 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
373 return RegName ==
"r1" || RegName ==
"x1";
378 static constexpr int MINIMUM_AIX_OS_MAJOR = 7;
379 static constexpr int MINIMUM_AIX_OS_MINOR = 2;
381 llvm::Triple Triple = getTriple();
383 return Triple.isOSGlibc() ||
385 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
389 llvm::Triple Triple = getTriple();
391 return Triple.isOSGlibc() ||
393 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
395 bool validateCpuSupports(StringRef Feature)
const override;
396 bool validateCpuIs(StringRef Name)
const override;
403 if (Triple.isOSAIX())
404 resetDataLayout(
"E-m:a-p:32:32-Fi32-i64:64-n32");
405 else if (Triple.getArch() == llvm::Triple::ppcle)
406 resetDataLayout(
"e-m:e-p:32:32-Fn32-i64:64-n32");
408 resetDataLayout(
"E-m:e-p:32:32-Fn32-i64:64-n32");
410 switch (getTriple().getOS()) {
411 case llvm::Triple::Linux:
412 case llvm::Triple::FreeBSD:
413 case llvm::Triple::NetBSD:
414 SizeType = UnsignedInt;
415 PtrDiffType = SignedInt;
416 IntPtrType = SignedInt;
418 case llvm::Triple::AIX:
419 SizeType = UnsignedLong;
420 PtrDiffType = SignedLong;
421 IntPtrType = SignedLong;
422 LongDoubleWidth = 64;
423 LongDoubleAlign = DoubleAlign = 32;
424 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
430 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
432 LongDoubleWidth = LongDoubleAlign = 64;
433 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
437 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
442 return TargetInfo::PowerABIBuiltinVaList;
446 return std::make_pair(32, 32);
456 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
457 IntMaxType = SignedLong;
458 Int64Type = SignedLong;
459 std::string DataLayout;
461 if (Triple.isOSAIX()) {
463 DataLayout =
"E-m:a-Fi64-i64:64-n32:64";
464 LongDoubleWidth = 64;
465 LongDoubleAlign = DoubleAlign = 32;
466 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
467 }
else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
468 DataLayout =
"e-m:e-Fn32-i64:64-n32:64";
471 DataLayout =
"E-m:e";
472 if (Triple.isPPC64ELFv2ABI()) {
474 DataLayout +=
"-Fn32";
477 DataLayout +=
"-Fi64";
479 DataLayout +=
"-i64:64-n32:64";
482 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
483 LongDoubleWidth = LongDoubleAlign = 64;
484 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
487 if (Triple.isOSAIX() || Triple.isOSLinux())
488 DataLayout +=
"-S128-v256:256:256-v512:512:512";
489 resetDataLayout(DataLayout);
492 MaxAtomicPromoteWidth = 128;
494 MaxAtomicInlineWidth = 64;
501 if (!getTriple().isOSAIX() &&
hasFeature(
"quadword-atomics"))
502 MaxAtomicInlineWidth = 128;
506 return TargetInfo::CharPtrBuiltinVaList;
510 bool setABI(
const std::string &Name)
override {
511 if (Name ==
"elfv1" || Name ==
"elfv2") {
530 return std::make_pair(128, 128);
537 using AIXTargetInfo::AIXTargetInfo;
539 return TargetInfo::CharPtrBuiltinVaList;
546 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.