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;
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;
84 bool HasAIXShLibTLSModelOpt =
false;
93 LongDoubleWidth = LongDoubleAlign = 128;
94 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
97 HasUnalignedAccess =
true;
106 bool isValidCPUName(StringRef Name)
const override;
109 bool setCPU(
const std::string &Name)
override {
110 bool CPUKnown = isValidCPUName(Name);
116 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
117 .Case(
"440", ArchDefineName)
118 .Case(
"450", ArchDefineName | ArchDefine440)
119 .Case(
"601", ArchDefineName)
120 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
121 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
122 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
123 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
124 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
125 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
126 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
127 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
128 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
129 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
130 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
131 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
133 .Case(
"a2", ArchDefineA2)
134 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
135 .Cases(
"power4",
"pwr4",
136 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
137 .Cases(
"power5",
"pwr5",
138 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
140 .Cases(
"power5x",
"pwr5x",
141 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
142 ArchDefinePpcgr | ArchDefinePpcsq)
143 .Cases(
"power6",
"pwr6",
144 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
145 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
146 .Cases(
"power6x",
"pwr6x",
147 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
148 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
150 .Cases(
"power7",
"pwr7",
151 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
152 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
155 .Cases(
"power8",
"pwr8",
"ppc64le",
156 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
157 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
158 ArchDefinePpcgr | ArchDefinePpcsq)
159 .Cases(
"power9",
"pwr9",
160 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
161 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
162 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
163 .Cases(
"power10",
"pwr10",
164 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
165 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
166 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
169 ArchDefineFuture | ArchDefinePwr10 | ArchDefinePwr9 |
170 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
171 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
172 ArchDefinePpcgr | ArchDefinePpcsq)
173 .Cases(
"8548",
"e500", ArchDefineE500)
174 .Default(ArchDefineNone);
179 StringRef
getABI()
const override {
return ABI; }
191 const std::vector<std::string> &FeaturesVec)
const override;
193 void addP10SpecificFeatures(llvm::StringMap<bool> &Features)
const;
194 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
196 bool handleTargetFeatures(std::vector<std::string> &Features,
199 bool hasFeature(StringRef Feature)
const override;
201 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
202 bool Enabled)
const override;
326 switch (*Constraint) {
330 R = std::string(
"^") + std::string(Constraint, 2);
351 if (LongDoubleWidth == 64)
353 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
363 return RegName ==
"r1" || RegName ==
"x1";
368 static constexpr
int MINIMUM_AIX_OS_MAJOR = 7;
369 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));
379 llvm::Triple Triple = getTriple();
381 return Triple.isOSGlibc() ||
383 !Triple.isOSVersionLT(MINIMUM_AIX_OS_MAJOR, MINIMUM_AIX_OS_MINOR));
385 bool validateCpuSupports(StringRef Feature)
const override;
386 bool validateCpuIs(StringRef Name)
const override;
393 if (Triple.isOSAIX())
394 resetDataLayout(
"E-m:a-p:32:32-Fi32-i64:64-n32");
395 else if (Triple.getArch() == llvm::Triple::ppcle)
396 resetDataLayout(
"e-m:e-p:32:32-Fn32-i64:64-n32");
398 resetDataLayout(
"E-m:e-p:32:32-Fn32-i64:64-n32");
400 switch (getTriple().getOS()) {
401 case llvm::Triple::Linux:
402 case llvm::Triple::FreeBSD:
403 case llvm::Triple::NetBSD:
404 SizeType = UnsignedInt;
405 PtrDiffType = SignedInt;
406 IntPtrType = SignedInt;
412 LongDoubleWidth = 64;
413 LongDoubleAlign = DoubleAlign = 32;
414 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
420 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
422 LongDoubleWidth = LongDoubleAlign = 64;
423 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
427 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
436 return std::make_pair(32, 32);
446 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
449 std::string DataLayout;
451 if (Triple.isOSAIX()) {
453 DataLayout =
"E-m:a-Fi64-i64:64-n32:64";
454 LongDoubleWidth = 64;
455 LongDoubleAlign = DoubleAlign = 32;
456 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
457 }
else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
458 DataLayout =
"e-m:e-Fn32-i64:64-n32:64";
461 DataLayout =
"E-m:e";
462 if (Triple.isPPC64ELFv2ABI()) {
464 DataLayout +=
"-Fn32";
467 DataLayout +=
"-Fi64";
469 DataLayout +=
"-i64:64-n32:64";
472 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
473 LongDoubleWidth = LongDoubleAlign = 64;
474 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
477 if (Triple.isOSAIX() || Triple.isOSLinux())
478 DataLayout +=
"-S128-v256:256:256-v512:512:512";
479 resetDataLayout(DataLayout);
482 MaxAtomicPromoteWidth = 128;
484 MaxAtomicInlineWidth = 64;
491 if (!getTriple().isOSAIX() &&
hasFeature(
"quadword-atomics"))
492 MaxAtomicInlineWidth = 128;
500 bool setABI(
const std::string &Name)
override {
501 if (Name ==
"elfv1" || Name ==
"elfv2") {
520 return std::make_pair(128, 128);
clang::driver::toolchains::AIX AIX
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.
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
virtual std::string convertConstraint(const char *&Constraint) const
Options for controlling the target.
BuiltinVaListKind getBuiltinVaListKind() const override
AIXTargetInfo(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...
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.
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...
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.
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
const char * getFloat128Mangling() const override
Return the mangled code of __float128.
const char * getIbm128Mangling() const override
Return the mangled code of __ibm128.
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.
Defines the clang::TargetInfo interface.
static const char *const GCCRegNames[]
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.