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 ArchDefineFuture = 1 << 15,
48 ArchDefineA2 = 1 << 16,
49 ArchDefineE500 = 1 << 18
52 ArchDefineTypes ArchDefs = ArchDefineNone;
53 static const char *
const GCCRegNames[];
56 enum PPCFloatABI { HardFloat, SoftFloat } FloatABI;
59 bool HasAltivec =
false;
61 bool HasROPProtect =
false;
62 bool HasPrivileged =
false;
63 bool HasAIXSmallLocalExecTLS =
false;
64 bool HasAIXSmallLocalDynamicTLS =
false;
66 bool UseCRBits =
false;
67 bool HasP8Vector =
false;
68 bool HasP8Crypto =
false;
69 bool HasDirectMove =
false;
71 bool HasBPERMD =
false;
72 bool HasExtDiv =
false;
73 bool HasP9Vector =
false;
75 bool PairedVectorMemops =
false;
76 bool HasP10Vector =
false;
77 bool HasPCRelativeMemops =
false;
78 bool HasPrefixInstrs =
false;
79 bool IsISA2_06 =
false;
80 bool IsISA2_07 =
false;
81 bool IsISA3_0 =
false;
82 bool IsISA3_1 =
false;
83 bool HasQuadwordAtomics =
false;
92 LongDoubleWidth = LongDoubleAlign = 128;
93 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
96 HasUnalignedAccess =
true;
105 bool isValidCPUName(StringRef Name)
const override;
108 bool setCPU(
const std::string &Name)
override {
109 bool CPUKnown = isValidCPUName(Name);
115 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
116 .Case(
"440", ArchDefineName)
117 .Case(
"450", ArchDefineName | ArchDefine440)
118 .Case(
"601", ArchDefineName)
119 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
120 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
121 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
122 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
123 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
124 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
125 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
126 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
127 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
128 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
129 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
130 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
132 .Case(
"a2", ArchDefineA2)
133 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
134 .Cases(
"power4",
"pwr4",
135 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
136 .Cases(
"power5",
"pwr5",
137 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
139 .Cases(
"power5x",
"pwr5x",
140 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
141 ArchDefinePpcgr | ArchDefinePpcsq)
142 .Cases(
"power6",
"pwr6",
143 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
144 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
145 .Cases(
"power6x",
"pwr6x",
146 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
147 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
149 .Cases(
"power7",
"pwr7",
150 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
151 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
154 .Cases(
"power8",
"pwr8",
"ppc64le",
155 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
156 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
157 ArchDefinePpcgr | ArchDefinePpcsq)
158 .Cases(
"power9",
"pwr9",
159 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
160 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
161 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
162 .Cases(
"power10",
"pwr10",
163 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
164 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
165 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
168 ArchDefineFuture | ArchDefinePwr10 | ArchDefinePwr9 |
169 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
170 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
171 ArchDefinePpcgr | ArchDefinePpcsq)
172 .Cases(
"8548",
"e500", ArchDefineE500)
173 .Default(ArchDefineNone);
178 StringRef
getABI()
const override {
return ABI; }
190 const std::vector<std::string> &FeaturesVec)
const override;
192 void addP10SpecificFeatures(llvm::StringMap<bool> &Features)
const;
193 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
195 bool handleTargetFeatures(std::vector<std::string> &Features,
198 bool hasFeature(StringRef Feature)
const override;
200 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
201 bool Enabled)
const override;
220 if (FloatABI == SoftFloat)
233 if (FloatABI == SoftFloat)
325 switch (*Constraint) {
329 R = std::string(
"^") + std::string(Constraint, 2);
333 return TargetInfo::convertConstraint(Constraint);
350 if (LongDoubleWidth == 64)
352 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
362 return RegName.equals(
"r1") || RegName.equals(
"x1");
367 static constexpr int MINIMUM_AIX_OS_MAJOR = 7;
368 static constexpr int MINIMUM_AIX_OS_MINOR = 2;
371 llvm::Triple Triple = getTriple();
373 return Triple.isOSGlibc() ||
375 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
377 bool validateCpuSupports(StringRef Feature)
const override;
378 bool validateCpuIs(StringRef Name)
const override;
385 if (Triple.isOSAIX())
386 resetDataLayout(
"E-m:a-p:32:32-Fi32-i64:64-n32");
387 else if (Triple.getArch() == llvm::Triple::ppcle)
388 resetDataLayout(
"e-m:e-p:32:32-Fn32-i64:64-n32");
390 resetDataLayout(
"E-m:e-p:32:32-Fn32-i64:64-n32");
392 switch (getTriple().getOS()) {
393 case llvm::Triple::Linux:
394 case llvm::Triple::FreeBSD:
395 case llvm::Triple::NetBSD:
396 SizeType = UnsignedInt;
397 PtrDiffType = SignedInt;
398 IntPtrType = SignedInt;
400 case llvm::Triple::AIX:
401 SizeType = UnsignedLong;
402 PtrDiffType = SignedLong;
403 IntPtrType = SignedLong;
404 LongDoubleWidth = 64;
405 LongDoubleAlign = DoubleAlign = 32;
406 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
412 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
414 LongDoubleWidth = LongDoubleAlign = 64;
415 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
419 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
424 return TargetInfo::PowerABIBuiltinVaList;
428 return std::make_pair(32, 32);
438 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
439 IntMaxType = SignedLong;
440 Int64Type = SignedLong;
441 std::string DataLayout;
443 if (Triple.isOSAIX()) {
445 DataLayout =
"E-m:a-Fi64-i64:64-n32:64";
446 LongDoubleWidth = 64;
447 LongDoubleAlign = DoubleAlign = 32;
448 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
449 }
else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
450 DataLayout =
"e-m:e-Fn32-i64:64-n32:64";
453 DataLayout =
"E-m:e";
454 if (Triple.isPPC64ELFv2ABI()) {
456 DataLayout +=
"-Fn32";
459 DataLayout +=
"-Fi64";
461 DataLayout +=
"-i64:64-n32:64";
464 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
465 LongDoubleWidth = LongDoubleAlign = 64;
466 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
469 if (Triple.isOSAIX() || Triple.isOSLinux())
470 DataLayout +=
"-S128-v256:256:256-v512:512:512";
471 resetDataLayout(DataLayout);
474 MaxAtomicPromoteWidth = 128;
476 MaxAtomicInlineWidth = 64;
483 if (!getTriple().isOSAIX() &&
hasFeature(
"quadword-atomics"))
484 MaxAtomicInlineWidth = 128;
488 return TargetInfo::CharPtrBuiltinVaList;
492 bool setABI(
const std::string &Name)
override {
493 if (Name ==
"elfv1" || Name ==
"elfv2") {
512 return std::make_pair(128, 128);
519 using AIXTargetInfo::AIXTargetInfo;
521 return TargetInfo::CharPtrBuiltinVaList;
528 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.