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