46#include "llvm/ADT/StringExtras.h"
47#include "llvm/TargetParser/Triple.h"
62 assert(MacroName[0] !=
'_' &&
"Identifier should be in the user's namespace");
67 Builder.defineMacro(MacroName);
70 Builder.defineMacro(
"__" + MacroName);
73 Builder.defineMacro(
"__" + MacroName +
"__");
77 Builder.defineMacro(
"__" + CPUName);
78 Builder.defineMacro(
"__" + CPUName +
"__");
80 Builder.defineMacro(
"__tune_" + CPUName +
"__");
88 if (Opts.DeclSpecKeyword)
89 Builder.defineMacro(
"__declspec",
"__declspec");
91 Builder.defineMacro(
"__declspec(a)",
"__attribute__((a))");
93 if (!Opts.MicrosoftExt) {
97 const char *CCs[] = {
"cdecl",
"stdcall",
"fastcall",
"thiscall",
"pascal"};
98 for (
const char *CC : CCs) {
99 std::string GCCSpelling =
"__attribute__((__";
101 GCCSpelling +=
"__))";
102 Builder.defineMacro(Twine(
"_") + CC, GCCSpelling);
103 Builder.defineMacro(Twine(
"__") + CC, GCCSpelling);
114 llvm::Triple::OSType os = Triple.getOS();
116 switch (Triple.getArch()) {
120 case llvm::Triple::arc:
121 return std::make_unique<ARCTargetInfo>(Triple, Opts);
123 case llvm::Triple::xcore:
124 return std::make_unique<XCoreTargetInfo>(Triple, Opts);
126 case llvm::Triple::hexagon:
127 if (os == llvm::Triple::Linux &&
128 Triple.getEnvironment() == llvm::Triple::Musl)
129 return std::make_unique<LinuxTargetInfo<HexagonTargetInfo>>(Triple, Opts);
130 return std::make_unique<HexagonTargetInfo>(Triple, Opts);
132 case llvm::Triple::lanai:
133 return std::make_unique<LanaiTargetInfo>(Triple, Opts);
135 case llvm::Triple::aarch64_32:
136 if (Triple.isOSDarwin())
137 return std::make_unique<DarwinAArch64TargetInfo>(Triple, Opts);
140 case llvm::Triple::aarch64:
141 if (Triple.isOSDarwin())
142 return std::make_unique<DarwinAArch64TargetInfo>(Triple, Opts);
145 case llvm::Triple::FreeBSD:
146 return std::make_unique<FreeBSDTargetInfo<AArch64leTargetInfo>>(Triple,
148 case llvm::Triple::Fuchsia:
149 return std::make_unique<FuchsiaTargetInfo<AArch64leTargetInfo>>(Triple,
151 case llvm::Triple::Haiku:
152 return std::make_unique<HaikuTargetInfo<AArch64leTargetInfo>>(Triple,
154 case llvm::Triple::Linux:
155 switch (Triple.getEnvironment()) {
157 return std::make_unique<LinuxTargetInfo<AArch64leTargetInfo>>(Triple,
159 case llvm::Triple::OpenHOS:
160 return std::make_unique<OHOSTargetInfo<AArch64leTargetInfo>>(Triple,
163 case llvm::Triple::NetBSD:
164 return std::make_unique<NetBSDTargetInfo<AArch64leTargetInfo>>(Triple,
166 case llvm::Triple::OpenBSD:
167 return std::make_unique<OpenBSDTargetInfo<AArch64leTargetInfo>>(Triple,
169 case llvm::Triple::Win32:
170 switch (Triple.getEnvironment()) {
171 case llvm::Triple::GNU:
172 return std::make_unique<MinGWARM64TargetInfo>(Triple, Opts);
173 case llvm::Triple::MSVC:
175 return std::make_unique<MicrosoftARM64TargetInfo>(Triple, Opts);
178 return std::make_unique<AArch64leTargetInfo>(Triple, Opts);
181 case llvm::Triple::aarch64_be:
183 case llvm::Triple::FreeBSD:
184 return std::make_unique<FreeBSDTargetInfo<AArch64beTargetInfo>>(Triple,
186 case llvm::Triple::Fuchsia:
187 return std::make_unique<FuchsiaTargetInfo<AArch64beTargetInfo>>(Triple,
189 case llvm::Triple::Linux:
190 return std::make_unique<LinuxTargetInfo<AArch64beTargetInfo>>(Triple,
192 case llvm::Triple::NetBSD:
193 return std::make_unique<NetBSDTargetInfo<AArch64beTargetInfo>>(Triple,
196 return std::make_unique<AArch64beTargetInfo>(Triple, Opts);
199 case llvm::Triple::arm:
200 case llvm::Triple::thumb:
201 if (Triple.isOSBinFormatMachO())
202 return std::make_unique<DarwinARMTargetInfo>(Triple, Opts);
205 case llvm::Triple::Linux:
206 switch (Triple.getEnvironment()) {
208 return std::make_unique<LinuxTargetInfo<ARMleTargetInfo>>(Triple, Opts);
209 case llvm::Triple::OpenHOS:
210 return std::make_unique<OHOSTargetInfo<ARMleTargetInfo>>(Triple, Opts);
212 case llvm::Triple::LiteOS:
213 return std::make_unique<OHOSTargetInfo<ARMleTargetInfo>>(Triple, Opts);
214 case llvm::Triple::FreeBSD:
215 return std::make_unique<FreeBSDTargetInfo<ARMleTargetInfo>>(Triple, Opts);
216 case llvm::Triple::NetBSD:
217 return std::make_unique<NetBSDTargetInfo<ARMleTargetInfo>>(Triple, Opts);
218 case llvm::Triple::OpenBSD:
219 return std::make_unique<OpenBSDTargetInfo<ARMleTargetInfo>>(Triple, Opts);
220 case llvm::Triple::RTEMS:
221 return std::make_unique<RTEMSTargetInfo<ARMleTargetInfo>>(Triple, Opts);
222 case llvm::Triple::Haiku:
223 return std::make_unique<HaikuTargetInfo<ARMleTargetInfo>>(Triple, Opts);
224 case llvm::Triple::NaCl:
225 return std::make_unique<NaClTargetInfo<ARMleTargetInfo>>(Triple, Opts);
226 case llvm::Triple::Win32:
227 switch (Triple.getEnvironment()) {
228 case llvm::Triple::Cygnus:
229 return std::make_unique<CygwinARMTargetInfo>(Triple, Opts);
230 case llvm::Triple::GNU:
231 return std::make_unique<MinGWARMTargetInfo>(Triple, Opts);
232 case llvm::Triple::Itanium:
233 return std::make_unique<ItaniumWindowsARMleTargetInfo>(Triple, Opts);
234 case llvm::Triple::MSVC:
236 return std::make_unique<MicrosoftARMleTargetInfo>(Triple, Opts);
239 return std::make_unique<ARMleTargetInfo>(Triple, Opts);
242 case llvm::Triple::armeb:
243 case llvm::Triple::thumbeb:
244 if (Triple.isOSDarwin())
245 return std::make_unique<DarwinARMTargetInfo>(Triple, Opts);
248 case llvm::Triple::Linux:
249 return std::make_unique<LinuxTargetInfo<ARMbeTargetInfo>>(Triple, Opts);
250 case llvm::Triple::NetBSD:
251 return std::make_unique<NetBSDTargetInfo<ARMbeTargetInfo>>(Triple, Opts);
252 case llvm::Triple::RTEMS:
253 return std::make_unique<RTEMSTargetInfo<ARMbeTargetInfo>>(Triple, Opts);
254 case llvm::Triple::NaCl:
255 return std::make_unique<NaClTargetInfo<ARMbeTargetInfo>>(Triple, Opts);
257 return std::make_unique<ARMbeTargetInfo>(Triple, Opts);
260 case llvm::Triple::avr:
261 return std::make_unique<AVRTargetInfo>(Triple, Opts);
262 case llvm::Triple::bpfeb:
263 case llvm::Triple::bpfel:
264 return std::make_unique<BPFTargetInfo>(Triple, Opts);
266 case llvm::Triple::msp430:
267 return std::make_unique<MSP430TargetInfo>(Triple, Opts);
269 case llvm::Triple::mips:
271 case llvm::Triple::Linux:
272 return std::make_unique<LinuxTargetInfo<MipsTargetInfo>>(Triple, Opts);
273 case llvm::Triple::RTEMS:
274 return std::make_unique<RTEMSTargetInfo<MipsTargetInfo>>(Triple, Opts);
275 case llvm::Triple::FreeBSD:
276 return std::make_unique<FreeBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
277 case llvm::Triple::NetBSD:
278 return std::make_unique<NetBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
280 return std::make_unique<MipsTargetInfo>(Triple, Opts);
283 case llvm::Triple::mipsel:
285 case llvm::Triple::Linux:
286 switch (Triple.getEnvironment()) {
288 return std::make_unique<LinuxTargetInfo<MipsTargetInfo>>(Triple, Opts);
289 case llvm::Triple::OpenHOS:
290 return std::make_unique<OHOSTargetInfo<MipsTargetInfo>>(Triple, Opts);
292 case llvm::Triple::RTEMS:
293 return std::make_unique<RTEMSTargetInfo<MipsTargetInfo>>(Triple, Opts);
294 case llvm::Triple::FreeBSD:
295 return std::make_unique<FreeBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
296 case llvm::Triple::NetBSD:
297 return std::make_unique<NetBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
298 case llvm::Triple::NaCl:
299 return std::make_unique<NaClTargetInfo<NaClMips32TargetInfo>>(Triple,
301 case llvm::Triple::Win32:
302 switch (Triple.getEnvironment()) {
303 case llvm::Triple::GNU:
304 return std::make_unique<MinGWMipsTargetInfo>(Triple, Opts);
305 case llvm::Triple::MSVC:
307 return std::make_unique<MicrosoftMipsTargetInfo>(Triple, Opts);
310 return std::make_unique<MipsTargetInfo>(Triple, Opts);
313 case llvm::Triple::mips64:
315 case llvm::Triple::Linux:
316 return std::make_unique<LinuxTargetInfo<MipsTargetInfo>>(Triple, Opts);
317 case llvm::Triple::RTEMS:
318 return std::make_unique<RTEMSTargetInfo<MipsTargetInfo>>(Triple, Opts);
319 case llvm::Triple::FreeBSD:
320 return std::make_unique<FreeBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
321 case llvm::Triple::NetBSD:
322 return std::make_unique<NetBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
323 case llvm::Triple::OpenBSD:
324 return std::make_unique<OpenBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
326 return std::make_unique<MipsTargetInfo>(Triple, Opts);
329 case llvm::Triple::mips64el:
331 case llvm::Triple::Linux:
332 return std::make_unique<LinuxTargetInfo<MipsTargetInfo>>(Triple, Opts);
333 case llvm::Triple::RTEMS:
334 return std::make_unique<RTEMSTargetInfo<MipsTargetInfo>>(Triple, Opts);
335 case llvm::Triple::FreeBSD:
336 return std::make_unique<FreeBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
337 case llvm::Triple::NetBSD:
338 return std::make_unique<NetBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
339 case llvm::Triple::OpenBSD:
340 return std::make_unique<OpenBSDTargetInfo<MipsTargetInfo>>(Triple, Opts);
342 return std::make_unique<MipsTargetInfo>(Triple, Opts);
345 case llvm::Triple::m68k:
347 case llvm::Triple::Linux:
348 return std::make_unique<LinuxTargetInfo<M68kTargetInfo>>(Triple, Opts);
349 case llvm::Triple::NetBSD:
350 return std::make_unique<NetBSDTargetInfo<M68kTargetInfo>>(Triple, Opts);
352 return std::make_unique<M68kTargetInfo>(Triple, Opts);
355 case llvm::Triple::ppc:
357 case llvm::Triple::Linux:
358 return std::make_unique<LinuxTargetInfo<PPC32TargetInfo>>(Triple, Opts);
359 case llvm::Triple::FreeBSD:
360 return std::make_unique<FreeBSDTargetInfo<PPC32TargetInfo>>(Triple, Opts);
361 case llvm::Triple::NetBSD:
362 return std::make_unique<NetBSDTargetInfo<PPC32TargetInfo>>(Triple, Opts);
363 case llvm::Triple::OpenBSD:
364 return std::make_unique<OpenBSDTargetInfo<PPC32TargetInfo>>(Triple, Opts);
365 case llvm::Triple::RTEMS:
366 return std::make_unique<RTEMSTargetInfo<PPC32TargetInfo>>(Triple, Opts);
367 case llvm::Triple::AIX:
368 return std::make_unique<AIXPPC32TargetInfo>(Triple, Opts);
370 return std::make_unique<PPC32TargetInfo>(Triple, Opts);
373 case llvm::Triple::ppcle:
375 case llvm::Triple::Linux:
376 return std::make_unique<LinuxTargetInfo<PPC32TargetInfo>>(Triple, Opts);
377 case llvm::Triple::FreeBSD:
378 return std::make_unique<FreeBSDTargetInfo<PPC32TargetInfo>>(Triple, Opts);
380 return std::make_unique<PPC32TargetInfo>(Triple, Opts);
383 case llvm::Triple::ppc64:
385 case llvm::Triple::Linux:
386 return std::make_unique<LinuxTargetInfo<PPC64TargetInfo>>(Triple, Opts);
387 case llvm::Triple::Lv2:
388 return std::make_unique<PS3PPUTargetInfo<PPC64TargetInfo>>(Triple, Opts);
389 case llvm::Triple::FreeBSD:
390 return std::make_unique<FreeBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
391 case llvm::Triple::NetBSD:
392 return std::make_unique<NetBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
393 case llvm::Triple::OpenBSD:
394 return std::make_unique<OpenBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
395 case llvm::Triple::AIX:
396 return std::make_unique<AIXPPC64TargetInfo>(Triple, Opts);
398 return std::make_unique<PPC64TargetInfo>(Triple, Opts);
401 case llvm::Triple::ppc64le:
403 case llvm::Triple::Linux:
404 return std::make_unique<LinuxTargetInfo<PPC64TargetInfo>>(Triple, Opts);
405 case llvm::Triple::FreeBSD:
406 return std::make_unique<FreeBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
407 case llvm::Triple::NetBSD:
408 return std::make_unique<NetBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
409 case llvm::Triple::OpenBSD:
410 return std::make_unique<OpenBSDTargetInfo<PPC64TargetInfo>>(Triple, Opts);
412 return std::make_unique<PPC64TargetInfo>(Triple, Opts);
415 case llvm::Triple::nvptx:
416 return std::make_unique<NVPTXTargetInfo>(Triple, Opts,
418 case llvm::Triple::nvptx64:
419 return std::make_unique<NVPTXTargetInfo>(Triple, Opts,
422 case llvm::Triple::amdgcn:
423 case llvm::Triple::r600:
424 return std::make_unique<AMDGPUTargetInfo>(Triple, Opts);
426 case llvm::Triple::riscv32:
428 case llvm::Triple::NetBSD:
429 return std::make_unique<NetBSDTargetInfo<RISCV32TargetInfo>>(Triple,
431 case llvm::Triple::Linux:
432 return std::make_unique<LinuxTargetInfo<RISCV32TargetInfo>>(Triple, Opts);
434 return std::make_unique<RISCV32TargetInfo>(Triple, Opts);
437 case llvm::Triple::riscv64:
439 case llvm::Triple::FreeBSD:
440 return std::make_unique<FreeBSDTargetInfo<RISCV64TargetInfo>>(Triple,
442 case llvm::Triple::NetBSD:
443 return std::make_unique<NetBSDTargetInfo<RISCV64TargetInfo>>(Triple,
445 case llvm::Triple::OpenBSD:
446 return std::make_unique<OpenBSDTargetInfo<RISCV64TargetInfo>>(Triple,
448 case llvm::Triple::Fuchsia:
449 return std::make_unique<FuchsiaTargetInfo<RISCV64TargetInfo>>(Triple,
451 case llvm::Triple::Haiku:
452 return std::make_unique<HaikuTargetInfo<RISCV64TargetInfo>>(Triple,
454 case llvm::Triple::Linux:
455 switch (Triple.getEnvironment()) {
457 return std::make_unique<LinuxTargetInfo<RISCV64TargetInfo>>(Triple,
459 case llvm::Triple::OpenHOS:
460 return std::make_unique<OHOSTargetInfo<RISCV64TargetInfo>>(Triple,
464 return std::make_unique<RISCV64TargetInfo>(Triple, Opts);
467 case llvm::Triple::sparc:
469 case llvm::Triple::Linux:
470 return std::make_unique<LinuxTargetInfo<SparcV8TargetInfo>>(Triple, Opts);
471 case llvm::Triple::Solaris:
472 return std::make_unique<SolarisTargetInfo<SparcV8TargetInfo>>(Triple,
474 case llvm::Triple::NetBSD:
475 return std::make_unique<NetBSDTargetInfo<SparcV8TargetInfo>>(Triple,
477 case llvm::Triple::RTEMS:
478 return std::make_unique<RTEMSTargetInfo<SparcV8TargetInfo>>(Triple, Opts);
480 return std::make_unique<SparcV8TargetInfo>(Triple, Opts);
483 case llvm::Triple::sparcel:
485 case llvm::Triple::Linux:
486 return std::make_unique<LinuxTargetInfo<SparcV8elTargetInfo>>(Triple,
488 case llvm::Triple::RTEMS:
489 return std::make_unique<RTEMSTargetInfo<SparcV8elTargetInfo>>(Triple,
492 return std::make_unique<SparcV8elTargetInfo>(Triple, Opts);
495 case llvm::Triple::sparcv9:
497 case llvm::Triple::Linux:
498 return std::make_unique<LinuxTargetInfo<SparcV9TargetInfo>>(Triple, Opts);
499 case llvm::Triple::Solaris:
500 return std::make_unique<SolarisTargetInfo<SparcV9TargetInfo>>(Triple,
502 case llvm::Triple::NetBSD:
503 return std::make_unique<NetBSDTargetInfo<SparcV9TargetInfo>>(Triple,
505 case llvm::Triple::OpenBSD:
506 return std::make_unique<OpenBSDTargetInfo<SparcV9TargetInfo>>(Triple,
508 case llvm::Triple::FreeBSD:
509 return std::make_unique<FreeBSDTargetInfo<SparcV9TargetInfo>>(Triple,
512 return std::make_unique<SparcV9TargetInfo>(Triple, Opts);
515 case llvm::Triple::systemz:
517 case llvm::Triple::Linux:
518 return std::make_unique<LinuxTargetInfo<SystemZTargetInfo>>(Triple, Opts);
519 case llvm::Triple::ZOS:
520 return std::make_unique<ZOSTargetInfo<SystemZTargetInfo>>(Triple, Opts);
522 return std::make_unique<SystemZTargetInfo>(Triple, Opts);
525 case llvm::Triple::tce:
526 return std::make_unique<TCETargetInfo>(Triple, Opts);
528 case llvm::Triple::tcele:
529 return std::make_unique<TCELETargetInfo>(Triple, Opts);
531 case llvm::Triple::x86:
532 if (Triple.isOSDarwin())
533 return std::make_unique<DarwinI386TargetInfo>(Triple, Opts);
536 case llvm::Triple::Linux: {
537 switch (Triple.getEnvironment()) {
539 return std::make_unique<LinuxTargetInfo<X86_32TargetInfo>>(Triple,
541 case llvm::Triple::Android:
542 return std::make_unique<AndroidX86_32TargetInfo>(Triple, Opts);
545 case llvm::Triple::DragonFly:
546 return std::make_unique<DragonFlyBSDTargetInfo<X86_32TargetInfo>>(Triple,
548 case llvm::Triple::NetBSD:
549 return std::make_unique<NetBSDI386TargetInfo>(Triple, Opts);
550 case llvm::Triple::OpenBSD:
551 return std::make_unique<OpenBSDI386TargetInfo>(Triple, Opts);
552 case llvm::Triple::FreeBSD:
553 return std::make_unique<FreeBSDTargetInfo<X86_32TargetInfo>>(Triple,
555 case llvm::Triple::Fuchsia:
556 return std::make_unique<FuchsiaTargetInfo<X86_32TargetInfo>>(Triple,
558 case llvm::Triple::KFreeBSD:
559 return std::make_unique<KFreeBSDTargetInfo<X86_32TargetInfo>>(Triple,
561 case llvm::Triple::Solaris:
562 return std::make_unique<SolarisTargetInfo<X86_32TargetInfo>>(Triple,
564 case llvm::Triple::Win32: {
565 switch (Triple.getEnvironment()) {
566 case llvm::Triple::Cygnus:
567 return std::make_unique<CygwinX86_32TargetInfo>(Triple, Opts);
568 case llvm::Triple::GNU:
569 return std::make_unique<MinGWX86_32TargetInfo>(Triple, Opts);
570 case llvm::Triple::Itanium:
571 case llvm::Triple::MSVC:
573 return std::make_unique<MicrosoftX86_32TargetInfo>(Triple, Opts);
576 case llvm::Triple::Haiku:
577 return std::make_unique<HaikuX86_32TargetInfo>(Triple, Opts);
578 case llvm::Triple::RTEMS:
579 return std::make_unique<RTEMSX86_32TargetInfo>(Triple, Opts);
580 case llvm::Triple::NaCl:
581 return std::make_unique<NaClTargetInfo<X86_32TargetInfo>>(Triple, Opts);
582 case llvm::Triple::ELFIAMCU:
583 return std::make_unique<MCUX86_32TargetInfo>(Triple, Opts);
584 case llvm::Triple::Hurd:
585 return std::make_unique<HurdTargetInfo<X86_32TargetInfo>>(Triple, Opts);
587 return std::make_unique<X86_32TargetInfo>(Triple, Opts);
590 case llvm::Triple::x86_64:
591 if (Triple.isOSDarwin() || Triple.isOSBinFormatMachO())
592 return std::make_unique<DarwinX86_64TargetInfo>(Triple, Opts);
595 case llvm::Triple::Linux: {
596 switch (Triple.getEnvironment()) {
598 return std::make_unique<LinuxTargetInfo<X86_64TargetInfo>>(Triple,
600 case llvm::Triple::Android:
601 return std::make_unique<AndroidX86_64TargetInfo>(Triple, Opts);
602 case llvm::Triple::OpenHOS:
603 return std::make_unique<OHOSX86_64TargetInfo>(Triple, Opts);
606 case llvm::Triple::DragonFly:
607 return std::make_unique<DragonFlyBSDTargetInfo<X86_64TargetInfo>>(Triple,
609 case llvm::Triple::NetBSD:
610 return std::make_unique<NetBSDTargetInfo<X86_64TargetInfo>>(Triple, Opts);
611 case llvm::Triple::OpenBSD:
612 return std::make_unique<OpenBSDX86_64TargetInfo>(Triple, Opts);
613 case llvm::Triple::FreeBSD:
614 return std::make_unique<FreeBSDTargetInfo<X86_64TargetInfo>>(Triple,
616 case llvm::Triple::Fuchsia:
617 return std::make_unique<FuchsiaTargetInfo<X86_64TargetInfo>>(Triple,
619 case llvm::Triple::KFreeBSD:
620 return std::make_unique<KFreeBSDTargetInfo<X86_64TargetInfo>>(Triple,
622 case llvm::Triple::Solaris:
623 return std::make_unique<SolarisTargetInfo<X86_64TargetInfo>>(Triple,
625 case llvm::Triple::UEFI:
626 return std::make_unique<UEFIX86_64TargetInfo>(Triple, Opts);
628 case llvm::Triple::Win32: {
629 switch (Triple.getEnvironment()) {
630 case llvm::Triple::Cygnus:
631 return std::make_unique<CygwinX86_64TargetInfo>(Triple, Opts);
632 case llvm::Triple::GNU:
633 return std::make_unique<MinGWX86_64TargetInfo>(Triple, Opts);
634 case llvm::Triple::MSVC:
636 return std::make_unique<MicrosoftX86_64TargetInfo>(Triple, Opts);
639 case llvm::Triple::Haiku:
640 return std::make_unique<HaikuTargetInfo<X86_64TargetInfo>>(Triple, Opts);
641 case llvm::Triple::NaCl:
642 return std::make_unique<NaClTargetInfo<X86_64TargetInfo>>(Triple, Opts);
643 case llvm::Triple::PS4:
644 return std::make_unique<PS4OSTargetInfo<X86_64TargetInfo>>(Triple, Opts);
645 case llvm::Triple::PS5:
646 return std::make_unique<PS5OSTargetInfo<X86_64TargetInfo>>(Triple, Opts);
647 case llvm::Triple::Hurd:
648 return std::make_unique<HurdTargetInfo<X86_64TargetInfo>>(Triple, Opts);
650 return std::make_unique<X86_64TargetInfo>(Triple, Opts);
653 case llvm::Triple::spir: {
654 if (os != llvm::Triple::UnknownOS ||
655 Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
657 return std::make_unique<SPIR32TargetInfo>(Triple, Opts);
659 case llvm::Triple::spir64: {
660 if (os != llvm::Triple::UnknownOS ||
661 Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
663 return std::make_unique<SPIR64TargetInfo>(Triple, Opts);
665 case llvm::Triple::spirv: {
666 return std::make_unique<SPIRVTargetInfo>(Triple, Opts);
668 case llvm::Triple::spirv32: {
669 if (os != llvm::Triple::UnknownOS ||
670 Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
672 return std::make_unique<SPIRV32TargetInfo>(Triple, Opts);
674 case llvm::Triple::spirv64: {
675 if (os != llvm::Triple::UnknownOS ||
676 Triple.getEnvironment() != llvm::Triple::UnknownEnvironment) {
677 if (os == llvm::Triple::OSType::AMDHSA)
678 return std::make_unique<SPIRV64AMDGCNTargetInfo>(Triple, Opts);
681 return std::make_unique<SPIRV64TargetInfo>(Triple, Opts);
683 case llvm::Triple::wasm32:
684 if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
685 Triple.getVendor() != llvm::Triple::UnknownVendor ||
686 !Triple.isOSBinFormatWasm())
689 case llvm::Triple::WASI:
690 return std::make_unique<WASITargetInfo<WebAssembly32TargetInfo>>(Triple,
692 case llvm::Triple::Emscripten:
693 return std::make_unique<EmscriptenTargetInfo<WebAssembly32TargetInfo>>(
695 case llvm::Triple::UnknownOS:
696 return std::make_unique<WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>>(
701 case llvm::Triple::wasm64:
702 if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
703 Triple.getVendor() != llvm::Triple::UnknownVendor ||
704 !Triple.isOSBinFormatWasm())
707 case llvm::Triple::WASI:
708 return std::make_unique<WASITargetInfo<WebAssembly64TargetInfo>>(Triple,
710 case llvm::Triple::Emscripten:
711 return std::make_unique<EmscriptenTargetInfo<WebAssembly64TargetInfo>>(
713 case llvm::Triple::UnknownOS:
714 return std::make_unique<WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>>(
720 case llvm::Triple::dxil:
721 return std::make_unique<DirectXTargetInfo>(Triple, Opts);
723 case llvm::Triple::ve:
724 return std::make_unique<LinuxTargetInfo<VETargetInfo>>(Triple, Opts);
726 case llvm::Triple::csky:
728 case llvm::Triple::Linux:
729 return std::make_unique<LinuxTargetInfo<CSKYTargetInfo>>(Triple, Opts);
731 return std::make_unique<CSKYTargetInfo>(Triple, Opts);
733 case llvm::Triple::loongarch32:
735 case llvm::Triple::Linux:
736 return std::make_unique<LinuxTargetInfo<LoongArch32TargetInfo>>(Triple,
738 case llvm::Triple::FreeBSD:
739 return std::make_unique<FreeBSDTargetInfo<LoongArch32TargetInfo>>(Triple,
742 return std::make_unique<LoongArch32TargetInfo>(Triple, Opts);
744 case llvm::Triple::loongarch64:
746 case llvm::Triple::Linux:
747 return std::make_unique<LinuxTargetInfo<LoongArch64TargetInfo>>(Triple,
749 case llvm::Triple::FreeBSD:
750 return std::make_unique<FreeBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
753 return std::make_unique<LoongArch64TargetInfo>(Triple, Opts);
756 case llvm::Triple::xtensa:
757 return std::make_unique<XtensaTargetInfo>(Triple, Opts);
768 const std::shared_ptr<TargetOptions> &Opts) {
769 llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple));
774 Diags.
Report(diag::err_target_unknown_triple) << Triple.str();
777 Target->TargetOpts = Opts;
780 if (!Opts->CPU.empty() && !
Target->setCPU(Opts->CPU)) {
781 Diags.
Report(diag::err_target_unknown_cpu) << Opts->CPU;
783 Target->fillValidCPUList(ValidList);
784 if (!ValidList.empty())
785 Diags.
Report(diag::note_valid_options) << llvm::join(ValidList,
", ");
790 if (!Opts->TuneCPU.empty() &&
791 !
Target->isValidTuneCPUName(Opts->TuneCPU)) {
792 Diags.
Report(diag::err_target_unknown_cpu) << Opts->TuneCPU;
794 Target->fillValidTuneCPUList(ValidList);
795 if (!ValidList.empty())
796 Diags.
Report(diag::note_valid_options) << llvm::join(ValidList,
", ");
801 if (!Opts->ABI.empty() && !
Target->setABI(Opts->ABI)) {
802 Diags.
Report(diag::err_target_unknown_abi) << Opts->ABI;
807 if (!Opts->FPMath.empty() && !
Target->setFPMath(Opts->FPMath)) {
808 Diags.
Report(diag::err_target_unknown_fpmath) << Opts->FPMath;
814 llvm::erase_if(Opts->FeaturesAsWritten, [&](StringRef Name) {
815 if (Target->isReadOnlyFeature(Name.substr(1))) {
816 Diags.Report(diag::warn_fe_backend_readonly_feature_flag) << Name;
821 if (!
Target->initFeatureMap(Opts->FeatureMap, Diags, Opts->CPU,
822 Opts->FeaturesAsWritten))
826 Opts->Features.clear();
827 for (
const auto &F : Opts->FeatureMap)
828 Opts->Features.push_back((F.getValue() ?
"+" :
"-") + F.getKey().str());
831 llvm::sort(Opts->Features);
833 if (!
Target->handleTargetFeatures(Opts->Features, Diags))
836 Target->setSupportedOpenCLOpts();
837 Target->setCommandLineOpenCLOpts();
838 Target->setMaxAtomicWidth();
840 if (!Opts->DarwinTargetVariantTriple.empty())
841 Target->DarwinTargetVariantTriple =
842 llvm::Triple(Opts->DarwinTargetVariantTriple);
844 if (!
Target->validateTarget(Diags))
847 Target->CheckFixedPointBits();
857 auto diagnoseNotSupportedCore = [&](llvm::StringRef Name,
auto... OptArgs) {
860 Diags.
Report(diag::warn_opencl_unsupported_core_feature)
861 << Name << Opts.OpenCLCPlusPlus
864#define OPENCL_GENERIC_EXTENSION(Ext, ...) \
865 diagnoseNotSupportedCore(#Ext, __VA_ARGS__);
866#include "clang/Basic/OpenCLExtensions.def"
Defines the Diagnostic-related interfaces.
llvm::MachO::Target Target
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
static bool diagnoseUnsupportedFeatureDependencies(const TargetInfo &TI, DiagnosticsEngine &Diags)
static bool diagnoseFeatureExtensionDifferences(const TargetInfo &TI, DiagnosticsEngine &Diags)
static bool isOpenCLOptionCoreIn(const LangOptions &LO, Args &&... args)
Exposes information about the current target.
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
static TargetInfo * CreateTargetInfo(DiagnosticsEngine &Diags, const std::shared_ptr< TargetOptions > &Opts)
Construct a target for the given options.
virtual bool validateOpenCLTarget(const LangOptions &Opts, DiagnosticsEngine &Diags) const
Check that OpenCL target has valid options setting based on OpenCL version.
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
Options for controlling the target.
LLVM_LIBRARY_VISIBILITY void defineCPUMacros(clang::MacroBuilder &Builder, llvm::StringRef CPUName, bool Tuning=true)
LLVM_LIBRARY_VISIBILITY void addCygMingDefines(const clang::LangOptions &Opts, clang::MacroBuilder &Builder)
LLVM_LIBRARY_VISIBILITY void DefineStd(clang::MacroBuilder &Builder, llvm::StringRef MacroName, const clang::LangOptions &Opts)
Define a macro name and standard variants.
std::unique_ptr< clang::TargetInfo > AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts)
The JSON file list parser is used to communicate input to InstallAPI.