13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H 14 #define LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H 19 #include "llvm/ADT/Triple.h" 20 #include "llvm/ADT/StringSwitch.h" 21 #include "llvm/Support/Compiler.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 ArchDefineA2 = 1 << 14,
47 ArchDefineA2q = 1 << 15
51 ArchDefineTypes ArchDefs = ArchDefineNone;
56 enum PPCFloatABI { HardFloat, SoftFloat }
FloatABI;
59 bool HasAltivec =
false;
61 bool HasP8Vector =
false;
62 bool HasP8Crypto =
false;
63 bool HasDirectMove =
false;
66 bool HasBPERMD =
false;
67 bool HasExtDiv =
false;
68 bool HasP9Vector =
false;
77 SimdDefaultAlign = 128;
78 LongDoubleWidth = LongDoubleAlign = 128;
79 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
89 bool isValidCPUName(StringRef Name)
const override;
92 bool setCPU(
const std::string &Name)
override {
93 bool CPUKnown = isValidCPUName(Name);
99 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
100 .Case(
"440", ArchDefineName)
101 .Case(
"450", ArchDefineName | ArchDefine440)
102 .Case(
"601", ArchDefineName)
103 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
104 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
105 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
106 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
107 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
108 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
109 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
110 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
111 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
112 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
113 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
114 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
116 .Case(
"a2", ArchDefineA2)
117 .Case(
"a2q", ArchDefineName | ArchDefineA2 | ArchDefineA2q)
118 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
119 .Cases(
"power4",
"pwr4",
120 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
121 .Cases(
"power5",
"pwr5",
122 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
124 .Cases(
"power5x",
"pwr5x",
125 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
126 ArchDefinePpcgr | ArchDefinePpcsq)
127 .Cases(
"power6",
"pwr6",
128 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
129 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
130 .Cases(
"power6x",
"pwr6x",
131 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
132 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
134 .Cases(
"power7",
"pwr7",
135 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
136 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
139 .Cases(
"power8",
"pwr8",
"ppc64le",
140 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
141 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
142 ArchDefinePpcgr | ArchDefinePpcsq)
143 .Cases(
"power9",
"pwr9",
144 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
145 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
146 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
147 .Default(ArchDefineNone);
152 StringRef
getABI()
const override {
return ABI; }
164 const std::vector<std::string> &FeaturesVec)
const override;
166 bool handleTargetFeatures(std::vector<std::string> &Features,
169 bool hasFeature(StringRef Feature)
const override;
171 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
172 bool Enabled)
const override;
189 if (FloatABI == SoftFloat)
202 if (FloatABI == SoftFloat)
293 switch (*Constraint) {
297 R = std::string(
"^") + std::string(Constraint, 2);
318 if (LongDoubleWidth == 64)
320 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
331 resetDataLayout(
"E-m:e-p:32:32-i64:64-n32");
333 switch (getTriple().getOS()) {
334 case llvm::Triple::Linux:
335 case llvm::Triple::FreeBSD:
336 case llvm::Triple::NetBSD:
337 SizeType = UnsignedInt;
338 PtrDiffType = SignedInt;
339 IntPtrType = SignedInt;
341 case llvm::Triple::AIX:
342 SizeType = UnsignedLong;
343 PtrDiffType = SignedLong;
344 IntPtrType = SignedLong;
351 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
352 Triple.getOS() == llvm::Triple::AIX || Triple.isMusl()) {
353 LongDoubleWidth = LongDoubleAlign = 64;
354 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
358 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
373 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
374 IntMaxType = SignedLong;
375 Int64Type = SignedLong;
377 if ((Triple.getArch() == llvm::Triple::ppc64le)) {
378 resetDataLayout(
"e-m:e-i64:64-n32:64");
381 resetDataLayout(
"E-m:e-i64:64-n32:64");
382 ABI = Triple.getEnvironment() == llvm::Triple::ELFv2 ?
"elfv2" :
"elfv1";
385 if (Triple.getOS() == llvm::Triple::AIX)
388 if (Triple.isOSFreeBSD() || Triple.getOS() == llvm::Triple::AIX ||
390 LongDoubleWidth = LongDoubleAlign = 64;
391 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
395 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
403 bool setABI(
const std::string &Name)
override {
404 if (Name ==
"elfv1" || Name ==
"elfv1-qpx" || Name ==
"elfv2") {
426 HasAlignMac68kSupport =
true;
427 BoolWidth = BoolAlign = 32;
428 PtrDiffType = SignedInt;
430 resetDataLayout(
"E-m:o-p:32:32-f64:32:64-n32");
443 HasAlignMac68kSupport =
true;
444 resetDataLayout(
"E-m:o-i64:64-n32:64");
465 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H
PPC32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
DarwinPPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
static const Builtin::Info BuiltinInfo[]
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...
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Options for controlling the target.
PPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Concrete class used by the front-end to report problems and issues.
StringRef getABI() const override
Get the ABI currently in use.
static const char *const GCCRegNames[]
AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
DarwinPPC32TargetInfo(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.
Exposes information about the current target.
bool setABI(const std::string &Name) override
Use the specified ABI.
bool setCPU(const std::string &Name) override
Target the specified CPU.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
Defines the clang::TargetOptions class.
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
const char * getFloat128Mangling() const override
Return the mangled code of __float128.
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
Dataflow Directional Tag Classes.
typedef char* __builtin_va_list;
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
Defines the clang::TargetInfo interface.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
std::string convertConstraint(const char *&Constraint) const override
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
virtual std::string convertConstraint(const char *&Constraint) const
const char * getLongDoubleMangling() const override
Return the mangled code of long double.