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 ArchDefinePwr11 = 1 << 15,
48 ArchDefineFuture = 1 << 16,
49 ArchDefineA2 = 1 << 17,
50 ArchDefineE500 = 1 << 18
53 ArchDefineTypes ArchDefs = ArchDefineNone;
54 static const char *
const GCCRegNames[];
57 enum PPCFloatABI { HardFloat, SoftFloat } FloatABI;
60 bool HasAltivec =
false;
62 bool HasROPProtect =
false;
64 bool HasP8Vector =
false;
65 bool HasP8Crypto =
false;
67 bool HasP9Vector =
false;
69 bool HasFrsqrte =
false;
70 bool HasFrsqrtes =
false;
71 bool HasP10Vector =
false;
72 bool HasPCRelativeMemops =
false;
73 bool HasQuadwordAtomics =
false;
74 bool UseLongCalls =
false;
97 bool isValidCPUName(StringRef Name)
const override;
100 bool setCPU(
const std::string &Name)
override {
107 (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
108 .Case(
"440", ArchDefineName)
109 .Case(
"450", ArchDefineName | ArchDefine440)
110 .Case(
"601", ArchDefineName)
111 .Case(
"602", ArchDefineName | ArchDefinePpcgr)
112 .Case(
"603", ArchDefineName | ArchDefinePpcgr)
113 .Case(
"603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
114 .Case(
"603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
115 .Case(
"604", ArchDefineName | ArchDefinePpcgr)
116 .Case(
"604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
117 .Case(
"620", ArchDefineName | ArchDefinePpcgr)
118 .Case(
"630", ArchDefineName | ArchDefinePpcgr)
119 .Case(
"7400", ArchDefineName | ArchDefinePpcgr)
120 .Case(
"7450", ArchDefineName | ArchDefinePpcgr)
121 .Case(
"750", ArchDefineName | ArchDefinePpcgr)
122 .Case(
"970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr |
124 .Case(
"a2", ArchDefineA2)
125 .Cases({
"power3",
"pwr3"}, ArchDefinePpcgr)
126 .Cases({
"power4",
"pwr4"},
127 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
128 .Cases({
"power5",
"pwr5"}, ArchDefinePwr5 | ArchDefinePwr4 |
129 ArchDefinePpcgr | ArchDefinePpcsq)
130 .Cases({
"power5x",
"pwr5x"},
131 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
132 ArchDefinePpcgr | ArchDefinePpcsq)
133 .Cases({
"power6",
"pwr6"}, ArchDefinePwr6 | ArchDefinePwr5x |
134 ArchDefinePwr5 | ArchDefinePwr4 |
135 ArchDefinePpcgr | ArchDefinePpcsq)
136 .Cases({
"power6x",
"pwr6x"},
137 ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x |
138 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
140 .Cases({
"power7",
"pwr7"}, ArchDefinePwr7 | ArchDefinePwr6 |
141 ArchDefinePwr5x | ArchDefinePwr5 |
142 ArchDefinePwr4 | ArchDefinePpcgr |
145 .Cases({
"power8",
"pwr8",
"ppc64le"},
146 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
147 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
148 ArchDefinePpcgr | ArchDefinePpcsq)
149 .Cases({
"power9",
"pwr9"},
150 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
151 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
152 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
153 .Cases({
"power10",
"pwr10"},
154 ArchDefinePwr10 | ArchDefinePwr9 | ArchDefinePwr8 |
155 ArchDefinePwr7 | ArchDefinePwr6 | ArchDefinePwr5x |
156 ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr |
158 .Cases({
"power11",
"pwr11"},
159 ArchDefinePwr11 | ArchDefinePwr10 | ArchDefinePwr9 |
160 ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6 |
161 ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4 |
162 ArchDefinePpcgr | ArchDefinePpcsq)
164 ArchDefineFuture | ArchDefinePwr11 | ArchDefinePwr10 |
165 ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
166 ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
167 ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
168 .Cases({
"8548",
"e500"}, ArchDefineE500)
186 const std::vector<std::string> &FeaturesVec)
const override;
198 bool Enabled)
const override;
217 if (FloatABI == SoftFloat)
230 if (FloatABI == SoftFloat)
324 switch (*Constraint) {
328 R = std::string(
"^") + std::string(Constraint, 2);
361 return RegName ==
"r1" || RegName ==
"x1";
371 return Triple.isOSGlibc() ||
379 return Triple.isOSGlibc() ||
383 bool validateCpuSupports(StringRef
Feature)
const override;
384 bool validateCpuIs(StringRef Name)
const override;
391 if (Triple.isOSAIX())
393 else if (Triple.getArch() == llvm::Triple::ppcle)
399 case llvm::Triple::Linux:
400 case llvm::Triple::FreeBSD:
401 case llvm::Triple::NetBSD:
406 case llvm::Triple::AIX:
418 if (Triple.isOSFreeBSD() || Triple.isOSNetBSD() || Triple.isOSOpenBSD() ||
434 return std::make_pair(32, 32);
448 if (Triple.isOSAIX()) {
450 LongDoubleWidth = 64;
451 LongDoubleAlign = DoubleAlign = 32;
452 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
453 }
else if ((Triple.getArch() == llvm::Triple::ppc64le) ||
454 Triple.isPPC64ELFv2ABI()) {
460 if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
461 LongDoubleWidth = LongDoubleAlign = 64;
462 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
486 std::string DataLayout;
489 DataLayout =
"E-m:a-Fi64-i64:64-i128:128-n32:64";
490 }
else if ((
getTriple().getArch() == llvm::Triple::ppc64le)) {
491 DataLayout =
"e-m:e-Fn32-i64:64-i128:128-n32:64";
493 DataLayout =
"E-m:e";
494 if (
ABI ==
"elfv2") {
495 DataLayout +=
"-Fn32";
497 DataLayout +=
"-Fi64";
499 DataLayout +=
"-i64:64-i128:128-n32:64";
503 DataLayout +=
"-S128-v256:256:256-v512:512:512";
508 bool setABI(
const std::string &Name)
override {
509 if (Name ==
"elfv1" || Name ==
"elfv2") {
529 return std::make_pair(128, 128);
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.
TargetInfo(const llvm::Triple &T)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
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;
unsigned HasUnalignedAccess
unsigned char MaxAtomicPromoteWidth
virtual std::string convertConstraint(const char *&Constraint) const
unsigned char MaxAtomicInlineWidth
Options for controlling the target.
AIXTargetInfo(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.
AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
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)
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.
void calculateDataLayout()
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
void addP10SpecificFeatures(llvm::StringMap< bool > &Features) const
static constexpr int MINIMUM_AIX_OS_MAJOR
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features.
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.
void addFutureSpecificFeatures(llvm::StringMap< bool > &Features) const
std::string convertConstraint(const char *&Constraint) const override
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const override
Enable or disable a specific target feature; the feature name must be valid.
static constexpr int MINIMUM_AIX_OS_MINOR
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.
void addP11SpecificFeatures(llvm::StringMap< bool > &Features) const
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.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
CallingConv
CallingConv - Specifies the calling convention that a function uses.
unsigned short SuitableAlign
unsigned char PointerWidth
const llvm::fltSemantics * LongDoubleFormat
unsigned char PointerAlign
unsigned char LongDoubleAlign
unsigned char LongDoubleWidth
unsigned char DoubleAlign