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