LLVM  10.0.0svn
Triple.h
Go to the documentation of this file.
1 //===-- llvm/ADT/Triple.h - Target triple helper class ----------*- C++ -*-===//
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 #ifndef LLVM_ADT_TRIPLE_H
10 #define LLVM_ADT_TRIPLE_H
11 
12 #include "llvm/ADT/Twine.h"
13 
14 // Some system headers or GCC predefined macros conflict with identifiers in
15 // this file. Undefine them here.
16 #undef NetBSD
17 #undef mips
18 #undef sparc
19 
20 namespace llvm {
21 
22 /// Triple - Helper class for working with autoconf configuration names. For
23 /// historical reasons, we also call these 'triples' (they used to contain
24 /// exactly three fields).
25 ///
26 /// Configuration names are strings in the canonical form:
27 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
28 /// or
29 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
30 ///
31 /// This class is used for clients which want to support arbitrary
32 /// configuration names, but also want to implement certain special
33 /// behavior for particular configurations. This class isolates the mapping
34 /// from the components of the configuration name to well known IDs.
35 ///
36 /// At its core the Triple class is designed to be a wrapper for a triple
37 /// string; the constructor does not change or normalize the triple string.
38 /// Clients that need to handle the non-canonical triples that users often
39 /// specify should use the normalize method.
40 ///
41 /// See autoconf/config.guess for a glimpse into what configuration names
42 /// look like in practice.
43 class Triple {
44 public:
45  enum ArchType {
47 
48  arm, // ARM (little endian): arm, armv.*, xscale
49  armeb, // ARM (big endian): armeb
50  aarch64, // AArch64 (little endian): aarch64
51  aarch64_be, // AArch64 (big endian): aarch64_be
52  aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
53  arc, // ARC: Synopsys ARC
54  avr, // AVR: Atmel AVR microcontroller
55  bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
56  bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
57  hexagon, // Hexagon: hexagon
58  mips, // MIPS: mips, mipsallegrex, mipsr6
59  mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
60  mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
61  mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
62  msp430, // MSP430: msp430
63  ppc, // PPC: powerpc
64  ppc64, // PPC64: powerpc64, ppu
65  ppc64le, // PPC64LE: powerpc64le
66  r600, // R600: AMD GPUs HD2XXX - HD6XXX
67  amdgcn, // AMDGCN: AMD GCN GPUs
68  riscv32, // RISC-V (32-bit): riscv32
69  riscv64, // RISC-V (64-bit): riscv64
70  sparc, // Sparc: sparc
71  sparcv9, // Sparcv9: Sparcv9
72  sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
73  systemz, // SystemZ: s390x
74  tce, // TCE (http://tce.cs.tut.fi/): tce
75  tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
76  thumb, // Thumb (little endian): thumb, thumbv.*
77  thumbeb, // Thumb (big endian): thumbeb
78  x86, // X86: i[3-9]86
79  x86_64, // X86-64: amd64, x86_64
80  xcore, // XCore: xcore
81  nvptx, // NVPTX: 32-bit
82  nvptx64, // NVPTX: 64-bit
83  le32, // le32: generic little-endian 32-bit CPU (PNaCl)
84  le64, // le64: generic little-endian 64-bit CPU (PNaCl)
85  amdil, // AMDIL
86  amdil64, // AMDIL with 64-bit pointers
87  hsail, // AMD HSAIL
88  hsail64, // AMD HSAIL with 64-bit pointers
89  spir, // SPIR: standard portable IR for OpenCL 32-bit version
90  spir64, // SPIR: standard portable IR for OpenCL 64-bit version
91  kalimba, // Kalimba: generic kalimba
92  shave, // SHAVE: Movidius vector VLIW processors
93  lanai, // Lanai: Lanai 32-bit
94  wasm32, // WebAssembly with 32-bit pointers
95  wasm64, // WebAssembly with 64-bit pointers
96  renderscript32, // 32-bit RenderScript
97  renderscript64, // 64-bit RenderScript
99  };
100  enum SubArchType {
102 
126 
130 
132  };
133  enum VendorType {
135 
137  PC,
153  };
154  enum OSType {
156 
166  Lv2, // PS3
175  NaCl, // Native Client
176  CNK, // BG/P Compute-Node Kernel
178  CUDA, // NVIDIA CUDA
179  NVCL, // NVIDIA OpenCL
180  AMDHSA, // AMD HSA Runtime
183  TvOS, // Apple tvOS
184  WatchOS, // Apple watchOS
187  AMDPAL, // AMD PAL Runtime
188  HermitCore, // HermitCore Unikernel/Multikernel
189  Hurd, // GNU/Hurd
190  WASI, // Experimental WebAssembly OS
193  };
196 
212 
217  Simulator, // Simulator variants of other systems, e.g., Apple's iOS
218  MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
220  };
223 
229  };
230 
231 private:
232  std::string Data;
233 
234  /// The parsed arch type.
235  ArchType Arch;
236 
237  /// The parsed subarchitecture type.
238  SubArchType SubArch;
239 
240  /// The parsed vendor type.
241  VendorType Vendor;
242 
243  /// The parsed OS type.
244  OSType OS;
245 
246  /// The parsed Environment type.
247  EnvironmentType Environment;
248 
249  /// The object format type.
250  ObjectFormatType ObjectFormat;
251 
252 public:
253  /// @name Constructors
254  /// @{
255 
256  /// Default constructor is the same as an empty string and leaves all
257  /// triple fields unknown.
259  : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
260  ObjectFormat() {}
261 
262  explicit Triple(const Twine &Str);
263  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
264  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
265  const Twine &EnvironmentStr);
266 
267  bool operator==(const Triple &Other) const {
268  return Arch == Other.Arch && SubArch == Other.SubArch &&
269  Vendor == Other.Vendor && OS == Other.OS &&
270  Environment == Other.Environment &&
271  ObjectFormat == Other.ObjectFormat;
272  }
273 
274  bool operator!=(const Triple &Other) const {
275  return !(*this == Other);
276  }
277 
278  /// @}
279  /// @name Normalization
280  /// @{
281 
282  /// normalize - Turn an arbitrary machine specification into the canonical
283  /// triple form (or something sensible that the Triple class understands if
284  /// nothing better can reasonably be done). In particular, it handles the
285  /// common case in which otherwise valid components are in the wrong order.
286  static std::string normalize(StringRef Str);
287 
288  /// Return the normalized form of this triple's string.
289  std::string normalize() const { return normalize(Data); }
290 
291  /// @}
292  /// @name Typed Component Access
293  /// @{
294 
295  /// getArch - Get the parsed architecture type of this triple.
296  ArchType getArch() const { return Arch; }
297 
298  /// getSubArch - get the parsed subarchitecture type for this triple.
299  SubArchType getSubArch() const { return SubArch; }
300 
301  /// getVendor - Get the parsed vendor type of this triple.
302  VendorType getVendor() const { return Vendor; }
303 
304  /// getOS - Get the parsed operating system type of this triple.
305  OSType getOS() const { return OS; }
306 
307  /// hasEnvironment - Does this triple have the optional environment
308  /// (fourth) component?
309  bool hasEnvironment() const {
310  return getEnvironmentName() != "";
311  }
312 
313  /// getEnvironment - Get the parsed environment type of this triple.
314  EnvironmentType getEnvironment() const { return Environment; }
315 
316  /// Parse the version number from the OS name component of the
317  /// triple, if present.
318  ///
319  /// For example, "fooos1.2.3" would return (1, 2, 3).
320  ///
321  /// If an entry is not defined, it will be returned as 0.
322  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
323  unsigned &Micro) const;
324 
325  /// getFormat - Get the object format for this triple.
326  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
327 
328  /// getOSVersion - Parse the version number from the OS name component of the
329  /// triple, if present.
330  ///
331  /// For example, "fooos1.2.3" would return (1, 2, 3).
332  ///
333  /// If an entry is not defined, it will be returned as 0.
334  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
335 
336  /// getOSMajorVersion - Return just the major version number, this is
337  /// specialized because it is a common query.
338  unsigned getOSMajorVersion() const {
339  unsigned Maj, Min, Micro;
340  getOSVersion(Maj, Min, Micro);
341  return Maj;
342  }
343 
344  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
345  /// translate generic "darwin" versions to the corresponding OS X versions.
346  /// This may also be called with IOS triples but the OS X version number is
347  /// just set to a constant 10.4.0 in that case. Returns true if successful.
348  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
349  unsigned &Micro) const;
350 
351  /// getiOSVersion - Parse the version number as with getOSVersion. This should
352  /// only be called with IOS or generic triples.
353  void getiOSVersion(unsigned &Major, unsigned &Minor,
354  unsigned &Micro) const;
355 
356  /// getWatchOSVersion - Parse the version number as with getOSVersion. This
357  /// should only be called with WatchOS or generic triples.
358  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
359  unsigned &Micro) const;
360 
361  /// @}
362  /// @name Direct Component Access
363  /// @{
364 
365  const std::string &str() const { return Data; }
366 
367  const std::string &getTriple() const { return Data; }
368 
369  /// getArchName - Get the architecture (first) component of the
370  /// triple.
371  StringRef getArchName() const;
372 
373  /// getVendorName - Get the vendor (second) component of the triple.
374  StringRef getVendorName() const;
375 
376  /// getOSName - Get the operating system (third) component of the
377  /// triple.
378  StringRef getOSName() const;
379 
380  /// getEnvironmentName - Get the optional environment (fourth)
381  /// component of the triple, or "" if empty.
383 
384  /// getOSAndEnvironmentName - Get the operating system and optional
385  /// environment components as a single string (separated by a '-'
386  /// if the environment component is present).
388 
389  /// @}
390  /// @name Convenience Predicates
391  /// @{
392 
393  /// Test whether the architecture is 64-bit
394  ///
395  /// Note that this tests for 64-bit pointer width, and nothing else. Note
396  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
397  /// 16-bit. The inner details of pointer width for particular architectures
398  /// is not summed up in the triple, and so only a coarse grained predicate
399  /// system is provided.
400  bool isArch64Bit() const;
401 
402  /// Test whether the architecture is 32-bit
403  ///
404  /// Note that this tests for 32-bit pointer width, and nothing else.
405  bool isArch32Bit() const;
406 
407  /// Test whether the architecture is 16-bit
408  ///
409  /// Note that this tests for 16-bit pointer width, and nothing else.
410  bool isArch16Bit() const;
411 
412  /// isOSVersionLT - Helper function for doing comparisons against version
413  /// numbers included in the target triple.
414  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
415  unsigned Micro = 0) const {
416  unsigned LHS[3];
417  getOSVersion(LHS[0], LHS[1], LHS[2]);
418 
419  if (LHS[0] != Major)
420  return LHS[0] < Major;
421  if (LHS[1] != Minor)
422  return LHS[1] < Minor;
423  if (LHS[2] != Micro)
424  return LHS[2] < Micro;
425 
426  return false;
427  }
428 
429  bool isOSVersionLT(const Triple &Other) const {
430  unsigned RHS[3];
431  Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
432  return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
433  }
434 
435  /// isMacOSXVersionLT - Comparison function for checking OS X version
436  /// compatibility, which handles supporting skewed version numbering schemes
437  /// used by the "darwin" triples.
438  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
439  unsigned Micro = 0) const {
440  assert(isMacOSX() && "Not an OS X triple!");
441 
442  // If this is OS X, expect a sane version number.
443  if (getOS() == Triple::MacOSX)
444  return isOSVersionLT(Major, Minor, Micro);
445 
446  // Otherwise, compare to the "Darwin" number.
447  assert(Major == 10 && "Unexpected major version");
448  return isOSVersionLT(Minor + 4, Micro, 0);
449  }
450 
451  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
452  /// "darwin" and "osx" as OS X triples.
453  bool isMacOSX() const {
454  return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
455  }
456 
457  /// Is this an iOS triple.
458  /// Note: This identifies tvOS as a variant of iOS. If that ever
459  /// changes, i.e., if the two operating systems diverge or their version
460  /// numbers get out of sync, that will need to be changed.
461  /// watchOS has completely different version numbers so it is not included.
462  bool isiOS() const {
463  return getOS() == Triple::IOS || isTvOS();
464  }
465 
466  /// Is this an Apple tvOS triple.
467  bool isTvOS() const {
468  return getOS() == Triple::TvOS;
469  }
470 
471  /// Is this an Apple watchOS triple.
472  bool isWatchOS() const {
473  return getOS() == Triple::WatchOS;
474  }
475 
476  bool isWatchABI() const {
478  }
479 
480  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
481  bool isOSDarwin() const {
482  return isMacOSX() || isiOS() || isWatchOS();
483  }
484 
485  bool isSimulatorEnvironment() const {
486  return getEnvironment() == Triple::Simulator;
487  }
488 
490  return getEnvironment() == Triple::MacABI;
491  }
492 
493  bool isOSNetBSD() const {
494  return getOS() == Triple::NetBSD;
495  }
496 
497  bool isOSOpenBSD() const {
498  return getOS() == Triple::OpenBSD;
499  }
500 
501  bool isOSFreeBSD() const {
502  return getOS() == Triple::FreeBSD;
503  }
504 
505  bool isOSFuchsia() const {
506  return getOS() == Triple::Fuchsia;
507  }
508 
509  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
510 
511  bool isOSSolaris() const {
512  return getOS() == Triple::Solaris;
513  }
514 
515  bool isOSIAMCU() const {
516  return getOS() == Triple::ELFIAMCU;
517  }
518 
519  bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
520 
521  bool isGNUEnvironment() const {
523  return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
524  Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
525  Env == Triple::GNUEABIHF || Env == Triple::GNUX32;
526  }
527 
528  bool isOSContiki() const {
529  return getOS() == Triple::Contiki;
530  }
531 
532  /// Tests whether the OS is Haiku.
533  bool isOSHaiku() const {
534  return getOS() == Triple::Haiku;
535  }
536 
537  /// Tests whether the OS is Windows.
538  bool isOSWindows() const {
539  return getOS() == Triple::Win32;
540  }
541 
542  /// Checks if the environment is MSVC.
544  return isOSWindows() && getEnvironment() == Triple::MSVC;
545  }
546 
547  /// Checks if the environment could be MSVC.
551  }
552 
554  return isOSWindows() && getEnvironment() == Triple::CoreCLR;
555  }
556 
558  return isOSWindows() && getEnvironment() == Triple::Itanium;
559  }
560 
562  return isOSWindows() && getEnvironment() == Triple::Cygnus;
563  }
564 
565  bool isWindowsGNUEnvironment() const {
566  return isOSWindows() && getEnvironment() == Triple::GNU;
567  }
568 
569  /// Tests for either Cygwin or MinGW OS
570  bool isOSCygMing() const {
572  }
573 
574  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
575  bool isOSMSVCRT() const {
578  }
579 
580  /// Tests whether the OS is NaCl (Native Client)
581  bool isOSNaCl() const {
582  return getOS() == Triple::NaCl;
583  }
584 
585  /// Tests whether the OS is Linux.
586  bool isOSLinux() const {
587  return getOS() == Triple::Linux;
588  }
589 
590  /// Tests whether the OS is kFreeBSD.
591  bool isOSKFreeBSD() const {
592  return getOS() == Triple::KFreeBSD;
593  }
594 
595  /// Tests whether the OS is Hurd.
596  bool isOSHurd() const {
597  return getOS() == Triple::Hurd;
598  }
599 
600  /// Tests whether the OS is WASI.
601  bool isOSWASI() const {
602  return getOS() == Triple::WASI;
603  }
604 
605  /// Tests whether the OS is Emscripten.
606  bool isOSEmscripten() const {
607  return getOS() == Triple::Emscripten;
608  }
609 
610  /// Tests whether the OS uses glibc.
611  bool isOSGlibc() const {
612  return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
613  getOS() == Triple::Hurd) &&
614  !isAndroid();
615  }
616 
617  /// Tests whether the OS is AIX.
618  bool isOSAIX() const {
619  return getOS() == Triple::AIX;
620  }
621 
622  /// Tests whether the OS uses the ELF binary format.
623  bool isOSBinFormatELF() const {
624  return getObjectFormat() == Triple::ELF;
625  }
626 
627  /// Tests whether the OS uses the COFF binary format.
628  bool isOSBinFormatCOFF() const {
629  return getObjectFormat() == Triple::COFF;
630  }
631 
632  /// Tests whether the environment is MachO.
633  bool isOSBinFormatMachO() const {
634  return getObjectFormat() == Triple::MachO;
635  }
636 
637  /// Tests whether the OS uses the Wasm binary format.
638  bool isOSBinFormatWasm() const {
639  return getObjectFormat() == Triple::Wasm;
640  }
641 
642  /// Tests whether the OS uses the XCOFF binary format.
643  bool isOSBinFormatXCOFF() const {
644  return getObjectFormat() == Triple::XCOFF;
645  }
646 
647  /// Tests whether the target is the PS4 CPU
648  bool isPS4CPU() const {
649  return getArch() == Triple::x86_64 &&
650  getVendor() == Triple::SCEI &&
651  getOS() == Triple::PS4;
652  }
653 
654  /// Tests whether the target is the PS4 platform
655  bool isPS4() const {
656  return getVendor() == Triple::SCEI &&
657  getOS() == Triple::PS4;
658  }
659 
660  /// Tests whether the target is Android
661  bool isAndroid() const { return getEnvironment() == Triple::Android; }
662 
663  bool isAndroidVersionLT(unsigned Major) const {
664  assert(isAndroid() && "Not an Android triple!");
665 
666  unsigned Env[3];
667  getEnvironmentVersion(Env[0], Env[1], Env[2]);
668 
669  // 64-bit targets did not exist before API level 21 (Lollipop).
670  if (isArch64Bit() && Env[0] < 21)
671  Env[0] = 21;
672 
673  return Env[0] < Major;
674  }
675 
676  /// Tests whether the environment is musl-libc
677  bool isMusl() const {
678  return getEnvironment() == Triple::Musl ||
681  }
682 
683  /// Tests whether the target is SPIR (32- or 64-bit).
684  bool isSPIR() const {
685  return getArch() == Triple::spir || getArch() == Triple::spir64;
686  }
687 
688  /// Tests whether the target is NVPTX (32- or 64-bit).
689  bool isNVPTX() const {
690  return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
691  }
692 
693  /// Tests whether the target is Thumb (little and big endian).
694  bool isThumb() const {
695  return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
696  }
697 
698  /// Tests whether the target is ARM (little and big endian).
699  bool isARM() const {
700  return getArch() == Triple::arm || getArch() == Triple::armeb;
701  }
702 
703  /// Tests whether the target is AArch64 (little and big endian).
704  bool isAArch64() const {
706  }
707 
708  /// Tests whether the target is MIPS 32-bit (little and big endian).
709  bool isMIPS32() const {
710  return getArch() == Triple::mips || getArch() == Triple::mipsel;
711  }
712 
713  /// Tests whether the target is MIPS 64-bit (little and big endian).
714  bool isMIPS64() const {
715  return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
716  }
717 
718  /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
719  bool isMIPS() const {
720  return isMIPS32() || isMIPS64();
721  }
722 
723  /// Tests whether the target is 64-bit PowerPC (little and big endian).
724  bool isPPC64() const {
725  return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
726  }
727 
728  /// Tests whether the target is RISC-V (32- and 64-bit).
729  bool isRISCV() const {
730  return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
731  }
732 
733  /// Tests whether the target supports comdat
734  bool supportsCOMDAT() const {
735  return !isOSBinFormatMachO();
736  }
737 
738  /// Tests whether the target uses emulated TLS as default.
739  bool hasDefaultEmulatedTLS() const {
741  }
742 
743  /// @}
744  /// @name Mutators
745  /// @{
746 
747  /// setArch - Set the architecture (first) component of the triple
748  /// to a known type.
749  void setArch(ArchType Kind);
750 
751  /// setVendor - Set the vendor (second) component of the triple to a
752  /// known type.
753  void setVendor(VendorType Kind);
754 
755  /// setOS - Set the operating system (third) component of the triple
756  /// to a known type.
757  void setOS(OSType Kind);
758 
759  /// setEnvironment - Set the environment (fourth) component of the triple
760  /// to a known type.
761  void setEnvironment(EnvironmentType Kind);
762 
763  /// setObjectFormat - Set the object file format
765 
766  /// setTriple - Set all components to the new triple \p Str.
767  void setTriple(const Twine &Str);
768 
769  /// setArchName - Set the architecture (first) component of the
770  /// triple by name.
771  void setArchName(StringRef Str);
772 
773  /// setVendorName - Set the vendor (second) component of the triple
774  /// by name.
775  void setVendorName(StringRef Str);
776 
777  /// setOSName - Set the operating system (third) component of the
778  /// triple by name.
779  void setOSName(StringRef Str);
780 
781  /// setEnvironmentName - Set the optional environment (fourth)
782  /// component of the triple by name.
783  void setEnvironmentName(StringRef Str);
784 
785  /// setOSAndEnvironmentName - Set the operating system and optional
786  /// environment components with a single string.
788 
789  /// @}
790  /// @name Helpers to build variants of a particular triple.
791  /// @{
792 
793  /// Form a triple with a 32-bit variant of the current architecture.
794  ///
795  /// This can be used to move across "families" of architectures where useful.
796  ///
797  /// \returns A new triple with a 32-bit architecture or an unknown
798  /// architecture if no such variant can be found.
800 
801  /// Form a triple with a 64-bit variant of the current architecture.
802  ///
803  /// This can be used to move across "families" of architectures where useful.
804  ///
805  /// \returns A new triple with a 64-bit architecture or an unknown
806  /// architecture if no such variant can be found.
808 
809  /// Form a triple with a big endian variant of the current architecture.
810  ///
811  /// This can be used to move across "families" of architectures where useful.
812  ///
813  /// \returns A new triple with a big endian architecture or an unknown
814  /// architecture if no such variant can be found.
816 
817  /// Form a triple with a little endian variant of the current architecture.
818  ///
819  /// This can be used to move across "families" of architectures where useful.
820  ///
821  /// \returns A new triple with a little endian architecture or an unknown
822  /// architecture if no such variant can be found.
824 
825  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
826  ///
827  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
828  /// string then the triple's arch name is used.
830 
831  /// Tests whether the target triple is little endian.
832  ///
833  /// \returns true if the triple is little endian, false otherwise.
834  bool isLittleEndian() const;
835 
836  /// Test whether target triples are compatible.
837  bool isCompatibleWith(const Triple &Other) const;
838 
839  /// Merge target triples.
840  std::string merge(const Triple &Other) const;
841 
842  /// @}
843  /// @name Static helpers for IDs.
844  /// @{
845 
846  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
847  static StringRef getArchTypeName(ArchType Kind);
848 
849  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
850  /// architecture. This is the prefix used by the architecture specific
851  /// builtins, and is suitable for passing to \see
852  /// Intrinsic::getIntrinsicForGCCBuiltin().
853  ///
854  /// \return - The architecture prefix, or 0 if none is defined.
855  static StringRef getArchTypePrefix(ArchType Kind);
856 
857  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
859 
860  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
861  static StringRef getOSTypeName(OSType Kind);
862 
863  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
864  /// environment.
866 
867  /// @}
868  /// @name Static helpers for converting alternate architecture names.
869  /// @{
870 
871  /// getArchTypeForLLVMName - The canonical type for the given LLVM
872  /// architecture name (e.g., "x86").
874 
875  /// @}
876 };
877 
878 } // End llvm namespace
879 
880 
881 #endif
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:481
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition: Triple.h:533
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition: Triple.h:606
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1114
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition: Triple.h:714
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:575
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:734
static StringRef getVendorTypeName(VendorType Kind)
getVendorTypeName - Get the canonical name for the Kind vendor.
Definition: Triple.cpp:150
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:453
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:623
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:305
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1172
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1300
bool isOSNaCl() const
Tests whether the OS is NaCl (Native Client)
Definition: Triple.h:581
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:953
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:472
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:309
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
Definition: Triple.cpp:1176
bool isOSFuchsia() const
Definition: Triple.h:505
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1180
void getEnvironmentVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
Parse the version number from the OS name component of the triple, if present.
Definition: Triple.cpp:1050
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:561
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1595
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
Definition: Triple.h:704
static StringRef getArchTypeName(ArchType Kind)
getArchTypeName - Get the canonical name for the Kind architecture.
Definition: Triple.cpp:19
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition: Triple.h:543
bool isMacCatalystEnvironment() const
Definition: Triple.h:489
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition: Triple.h:596
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition: Triple.h:739
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1207
bool isOSSolaris() const
Definition: Triple.h:511
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:258
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:299
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:296
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1296
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:462
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:655
bool isOSWASI() const
Tests whether the OS is WASI.
Definition: Triple.h:601
bool isOSNetBSD() const
Definition: Triple.h:493
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:557
bool isWindowsGNUEnvironment() const
Definition: Triple.h:565
static StringRef getOSTypeName(OSType Kind)
getOSTypeName - Get the canonical name for the Kind operating system.
Definition: Triple.cpp:175
bool isWindowsCoreCLREnvironment() const
Definition: Triple.h:553
const std::string & str() const
Definition: Triple.h:365
bool isOSDragonFly() const
Definition: Triple.h:509
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:538
void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getOSVersion - Parse the version number from the OS name component of the triple, if present...
Definition: Triple.cpp:1060
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:677
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1188
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:1010
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1304
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1518
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:302
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:628
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name...
Definition: Triple.cpp:1219
bool isOSOpenBSD() const
Definition: Triple.h:497
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1432
bool isWatchABI() const
Definition: Triple.h:476
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1164
bool operator==(const Triple &Other) const
Definition: Triple.h:267
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1562
static StringRef getArchTypePrefix(ArchType Kind)
getArchTypePrefix - Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:78
bool operator!=(const Triple &Other) const
Definition: Triple.h:274
bool isAndroidVersionLT(unsigned Major) const
Definition: Triple.h:663
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
Definition: Triple.h:648
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1140
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition: Triple.h:591
void setArchName(StringRef Str)
setArchName - Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1196
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition: Triple.h:724
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:633
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1211
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:338
bool isOSUnknown() const
Definition: Triple.h:519
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
bool isOSAIX() const
Tests whether the OS is AIX.
Definition: Triple.h:618
bool isOSIAMCU() const
Definition: Triple.h:515
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:989
bool getMacOSXVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getMacOSXVersion - Parse the version number as with getOSVersion and then translate generic "darwin" ...
Definition: Triple.cpp:1073
bool isOSContiki() const
Definition: Triple.h:528
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:263
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:998
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:586
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:314
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1586
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:429
bool isOSFreeBSD() const
Definition: Triple.h:501
std::string normalize() const
Return the normalized form of this triple&#39;s string.
Definition: Triple.h:289
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1004
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:719
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition: Triple.h:643
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:570
const std::string & getTriple() const
Definition: Triple.h:367
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition: Triple.h:709
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:611
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1486
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition: Triple.h:694
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:326
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1224
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1292
bool isGNUEnvironment() const
Definition: Triple.h:521
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
Definition: Triple.h:729
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
Definition: Triple.h:438
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:993
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSimulatorEnvironment() const
Definition: Triple.h:485
ObjectFormatType
Definition: Triple.h:221
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:467
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:661
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1368
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:689
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isOSVersionLT - Helper function for doing comparisons against version numbers included in the target ...
Definition: Triple.h:414
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition: Triple.h:638
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:548
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition: Triple.h:684
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition: Triple.h:699
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1168
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:219