PPC.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. //===--- PPC.cpp - Implement PPC target feature support -------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements PPC TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "PPC.h"
  13. #include "clang/Basic/Diagnostic.h"
  14. #include "clang/Basic/MacroBuilder.h"
  15. #include "clang/Basic/TargetBuiltins.h"
  16. using namespace clang;
  17. using namespace clang::targets;
  18. const Builtin::Info PPCTargetInfo::BuiltinInfo[] = {
  19. #define BUILTIN(ID, TYPE, ATTRS) \
  20. {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
  21. #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
  22. {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
  23. #include "clang/Basic/BuiltinsPPC.def"
  24. };
  25. /// handleTargetFeatures - Perform initialization based on the user
  26. /// configured set of features.
  27. bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
  28. DiagnosticsEngine &Diags) {
  29. FloatABI = HardFloat;
  30. for (const auto &Feature : Features) {
  31. if (Feature == "+altivec") {
  32. HasAltivec = true;
  33. } else if (Feature == "+vsx") {
  34. HasVSX = true;
  35. } else if (Feature == "+bpermd") {
  36. HasBPERMD = true;
  37. } else if (Feature == "+extdiv") {
  38. HasExtDiv = true;
  39. } else if (Feature == "+power8-vector") {
  40. HasP8Vector = true;
  41. } else if (Feature == "+crypto") {
  42. HasP8Crypto = true;
  43. } else if (Feature == "+direct-move") {
  44. HasDirectMove = true;
  45. } else if (Feature == "+qpx") {
  46. HasQPX = true;
  47. } else if (Feature == "+htm") {
  48. HasHTM = true;
  49. } else if (Feature == "+float128") {
  50. HasFloat128 = true;
  51. } else if (Feature == "+power9-vector") {
  52. HasP9Vector = true;
  53. } else if (Feature == "+spe") {
  54. HasSPE = true;
  55. LongDoubleWidth = LongDoubleAlign = 64;
  56. LongDoubleFormat = &llvm::APFloat::IEEEdouble();
  57. } else if (Feature == "-hard-float") {
  58. FloatABI = SoftFloat;
  59. }
  60. // TODO: Finish this list and add an assert that we've handled them
  61. // all.
  62. }
  63. return true;
  64. }
  65. /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific
  66. /// #defines that are not tied to a specific subtarget.
  67. void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
  68. MacroBuilder &Builder) const {
  69. // Target identification.
  70. Builder.defineMacro("__ppc__");
  71. Builder.defineMacro("__PPC__");
  72. Builder.defineMacro("_ARCH_PPC");
  73. Builder.defineMacro("__powerpc__");
  74. Builder.defineMacro("__POWERPC__");
  75. if (PointerWidth == 64) {
  76. Builder.defineMacro("_ARCH_PPC64");
  77. Builder.defineMacro("__powerpc64__");
  78. Builder.defineMacro("__ppc64__");
  79. Builder.defineMacro("__PPC64__");
  80. }
  81. // Target properties.
  82. if (getTriple().getArch() == llvm::Triple::ppc64le) {
  83. Builder.defineMacro("_LITTLE_ENDIAN");
  84. } else {
  85. if (!getTriple().isOSNetBSD() &&
  86. !getTriple().isOSOpenBSD())
  87. Builder.defineMacro("_BIG_ENDIAN");
  88. }
  89. // ABI options.
  90. if (ABI == "elfv1" || ABI == "elfv1-qpx")
  91. Builder.defineMacro("_CALL_ELF", "1");
  92. if (ABI == "elfv2")
  93. Builder.defineMacro("_CALL_ELF", "2");
  94. // This typically is only for a new enough linker (bfd >= 2.16.2 or gold), but
  95. // our support post-dates this and it should work on all 64-bit ppc linux
  96. // platforms. It is guaranteed to work on all elfv2 platforms.
  97. if (getTriple().getOS() == llvm::Triple::Linux && PointerWidth == 64)
  98. Builder.defineMacro("_CALL_LINUX", "1");
  99. // Subtarget options.
  100. if (!getTriple().isOSAIX()){
  101. Builder.defineMacro("__NATURAL_ALIGNMENT__");
  102. }
  103. Builder.defineMacro("__REGISTER_PREFIX__", "");
  104. // FIXME: Should be controlled by command line option.
  105. if (LongDoubleWidth == 128) {
  106. Builder.defineMacro("__LONG_DOUBLE_128__");
  107. Builder.defineMacro("__LONGDOUBLE128");
  108. }
  109. // Define this for elfv2 (64-bit only) or 64-bit darwin.
  110. if (ABI == "elfv2" ||
  111. (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))
  112. Builder.defineMacro("__STRUCT_PARM_ALIGN__", "16");
  113. if (ArchDefs & ArchDefineName)
  114. Builder.defineMacro(Twine("_ARCH_", StringRef(CPU).upper()));
  115. if (ArchDefs & ArchDefinePpcgr)
  116. Builder.defineMacro("_ARCH_PPCGR");
  117. if (ArchDefs & ArchDefinePpcsq)
  118. Builder.defineMacro("_ARCH_PPCSQ");
  119. if (ArchDefs & ArchDefine440)
  120. Builder.defineMacro("_ARCH_440");
  121. if (ArchDefs & ArchDefine603)
  122. Builder.defineMacro("_ARCH_603");
  123. if (ArchDefs & ArchDefine604)
  124. Builder.defineMacro("_ARCH_604");
  125. if (ArchDefs & ArchDefinePwr4)
  126. Builder.defineMacro("_ARCH_PWR4");
  127. if (ArchDefs & ArchDefinePwr5)
  128. Builder.defineMacro("_ARCH_PWR5");
  129. if (ArchDefs & ArchDefinePwr5x)
  130. Builder.defineMacro("_ARCH_PWR5X");
  131. if (ArchDefs & ArchDefinePwr6)
  132. Builder.defineMacro("_ARCH_PWR6");
  133. if (ArchDefs & ArchDefinePwr6x)
  134. Builder.defineMacro("_ARCH_PWR6X");
  135. if (ArchDefs & ArchDefinePwr7)
  136. Builder.defineMacro("_ARCH_PWR7");
  137. if (ArchDefs & ArchDefinePwr8)
  138. Builder.defineMacro("_ARCH_PWR8");
  139. if (ArchDefs & ArchDefinePwr9)
  140. Builder.defineMacro("_ARCH_PWR9");
  141. if (ArchDefs & ArchDefineA2)
  142. Builder.defineMacro("_ARCH_A2");
  143. if (ArchDefs & ArchDefineA2q) {
  144. Builder.defineMacro("_ARCH_A2Q");
  145. Builder.defineMacro("_ARCH_QP");
  146. }
  147. if (getTriple().getVendor() == llvm::Triple::BGQ) {
  148. Builder.defineMacro("__bg__");
  149. Builder.defineMacro("__THW_BLUEGENE__");
  150. Builder.defineMacro("__bgq__");
  151. Builder.defineMacro("__TOS_BGQ__");
  152. }
  153. if (HasAltivec) {
  154. Builder.defineMacro("__VEC__", "10206");
  155. Builder.defineMacro("__ALTIVEC__");
  156. }
  157. if (HasSPE) {
  158. Builder.defineMacro("__SPE__");
  159. Builder.defineMacro("__NO_FPRS__");
  160. }
  161. if (HasVSX)
  162. Builder.defineMacro("__VSX__");
  163. if (HasP8Vector)
  164. Builder.defineMacro("__POWER8_VECTOR__");
  165. if (HasP8Crypto)
  166. Builder.defineMacro("__CRYPTO__");
  167. if (HasHTM)
  168. Builder.defineMacro("__HTM__");
  169. if (HasFloat128)
  170. Builder.defineMacro("__FLOAT128__");
  171. if (HasP9Vector)
  172. Builder.defineMacro("__POWER9_VECTOR__");
  173. Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
  174. Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
  175. Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
  176. if (PointerWidth == 64)
  177. Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
  178. // We have support for the bswap intrinsics so we can define this.
  179. Builder.defineMacro("__HAVE_BSWAP__", "1");
  180. // FIXME: The following are not yet generated here by Clang, but are
  181. // generated by GCC:
  182. //
  183. // _SOFT_FLOAT_
  184. // __RECIP_PRECISION__
  185. // __APPLE_ALTIVEC__
  186. // __RECIP__
  187. // __RECIPF__
  188. // __RSQRTE__
  189. // __RSQRTEF__
  190. // _SOFT_DOUBLE_
  191. // __NO_LWSYNC__
  192. // __CMODEL_MEDIUM__
  193. // __CMODEL_LARGE__
  194. // _CALL_SYSV
  195. // _CALL_DARWIN
  196. }
  197. // Handle explicit options being passed to the compiler here: if we've
  198. // explicitly turned off vsx and turned on any of:
  199. // - power8-vector
  200. // - direct-move
  201. // - float128
  202. // - power9-vector
  203. // then go ahead and error since the customer has expressed an incompatible
  204. // set of options.
  205. static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
  206. const std::vector<std::string> &FeaturesVec) {
  207. if (llvm::find(FeaturesVec, "-vsx") != FeaturesVec.end()) {
  208. if (llvm::find(FeaturesVec, "+power8-vector") != FeaturesVec.end()) {
  209. Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
  210. << "-mno-vsx";
  211. return false;
  212. }
  213. if (llvm::find(FeaturesVec, "+direct-move") != FeaturesVec.end()) {
  214. Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
  215. << "-mno-vsx";
  216. return false;
  217. }
  218. if (llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) {
  219. Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128"
  220. << "-mno-vsx";
  221. return false;
  222. }
  223. if (llvm::find(FeaturesVec, "+power9-vector") != FeaturesVec.end()) {
  224. Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower9-vector"
  225. << "-mno-vsx";
  226. return false;
  227. }
  228. }
  229. return true;
  230. }
  231. bool PPCTargetInfo::initFeatureMap(
  232. llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
  233. const std::vector<std::string> &FeaturesVec) const {
  234. Features["altivec"] = llvm::StringSwitch<bool>(CPU)
  235. .Case("7400", true)
  236. .Case("g4", true)
  237. .Case("7450", true)
  238. .Case("g4+", true)
  239. .Case("970", true)
  240. .Case("g5", true)
  241. .Case("pwr6", true)
  242. .Case("pwr7", true)
  243. .Case("pwr8", true)
  244. .Case("pwr9", true)
  245. .Case("ppc64", true)
  246. .Case("ppc64le", true)
  247. .Default(false);
  248. Features["qpx"] = (CPU == "a2q");
  249. Features["power9-vector"] = (CPU == "pwr9");
  250. Features["crypto"] = llvm::StringSwitch<bool>(CPU)
  251. .Case("ppc64le", true)
  252. .Case("pwr9", true)
  253. .Case("pwr8", true)
  254. .Default(false);
  255. Features["power8-vector"] = llvm::StringSwitch<bool>(CPU)
  256. .Case("ppc64le", true)
  257. .Case("pwr9", true)
  258. .Case("pwr8", true)
  259. .Default(false);
  260. Features["bpermd"] = llvm::StringSwitch<bool>(CPU)
  261. .Case("ppc64le", true)
  262. .Case("pwr9", true)
  263. .Case("pwr8", true)
  264. .Case("pwr7", true)
  265. .Default(false);
  266. Features["extdiv"] = llvm::StringSwitch<bool>(CPU)
  267. .Case("ppc64le", true)
  268. .Case("pwr9", true)
  269. .Case("pwr8", true)
  270. .Case("pwr7", true)
  271. .Default(false);
  272. Features["direct-move"] = llvm::StringSwitch<bool>(CPU)
  273. .Case("ppc64le", true)
  274. .Case("pwr9", true)
  275. .Case("pwr8", true)
  276. .Default(false);
  277. Features["vsx"] = llvm::StringSwitch<bool>(CPU)
  278. .Case("ppc64le", true)
  279. .Case("pwr9", true)
  280. .Case("pwr8", true)
  281. .Case("pwr7", true)
  282. .Default(false);
  283. Features["htm"] = llvm::StringSwitch<bool>(CPU)
  284. .Case("ppc64le", true)
  285. .Case("pwr9", true)
  286. .Case("pwr8", true)
  287. .Default(false);
  288. if (!ppcUserFeaturesCheck(Diags, FeaturesVec))
  289. return false;
  290. if (!(ArchDefs & ArchDefinePwr9) && (ArchDefs & ArchDefinePpcgr) &&
  291. llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) {
  292. // We have __float128 on PPC but not power 9 and above.
  293. Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" << CPU;
  294. return false;
  295. }
  296. return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
  297. }
  298. bool PPCTargetInfo::hasFeature(StringRef Feature) const {
  299. return llvm::StringSwitch<bool>(Feature)
  300. .Case("powerpc", true)
  301. .Case("altivec", HasAltivec)
  302. .Case("vsx", HasVSX)
  303. .Case("power8-vector", HasP8Vector)
  304. .Case("crypto", HasP8Crypto)
  305. .Case("direct-move", HasDirectMove)
  306. .Case("qpx", HasQPX)
  307. .Case("htm", HasHTM)
  308. .Case("bpermd", HasBPERMD)
  309. .Case("extdiv", HasExtDiv)
  310. .Case("float128", HasFloat128)
  311. .Case("power9-vector", HasP9Vector)
  312. .Case("spe", HasSPE)
  313. .Default(false);
  314. }
  315. void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
  316. StringRef Name, bool Enabled) const {
  317. if (Enabled) {
  318. // If we're enabling any of the vsx based features then enable vsx and
  319. // altivec. We'll diagnose any problems later.
  320. bool FeatureHasVSX = llvm::StringSwitch<bool>(Name)
  321. .Case("vsx", true)
  322. .Case("direct-move", true)
  323. .Case("power8-vector", true)
  324. .Case("power9-vector", true)
  325. .Case("float128", true)
  326. .Default(false);
  327. if (FeatureHasVSX)
  328. Features["vsx"] = Features["altivec"] = true;
  329. if (Name == "power9-vector")
  330. Features["power8-vector"] = true;
  331. Features[Name] = true;
  332. } else {
  333. // If we're disabling altivec or vsx go ahead and disable all of the vsx
  334. // features.
  335. if ((Name == "altivec") || (Name == "vsx"))
  336. Features["vsx"] = Features["direct-move"] = Features["power8-vector"] =
  337. Features["float128"] = Features["power9-vector"] = false;
  338. if (Name == "power8-vector")
  339. Features["power9-vector"] = false;
  340. Features[Name] = false;
  341. }
  342. }
  343. const char *const PPCTargetInfo::GCCRegNames[] = {
  344. "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",
  345. "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
  346. "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
  347. "r27", "r28", "r29", "r30", "r31", "f0", "f1", "f2", "f3",
  348. "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12",
  349. "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21",
  350. "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30",
  351. "f31", "mq", "lr", "ctr", "ap", "cr0", "cr1", "cr2", "cr3",
  352. "cr4", "cr5", "cr6", "cr7", "xer", "v0", "v1", "v2", "v3",
  353. "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12",
  354. "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21",
  355. "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30",
  356. "v31", "vrsave", "vscr", "spe_acc", "spefscr", "sfp"
  357. };
  358. ArrayRef<const char *> PPCTargetInfo::getGCCRegNames() const {
  359. return llvm::makeArrayRef(GCCRegNames);
  360. }
  361. const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = {
  362. // While some of these aliases do map to different registers
  363. // they still share the same register name.
  364. {{"0"}, "r0"}, {{"1"}, "r1"}, {{"2"}, "r2"}, {{"3"}, "r3"},
  365. {{"4"}, "r4"}, {{"5"}, "r5"}, {{"6"}, "r6"}, {{"7"}, "r7"},
  366. {{"8"}, "r8"}, {{"9"}, "r9"}, {{"10"}, "r10"}, {{"11"}, "r11"},
  367. {{"12"}, "r12"}, {{"13"}, "r13"}, {{"14"}, "r14"}, {{"15"}, "r15"},
  368. {{"16"}, "r16"}, {{"17"}, "r17"}, {{"18"}, "r18"}, {{"19"}, "r19"},
  369. {{"20"}, "r20"}, {{"21"}, "r21"}, {{"22"}, "r22"}, {{"23"}, "r23"},
  370. {{"24"}, "r24"}, {{"25"}, "r25"}, {{"26"}, "r26"}, {{"27"}, "r27"},
  371. {{"28"}, "r28"}, {{"29"}, "r29"}, {{"30"}, "r30"}, {{"31"}, "r31"},
  372. {{"fr0"}, "f0"}, {{"fr1"}, "f1"}, {{"fr2"}, "f2"}, {{"fr3"}, "f3"},
  373. {{"fr4"}, "f4"}, {{"fr5"}, "f5"}, {{"fr6"}, "f6"}, {{"fr7"}, "f7"},
  374. {{"fr8"}, "f8"}, {{"fr9"}, "f9"}, {{"fr10"}, "f10"}, {{"fr11"}, "f11"},
  375. {{"fr12"}, "f12"}, {{"fr13"}, "f13"}, {{"fr14"}, "f14"}, {{"fr15"}, "f15"},
  376. {{"fr16"}, "f16"}, {{"fr17"}, "f17"}, {{"fr18"}, "f18"}, {{"fr19"}, "f19"},
  377. {{"fr20"}, "f20"}, {{"fr21"}, "f21"}, {{"fr22"}, "f22"}, {{"fr23"}, "f23"},
  378. {{"fr24"}, "f24"}, {{"fr25"}, "f25"}, {{"fr26"}, "f26"}, {{"fr27"}, "f27"},
  379. {{"fr28"}, "f28"}, {{"fr29"}, "f29"}, {{"fr30"}, "f30"}, {{"fr31"}, "f31"},
  380. {{"cc"}, "cr0"},
  381. };
  382. ArrayRef<TargetInfo::GCCRegAlias> PPCTargetInfo::getGCCRegAliases() const {
  383. return llvm::makeArrayRef(GCCRegAliases);
  384. }
  385. // PPC ELFABIv2 DWARF Definitoin "Table 2.26. Mappings of Common Registers".
  386. // vs0 ~ vs31 is mapping to 32 - 63,
  387. // vs32 ~ vs63 is mapping to 77 - 108.
  388. const TargetInfo::AddlRegName GCCAddlRegNames[] = {
  389. // Table of additional register names to use in user input.
  390. {{"vs0"}, 32}, {{"vs1"}, 33}, {{"vs2"}, 34}, {{"vs3"}, 35},
  391. {{"vs4"}, 36}, {{"vs5"}, 37}, {{"vs6"}, 38}, {{"vs7"}, 39},
  392. {{"vs8"}, 40}, {{"vs9"}, 41}, {{"vs10"}, 42}, {{"vs11"}, 43},
  393. {{"vs12"}, 44}, {{"vs13"}, 45}, {{"vs14"}, 46}, {{"vs15"}, 47},
  394. {{"vs16"}, 48}, {{"vs17"}, 49}, {{"vs18"}, 50}, {{"vs19"}, 51},
  395. {{"vs20"}, 52}, {{"vs21"}, 53}, {{"vs22"}, 54}, {{"vs23"}, 55},
  396. {{"vs24"}, 56}, {{"vs25"}, 57}, {{"vs26"}, 58}, {{"vs27"}, 59},
  397. {{"vs28"}, 60}, {{"vs29"}, 61}, {{"vs30"}, 62}, {{"vs31"}, 63},
  398. {{"vs32"}, 77}, {{"vs33"}, 78}, {{"vs34"}, 79}, {{"vs35"}, 80},
  399. {{"vs36"}, 81}, {{"vs37"}, 82}, {{"vs38"}, 83}, {{"vs39"}, 84},
  400. {{"vs40"}, 85}, {{"vs41"}, 86}, {{"vs42"}, 87}, {{"vs43"}, 88},
  401. {{"vs44"}, 89}, {{"vs45"}, 90}, {{"vs46"}, 91}, {{"vs47"}, 92},
  402. {{"vs48"}, 93}, {{"vs49"}, 94}, {{"vs50"}, 95}, {{"vs51"}, 96},
  403. {{"vs52"}, 97}, {{"vs53"}, 98}, {{"vs54"}, 99}, {{"vs55"}, 100},
  404. {{"vs56"}, 101}, {{"vs57"}, 102}, {{"vs58"}, 103}, {{"vs59"}, 104},
  405. {{"vs60"}, 105}, {{"vs61"}, 106}, {{"vs62"}, 107}, {{"vs63"}, 108},
  406. };
  407. ArrayRef<TargetInfo::AddlRegName> PPCTargetInfo::getGCCAddlRegNames() const {
  408. if (ABI == "elfv2")
  409. return llvm::makeArrayRef(GCCAddlRegNames);
  410. else
  411. return TargetInfo::getGCCAddlRegNames();
  412. }
  413. static constexpr llvm::StringLiteral ValidCPUNames[] = {
  414. {"generic"}, {"440"}, {"450"}, {"601"}, {"602"},
  415. {"603"}, {"603e"}, {"603ev"}, {"604"}, {"604e"},
  416. {"620"}, {"630"}, {"g3"}, {"7400"}, {"g4"},
  417. {"7450"}, {"g4+"}, {"750"}, {"970"}, {"g5"},
  418. {"a2"}, {"a2q"}, {"e500mc"}, {"e5500"}, {"power3"},
  419. {"pwr3"}, {"power4"}, {"pwr4"}, {"power5"}, {"pwr5"},
  420. {"power5x"}, {"pwr5x"}, {"power6"}, {"pwr6"}, {"power6x"},
  421. {"pwr6x"}, {"power7"}, {"pwr7"}, {"power8"}, {"pwr8"},
  422. {"power9"}, {"pwr9"}, {"powerpc"}, {"ppc"}, {"powerpc64"},
  423. {"ppc64"}, {"powerpc64le"}, {"ppc64le"},
  424. };
  425. bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
  426. return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
  427. }
  428. void PPCTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
  429. Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
  430. }
  431. void PPCTargetInfo::adjust(LangOptions &Opts) {
  432. if (HasAltivec)
  433. Opts.AltiVec = 1;
  434. TargetInfo::adjust(Opts);
  435. if (LongDoubleFormat != &llvm::APFloat::IEEEdouble())
  436. LongDoubleFormat = Opts.PPCIEEELongDouble
  437. ? &llvm::APFloat::IEEEquad()
  438. : &llvm::APFloat::PPCDoubleDouble();
  439. }
  440. ArrayRef<Builtin::Info> PPCTargetInfo::getTargetBuiltins() const {
  441. return llvm::makeArrayRef(BuiltinInfo, clang::PPC::LastTSBuiltin -
  442. Builtin::FirstTSBuiltin);
  443. }