LLVM  5.0.0
Triple.h
Go to the documentation of this file.
1 //===-- llvm/ADT/Triple.h - Target triple helper class ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_ADT_TRIPLE_H
11 #define LLVM_ADT_TRIPLE_H
12 
13 #include "llvm/ADT/Twine.h"
14 
15 // Some system headers or GCC predefined macros conflict with identifiers in
16 // this file. Undefine them here.
17 #undef NetBSD
18 #undef mips
19 #undef sparc
20 
21 namespace llvm {
22 
23 /// Triple - Helper class for working with autoconf configuration names. For
24 /// historical reasons, we also call these 'triples' (they used to contain
25 /// exactly three fields).
26 ///
27 /// Configuration names are strings in the canonical form:
28 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM
29 /// or
30 /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
31 ///
32 /// This class is used for clients which want to support arbitrary
33 /// configuration names, but also want to implement certain special
34 /// behavior for particular configurations. This class isolates the mapping
35 /// from the components of the configuration name to well known IDs.
36 ///
37 /// At its core the Triple class is designed to be a wrapper for a triple
38 /// string; the constructor does not change or normalize the triple string.
39 /// Clients that need to handle the non-canonical triples that users often
40 /// specify should use the normalize method.
41 ///
42 /// See autoconf/config.guess for a glimpse into what configuration names
43 /// look like in practice.
44 class Triple {
45 public:
46  enum ArchType {
48 
49  arm, // ARM (little endian): arm, armv.*, xscale
50  armeb, // ARM (big endian): armeb
51  aarch64, // AArch64 (little endian): aarch64
52  aarch64_be, // AArch64 (big endian): aarch64_be
53  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
58  mipsel, // MIPSEL: mipsel, mipsallegrexel
59  mips64, // MIPS64: mips64
60  mips64el, // MIPS64EL: mips64el
61  msp430, // MSP430: msp430
62  nios2, // NIOSII: nios2
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 
122 
126  };
127  enum VendorType {
129 
131  PC,
146  };
147  enum OSType {
149 
159  Lv2, // PS3
168  NaCl, // Native Client
169  CNK, // BG/P Compute-Node Kernel
172  CUDA, // NVIDIA CUDA
173  NVCL, // NVIDIA OpenCL
174  AMDHSA, // AMD HSA Runtime
177  TvOS, // Apple tvOS
178  WatchOS, // Apple watchOS
182  };
185 
198 
206  };
209 
214  };
215 
216 private:
217  std::string Data;
218 
219  /// The parsed arch type.
220  ArchType Arch;
221 
222  /// The parsed subarchitecture type.
223  SubArchType SubArch;
224 
225  /// The parsed vendor type.
226  VendorType Vendor;
227 
228  /// The parsed OS type.
229  OSType OS;
230 
231  /// The parsed Environment type.
232  EnvironmentType Environment;
233 
234  /// The object format type.
235  ObjectFormatType ObjectFormat;
236 
237 public:
238  /// @name Constructors
239  /// @{
240 
241  /// Default constructor is the same as an empty string and leaves all
242  /// triple fields unknown.
244  : Data(), Arch(), SubArch(), Vendor(), OS(), Environment(),
245  ObjectFormat() {}
246 
247  explicit Triple(const Twine &Str);
248  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
249  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
250  const Twine &EnvironmentStr);
251 
252  bool operator==(const Triple &Other) const {
253  return Arch == Other.Arch && SubArch == Other.SubArch &&
254  Vendor == Other.Vendor && OS == Other.OS &&
255  Environment == Other.Environment &&
256  ObjectFormat == Other.ObjectFormat;
257  }
258 
259  bool operator!=(const Triple &Other) const {
260  return !(*this == Other);
261  }
262 
263  /// @}
264  /// @name Normalization
265  /// @{
266 
267  /// normalize - Turn an arbitrary machine specification into the canonical
268  /// triple form (or something sensible that the Triple class understands if
269  /// nothing better can reasonably be done). In particular, it handles the
270  /// common case in which otherwise valid components are in the wrong order.
271  static std::string normalize(StringRef Str);
272 
273  /// Return the normalized form of this triple's string.
274  std::string normalize() const { return normalize(Data); }
275 
276  /// @}
277  /// @name Typed Component Access
278  /// @{
279 
280  /// getArch - Get the parsed architecture type of this triple.
281  ArchType getArch() const { return Arch; }
282 
283  /// getSubArch - get the parsed subarchitecture type for this triple.
284  SubArchType getSubArch() const { return SubArch; }
285 
286  /// getVendor - Get the parsed vendor type of this triple.
287  VendorType getVendor() const { return Vendor; }
288 
289  /// getOS - Get the parsed operating system type of this triple.
290  OSType getOS() const { return OS; }
291 
292  /// hasEnvironment - Does this triple have the optional environment
293  /// (fourth) component?
294  bool hasEnvironment() const {
295  return getEnvironmentName() != "";
296  }
297 
298  /// getEnvironment - Get the parsed environment type of this triple.
299  EnvironmentType getEnvironment() const { return Environment; }
300 
301  /// Parse the version number from the OS name component of the
302  /// triple, if present.
303  ///
304  /// For example, "fooos1.2.3" would return (1, 2, 3).
305  ///
306  /// If an entry is not defined, it will be returned as 0.
307  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
308  unsigned &Micro) const;
309 
310  /// getFormat - Get the object format for this triple.
311  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
312 
313  /// getOSVersion - Parse the version number from the OS name component of the
314  /// triple, if present.
315  ///
316  /// For example, "fooos1.2.3" would return (1, 2, 3).
317  ///
318  /// If an entry is not defined, it will be returned as 0.
319  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
320 
321  /// getOSMajorVersion - Return just the major version number, this is
322  /// specialized because it is a common query.
323  unsigned getOSMajorVersion() const {
324  unsigned Maj, Min, Micro;
325  getOSVersion(Maj, Min, Micro);
326  return Maj;
327  }
328 
329  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
330  /// translate generic "darwin" versions to the corresponding OS X versions.
331  /// This may also be called with IOS triples but the OS X version number is
332  /// just set to a constant 10.4.0 in that case. Returns true if successful.
333  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
334  unsigned &Micro) const;
335 
336  /// getiOSVersion - Parse the version number as with getOSVersion. This should
337  /// only be called with IOS or generic triples.
338  void getiOSVersion(unsigned &Major, unsigned &Minor,
339  unsigned &Micro) const;
340 
341  /// getWatchOSVersion - Parse the version number as with getOSVersion. This
342  /// should only be called with WatchOS or generic triples.
343  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
344  unsigned &Micro) const;
345 
346  /// @}
347  /// @name Direct Component Access
348  /// @{
349 
350  const std::string &str() const { return Data; }
351 
352  const std::string &getTriple() const { return Data; }
353 
354  /// getArchName - Get the architecture (first) component of the
355  /// triple.
356  StringRef getArchName() const;
357 
358  /// getVendorName - Get the vendor (second) component of the triple.
359  StringRef getVendorName() const;
360 
361  /// getOSName - Get the operating system (third) component of the
362  /// triple.
363  StringRef getOSName() const;
364 
365  /// getEnvironmentName - Get the optional environment (fourth)
366  /// component of the triple, or "" if empty.
368 
369  /// getOSAndEnvironmentName - Get the operating system and optional
370  /// environment components as a single string (separated by a '-'
371  /// if the environment component is present).
373 
374  /// @}
375  /// @name Convenience Predicates
376  /// @{
377 
378  /// Test whether the architecture is 64-bit
379  ///
380  /// Note that this tests for 64-bit pointer width, and nothing else. Note
381  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
382  /// 16-bit. The inner details of pointer width for particular architectures
383  /// is not summed up in the triple, and so only a coarse grained predicate
384  /// system is provided.
385  bool isArch64Bit() const;
386 
387  /// Test whether the architecture is 32-bit
388  ///
389  /// Note that this tests for 32-bit pointer width, and nothing else.
390  bool isArch32Bit() const;
391 
392  /// Test whether the architecture is 16-bit
393  ///
394  /// Note that this tests for 16-bit pointer width, and nothing else.
395  bool isArch16Bit() const;
396 
397  /// isOSVersionLT - Helper function for doing comparisons against version
398  /// numbers included in the target triple.
399  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
400  unsigned Micro = 0) const {
401  unsigned LHS[3];
402  getOSVersion(LHS[0], LHS[1], LHS[2]);
403 
404  if (LHS[0] != Major)
405  return LHS[0] < Major;
406  if (LHS[1] != Minor)
407  return LHS[1] < Minor;
408  if (LHS[2] != Micro)
409  return LHS[1] < Micro;
410 
411  return false;
412  }
413 
414  bool isOSVersionLT(const Triple &Other) const {
415  unsigned RHS[3];
416  Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
417  return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
418  }
419 
420  /// isMacOSXVersionLT - Comparison function for checking OS X version
421  /// compatibility, which handles supporting skewed version numbering schemes
422  /// used by the "darwin" triples.
423  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
424  unsigned Micro = 0) const {
425  assert(isMacOSX() && "Not an OS X triple!");
426 
427  // If this is OS X, expect a sane version number.
428  if (getOS() == Triple::MacOSX)
429  return isOSVersionLT(Major, Minor, Micro);
430 
431  // Otherwise, compare to the "Darwin" number.
432  assert(Major == 10 && "Unexpected major version");
433  return isOSVersionLT(Minor + 4, Micro, 0);
434  }
435 
436  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
437  /// "darwin" and "osx" as OS X triples.
438  bool isMacOSX() const {
439  return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
440  }
441 
442  /// Is this an iOS triple.
443  /// Note: This identifies tvOS as a variant of iOS. If that ever
444  /// changes, i.e., if the two operating systems diverge or their version
445  /// numbers get out of sync, that will need to be changed.
446  /// watchOS has completely different version numbers so it is not included.
447  bool isiOS() const {
448  return getOS() == Triple::IOS || isTvOS();
449  }
450 
451  /// Is this an Apple tvOS triple.
452  bool isTvOS() const {
453  return getOS() == Triple::TvOS;
454  }
455 
456  /// Is this an Apple watchOS triple.
457  bool isWatchOS() const {
458  return getOS() == Triple::WatchOS;
459  }
460 
461  bool isWatchABI() const {
463  }
464 
465  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
466  bool isOSDarwin() const {
467  return isMacOSX() || isiOS() || isWatchOS();
468  }
469 
470  bool isOSNetBSD() const {
471  return getOS() == Triple::NetBSD;
472  }
473 
474  bool isOSOpenBSD() const {
475  return getOS() == Triple::OpenBSD;
476  }
477 
478  bool isOSFreeBSD() const {
479  return getOS() == Triple::FreeBSD;
480  }
481 
482  bool isOSFuchsia() const {
483  return getOS() == Triple::Fuchsia;
484  }
485 
486  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
487 
488  bool isOSSolaris() const {
489  return getOS() == Triple::Solaris;
490  }
491 
492  bool isOSBitrig() const {
493  return getOS() == Triple::Bitrig;
494  }
495 
496  bool isOSIAMCU() const {
497  return getOS() == Triple::ELFIAMCU;
498  }
499 
500  bool isGNUEnvironment() const {
502  return Env == Triple::GNU || Env == Triple::GNUABI64 ||
503  Env == Triple::GNUEABI || Env == Triple::GNUEABIHF ||
504  Env == Triple::GNUX32;
505  }
506 
507  bool isOSContiki() const {
508  return getOS() == Triple::Contiki;
509  }
510 
511  /// Checks if the environment could be MSVC.
513  return getOS() == Triple::Win32 &&
516  }
517 
518  /// Checks if the environment is MSVC.
520  return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
521  }
522 
525  }
526 
529  }
530 
532  return getOS() == Triple::Win32 && getEnvironment() == Triple::Cygnus;
533  }
534 
535  bool isWindowsGNUEnvironment() const {
536  return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU;
537  }
538 
539  /// Tests for either Cygwin or MinGW OS
540  bool isOSCygMing() const {
542  }
543 
544  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
545  bool isOSMSVCRT() const {
548  }
549 
550  /// Tests whether the OS is Windows.
551  bool isOSWindows() const {
552  return getOS() == Triple::Win32;
553  }
554 
555  /// Tests whether the OS is NaCl (Native Client)
556  bool isOSNaCl() const {
557  return getOS() == Triple::NaCl;
558  }
559 
560  /// Tests whether the OS is Linux.
561  bool isOSLinux() const {
562  return getOS() == Triple::Linux;
563  }
564 
565  /// Tests whether the OS is kFreeBSD.
566  bool isOSKFreeBSD() const {
567  return getOS() == Triple::KFreeBSD;
568  }
569 
570  /// Tests whether the OS uses glibc.
571  bool isOSGlibc() const {
572  return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD) &&
573  !isAndroid();
574  }
575 
576  /// Tests whether the OS uses the ELF binary format.
577  bool isOSBinFormatELF() const {
578  return getObjectFormat() == Triple::ELF;
579  }
580 
581  /// Tests whether the OS uses the COFF binary format.
582  bool isOSBinFormatCOFF() const {
583  return getObjectFormat() == Triple::COFF;
584  }
585 
586  /// Tests whether the environment is MachO.
587  bool isOSBinFormatMachO() const {
588  return getObjectFormat() == Triple::MachO;
589  }
590 
591  /// Tests whether the OS uses the Wasm binary format.
592  bool isOSBinFormatWasm() const {
593  return getObjectFormat() == Triple::Wasm;
594  }
595 
596  /// Tests whether the target is the PS4 CPU
597  bool isPS4CPU() const {
598  return getArch() == Triple::x86_64 &&
599  getVendor() == Triple::SCEI &&
600  getOS() == Triple::PS4;
601  }
602 
603  /// Tests whether the target is the PS4 platform
604  bool isPS4() const {
605  return getVendor() == Triple::SCEI &&
606  getOS() == Triple::PS4;
607  }
608 
609  /// Tests whether the target is Android
610  bool isAndroid() const { return getEnvironment() == Triple::Android; }
611 
612  bool isAndroidVersionLT(unsigned Major) const {
613  assert(isAndroid() && "Not an Android triple!");
614 
615  unsigned Env[3];
616  getEnvironmentVersion(Env[0], Env[1], Env[2]);
617 
618  // 64-bit targets did not exist before API level 21 (Lollipop).
619  if (isArch64Bit() && Env[0] < 21)
620  Env[0] = 21;
621 
622  return Env[0] < Major;
623  }
624 
625  /// Tests whether the environment is musl-libc
626  bool isMusl() const {
627  return getEnvironment() == Triple::Musl ||
630  }
631 
632  /// Tests whether the target is NVPTX (32- or 64-bit).
633  bool isNVPTX() const {
634  return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
635  }
636 
637  /// Tests wether the target supports comdat
638  bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
639 
640  /// @}
641  /// @name Mutators
642  /// @{
643 
644  /// setArch - Set the architecture (first) component of the triple
645  /// to a known type.
646  void setArch(ArchType Kind);
647 
648  /// setVendor - Set the vendor (second) component of the triple to a
649  /// known type.
650  void setVendor(VendorType Kind);
651 
652  /// setOS - Set the operating system (third) component of the triple
653  /// to a known type.
654  void setOS(OSType Kind);
655 
656  /// setEnvironment - Set the environment (fourth) component of the triple
657  /// to a known type.
659 
660  /// setObjectFormat - Set the object file format
662 
663  /// setTriple - Set all components to the new triple \p Str.
664  void setTriple(const Twine &Str);
665 
666  /// setArchName - Set the architecture (first) component of the
667  /// triple by name.
668  void setArchName(StringRef Str);
669 
670  /// setVendorName - Set the vendor (second) component of the triple
671  /// by name.
672  void setVendorName(StringRef Str);
673 
674  /// setOSName - Set the operating system (third) component of the
675  /// triple by name.
676  void setOSName(StringRef Str);
677 
678  /// setEnvironmentName - Set the optional environment (fourth)
679  /// component of the triple by name.
680  void setEnvironmentName(StringRef Str);
681 
682  /// setOSAndEnvironmentName - Set the operating system and optional
683  /// environment components with a single string.
685 
686  /// @}
687  /// @name Helpers to build variants of a particular triple.
688  /// @{
689 
690  /// Form a triple with a 32-bit variant of the current architecture.
691  ///
692  /// This can be used to move across "families" of architectures where useful.
693  ///
694  /// \returns A new triple with a 32-bit architecture or an unknown
695  /// architecture if no such variant can be found.
697 
698  /// Form a triple with a 64-bit variant of the current architecture.
699  ///
700  /// This can be used to move across "families" of architectures where useful.
701  ///
702  /// \returns A new triple with a 64-bit architecture or an unknown
703  /// architecture if no such variant can be found.
705 
706  /// Form a triple with a big endian variant of the current architecture.
707  ///
708  /// This can be used to move across "families" of architectures where useful.
709  ///
710  /// \returns A new triple with a big endian architecture or an unknown
711  /// architecture if no such variant can be found.
713 
714  /// Form a triple with a little endian variant of the current architecture.
715  ///
716  /// This can be used to move across "families" of architectures where useful.
717  ///
718  /// \returns A new triple with a little endian architecture or an unknown
719  /// architecture if no such variant can be found.
721 
722  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
723  ///
724  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
725  /// string then the triple's arch name is used.
727 
728  /// Tests whether the target triple is little endian.
729  ///
730  /// \returns true if the triple is little endian, false otherwise.
731  bool isLittleEndian() const;
732 
733  /// Test whether target triples are compatible.
734  bool isCompatibleWith(const Triple &Other) const;
735 
736  /// Merge target triples.
737  std::string merge(const Triple &Other) const;
738 
739  /// @}
740  /// @name Static helpers for IDs.
741  /// @{
742 
743  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
745 
746  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
747  /// architecture. This is the prefix used by the architecture specific
748  /// builtins, and is suitable for passing to \see
749  /// Intrinsic::getIntrinsicForGCCBuiltin().
750  ///
751  /// \return - The architecture prefix, or 0 if none is defined.
753 
754  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
756 
757  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
759 
760  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
761  /// environment.
763 
764  /// @}
765  /// @name Static helpers for converting alternate architecture names.
766  /// @{
767 
768  /// getArchTypeForLLVMName - The canonical type for the given LLVM
769  /// architecture name (e.g., "x86").
771 
772  /// @}
773 };
774 
775 } // End llvm namespace
776 
777 
778 #endif
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:290
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition: Triple.h:566
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:323
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:587
static StringRef getVendorTypeName(VendorType Kind)
getVendorTypeName - Get the canonical name for the Kind vendor.
Definition: Triple.cpp:149
bool isOSContiki() const
Definition: Triple.h:507
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1104
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1072
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:423
const std::string & str() const
Definition: Triple.h:350
bool isOSIAMCU() const
Definition: Triple.h:496
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
Definition: Triple.cpp:1108
bool isOSDragonFly() const
Definition: Triple.h:486
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1112
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1361
bool supportsCOMDAT() const
Tests wether the target supports comdat.
Definition: Triple.h:638
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:610
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:551
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:540
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:438
bool isAndroidVersionLT(unsigned Major) const
Definition: Triple.h:612
bool isOSBitrig() const
Definition: Triple.h:492
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
static StringRef getArchTypeName(ArchType Kind)
getArchTypeName - Get the canonical name for the Kind architecture.
Definition: Triple.cpp:20
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:311
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1139
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:243
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:512
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1223
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:561
bool isOSNaCl() const
Tests whether the OS is NaCl (Native Client)
Definition: Triple.h:556
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:942
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:281
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:452
static StringRef getOSTypeName(OSType Kind)
getOSTypeName - Get the canonical name for the Kind operating system.
Definition: Triple.cpp:173
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:284
bool isOSNetBSD() const
Definition: Triple.h:470
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1235
T Min(T a, T b)
Definition: FuzzerDefs.h:90
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:447
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:936
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1120
bool isWindowsGNUEnvironment() const
Definition: Triple.h:535
bool isOSBinFormatWasm() const
Tests whether the OS uses the Wasm binary format.
Definition: Triple.h:592
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name...
Definition: Triple.cpp:1151
const std::string & getTriple() const
Definition: Triple.h:352
bool isOSOpenBSD() const
Definition: Triple.h:474
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1096
static StringRef getArchTypePrefix(ArchType Kind)
getArchTypePrefix - Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:78
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1525
bool isOSFuchsia() const
Definition: Triple.h:482
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:457
bool operator!=(const Triple &Other) const
Definition: Triple.h:259
void setArchName(StringRef Str)
setArchName - Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1128
std::string normalize() const
Return the normalized form of this triple's string.
Definition: Triple.h:274
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1046
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:582
bool isWindowsCoreCLREnvironment() const
Definition: Triple.h:523
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1143
bool isCompatibleWith(const Triple &Other) const
Test whether target triples are compatible.
Definition: Triple.cpp:1492
bool isOSSolaris() const
Definition: Triple.h:488
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:466
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1416
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:992
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:930
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:254
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1231
bool isGNUEnvironment() const
Definition: Triple.h:500
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:399
bool isWatchABI() const
Definition: Triple.h:461
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1448
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:633
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:577
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1298
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1156
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:571
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:531
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:921
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:545
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:1005
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
Definition: Triple.h:597
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:294
bool isOSFreeBSD() const
Definition: Triple.h:478
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:414
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:299
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ObjectFormatType
Definition: Triple.h:207
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition: Triple.h:519
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:527
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:287
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:626
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:604
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1227
bool operator==(const Triple &Other) const
Definition: Triple.h:252
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:982
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:925
std::string merge(const Triple &Other) const
Merge target triples.
Definition: Triple.cpp:1516
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1100
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:213