18 using namespace clang;
22 #define BUILTIN(ID, TYPE, ATTRS) \ 23 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 24 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ 25 {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, 26 #include "clang/Basic/BuiltinsPPC.def" 34 for (
const auto &Feature : Features) {
35 if (Feature ==
"+altivec") {
37 }
else if (Feature ==
"+vsx") {
39 }
else if (Feature ==
"+bpermd") {
41 }
else if (Feature ==
"+extdiv") {
43 }
else if (Feature ==
"+power8-vector") {
45 }
else if (Feature ==
"+crypto") {
47 }
else if (Feature ==
"+direct-move") {
49 }
else if (Feature ==
"+qpx") {
51 }
else if (Feature ==
"+htm") {
53 }
else if (Feature ==
"+float128") {
55 }
else if (Feature ==
"+power9-vector") {
57 }
else if (Feature ==
"+spe") {
61 }
else if (Feature ==
"-hard-float") {
89 if (
getTriple().getArch() == llvm::Triple::ppc64le) {
98 if (
ABI ==
"elfv1" ||
ABI ==
"elfv1-qpx")
122 if (
ABI ==
"elfv2" ||
124 Builder.
defineMacro(
"__STRUCT_PARM_ALIGN__",
"16");
126 if (ArchDefs & ArchDefineName)
127 Builder.
defineMacro(Twine(
"_ARCH_", StringRef(CPU).upper()));
128 if (ArchDefs & ArchDefinePpcgr)
130 if (ArchDefs & ArchDefinePpcsq)
132 if (ArchDefs & ArchDefine440)
134 if (ArchDefs & ArchDefine603)
136 if (ArchDefs & ArchDefine604)
138 if (ArchDefs & ArchDefinePwr4)
140 if (ArchDefs & ArchDefinePwr5)
142 if (ArchDefs & ArchDefinePwr5x)
144 if (ArchDefs & ArchDefinePwr6)
146 if (ArchDefs & ArchDefinePwr6x)
148 if (ArchDefs & ArchDefinePwr7)
150 if (ArchDefs & ArchDefinePwr8)
152 if (ArchDefs & ArchDefinePwr9)
154 if (ArchDefs & ArchDefineA2)
156 if (ArchDefs & ArchDefineA2q) {
160 if (ArchDefs & ArchDefineE500)
162 if (ArchDefs & ArchDefineFuture)
165 if (
getTriple().getVendor() == llvm::Triple::BGQ) {
193 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
194 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
195 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
197 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
229 const std::vector<std::string> &FeaturesVec) {
231 if (llvm::find(FeaturesVec,
"-vsx") != FeaturesVec.end()) {
232 if (llvm::find(FeaturesVec,
"+power8-vector") != FeaturesVec.end()) {
233 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mpower8-vector" 238 if (llvm::find(FeaturesVec,
"+direct-move") != FeaturesVec.end()) {
239 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mdirect-move" 244 if (llvm::find(FeaturesVec,
"+float128") != FeaturesVec.end()) {
245 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfloat128" 250 if (llvm::find(FeaturesVec,
"+power9-vector") != FeaturesVec.end()) {
251 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mpower9-vector" 262 const std::vector<std::string> &FeaturesVec)
const {
263 Features[
"altivec"] = llvm::StringSwitch<bool>(CPU)
275 .Case(
"ppc64le",
true)
278 Features[
"qpx"] = (CPU ==
"a2q");
279 Features[
"power9-vector"] = (CPU ==
"pwr9");
280 Features[
"crypto"] = llvm::StringSwitch<bool>(CPU)
281 .Case(
"ppc64le",
true)
285 Features[
"power8-vector"] = llvm::StringSwitch<bool>(CPU)
286 .Case(
"ppc64le",
true)
290 Features[
"bpermd"] = llvm::StringSwitch<bool>(CPU)
291 .Case(
"ppc64le",
true)
296 Features[
"extdiv"] = llvm::StringSwitch<bool>(CPU)
297 .Case(
"ppc64le",
true)
302 Features[
"direct-move"] = llvm::StringSwitch<bool>(CPU)
303 .Case(
"ppc64le",
true)
307 Features[
"vsx"] = llvm::StringSwitch<bool>(CPU)
308 .Case(
"ppc64le",
true)
313 Features[
"htm"] = llvm::StringSwitch<bool>(CPU)
314 .Case(
"ppc64le",
true)
319 Features[
"spe"] = llvm::StringSwitch<bool>(CPU)
326 if (CPU ==
"future") {
334 if (!(ArchDefs & ArchDefinePwr9) && (ArchDefs & ArchDefinePpcgr) &&
335 llvm::find(FeaturesVec,
"+float128") != FeaturesVec.end()) {
337 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfloat128" << CPU;
346 llvm::StringMap<bool> &Features)
const {
351 return llvm::StringSwitch<bool>(Feature)
352 .Case(
"powerpc",
true)
353 .Case(
"altivec", HasAltivec)
355 .Case(
"power8-vector", HasP8Vector)
356 .Case(
"crypto", HasP8Crypto)
357 .Case(
"direct-move", HasDirectMove)
360 .Case(
"bpermd", HasBPERMD)
361 .Case(
"extdiv", HasExtDiv)
363 .Case(
"power9-vector", HasP9Vector)
369 StringRef Name,
bool Enabled)
const {
373 bool FeatureHasVSX = llvm::StringSwitch<bool>(Name)
375 .Case(
"direct-move",
true)
376 .Case(
"power8-vector",
true)
377 .Case(
"power9-vector",
true)
378 .Case(
"float128",
true)
381 Features[
"vsx"] = Features[
"altivec"] =
true;
382 if (Name ==
"power9-vector")
383 Features[
"power8-vector"] =
true;
384 Features[Name] =
true;
388 if ((Name ==
"altivec") || (Name ==
"vsx"))
389 Features[
"vsx"] = Features[
"direct-move"] = Features[
"power8-vector"] =
390 Features[
"float128"] = Features[
"power9-vector"] =
false;
391 if (Name ==
"power8-vector")
392 Features[
"power9-vector"] =
false;
393 Features[Name] =
false;
397 const char *
const PPCTargetInfo::GCCRegNames[] = {
398 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
"r8",
399 "r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
"r16",
"r17",
400 "r18",
"r19",
"r20",
"r21",
"r22",
"r23",
"r24",
"r25",
"r26",
401 "r27",
"r28",
"r29",
"r30",
"r31",
"f0",
"f1",
"f2",
"f3",
402 "f4",
"f5",
"f6",
"f7",
"f8",
"f9",
"f10",
"f11",
"f12",
403 "f13",
"f14",
"f15",
"f16",
"f17",
"f18",
"f19",
"f20",
"f21",
404 "f22",
"f23",
"f24",
"f25",
"f26",
"f27",
"f28",
"f29",
"f30",
405 "f31",
"mq",
"lr",
"ctr",
"ap",
"cr0",
"cr1",
"cr2",
"cr3",
406 "cr4",
"cr5",
"cr6",
"cr7",
"xer",
"v0",
"v1",
"v2",
"v3",
407 "v4",
"v5",
"v6",
"v7",
"v8",
"v9",
"v10",
"v11",
"v12",
408 "v13",
"v14",
"v15",
"v16",
"v17",
"v18",
"v19",
"v20",
"v21",
409 "v22",
"v23",
"v24",
"v25",
"v26",
"v27",
"v28",
"v29",
"v30",
410 "v31",
"vrsave",
"vscr",
"spe_acc",
"spefscr",
"sfp" 414 return llvm::makeArrayRef(GCCRegNames);
420 {{
"0"},
"r0"}, {{
"1"},
"r1"}, {{
"2"},
"r2"}, {{
"3"},
"r3"},
421 {{
"4"},
"r4"}, {{
"5"},
"r5"}, {{
"6"},
"r6"}, {{
"7"},
"r7"},
422 {{
"8"},
"r8"}, {{
"9"},
"r9"}, {{
"10"},
"r10"}, {{
"11"},
"r11"},
423 {{
"12"},
"r12"}, {{
"13"},
"r13"}, {{
"14"},
"r14"}, {{
"15"},
"r15"},
424 {{
"16"},
"r16"}, {{
"17"},
"r17"}, {{
"18"},
"r18"}, {{
"19"},
"r19"},
425 {{
"20"},
"r20"}, {{
"21"},
"r21"}, {{
"22"},
"r22"}, {{
"23"},
"r23"},
426 {{
"24"},
"r24"}, {{
"25"},
"r25"}, {{
"26"},
"r26"}, {{
"27"},
"r27"},
427 {{
"28"},
"r28"}, {{
"29"},
"r29"}, {{
"30"},
"r30"}, {{
"31"},
"r31"},
428 {{
"fr0"},
"f0"}, {{
"fr1"},
"f1"}, {{
"fr2"},
"f2"}, {{
"fr3"},
"f3"},
429 {{
"fr4"},
"f4"}, {{
"fr5"},
"f5"}, {{
"fr6"},
"f6"}, {{
"fr7"},
"f7"},
430 {{
"fr8"},
"f8"}, {{
"fr9"},
"f9"}, {{
"fr10"},
"f10"}, {{
"fr11"},
"f11"},
431 {{
"fr12"},
"f12"}, {{
"fr13"},
"f13"}, {{
"fr14"},
"f14"}, {{
"fr15"},
"f15"},
432 {{
"fr16"},
"f16"}, {{
"fr17"},
"f17"}, {{
"fr18"},
"f18"}, {{
"fr19"},
"f19"},
433 {{
"fr20"},
"f20"}, {{
"fr21"},
"f21"}, {{
"fr22"},
"f22"}, {{
"fr23"},
"f23"},
434 {{
"fr24"},
"f24"}, {{
"fr25"},
"f25"}, {{
"fr26"},
"f26"}, {{
"fr27"},
"f27"},
435 {{
"fr28"},
"f28"}, {{
"fr29"},
"f29"}, {{
"fr30"},
"f30"}, {{
"fr31"},
"f31"},
440 return llvm::makeArrayRef(GCCRegAliases);
448 {{
"vs0"}, 32}, {{
"vs1"}, 33}, {{
"vs2"}, 34}, {{
"vs3"}, 35},
449 {{
"vs4"}, 36}, {{
"vs5"}, 37}, {{
"vs6"}, 38}, {{
"vs7"}, 39},
450 {{
"vs8"}, 40}, {{
"vs9"}, 41}, {{
"vs10"}, 42}, {{
"vs11"}, 43},
451 {{
"vs12"}, 44}, {{
"vs13"}, 45}, {{
"vs14"}, 46}, {{
"vs15"}, 47},
452 {{
"vs16"}, 48}, {{
"vs17"}, 49}, {{
"vs18"}, 50}, {{
"vs19"}, 51},
453 {{
"vs20"}, 52}, {{
"vs21"}, 53}, {{
"vs22"}, 54}, {{
"vs23"}, 55},
454 {{
"vs24"}, 56}, {{
"vs25"}, 57}, {{
"vs26"}, 58}, {{
"vs27"}, 59},
455 {{
"vs28"}, 60}, {{
"vs29"}, 61}, {{
"vs30"}, 62}, {{
"vs31"}, 63},
456 {{
"vs32"}, 77}, {{
"vs33"}, 78}, {{
"vs34"}, 79}, {{
"vs35"}, 80},
457 {{
"vs36"}, 81}, {{
"vs37"}, 82}, {{
"vs38"}, 83}, {{
"vs39"}, 84},
458 {{
"vs40"}, 85}, {{
"vs41"}, 86}, {{
"vs42"}, 87}, {{
"vs43"}, 88},
459 {{
"vs44"}, 89}, {{
"vs45"}, 90}, {{
"vs46"}, 91}, {{
"vs47"}, 92},
460 {{
"vs48"}, 93}, {{
"vs49"}, 94}, {{
"vs50"}, 95}, {{
"vs51"}, 96},
461 {{
"vs52"}, 97}, {{
"vs53"}, 98}, {{
"vs54"}, 99}, {{
"vs55"}, 100},
462 {{
"vs56"}, 101}, {{
"vs57"}, 102}, {{
"vs58"}, 103}, {{
"vs59"}, 104},
463 {{
"vs60"}, 105}, {{
"vs61"}, 106}, {{
"vs62"}, 107}, {{
"vs63"}, 108},
468 return llvm::makeArrayRef(GCCAddlRegNames);
474 {
"generic"}, {
"440"}, {
"450"}, {
"601"}, {
"602"},
475 {
"603"}, {
"603e"}, {
"603ev"}, {
"604"}, {
"604e"},
476 {
"620"}, {
"630"}, {
"g3"}, {
"7400"}, {
"g4"},
477 {
"7450"}, {
"g4+"}, {
"750"}, {
"8548"}, {
"970"},
478 {
"g5"}, {
"a2"}, {
"a2q"}, {
"e500"}, {
"e500mc"},
479 {
"e5500"}, {
"power3"}, {
"pwr3"}, {
"power4"}, {
"pwr4"},
480 {
"power5"}, {
"pwr5"}, {
"power5x"}, {
"pwr5x"}, {
"power6"},
481 {
"pwr6"}, {
"power6x"}, {
"pwr6x"}, {
"power7"}, {
"pwr7"},
482 {
"power8"}, {
"pwr8"}, {
"power9"}, {
"pwr9"}, {
"powerpc"},
483 {
"ppc"}, {
"powerpc64"}, {
"ppc64"}, {
"powerpc64le"}, {
"ppc64le"},
501 ? &llvm::APFloat::IEEEquad()
502 : &llvm::APFloat::PPCDoubleDouble();
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Defines the clang::MacroBuilder utility class.
virtual void adjust(LangOptions &Opts)
Set forced language options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
ArrayRef< TargetInfo::AddlRegName > getGCCAddlRegNames() const override
unsigned char LongDoubleAlign
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.
Defines the Diagnostic-related interfaces.
void addFutureSpecificFeatures(llvm::StringMap< bool > &Features) const
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
ArrayRef< const char * > getGCCRegNames() const override
const llvm::fltSemantics * LongDoubleFormat
Enumerates target-specific builtins in their own namespaces within namespace clang.
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
unsigned char LongDoubleWidth
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features...
unsigned char PointerWidth
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Dataflow Directional Tag Classes.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific #defines that are not tied to ...
void adjust(LangOptions &Opts) override
Set forced language options.
static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, const std::vector< std::string > &FeaturesVec)
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
const TargetInfo::AddlRegName GCCAddlRegNames[]
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...
static constexpr llvm::StringLiteral ValidCPUNames[]