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 ArchDefineFuture = 1 << 14,
47 ArchDefineA2 = 1 << 15,
48 ArchDefineA2q = 1 << 16,
49 ArchDefineE500 = 1 << 17
53 ArchDefineTypes ArchDefs = ArchDefineNone;
58 enum PPCFloatABI { HardFloat, SoftFloat }
FloatABI;
61 bool HasAltivec =
false;
63 bool HasP8Vector =
false;
64 bool HasP8Crypto =
false;
65 bool HasDirectMove =
false;
68 bool HasBPERMD =
false;
69 bool HasExtDiv =
false;
70 bool HasP9Vector =
false;
80 SimdDefaultAlign = 128;
81 LongDoubleWidth = LongDoubleAlign = 128;
82 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
91 bool isValidCPUName(StringRef Name)
const override;
94 bool setCPU(
const std::string &Name)
override {
95 bool CPUKnown = isValidCPUName(Name);
101 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
102 .Case(
"440", ArchDefineName)
103 .Case(
"450", ArchDefineName | ArchDefine440)
104 .Case(
"601", ArchDefineName)
105 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
106 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
107 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
108 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
109 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
110 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
111 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
112 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
113 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
114 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
115 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
116 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
118 .Case(
"a2", ArchDefineA2)
119 .Case(
"a2q", ArchDefineName | ArchDefineA2 | ArchDefineA2q)
120 .Cases(
"power3",
"pwr3", ArchDefinePpcgr)
121 .Cases(
"power4",
"pwr4",
122 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
123 .Cases(
"power5",
"pwr5",
124 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
126 .Cases(
"power5x",
"pwr5x",
127 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
128 ArchDefinePpcgr | ArchDefinePpcsq)
129 .Cases(
"power6",
"pwr6",
130 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
131 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
132 .Cases(
"power6x",
"pwr6x",
133 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
134 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
136 .Cases(
"power7",
"pwr7",
137 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
138 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
141 .Cases(
"power8",
"pwr8",
"ppc64le",
142 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
143 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
144 ArchDefinePpcgr | ArchDefinePpcsq)
145 .Cases(
"power9",
"pwr9",
146 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
147 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
148 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
150 ArchDefineFuture | ArchDefinePwr9 | ArchDefinePwr8 |
151 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
152 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
154 .Cases(
"8548",
"e500", ArchDefineE500)
155 .Default(ArchDefineNone);
160 StringRef
getABI()
const override {
return ABI; }
172 const std::vector<std::string> &FeaturesVec)
const override;
174 void addFutureSpecificFeatures(llvm::StringMap<bool> &Features)
const;
176 bool handleTargetFeatures(std::vector<std::string> &Features,
179 bool hasFeature(StringRef Feature)
const override;
181 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
182 bool Enabled)
const override;
199 if (FloatABI == SoftFloat)
212 if (FloatABI == SoftFloat)
303 switch (*Constraint) {
307 R = std::string(
"^") + std::string(Constraint, 2);
328 if (LongDoubleWidth == 64)
330 return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
341 resetDataLayout(
"E-m:e-p:32:32-i64:64-n32");
343 switch (getTriple().getOS()) {
344 case llvm::Triple::Linux:
345 case llvm::Triple::FreeBSD:
346 case llvm::Triple::NetBSD:
347 SizeType = UnsignedInt;
348 PtrDiffType = SignedInt;
349 IntPtrType = SignedInt;
352 SizeType = UnsignedLong;
353 PtrDiffType = SignedLong;
354 IntPtrType = SignedLong;
361 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
363 LongDoubleWidth = LongDoubleAlign = 64;
364 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
368 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
383 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
384 IntMaxType = SignedLong;
385 Int64Type = SignedLong;
387 if ((Triple.getArch() == llvm::Triple::ppc64le)) {
388 resetDataLayout(
"e-m:e-i64:64-n32:64");
391 resetDataLayout(
"E-m:e-i64:64-n32:64");
400 LongDoubleWidth = LongDoubleAlign = 64;
401 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
405 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
413 bool setABI(
const std::string &Name)
override {
414 if (Name ==
"elfv1" || Name ==
"elfv1-qpx" || Name ==
"elfv2") {
436 HasAlignMac68kSupport =
true;
437 BoolWidth = BoolAlign = 32;
438 PtrDiffType = SignedInt;
440 resetDataLayout(
"E-m:o-p:32:32-f64:32:64-n32");
453 HasAlignMac68kSupport =
true;
454 resetDataLayout(
"E-m:o-i64:64-n32:64");
475 #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[]
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.
clang::driver::toolchains::AIX AIX
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...
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::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.