LLVM  9.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  arc, // ARC: Synopsys ARC
53  avr, // AVR: Atmel AVR microcontroller
54  bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
55  bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
56  hexagon, // Hexagon: hexagon
57  mips, // MIPS: mips, mipsallegrex, mipsr6
58  mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
59  mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
60  mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
61  msp430, // MSP430: msp430
62  ppc, // PPC: powerpc
63  ppc64, // PPC64: powerpc64, ppu
64  ppc64le, // PPC64LE: powerpc64le
65  r600, // R600: AMD GPUs HD2XXX - HD6XXX
66  amdgcn, // AMDGCN: AMD GCN GPUs
67  riscv32, // RISC-V (32-bit): riscv32
68  riscv64, // RISC-V (64-bit): riscv64
69  sparc, // Sparc: sparc
70  sparcv9, // Sparcv9: Sparcv9
71  sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
72  systemz, // SystemZ: s390x
73  tce, // TCE (http://tce.cs.tut.fi/): tce
74  tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
75  thumb, // Thumb (little endian): thumb, thumbv.*
76  thumbeb, // Thumb (big endian): thumbeb
77  x86, // X86: i[3-9]86
78  x86_64, // X86-64: amd64, x86_64
79  xcore, // XCore: xcore
80  nvptx, // NVPTX: 32-bit
81  nvptx64, // NVPTX: 64-bit
82  le32, // le32: generic little-endian 32-bit CPU (PNaCl)
83  le64, // le64: generic little-endian 64-bit CPU (PNaCl)
84  amdil, // AMDIL
85  amdil64, // AMDIL with 64-bit pointers
86  hsail, // AMD HSAIL
87  hsail64, // AMD HSAIL with 64-bit pointers
88  spir, // SPIR: standard portable IR for OpenCL 32-bit version
89  spir64, // SPIR: standard portable IR for OpenCL 64-bit version
90  kalimba, // Kalimba: generic kalimba
91  shave, // SHAVE: Movidius vector VLIW processors
92  lanai, // Lanai: Lanai 32-bit
93  wasm32, // WebAssembly with 32-bit pointers
94  wasm64, // WebAssembly with 64-bit pointers
95  renderscript32, // 32-bit RenderScript
96  renderscript64, // 64-bit RenderScript
98  };
99  enum SubArchType {
101 
124 
128 
130  };
131  enum VendorType {
133 
135  PC,
151  };
152  enum OSType {
154 
164  Lv2, // PS3
173  NaCl, // Native Client
174  CNK, // BG/P Compute-Node Kernel
176  CUDA, // NVIDIA CUDA
177  NVCL, // NVIDIA OpenCL
178  AMDHSA, // AMD HSA Runtime
181  TvOS, // Apple tvOS
182  WatchOS, // Apple watchOS
185  AMDPAL, // AMD PAL Runtime
186  HermitCore, // HermitCore Unikernel/Multikernel
187  Hurd, // GNU/Hurd
188  WASI, // Experimental WebAssembly OS
191  };
194 
208 
213  Simulator, // Simulator variants of other systems, e.g., Apple's iOS
215  };
218 
224  };
225 
226 private:
227  std::string Data;
228 
229  /// The parsed arch type.
230  ArchType Arch;
231 
232  /// The parsed subarchitecture type.
233  SubArchType SubArch;
234 
235  /// The parsed vendor type.
236  VendorType Vendor;
237 
238  /// The parsed OS type.
239  OSType OS;
240 
241  /// The parsed Environment type.
242  EnvironmentType Environment;
243 
244  /// The object format type.
245  ObjectFormatType ObjectFormat;
246 
247 public:
248  /// @name Constructors
249  /// @{
250 
251  /// Default constructor is the same as an empty string and leaves all
252  /// triple fields unknown.
254  : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
255  ObjectFormat() {}
256 
257  explicit Triple(const Twine &Str);
258  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
259  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
260  const Twine &EnvironmentStr);
261 
262  bool operator==(const Triple &Other) const {
263  return Arch == Other.Arch && SubArch == Other.SubArch &&
264  Vendor == Other.Vendor && OS == Other.OS &&
265  Environment == Other.Environment &&
266  ObjectFormat == Other.ObjectFormat;
267  }
268 
269  bool operator!=(const Triple &Other) const {
270  return !(*this == Other);
271  }
272 
273  /// @}
274  /// @name Normalization
275  /// @{
276 
277  /// normalize - Turn an arbitrary machine specification into the canonical
278  /// triple form (or something sensible that the Triple class understands if
279  /// nothing better can reasonably be done). In particular, it handles the
280  /// common case in which otherwise valid components are in the wrong order.
281  static std::string normalize(StringRef Str);
282 
283  /// Return the normalized form of this triple's string.
284  std::string normalize() const { return normalize(Data); }
285 
286  /// @}
287  /// @name Typed Component Access
288  /// @{
289 
290  /// getArch - Get the parsed architecture type of this triple.
291  ArchType getArch() const { return Arch; }
292 
293  /// getSubArch - get the parsed subarchitecture type for this triple.
294  SubArchType getSubArch() const { return SubArch; }
295 
296  /// getVendor - Get the parsed vendor type of this triple.
297  VendorType getVendor() const { return Vendor; }
298 
299  /// getOS - Get the parsed operating system type of this triple.
300  OSType getOS() const { return OS; }
301 
302  /// hasEnvironment - Does this triple have the optional environment
303  /// (fourth) component?
304  bool hasEnvironment() const {
305  return getEnvironmentName() != "";
306  }
307 
308  /// getEnvironment - Get the parsed environment type of this triple.
309  EnvironmentType getEnvironment() const { return Environment; }
310 
311  /// Parse the version number from the OS name component of the
312  /// triple, if present.
313  ///
314  /// For example, "fooos1.2.3" would return (1, 2, 3).
315  ///
316  /// If an entry is not defined, it will be returned as 0.
317  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
318  unsigned &Micro) const;
319 
320  /// getFormat - Get the object format for this triple.
321  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
322 
323  /// getOSVersion - Parse the version number from the OS name component of the
324  /// triple, if present.
325  ///
326  /// For example, "fooos1.2.3" would return (1, 2, 3).
327  ///
328  /// If an entry is not defined, it will be returned as 0.
329  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
330 
331  /// getOSMajorVersion - Return just the major version number, this is
332  /// specialized because it is a common query.
333  unsigned getOSMajorVersion() const {
334  unsigned Maj, Min, Micro;
335  getOSVersion(Maj, Min, Micro);
336  return Maj;
337  }
338 
339  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
340  /// translate generic "darwin" versions to the corresponding OS X versions.
341  /// This may also be called with IOS triples but the OS X version number is
342  /// just set to a constant 10.4.0 in that case. Returns true if successful.
343  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
344  unsigned &Micro) const;
345 
346  /// getiOSVersion - Parse the version number as with getOSVersion. This should
347  /// only be called with IOS or generic triples.
348  void getiOSVersion(unsigned &Major, unsigned &Minor,
349  unsigned &Micro) const;
350 
351  /// getWatchOSVersion - Parse the version number as with getOSVersion. This
352  /// should only be called with WatchOS or generic triples.
353  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
354  unsigned &Micro) const;
355 
356  /// @}
357  /// @name Direct Component Access
358  /// @{
359 
360  const std::string &str() const { return Data; }
361 
362  const std::string &getTriple() const { return Data; }
363 
364  /// getArchName - Get the architecture (first) component of the
365  /// triple.
366  StringRef getArchName() const;
367 
368  /// getVendorName - Get the vendor (second) component of the triple.
369  StringRef getVendorName() const;
370 
371  /// getOSName - Get the operating system (third) component of the
372  /// triple.
373  StringRef getOSName() const;
374 
375  /// getEnvironmentName - Get the optional environment (fourth)
376  /// component of the triple, or "" if empty.
378 
379  /// getOSAndEnvironmentName - Get the operating system and optional
380  /// environment components as a single string (separated by a '-'
381  /// if the environment component is present).
383 
384  /// @}
385  /// @name Convenience Predicates
386  /// @{
387 
388  /// Test whether the architecture is 64-bit
389  ///
390  /// Note that this tests for 64-bit pointer width, and nothing else. Note
391  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
392  /// 16-bit. The inner details of pointer width for particular architectures
393  /// is not summed up in the triple, and so only a coarse grained predicate
394  /// system is provided.
395  bool isArch64Bit() const;
396 
397  /// Test whether the architecture is 32-bit
398  ///
399  /// Note that this tests for 32-bit pointer width, and nothing else.
400  bool isArch32Bit() const;
401 
402  /// Test whether the architecture is 16-bit
403  ///
404  /// Note that this tests for 16-bit pointer width, and nothing else.
405  bool isArch16Bit() const;
406 
407  /// isOSVersionLT - Helper function for doing comparisons against version
408  /// numbers included in the target triple.
409  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
410  unsigned Micro = 0) const {
411  unsigned LHS[3];
412  getOSVersion(LHS[0], LHS[1], LHS[2]);
413 
414  if (LHS[0] != Major)
415  return LHS[0] < Major;
416  if (LHS[1] != Minor)
417  return LHS[1] < Minor;
418  if (LHS[2] != Micro)
419  return LHS[2] < Micro;
420 
421  return false;
422  }
423 
424  bool isOSVersionLT(const Triple &Other) const {
425  unsigned RHS[3];
426  Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
427  return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
428  }
429 
430  /// isMacOSXVersionLT - Comparison function for checking OS X version
431  /// compatibility, which handles supporting skewed version numbering schemes
432  /// used by the "darwin" triples.
433  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
434  unsigned Micro = 0) const {
435  assert(isMacOSX() && "Not an OS X triple!");
436 
437  // If this is OS X, expect a sane version number.
438  if (getOS() == Triple::MacOSX)
439  return isOSVersionLT(Major, Minor, Micro);
440 
441  // Otherwise, compare to the "Darwin" number.
442  assert(Major == 10 && "Unexpected major version");
443  return isOSVersionLT(Minor + 4, Micro, 0);
444  }
445 
446  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
447  /// "darwin" and "osx" as OS X triples.
448  bool isMacOSX() const {
449  return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
450  }
451 
452  /// Is this an iOS triple.
453  /// Note: This identifies tvOS as a variant of iOS. If that ever
454  /// changes, i.e., if the two operating systems diverge or their version
455  /// numbers get out of sync, that will need to be changed.
456  /// watchOS has completely different version numbers so it is not included.
457  bool isiOS() const {
458  return getOS() == Triple::IOS || isTvOS();
459  }
460 
461  /// Is this an Apple tvOS triple.
462  bool isTvOS() const {
463  return getOS() == Triple::TvOS;
464  }
465 
466  /// Is this an Apple watchOS triple.
467  bool isWatchOS() const {
468  return getOS() == Triple::WatchOS;
469  }
470 
471  bool isWatchABI() const {
473  }
474 
475  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
476  bool isOSDarwin() const {
477  return isMacOSX() || isiOS() || isWatchOS();
478  }
479 
480  bool isSimulatorEnvironment() const {
481  return getEnvironment() == Triple::Simulator;
482  }
483 
484  bool isOSNetBSD() const {
485  return getOS() == Triple::NetBSD;
486  }
487 
488  bool isOSOpenBSD() const {
489  return getOS() == Triple::OpenBSD;
490  }
491 
492  bool isOSFreeBSD() const {
493  return getOS() == Triple::FreeBSD;
494  }
495 
496  bool isOSFuchsia() const {
497  return getOS() == Triple::Fuchsia;
498  }
499 
500  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
501 
502  bool isOSSolaris() const {
503  return getOS() == Triple::Solaris;
504  }
505 
506  bool isOSIAMCU() const {
507  return getOS() == Triple::ELFIAMCU;
508  }
509 
510  bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
511 
512  bool isGNUEnvironment() const {
514  return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
515  Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
516  Env == Triple::GNUEABIHF || Env == Triple::GNUX32;
517  }
518 
519  bool isOSContiki() const {
520  return getOS() == Triple::Contiki;
521  }
522 
523  /// Tests whether the OS is Haiku.
524  bool isOSHaiku() const {
525  return getOS() == Triple::Haiku;
526  }
527 
528  /// Tests whether the OS is Windows.
529  bool isOSWindows() const {
530  return getOS() == Triple::Win32;
531  }
532 
533  /// Checks if the environment is MSVC.
535  return isOSWindows() && getEnvironment() == Triple::MSVC;
536  }
537 
538  /// Checks if the environment could be MSVC.
542  }
543 
545  return isOSWindows() && getEnvironment() == Triple::CoreCLR;
546  }
547 
549  return isOSWindows() && getEnvironment() == Triple::Itanium;
550  }
551 
553  return isOSWindows() && getEnvironment() == Triple::Cygnus;
554  }
555 
556  bool isWindowsGNUEnvironment() const {
557  return isOSWindows() && getEnvironment() == Triple::GNU;
558  }
559 
560  /// Tests for either Cygwin or MinGW OS
561  bool isOSCygMing() const {
563  }
564 
565  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
566  bool isOSMSVCRT() const {
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 is WASI.
592  bool isOSWASI() const {
593  return getOS() == Triple::WASI;
594  }
595 
596  /// Tests whether the OS is Emscripten.
597  bool isOSEmscripten() const {
598  return getOS() == Triple::Emscripten;
599  }
600 
601  /// Tests whether the OS uses glibc.
602  bool isOSGlibc() const {
603  return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
604  getOS() == Triple::Hurd) &&
605  !isAndroid();
606  }
607 
608  /// Tests whether the OS is AIX.
609  bool isOSAIX() const {
610  return getOS() == Triple::AIX;
611  }
612 
613  /// Tests whether the OS uses the ELF binary format.
614  bool isOSBinFormatELF() const {
615  return getObjectFormat() == Triple::ELF;
616  }
617 
618  /// Tests whether the OS uses the COFF binary format.
619  bool isOSBinFormatCOFF() const {
620  return getObjectFormat() == Triple::COFF;
621  }
622 
623  /// Tests whether the environment is MachO.
624  bool isOSBinFormatMachO() const {
625  return getObjectFormat() == Triple::MachO;
626  }
627 
628  /// Tests whether the OS uses the Wasm binary format.
629  bool isOSBinFormatWasm() const {
630  return getObjectFormat() == Triple::Wasm;
631  }
632 
633  /// Tests whether the OS uses the XCOFF binary format.
634  bool isOSBinFormatXCOFF() const {
635  return getObjectFormat() == Triple::XCOFF;
636  }
637 
638  /// Tests whether the target is the PS4 CPU
639  bool isPS4CPU() const {
640  return getArch() == Triple::x86_64 &&
641  getVendor() == Triple::SCEI &&
642  getOS() == Triple::PS4;
643  }
644 
645  /// Tests whether the target is the PS4 platform
646  bool isPS4() const {
647  return getVendor() == Triple::SCEI &&
648  getOS() == Triple::PS4;
649  }
650 
651  /// Tests whether the target is Android
652  bool isAndroid() const { return getEnvironment() == Triple::Android; }
653 
654  bool isAndroidVersionLT(unsigned Major) const {
655  assert(isAndroid() && "Not an Android triple!");
656 
657  unsigned Env[3];
658  getEnvironmentVersion(Env[0], Env[1], Env[2]);
659 
660  // 64-bit targets did not exist before API level 21 (Lollipop).
661  if (isArch64Bit() && Env[0] < 21)
662  Env[0] = 21;
663 
664  return Env[0] < Major;
665  }
666 
667  /// Tests whether the environment is musl-libc
668  bool isMusl() const {
669  return getEnvironment() == Triple::Musl ||
672  }
673 
674  /// Tests whether the target is NVPTX (32- or 64-bit).
675  bool isNVPTX() const {
676  return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
677  }
678 
679  /// Tests whether the target is Thumb (little and big endian).
680  bool isThumb() const {
681  return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
682  }
683 
684  /// Tests whether the target is ARM (little and big endian).
685  bool isARM() const {
686  return getArch() == Triple::arm || getArch() == Triple::armeb;
687  }
688 
689  /// Tests whether the target is AArch64 (little and big endian).
690  bool isAArch64() const {
692  }
693 
694  /// Tests whether the target is MIPS 32-bit (little and big endian).
695  bool isMIPS32() const {
696  return getArch() == Triple::mips || getArch() == Triple::mipsel;
697  }
698 
699  /// Tests whether the target is MIPS 64-bit (little and big endian).
700  bool isMIPS64() const {
701  return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
702  }
703 
704  /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
705  bool isMIPS() const {
706  return isMIPS32() || isMIPS64();
707  }
708 
709  /// Tests whether the target supports comdat
710  bool supportsCOMDAT() const {
711  return !isOSBinFormatMachO();
712  }
713 
714  /// Tests whether the target uses emulated TLS as default.
715  bool hasDefaultEmulatedTLS() const {
717  }
718 
719  /// @}
720  /// @name Mutators
721  /// @{
722 
723  /// setArch - Set the architecture (first) component of the triple
724  /// to a known type.
725  void setArch(ArchType Kind);
726 
727  /// setVendor - Set the vendor (second) component of the triple to a
728  /// known type.
729  void setVendor(VendorType Kind);
730 
731  /// setOS - Set the operating system (third) component of the triple
732  /// to a known type.
733  void setOS(OSType Kind);
734 
735  /// setEnvironment - Set the environment (fourth) component of the triple
736  /// to a known type.
737  void setEnvironment(EnvironmentType Kind);
738 
739  /// setObjectFormat - Set the object file format
741 
742  /// setTriple - Set all components to the new triple \p Str.
743  void setTriple(const Twine &Str);
744 
745  /// setArchName - Set the architecture (first) component of the
746  /// triple by name.
747  void setArchName(StringRef Str);
748 
749  /// setVendorName - Set the vendor (second) component of the triple
750  /// by name.
751  void setVendorName(StringRef Str);
752 
753  /// setOSName - Set the operating system (third) component of the
754  /// triple by name.
755  void setOSName(StringRef Str);
756 
757  /// setEnvironmentName - Set the optional environment (fourth)
758  /// component of the triple by name.
759  void setEnvironmentName(StringRef Str);
760 
761  /// setOSAndEnvironmentName - Set the operating system and optional
762  /// environment components with a single string.
764 
765  /// @}
766  /// @name Helpers to build variants of a particular triple.
767  /// @{
768 
769  /// Form a triple with a 32-bit variant of the current architecture.
770  ///
771  /// This can be used to move across "families" of architectures where useful.
772  ///
773  /// \returns A new triple with a 32-bit architecture or an unknown
774  /// architecture if no such variant can be found.
776 
777  /// Form a triple with a 64-bit variant of the current architecture.
778  ///
779  /// This can be used to move across "families" of architectures where useful.
780  ///
781  /// \returns A new triple with a 64-bit architecture or an unknown
782  /// architecture if no such variant can be found.
784 
785  /// Form a triple with a big endian variant of the current architecture.
786  ///
787  /// This can be used to move across "families" of architectures where useful.
788  ///
789  /// \returns A new triple with a big endian architecture or an unknown
790  /// architecture if no such variant can be found.
792 
793  /// Form a triple with a little endian 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 little endian architecture or an unknown
798  /// architecture if no such variant can be found.
800 
801  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
802  ///
803  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
804  /// string then the triple's arch name is used.
806 
807  /// Tests whether the target triple is little endian.
808  ///
809  /// \returns true if the triple is little endian, false otherwise.
810  bool isLittleEndian() const;
811 
812  /// Test whether target triples are compatible.
813  bool isCompatibleWith(const Triple &Other) const;
814 
815  /// Merge target triples.
816  std::string merge(const Triple &Other) const;
817 
818  /// @}
819  /// @name Static helpers for IDs.
820  /// @{
821 
822  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
823  static StringRef getArchTypeName(ArchType Kind);
824 
825  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
826  /// architecture. This is the prefix used by the architecture specific
827  /// builtins, and is suitable for passing to \see
828  /// Intrinsic::getIntrinsicForGCCBuiltin().
829  ///
830  /// \return - The architecture prefix, or 0 if none is defined.
831  static StringRef getArchTypePrefix(ArchType Kind);
832 
833  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
835 
836  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
837  static StringRef getOSTypeName(OSType Kind);
838 
839  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
840  /// environment.
842 
843  /// @}
844  /// @name Static helpers for converting alternate architecture names.
845  /// @{
846 
847  /// getArchTypeForLLVMName - The canonical type for the given LLVM
848  /// architecture name (e.g., "x86").
850 
851  /// @}
852 };
853 
854 } // End llvm namespace
855 
856 
857 #endif
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:476
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition: Triple.h:524
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition: Triple.h:597
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1099
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition: Triple.h:700
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:566
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:710
static StringRef getVendorTypeName(VendorType Kind)
getVendorTypeName - Get the canonical name for the Kind vendor.
Definition: Triple.cpp:148
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:448
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:614
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:300
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1157
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1284
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:467
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:304
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
Definition: Triple.cpp:1161
bool isOSFuchsia() const
Definition: Triple.h:496
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1165
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:1035
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:552
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1576
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:690
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:534
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:715
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1192
bool isOSSolaris() const
Definition: Triple.h:502
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:849
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:253
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:294
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:291
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1280
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:457
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:646
bool isOSWASI() const
Tests whether the OS is WASI.
Definition: Triple.h:592
bool isOSNetBSD() const
Definition: Triple.h:484
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:548
bool isWindowsGNUEnvironment() const
Definition: Triple.h:556
static StringRef getOSTypeName(OSType Kind)
getOSTypeName - Get the canonical name for the Kind operating system.
Definition: Triple.cpp:173
bool isWindowsCoreCLREnvironment() const
Definition: Triple.h:544
const std::string & str() const
Definition: Triple.h:360
bool isOSDragonFly() const
Definition: Triple.h:500
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:529
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:1045
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:668
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1173
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:995
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1288
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1500
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:297
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:619
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name...
Definition: Triple.cpp:1204
bool isOSOpenBSD() const
Definition: Triple.h:488
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:471
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1149
bool operator==(const Triple &Other) const
Definition: Triple.h:262
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1543
static StringRef getArchTypePrefix(ArchType Kind)
getArchTypePrefix - Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:77
bool operator!=(const Triple &Other) const
Definition: Triple.h:269
bool isAndroidVersionLT(unsigned Major) const
Definition: Triple.h:654
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
Definition: Triple.h:639
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1125
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:1181
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:624
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1196
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:333
bool isOSUnknown() const
Definition: Triple.h:510
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:609
bool isOSIAMCU() const
Definition: Triple.h:506
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:974
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:1058
bool isOSContiki() const
Definition: Triple.h:519
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:258
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:983
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:309
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1567
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:424
bool isOSFreeBSD() const
Definition: Triple.h:492
std::string normalize() const
Return the normalized form of this triple&#39;s string.
Definition: Triple.h:284
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:989
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:705
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition: Triple.h:634
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:561
const std::string & getTriple() const
Definition: Triple.h:362
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition: Triple.h:695
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:602
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1468
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition: Triple.h:680
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:321
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1209
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1276
bool isGNUEnvironment() const
Definition: Triple.h:512
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:433
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:978
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSimulatorEnvironment() const
Definition: Triple.h:480
ObjectFormatType
Definition: Triple.h:216
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:462
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:652
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1351
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:675
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:409
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition: Triple.h:629
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:539
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition: Triple.h:685
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1153
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:217