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;
64 bool UseCRBits =
false;
65 bool HasP8Vector =
false;
66 bool HasP8Crypto =
false;
67 bool HasDirectMove =
false;
69 bool HasBPERMD =
false;
70 bool HasExtDiv =
false;
71 bool HasP9Vector =
false;
73 bool PairedVectorMemops =
false;
74 bool HasP10Vector =
false;
75 bool HasPCRelativeMemops =
false;
76 bool HasPrefixInstrs =
false;
77 bool IsISA2_06 =
false;
78 bool IsISA2_07 =
false;
79 bool IsISA3_0 =
false;
80 bool IsISA3_1 =
false;
81 bool HasQuadwordAtomics =
false;
90 LongDoubleWidth = LongDoubleAlign = 128;
91 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
102 bool isValidCPUName(StringRef Name)
const override;
105 bool setCPU(
const std::string &Name)
override {
106 bool CPUKnown = isValidCPUName(Name);
112 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
113 .Case(
"440", ArchDefineName)
114 .Case(
"450", ArchDefineName | ArchDefine440)
115 .Case(
"601", ArchDefineName)
116 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
117 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
118 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
119 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
120 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
121 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
122 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
123 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
124 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
125 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
126 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
127 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
129 .Case(
"a2", ArchDefineA2)
130 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
131 .Cases(
"power4",
"pwr4",
132 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
133 .Cases(
"power5",
"pwr5",
134 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
136 .Cases(
"power5x",
"pwr5x",
137 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
138 ArchDefinePpcgr | ArchDefinePpcsq)
139 .Cases(
"power6",
"pwr6",
140 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
141 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
142 .Cases(
"power6x",
"pwr6x",
143 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
144 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
146 .Cases(
"power7",
"pwr7",
147 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
148 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
151 .Cases(
"power8",
"pwr8",
"ppc64le",
152 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
153 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
154 ArchDefinePpcgr | ArchDefinePpcsq)
155 .Cases(
"power9",
"pwr9",
156 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
157 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
158 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
159 .Cases(
"power10",
"pwr10",
160 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
161 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
162 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
165 ArchDefineFuture | ArchDefinePwr10 | ArchDefinePwr9 |
166 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
167 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
168 ArchDefinePpcgr | ArchDefinePpcsq)
169 .Cases(
"8548",
"e500", ArchDefineE500)
170 .Default(ArchDefineNone);
175 StringRef
getABI()
const override {
return ABI; }
187 const std::vector<std::string> &FeaturesVec)
const override;
189 void addP10SpecificFeatures(llvm::StringMap<bool> &Features)
const;
190 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
192 bool handleTargetFeatures(std::vector<std::string> &Features,
195 bool hasFeature(StringRef Feature)
const override;
197 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
198 bool Enabled)
const override;
215 if (FloatABI == SoftFloat)
228 if (FloatABI == SoftFloat)
320 switch (*Constraint) {
324 R = std::string(
"^") + std::string(Constraint, 2);
328 return TargetInfo::convertConstraint(Constraint);
345 if (LongDoubleWidth == 64)
347 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
357 return RegName.equals(
"r1") || RegName.equals(
"x1");
365 if (Triple.isOSAIX())
366 resetDataLayout(
"E-m:a-p:32:32-Fi32-i64:64-n32");
367 else if (Triple.getArch() == llvm::Triple::ppcle)
368 resetDataLayout(
"e-m:e-p:32:32-Fn32-i64:64-n32");
370 resetDataLayout(
"E-m:e-p:32:32-Fn32-i64:64-n32");
372 switch (getTriple().getOS()) {
373 case llvm::Triple::Linux:
374 case llvm::Triple::FreeBSD:
375 case llvm::Triple::NetBSD:
376 SizeType = UnsignedInt;
377 PtrDiffType = SignedInt;
378 IntPtrType = SignedInt;
380 case llvm::Triple::AIX:
381 SizeType = UnsignedLong;
382 PtrDiffType = SignedLong;
383 IntPtrType = SignedLong;
384 LongDoubleWidth = 64;
385 LongDoubleAlign = DoubleAlign = 32;
386 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
392 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
394 LongDoubleWidth = LongDoubleAlign = 64;
395 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
399 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
404 return TargetInfo::PowerABIBuiltinVaList;
414 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
415 IntMaxType = SignedLong;
416 Int64Type = SignedLong;
417 std::string DataLayout;
419 if (Triple.isOSAIX()) {
421 DataLayout =
"E-m:a-Fi64-i64:64-n32:64";
422 LongDoubleWidth = 64;
423 LongDoubleAlign = DoubleAlign = 32;
424 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
425 }
else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
426 DataLayout =
"e-m:e-Fn32-i64:64-n32:64";
429 DataLayout =
"E-m:e";
430 if (Triple.isPPC64ELFv2ABI()) {
432 DataLayout +=
"-Fn32";
435 DataLayout +=
"-Fi64";
437 DataLayout +=
"-i64:64-n32:64";
440 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
441 LongDoubleWidth = LongDoubleAlign = 64;
442 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
445 if (Triple.isOSAIX() || Triple.isOSLinux())
446 DataLayout +=
"-S128-v256:256:256-v512:512:512";
447 resetDataLayout(DataLayout);
450 MaxAtomicPromoteWidth = 128;
452 MaxAtomicInlineWidth = 64;
459 if (!getTriple().isOSAIX() &&
hasFeature(
"quadword-atomics"))
460 MaxAtomicInlineWidth = 128;
464 return TargetInfo::CharPtrBuiltinVaList;
468 bool setABI(
const std::string &Name)
override {
469 if (Name ==
"elfv1" || Name ==
"elfv2") {
491 using AIXTargetInfo::AIXTargetInfo;
493 return TargetInfo::CharPtrBuiltinVaList;
500 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
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)
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 &)
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
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.
CallingConv
CallingConv - Specifies the calling convention that a function uses.