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  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
219  };
222 
228  };
229 
230 private:
231  std::string Data;
232 
233  /// The parsed arch type.
234  ArchType Arch;
235 
236  /// The parsed subarchitecture type.
237  SubArchType SubArch;
238 
239  /// The parsed vendor type.
240  VendorType Vendor;
241 
242  /// The parsed OS type.
243  OSType OS;
244 
245  /// The parsed Environment type.
246  EnvironmentType Environment;
247 
248  /// The object format type.
249  ObjectFormatType ObjectFormat;
250 
251 public:
252  /// @name Constructors
253  /// @{
254 
255  /// Default constructor is the same as an empty string and leaves all
256  /// triple fields unknown.
258  : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
259  ObjectFormat() {}
260 
261  explicit Triple(const Twine &Str);
262  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
263  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
264  const Twine &EnvironmentStr);
265 
266  bool operator==(const Triple &Other) const {
267  return Arch == Other.Arch && SubArch == Other.SubArch &&
268  Vendor == Other.Vendor && OS == Other.OS &&
269  Environment == Other.Environment &&
270  ObjectFormat == Other.ObjectFormat;
271  }
272 
273  bool operator!=(const Triple &Other) const {
274  return !(*this == Other);
275  }
276 
277  /// @}
278  /// @name Normalization
279  /// @{
280 
281  /// normalize - Turn an arbitrary machine specification into the canonical
282  /// triple form (or something sensible that the Triple class understands if
283  /// nothing better can reasonably be done). In particular, it handles the
284  /// common case in which otherwise valid components are in the wrong order.
285  static std::string normalize(StringRef Str);
286 
287  /// Return the normalized form of this triple's string.
288  std::string normalize() const { return normalize(Data); }
289 
290  /// @}
291  /// @name Typed Component Access
292  /// @{
293 
294  /// getArch - Get the parsed architecture type of this triple.
295  ArchType getArch() const { return Arch; }
296 
297  /// getSubArch - get the parsed subarchitecture type for this triple.
298  SubArchType getSubArch() const { return SubArch; }
299 
300  /// getVendor - Get the parsed vendor type of this triple.
301  VendorType getVendor() const { return Vendor; }
302 
303  /// getOS - Get the parsed operating system type of this triple.
304  OSType getOS() const { return OS; }
305 
306  /// hasEnvironment - Does this triple have the optional environment
307  /// (fourth) component?
308  bool hasEnvironment() const {
309  return getEnvironmentName() != "";
310  }
311 
312  /// getEnvironment - Get the parsed environment type of this triple.
313  EnvironmentType getEnvironment() const { return Environment; }
314 
315  /// Parse the version number from the OS name component of the
316  /// triple, if present.
317  ///
318  /// For example, "fooos1.2.3" would return (1, 2, 3).
319  ///
320  /// If an entry is not defined, it will be returned as 0.
321  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
322  unsigned &Micro) const;
323 
324  /// getFormat - Get the object format for this triple.
325  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
326 
327  /// getOSVersion - Parse the version number from the OS name component of the
328  /// triple, if present.
329  ///
330  /// For example, "fooos1.2.3" would return (1, 2, 3).
331  ///
332  /// If an entry is not defined, it will be returned as 0.
333  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
334 
335  /// getOSMajorVersion - Return just the major version number, this is
336  /// specialized because it is a common query.
337  unsigned getOSMajorVersion() const {
338  unsigned Maj, Min, Micro;
339  getOSVersion(Maj, Min, Micro);
340  return Maj;
341  }
342 
343  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
344  /// translate generic "darwin" versions to the corresponding OS X versions.
345  /// This may also be called with IOS triples but the OS X version number is
346  /// just set to a constant 10.4.0 in that case. Returns true if successful.
347  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
348  unsigned &Micro) const;
349 
350  /// getiOSVersion - Parse the version number as with getOSVersion. This should
351  /// only be called with IOS or generic triples.
352  void getiOSVersion(unsigned &Major, unsigned &Minor,
353  unsigned &Micro) const;
354 
355  /// getWatchOSVersion - Parse the version number as with getOSVersion. This
356  /// should only be called with WatchOS or generic triples.
357  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
358  unsigned &Micro) const;
359 
360  /// @}
361  /// @name Direct Component Access
362  /// @{
363 
364  const std::string &str() const { return Data; }
365 
366  const std::string &getTriple() const { return Data; }
367 
368  /// getArchName - Get the architecture (first) component of the
369  /// triple.
370  StringRef getArchName() const;
371 
372  /// getVendorName - Get the vendor (second) component of the triple.
373  StringRef getVendorName() const;
374 
375  /// getOSName - Get the operating system (third) component of the
376  /// triple.
377  StringRef getOSName() const;
378 
379  /// getEnvironmentName - Get the optional environment (fourth)
380  /// component of the triple, or "" if empty.
382 
383  /// getOSAndEnvironmentName - Get the operating system and optional
384  /// environment components as a single string (separated by a '-'
385  /// if the environment component is present).
387 
388  /// @}
389  /// @name Convenience Predicates
390  /// @{
391 
392  /// Test whether the architecture is 64-bit
393  ///
394  /// Note that this tests for 64-bit pointer width, and nothing else. Note
395  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
396  /// 16-bit. The inner details of pointer width for particular architectures
397  /// is not summed up in the triple, and so only a coarse grained predicate
398  /// system is provided.
399  bool isArch64Bit() const;
400 
401  /// Test whether the architecture is 32-bit
402  ///
403  /// Note that this tests for 32-bit pointer width, and nothing else.
404  bool isArch32Bit() const;
405 
406  /// Test whether the architecture is 16-bit
407  ///
408  /// Note that this tests for 16-bit pointer width, and nothing else.
409  bool isArch16Bit() const;
410 
411  /// isOSVersionLT - Helper function for doing comparisons against version
412  /// numbers included in the target triple.
413  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
414  unsigned Micro = 0) const {
415  unsigned LHS[3];
416  getOSVersion(LHS[0], LHS[1], LHS[2]);
417 
418  if (LHS[0] != Major)
419  return LHS[0] < Major;
420  if (LHS[1] != Minor)
421  return LHS[1] < Minor;
422  if (LHS[2] != Micro)
423  return LHS[2] < Micro;
424 
425  return false;
426  }
427 
428  bool isOSVersionLT(const Triple &Other) const {
429  unsigned RHS[3];
430  Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
431  return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
432  }
433 
434  /// isMacOSXVersionLT - Comparison function for checking OS X version
435  /// compatibility, which handles supporting skewed version numbering schemes
436  /// used by the "darwin" triples.
437  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
438  unsigned Micro = 0) const {
439  assert(isMacOSX() && "Not an OS X triple!");
440 
441  // If this is OS X, expect a sane version number.
442  if (getOS() == Triple::MacOSX)
443  return isOSVersionLT(Major, Minor, Micro);
444 
445  // Otherwise, compare to the "Darwin" number.
446  assert(Major == 10 && "Unexpected major version");
447  return isOSVersionLT(Minor + 4, Micro, 0);
448  }
449 
450  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
451  /// "darwin" and "osx" as OS X triples.
452  bool isMacOSX() const {
453  return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
454  }
455 
456  /// Is this an iOS triple.
457  /// Note: This identifies tvOS as a variant of iOS. If that ever
458  /// changes, i.e., if the two operating systems diverge or their version
459  /// numbers get out of sync, that will need to be changed.
460  /// watchOS has completely different version numbers so it is not included.
461  bool isiOS() const {
462  return getOS() == Triple::IOS || isTvOS();
463  }
464 
465  /// Is this an Apple tvOS triple.
466  bool isTvOS() const {
467  return getOS() == Triple::TvOS;
468  }
469 
470  /// Is this an Apple watchOS triple.
471  bool isWatchOS() const {
472  return getOS() == Triple::WatchOS;
473  }
474 
475  bool isWatchABI() const {
477  }
478 
479  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
480  bool isOSDarwin() const {
481  return isMacOSX() || isiOS() || isWatchOS();
482  }
483 
484  bool isSimulatorEnvironment() const {
485  return getEnvironment() == Triple::Simulator;
486  }
487 
488  bool isOSNetBSD() const {
489  return getOS() == Triple::NetBSD;
490  }
491 
492  bool isOSOpenBSD() const {
493  return getOS() == Triple::OpenBSD;
494  }
495 
496  bool isOSFreeBSD() const {
497  return getOS() == Triple::FreeBSD;
498  }
499 
500  bool isOSFuchsia() const {
501  return getOS() == Triple::Fuchsia;
502  }
503 
504  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
505 
506  bool isOSSolaris() const {
507  return getOS() == Triple::Solaris;
508  }
509 
510  bool isOSIAMCU() const {
511  return getOS() == Triple::ELFIAMCU;
512  }
513 
514  bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
515 
516  bool isGNUEnvironment() const {
518  return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
519  Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
520  Env == Triple::GNUEABIHF || Env == Triple::GNUX32;
521  }
522 
523  bool isOSContiki() const {
524  return getOS() == Triple::Contiki;
525  }
526 
527  /// Tests whether the OS is Haiku.
528  bool isOSHaiku() const {
529  return getOS() == Triple::Haiku;
530  }
531 
532  /// Tests whether the OS is Windows.
533  bool isOSWindows() const {
534  return getOS() == Triple::Win32;
535  }
536 
537  /// Checks if the environment is MSVC.
539  return isOSWindows() && getEnvironment() == Triple::MSVC;
540  }
541 
542  /// Checks if the environment could be MSVC.
546  }
547 
549  return isOSWindows() && getEnvironment() == Triple::CoreCLR;
550  }
551 
553  return isOSWindows() && getEnvironment() == Triple::Itanium;
554  }
555 
557  return isOSWindows() && getEnvironment() == Triple::Cygnus;
558  }
559 
560  bool isWindowsGNUEnvironment() const {
561  return isOSWindows() && getEnvironment() == Triple::GNU;
562  }
563 
564  /// Tests for either Cygwin or MinGW OS
565  bool isOSCygMing() const {
567  }
568 
569  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
570  bool isOSMSVCRT() const {
573  }
574 
575  /// Tests whether the OS is NaCl (Native Client)
576  bool isOSNaCl() const {
577  return getOS() == Triple::NaCl;
578  }
579 
580  /// Tests whether the OS is Linux.
581  bool isOSLinux() const {
582  return getOS() == Triple::Linux;
583  }
584 
585  /// Tests whether the OS is kFreeBSD.
586  bool isOSKFreeBSD() const {
587  return getOS() == Triple::KFreeBSD;
588  }
589 
590  /// Tests whether the OS is Hurd.
591  bool isOSHurd() const {
592  return getOS() == Triple::Hurd;
593  }
594 
595  /// Tests whether the OS is WASI.
596  bool isOSWASI() const {
597  return getOS() == Triple::WASI;
598  }
599 
600  /// Tests whether the OS is Emscripten.
601  bool isOSEmscripten() const {
602  return getOS() == Triple::Emscripten;
603  }
604 
605  /// Tests whether the OS uses glibc.
606  bool isOSGlibc() const {
607  return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
608  getOS() == Triple::Hurd) &&
609  !isAndroid();
610  }
611 
612  /// Tests whether the OS is AIX.
613  bool isOSAIX() const {
614  return getOS() == Triple::AIX;
615  }
616 
617  /// Tests whether the OS uses the ELF binary format.
618  bool isOSBinFormatELF() const {
619  return getObjectFormat() == Triple::ELF;
620  }
621 
622  /// Tests whether the OS uses the COFF binary format.
623  bool isOSBinFormatCOFF() const {
624  return getObjectFormat() == Triple::COFF;
625  }
626 
627  /// Tests whether the environment is MachO.
628  bool isOSBinFormatMachO() const {
629  return getObjectFormat() == Triple::MachO;
630  }
631 
632  /// Tests whether the OS uses the Wasm binary format.
633  bool isOSBinFormatWasm() const {
634  return getObjectFormat() == Triple::Wasm;
635  }
636 
637  /// Tests whether the OS uses the XCOFF binary format.
638  bool isOSBinFormatXCOFF() const {
639  return getObjectFormat() == Triple::XCOFF;
640  }
641 
642  /// Tests whether the target is the PS4 CPU
643  bool isPS4CPU() const {
644  return getArch() == Triple::x86_64 &&
645  getVendor() == Triple::SCEI &&
646  getOS() == Triple::PS4;
647  }
648 
649  /// Tests whether the target is the PS4 platform
650  bool isPS4() const {
651  return getVendor() == Triple::SCEI &&
652  getOS() == Triple::PS4;
653  }
654 
655  /// Tests whether the target is Android
656  bool isAndroid() const { return getEnvironment() == Triple::Android; }
657 
658  bool isAndroidVersionLT(unsigned Major) const {
659  assert(isAndroid() && "Not an Android triple!");
660 
661  unsigned Env[3];
662  getEnvironmentVersion(Env[0], Env[1], Env[2]);
663 
664  // 64-bit targets did not exist before API level 21 (Lollipop).
665  if (isArch64Bit() && Env[0] < 21)
666  Env[0] = 21;
667 
668  return Env[0] < Major;
669  }
670 
671  /// Tests whether the environment is musl-libc
672  bool isMusl() const {
673  return getEnvironment() == Triple::Musl ||
676  }
677 
678  /// Tests whether the target is SPIR (32- or 64-bit).
679  bool isSPIR() const {
680  return getArch() == Triple::spir || getArch() == Triple::spir64;
681  }
682 
683  /// Tests whether the target is NVPTX (32- or 64-bit).
684  bool isNVPTX() const {
685  return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
686  }
687 
688  /// Tests whether the target is Thumb (little and big endian).
689  bool isThumb() const {
690  return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
691  }
692 
693  /// Tests whether the target is ARM (little and big endian).
694  bool isARM() const {
695  return getArch() == Triple::arm || getArch() == Triple::armeb;
696  }
697 
698  /// Tests whether the target is AArch64 (little and big endian).
699  bool isAArch64() const {
701  }
702 
703  /// Tests whether the target is MIPS 32-bit (little and big endian).
704  bool isMIPS32() const {
705  return getArch() == Triple::mips || getArch() == Triple::mipsel;
706  }
707 
708  /// Tests whether the target is MIPS 64-bit (little and big endian).
709  bool isMIPS64() const {
710  return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
711  }
712 
713  /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
714  bool isMIPS() const {
715  return isMIPS32() || isMIPS64();
716  }
717 
718  /// Tests whether the target is 64-bit PowerPC (little and big endian).
719  bool isPPC64() const {
720  return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
721  }
722 
723  /// Tests whether the target supports comdat
724  bool supportsCOMDAT() const {
725  return !isOSBinFormatMachO();
726  }
727 
728  /// Tests whether the target uses emulated TLS as default.
729  bool hasDefaultEmulatedTLS() const {
731  }
732 
733  /// @}
734  /// @name Mutators
735  /// @{
736 
737  /// setArch - Set the architecture (first) component of the triple
738  /// to a known type.
739  void setArch(ArchType Kind);
740 
741  /// setVendor - Set the vendor (second) component of the triple to a
742  /// known type.
743  void setVendor(VendorType Kind);
744 
745  /// setOS - Set the operating system (third) component of the triple
746  /// to a known type.
747  void setOS(OSType Kind);
748 
749  /// setEnvironment - Set the environment (fourth) component of the triple
750  /// to a known type.
751  void setEnvironment(EnvironmentType Kind);
752 
753  /// setObjectFormat - Set the object file format
755 
756  /// setTriple - Set all components to the new triple \p Str.
757  void setTriple(const Twine &Str);
758 
759  /// setArchName - Set the architecture (first) component of the
760  /// triple by name.
761  void setArchName(StringRef Str);
762 
763  /// setVendorName - Set the vendor (second) component of the triple
764  /// by name.
765  void setVendorName(StringRef Str);
766 
767  /// setOSName - Set the operating system (third) component of the
768  /// triple by name.
769  void setOSName(StringRef Str);
770 
771  /// setEnvironmentName - Set the optional environment (fourth)
772  /// component of the triple by name.
773  void setEnvironmentName(StringRef Str);
774 
775  /// setOSAndEnvironmentName - Set the operating system and optional
776  /// environment components with a single string.
778 
779  /// @}
780  /// @name Helpers to build variants of a particular triple.
781  /// @{
782 
783  /// Form a triple with a 32-bit variant of the current architecture.
784  ///
785  /// This can be used to move across "families" of architectures where useful.
786  ///
787  /// \returns A new triple with a 32-bit architecture or an unknown
788  /// architecture if no such variant can be found.
790 
791  /// Form a triple with a 64-bit variant of the current architecture.
792  ///
793  /// This can be used to move across "families" of architectures where useful.
794  ///
795  /// \returns A new triple with a 64-bit architecture or an unknown
796  /// architecture if no such variant can be found.
798 
799  /// Form a triple with a big endian variant of the current architecture.
800  ///
801  /// This can be used to move across "families" of architectures where useful.
802  ///
803  /// \returns A new triple with a big endian architecture or an unknown
804  /// architecture if no such variant can be found.
806 
807  /// Form a triple with a little endian variant of the current architecture.
808  ///
809  /// This can be used to move across "families" of architectures where useful.
810  ///
811  /// \returns A new triple with a little endian architecture or an unknown
812  /// architecture if no such variant can be found.
814 
815  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
816  ///
817  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
818  /// string then the triple's arch name is used.
820 
821  /// Tests whether the target triple is little endian.
822  ///
823  /// \returns true if the triple is little endian, false otherwise.
824  bool isLittleEndian() const;
825 
826  /// Test whether target triples are compatible.
827  bool isCompatibleWith(const Triple &Other) const;
828 
829  /// Merge target triples.
830  std::string merge(const Triple &Other) const;
831 
832  /// @}
833  /// @name Static helpers for IDs.
834  /// @{
835 
836  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
837  static StringRef getArchTypeName(ArchType Kind);
838 
839  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
840  /// architecture. This is the prefix used by the architecture specific
841  /// builtins, and is suitable for passing to \see
842  /// Intrinsic::getIntrinsicForGCCBuiltin().
843  ///
844  /// \return - The architecture prefix, or 0 if none is defined.
845  static StringRef getArchTypePrefix(ArchType Kind);
846 
847  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
849 
850  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
851  static StringRef getOSTypeName(OSType Kind);
852 
853  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
854  /// environment.
856 
857  /// @}
858  /// @name Static helpers for converting alternate architecture names.
859  /// @{
860 
861  /// getArchTypeForLLVMName - The canonical type for the given LLVM
862  /// architecture name (e.g., "x86").
864 
865  /// @}
866 };
867 
868 } // End llvm namespace
869 
870 
871 #endif
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:480
bool isOSHaiku() const
Tests whether the OS is Haiku.
Definition: Triple.h:528
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition: Triple.h:601
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1112
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition: Triple.h:709
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:570
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:724
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:452
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:618
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:304
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1170
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1298
bool isOSNaCl() const
Tests whether the OS is NaCl (Native Client)
Definition: Triple.h:576
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:471
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:308
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
Definition: Triple.cpp:1174
bool isOSFuchsia() const
Definition: Triple.h:500
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1178
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:1048
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:556
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1593
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:699
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:538
bool isOSHurd() const
Tests whether the OS is Hurd.
Definition: Triple.h:591
bool hasDefaultEmulatedTLS() const
Tests whether the target uses emulated TLS as default.
Definition: Triple.h:729
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1205
bool isOSSolaris() const
Definition: Triple.h:506
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:870
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:257
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:298
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:295
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1294
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:461
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:650
bool isOSWASI() const
Tests whether the OS is WASI.
Definition: Triple.h:596
bool isOSNetBSD() const
Definition: Triple.h:488
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:552
bool isWindowsGNUEnvironment() const
Definition: Triple.h:560
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:548
const std::string & str() const
Definition: Triple.h:364
bool isOSDragonFly() const
Definition: Triple.h:504
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:533
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:1058
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:672
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1186
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:1008
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1302
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1516
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:301
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:623
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name...
Definition: Triple.cpp:1217
bool isOSOpenBSD() const
Definition: Triple.h:492
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1430
bool isWatchABI() const
Definition: Triple.h:475
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1162
bool operator==(const Triple &Other) const
Definition: Triple.h:266
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1560
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:273
bool isAndroidVersionLT(unsigned Major) const
Definition: Triple.h:658
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
Definition: Triple.h:643
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1138
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition: Triple.h:586
void setArchName(StringRef Str)
setArchName - Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1194
bool isPPC64() const
Tests whether the target is 64-bit PowerPC (little and big endian).
Definition: Triple.h:719
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:628
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1209
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:337
bool isOSUnknown() const
Definition: Triple.h:514
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:613
bool isOSIAMCU() const
Definition: Triple.h:510
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:987
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:1071
bool isOSContiki() const
Definition: Triple.h:523
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:262
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:996
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:581
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:313
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1584
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:428
bool isOSFreeBSD() const
Definition: Triple.h:496
std::string normalize() const
Return the normalized form of this triple&#39;s string.
Definition: Triple.h:288
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:1002
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:714
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
Definition: Triple.h:638
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:565
const std::string & getTriple() const
Definition: Triple.h:366
bool isMIPS32() const
Tests whether the target is MIPS 32-bit (little and big endian).
Definition: Triple.h:704
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:606
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1484
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
Definition: Triple.h:689
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:325
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1222
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1290
bool isGNUEnvironment() const
Definition: Triple.h:516
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:437
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:991
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSimulatorEnvironment() const
Definition: Triple.h:484
ObjectFormatType
Definition: Triple.h:220
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:466
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:656
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1366
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:684
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:413
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition: Triple.h:633
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:543
bool isSPIR() const
Tests whether the target is SPIR (32- or 64-bit).
Definition: Triple.h:679
bool isARM() const
Tests whether the target is ARM (little and big endian).
Definition: Triple.h:694
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1166
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:219