18 #include "llvm/ADT/StringSwitch.h" 20 using namespace clang;
24 #define BUILTIN(ID, TYPE, ATTRS) \ 25 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 26 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ 27 {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, 28 #include "clang/Basic/BuiltinsPPC.def" 35 for (
const auto &Feature : Features) {
36 if (Feature ==
"+altivec") {
38 }
else if (Feature ==
"+vsx") {
40 }
else if (Feature ==
"+bpermd") {
42 }
else if (Feature ==
"+extdiv") {
44 }
else if (Feature ==
"+power8-vector") {
46 }
else if (Feature ==
"+crypto") {
48 }
else if (Feature ==
"+direct-move") {
50 }
else if (Feature ==
"+qpx") {
52 }
else if (Feature ==
"+htm") {
54 }
else if (Feature ==
"+float128") {
56 }
else if (Feature ==
"+power9-vector") {
84 if (
getTriple().getArch() == llvm::Triple::ppc64le) {
87 if (
getTriple().getOS() != llvm::Triple::NetBSD &&
88 getTriple().getOS() != llvm::Triple::OpenBSD)
93 if (
ABI ==
"elfv1" ||
ABI ==
"elfv1-qpx")
115 if (
ABI ==
"elfv2" ||
117 Builder.
defineMacro(
"__STRUCT_PARM_ALIGN__",
"16");
194 Builder.
defineMacro(Twine(
"_ARCH_", StringRef(CPU).upper()));
228 if (
getTriple().getVendor() == llvm::Triple::BGQ) {
252 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
253 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
254 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
256 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
289 const std::vector<std::string> &FeaturesVec) {
291 if (std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-vsx") !=
293 if (std::find(FeaturesVec.begin(), FeaturesVec.end(),
"+power8-vector") !=
295 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mpower8-vector" 300 if (std::find(FeaturesVec.begin(), FeaturesVec.end(),
"+direct-move") !=
302 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mdirect-move" 307 if (std::find(FeaturesVec.begin(), FeaturesVec.end(),
"+float128") !=
309 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mfloat128" 314 if (std::find(FeaturesVec.begin(), FeaturesVec.end(),
"+power9-vector") !=
316 Diags.
Report(diag::err_opt_not_valid_with_opt) <<
"-mpower9-vector" 327 const std::vector<std::string> &FeaturesVec)
const {
328 Features[
"altivec"] = llvm::StringSwitch<bool>(CPU)
340 .Case(
"ppc64le",
true)
343 Features[
"qpx"] = (CPU ==
"a2q");
344 Features[
"power9-vector"] = (CPU ==
"pwr9");
345 Features[
"crypto"] = llvm::StringSwitch<bool>(CPU)
346 .Case(
"ppc64le",
true)
350 Features[
"power8-vector"] = llvm::StringSwitch<bool>(CPU)
351 .Case(
"ppc64le",
true)
355 Features[
"bpermd"] = llvm::StringSwitch<bool>(CPU)
356 .Case(
"ppc64le",
true)
361 Features[
"extdiv"] = llvm::StringSwitch<bool>(CPU)
362 .Case(
"ppc64le",
true)
367 Features[
"direct-move"] = llvm::StringSwitch<bool>(CPU)
368 .Case(
"ppc64le",
true)
372 Features[
"vsx"] = llvm::StringSwitch<bool>(CPU)
373 .Case(
"ppc64le",
true)
378 Features[
"htm"] = llvm::StringSwitch<bool>(CPU)
379 .Case(
"ppc64le",
true)
391 return llvm::StringSwitch<bool>(Feature)
392 .Case(
"powerpc",
true)
393 .Case(
"altivec", HasAltivec)
395 .Case(
"power8-vector", HasP8Vector)
396 .Case(
"crypto", HasP8Crypto)
397 .Case(
"direct-move", HasDirectMove)
400 .Case(
"bpermd", HasBPERMD)
401 .Case(
"extdiv", HasExtDiv)
403 .Case(
"power9-vector", HasP9Vector)
408 StringRef Name,
bool Enabled)
const {
412 bool FeatureHasVSX = llvm::StringSwitch<bool>(Name)
414 .Case(
"direct-move",
true)
415 .Case(
"power8-vector",
true)
416 .Case(
"power9-vector",
true)
417 .Case(
"float128",
true)
420 Features[
"vsx"] = Features[
"altivec"] =
true;
421 if (Name ==
"power9-vector")
422 Features[
"power8-vector"] =
true;
423 Features[Name] =
true;
427 if ((Name ==
"altivec") || (Name ==
"vsx"))
428 Features[
"vsx"] = Features[
"direct-move"] = Features[
"power8-vector"] =
429 Features[
"float128"] = Features[
"power9-vector"] =
false;
430 if (Name ==
"power8-vector")
431 Features[
"power9-vector"] =
false;
432 Features[Name] =
false;
436 const char *
const PPCTargetInfo::GCCRegNames[] = {
437 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
"r8",
438 "r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
"r16",
"r17",
439 "r18",
"r19",
"r20",
"r21",
"r22",
"r23",
"r24",
"r25",
"r26",
440 "r27",
"r28",
"r29",
"r30",
"r31",
"f0",
"f1",
"f2",
"f3",
441 "f4",
"f5",
"f6",
"f7",
"f8",
"f9",
"f10",
"f11",
"f12",
442 "f13",
"f14",
"f15",
"f16",
"f17",
"f18",
"f19",
"f20",
"f21",
443 "f22",
"f23",
"f24",
"f25",
"f26",
"f27",
"f28",
"f29",
"f30",
444 "f31",
"mq",
"lr",
"ctr",
"ap",
"cr0",
"cr1",
"cr2",
"cr3",
445 "cr4",
"cr5",
"cr6",
"cr7",
"xer",
"v0",
"v1",
"v2",
"v3",
446 "v4",
"v5",
"v6",
"v7",
"v8",
"v9",
"v10",
"v11",
"v12",
447 "v13",
"v14",
"v15",
"v16",
"v17",
"v18",
"v19",
"v20",
"v21",
448 "v22",
"v23",
"v24",
"v25",
"v26",
"v27",
"v28",
"v29",
"v30",
449 "v31",
"vrsave",
"vscr",
"spe_acc",
"spefscr",
"sfp" 453 return llvm::makeArrayRef(GCCRegNames);
459 {{
"0"},
"r0"}, {{
"1"},
"r1"}, {{
"2"},
"r2"}, {{
"3"},
"r3"},
460 {{
"4"},
"r4"}, {{
"5"},
"r5"}, {{
"6"},
"r6"}, {{
"7"},
"r7"},
461 {{
"8"},
"r8"}, {{
"9"},
"r9"}, {{
"10"},
"r10"}, {{
"11"},
"r11"},
462 {{
"12"},
"r12"}, {{
"13"},
"r13"}, {{
"14"},
"r14"}, {{
"15"},
"r15"},
463 {{
"16"},
"r16"}, {{
"17"},
"r17"}, {{
"18"},
"r18"}, {{
"19"},
"r19"},
464 {{
"20"},
"r20"}, {{
"21"},
"r21"}, {{
"22"},
"r22"}, {{
"23"},
"r23"},
465 {{
"24"},
"r24"}, {{
"25"},
"r25"}, {{
"26"},
"r26"}, {{
"27"},
"r27"},
466 {{
"28"},
"r28"}, {{
"29"},
"r29"}, {{
"30"},
"r30"}, {{
"31"},
"r31"},
467 {{
"fr0"},
"f0"}, {{
"fr1"},
"f1"}, {{
"fr2"},
"f2"}, {{
"fr3"},
"f3"},
468 {{
"fr4"},
"f4"}, {{
"fr5"},
"f5"}, {{
"fr6"},
"f6"}, {{
"fr7"},
"f7"},
469 {{
"fr8"},
"f8"}, {{
"fr9"},
"f9"}, {{
"fr10"},
"f10"}, {{
"fr11"},
"f11"},
470 {{
"fr12"},
"f12"}, {{
"fr13"},
"f13"}, {{
"fr14"},
"f14"}, {{
"fr15"},
"f15"},
471 {{
"fr16"},
"f16"}, {{
"fr17"},
"f17"}, {{
"fr18"},
"f18"}, {{
"fr19"},
"f19"},
472 {{
"fr20"},
"f20"}, {{
"fr21"},
"f21"}, {{
"fr22"},
"f22"}, {{
"fr23"},
"f23"},
473 {{
"fr24"},
"f24"}, {{
"fr25"},
"f25"}, {{
"fr26"},
"f26"}, {{
"fr27"},
"f27"},
474 {{
"fr28"},
"f28"}, {{
"fr29"},
"f29"}, {{
"fr30"},
"f30"}, {{
"fr31"},
"f31"},
479 return llvm::makeArrayRef(GCCRegAliases);
483 return llvm::StringSwitch<bool>(Name)
484 .Case(
"generic",
true)
506 .Case(
"e500mc",
true)
508 .Case(
"power3",
true)
510 .Case(
"power4",
true)
512 .Case(
"power5",
true)
514 .Case(
"power5x",
true)
516 .Case(
"power6",
true)
518 .Case(
"power6x",
true)
520 .Case(
"power7",
true)
522 .Case(
"power8",
true)
524 .Case(
"power9",
true)
526 .Case(
"powerpc",
true)
528 .Case(
"powerpc64",
true)
530 .Case(
"powerpc64le",
true)
531 .Case(
"ppc64le",
true)
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.
unsigned char LongDoubleWidth
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned char PointerWidth
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
ArchDefineTypes
Flags for architecture specific defines.
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
Enumerates target-specific builtins in their own namespaces within namespace clang.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features...
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".
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 ...