LLVM  4.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  ppc, // PPC: powerpc
63  ppc64, // PPC64: powerpc64, ppu
64  ppc64le, // PPC64LE: powerpc64le
65  r600, // R600: AMD GPUs HD2XXX - HD6XXX
66  amdgcn, // AMDGCN: AMD GCN GPUs
67  riscv32, // RISC-V (32-bit): riscv32
68  riscv64, // RISC-V (64-bit): riscv64
69  sparc, // Sparc: sparc
70  sparcv9, // Sparcv9: Sparcv9
71  sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
72  systemz, // SystemZ: s390x
73  tce, // TCE (http://tce.cs.tut.fi/): tce
74  tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
75  thumb, // Thumb (little endian): thumb, thumbv.*
76  thumbeb, // Thumb (big endian): thumbeb
77  x86, // X86: i[3-9]86
78  x86_64, // X86-64: amd64, x86_64
79  xcore, // XCore: xcore
80  nvptx, // NVPTX: 32-bit
81  nvptx64, // NVPTX: 64-bit
82  le32, // le32: generic little-endian 32-bit CPU (PNaCl)
83  le64, // le64: generic little-endian 64-bit CPU (PNaCl)
84  amdil, // AMDIL
85  amdil64, // AMDIL with 64-bit pointers
86  hsail, // AMD HSAIL
87  hsail64, // AMD HSAIL with 64-bit pointers
88  spir, // SPIR: standard portable IR for OpenCL 32-bit version
89  spir64, // SPIR: standard portable IR for OpenCL 64-bit version
90  kalimba, // Kalimba: generic kalimba
91  shave, // SHAVE: Movidius vector VLIW processors
92  lanai, // Lanai: Lanai 32-bit
93  wasm32, // WebAssembly with 32-bit pointers
94  wasm64, // WebAssembly with 64-bit pointers
95  renderscript32, // 32-bit RenderScript
96  renderscript64, // 64-bit RenderScript
98  };
99  enum SubArchType {
101 
120 
124  };
125  enum VendorType {
127 
129  PC,
143  };
144  enum OSType {
146 
155  Lv2, // PS3
164  NaCl, // Native Client
165  CNK, // BG/P Compute-Node Kernel
168  CUDA, // NVIDIA CUDA
169  NVCL, // NVIDIA OpenCL
170  AMDHSA, // AMD HSA Runtime
173  TvOS, // Apple tvOS
174  WatchOS, // Apple watchOS
178  };
181 
194 
202  };
205 
209  };
210 
211 private:
212  std::string Data;
213 
214  /// The parsed arch type.
215  ArchType Arch;
216 
217  /// The parsed subarchitecture type.
218  SubArchType SubArch;
219 
220  /// The parsed vendor type.
221  VendorType Vendor;
222 
223  /// The parsed OS type.
224  OSType OS;
225 
226  /// The parsed Environment type.
227  EnvironmentType Environment;
228 
229  /// The object format type.
230  ObjectFormatType ObjectFormat;
231 
232 public:
233  /// @name Constructors
234  /// @{
235 
236  /// Default constructor is the same as an empty string and leaves all
237  /// triple fields unknown.
238  Triple() : Data(), Arch(), Vendor(), OS(), Environment(), ObjectFormat() {}
239 
240  explicit Triple(const Twine &Str);
241  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
242  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
243  const Twine &EnvironmentStr);
244 
245  bool operator==(const Triple &Other) const {
246  return Arch == Other.Arch && SubArch == Other.SubArch &&
247  Vendor == Other.Vendor && OS == Other.OS &&
248  Environment == Other.Environment &&
249  ObjectFormat == Other.ObjectFormat;
250  }
251 
252  /// @}
253  /// @name Normalization
254  /// @{
255 
256  /// normalize - Turn an arbitrary machine specification into the canonical
257  /// triple form (or something sensible that the Triple class understands if
258  /// nothing better can reasonably be done). In particular, it handles the
259  /// common case in which otherwise valid components are in the wrong order.
260  static std::string normalize(StringRef Str);
261 
262  /// Return the normalized form of this triple's string.
263  std::string normalize() const { return normalize(Data); }
264 
265  /// @}
266  /// @name Typed Component Access
267  /// @{
268 
269  /// getArch - Get the parsed architecture type of this triple.
270  ArchType getArch() const { return Arch; }
271 
272  /// getSubArch - get the parsed subarchitecture type for this triple.
273  SubArchType getSubArch() const { return SubArch; }
274 
275  /// getVendor - Get the parsed vendor type of this triple.
276  VendorType getVendor() const { return Vendor; }
277 
278  /// getOS - Get the parsed operating system type of this triple.
279  OSType getOS() const { return OS; }
280 
281  /// hasEnvironment - Does this triple have the optional environment
282  /// (fourth) component?
283  bool hasEnvironment() const {
284  return getEnvironmentName() != "";
285  }
286 
287  /// getEnvironment - Get the parsed environment type of this triple.
288  EnvironmentType getEnvironment() const { return Environment; }
289 
290  /// Parse the version number from the OS name component of the
291  /// triple, if present.
292  ///
293  /// For example, "fooos1.2.3" would return (1, 2, 3).
294  ///
295  /// If an entry is not defined, it will be returned as 0.
296  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
297  unsigned &Micro) const;
298 
299  /// getFormat - Get the object format for this triple.
300  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
301 
302  /// getOSVersion - Parse the version number from the OS name component of the
303  /// triple, if present.
304  ///
305  /// For example, "fooos1.2.3" would return (1, 2, 3).
306  ///
307  /// If an entry is not defined, it will be returned as 0.
308  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
309 
310  /// getOSMajorVersion - Return just the major version number, this is
311  /// specialized because it is a common query.
312  unsigned getOSMajorVersion() const {
313  unsigned Maj, Min, Micro;
314  getOSVersion(Maj, Min, Micro);
315  return Maj;
316  }
317 
318  /// getMacOSXVersion - Parse the version number as with getOSVersion and then
319  /// translate generic "darwin" versions to the corresponding OS X versions.
320  /// This may also be called with IOS triples but the OS X version number is
321  /// just set to a constant 10.4.0 in that case. Returns true if successful.
322  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
323  unsigned &Micro) const;
324 
325  /// getiOSVersion - Parse the version number as with getOSVersion. This should
326  /// only be called with IOS or generic triples.
327  void getiOSVersion(unsigned &Major, unsigned &Minor,
328  unsigned &Micro) const;
329 
330  /// getWatchOSVersion - Parse the version number as with getOSVersion. This
331  /// should only be called with WatchOS or generic triples.
332  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
333  unsigned &Micro) const;
334 
335  /// @}
336  /// @name Direct Component Access
337  /// @{
338 
339  const std::string &str() const { return Data; }
340 
341  const std::string &getTriple() const { return Data; }
342 
343  /// getArchName - Get the architecture (first) component of the
344  /// triple.
345  StringRef getArchName() const;
346 
347  /// getVendorName - Get the vendor (second) component of the triple.
348  StringRef getVendorName() const;
349 
350  /// getOSName - Get the operating system (third) component of the
351  /// triple.
352  StringRef getOSName() const;
353 
354  /// getEnvironmentName - Get the optional environment (fourth)
355  /// component of the triple, or "" if empty.
357 
358  /// getOSAndEnvironmentName - Get the operating system and optional
359  /// environment components as a single string (separated by a '-'
360  /// if the environment component is present).
362 
363  /// @}
364  /// @name Convenience Predicates
365  /// @{
366 
367  /// Test whether the architecture is 64-bit
368  ///
369  /// Note that this tests for 64-bit pointer width, and nothing else. Note
370  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
371  /// 16-bit. The inner details of pointer width for particular architectures
372  /// is not summed up in the triple, and so only a coarse grained predicate
373  /// system is provided.
374  bool isArch64Bit() const;
375 
376  /// Test whether the architecture is 32-bit
377  ///
378  /// Note that this tests for 32-bit pointer width, and nothing else.
379  bool isArch32Bit() const;
380 
381  /// Test whether the architecture is 16-bit
382  ///
383  /// Note that this tests for 16-bit pointer width, and nothing else.
384  bool isArch16Bit() const;
385 
386  /// isOSVersionLT - Helper function for doing comparisons against version
387  /// numbers included in the target triple.
388  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
389  unsigned Micro = 0) const {
390  unsigned LHS[3];
391  getOSVersion(LHS[0], LHS[1], LHS[2]);
392 
393  if (LHS[0] != Major)
394  return LHS[0] < Major;
395  if (LHS[1] != Minor)
396  return LHS[1] < Minor;
397  if (LHS[2] != Micro)
398  return LHS[1] < Micro;
399 
400  return false;
401  }
402 
403  bool isOSVersionLT(const Triple &Other) const {
404  unsigned RHS[3];
405  Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
406  return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
407  }
408 
409  /// isMacOSXVersionLT - Comparison function for checking OS X version
410  /// compatibility, which handles supporting skewed version numbering schemes
411  /// used by the "darwin" triples.
412  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
413  unsigned Micro = 0) const {
414  assert(isMacOSX() && "Not an OS X triple!");
415 
416  // If this is OS X, expect a sane version number.
417  if (getOS() == Triple::MacOSX)
418  return isOSVersionLT(Major, Minor, Micro);
419 
420  // Otherwise, compare to the "Darwin" number.
421  assert(Major == 10 && "Unexpected major version");
422  return isOSVersionLT(Minor + 4, Micro, 0);
423  }
424 
425  /// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
426  /// "darwin" and "osx" as OS X triples.
427  bool isMacOSX() const {
428  return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
429  }
430 
431  /// Is this an iOS triple.
432  /// Note: This identifies tvOS as a variant of iOS. If that ever
433  /// changes, i.e., if the two operating systems diverge or their version
434  /// numbers get out of sync, that will need to be changed.
435  /// watchOS has completely different version numbers so it is not included.
436  bool isiOS() const {
437  return getOS() == Triple::IOS || isTvOS();
438  }
439 
440  /// Is this an Apple tvOS triple.
441  bool isTvOS() const {
442  return getOS() == Triple::TvOS;
443  }
444 
445  /// Is this an Apple watchOS triple.
446  bool isWatchOS() const {
447  return getOS() == Triple::WatchOS;
448  }
449 
450  bool isWatchABI() const {
452  }
453 
454  /// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
455  bool isOSDarwin() const {
456  return isMacOSX() || isiOS() || isWatchOS();
457  }
458 
459  bool isOSNetBSD() const {
460  return getOS() == Triple::NetBSD;
461  }
462 
463  bool isOSOpenBSD() const {
464  return getOS() == Triple::OpenBSD;
465  }
466 
467  bool isOSFreeBSD() const {
468  return getOS() == Triple::FreeBSD;
469  }
470 
471  bool isOSFuchsia() const {
472  return getOS() == Triple::Fuchsia;
473  }
474 
475  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
476 
477  bool isOSSolaris() const {
478  return getOS() == Triple::Solaris;
479  }
480 
481  bool isOSBitrig() const {
482  return getOS() == Triple::Bitrig;
483  }
484 
485  bool isOSIAMCU() const {
486  return getOS() == Triple::ELFIAMCU;
487  }
488 
489  bool isGNUEnvironment() const {
491  return Env == Triple::GNU || Env == Triple::GNUABI64 ||
492  Env == Triple::GNUEABI || Env == Triple::GNUEABIHF ||
493  Env == Triple::GNUX32;
494  }
495 
496  bool isOSContiki() const {
497  return getOS() == Triple::Contiki;
498  }
499 
500  /// Checks if the environment could be MSVC.
502  return getOS() == Triple::Win32 &&
505  }
506 
507  /// Checks if the environment is MSVC.
509  return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
510  }
511 
514  }
515 
518  }
519 
521  return getOS() == Triple::Win32 && getEnvironment() == Triple::Cygnus;
522  }
523 
524  bool isWindowsGNUEnvironment() const {
525  return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU;
526  }
527 
528  /// Tests for either Cygwin or MinGW OS
529  bool isOSCygMing() const {
531  }
532 
533  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
534  bool isOSMSVCRT() const {
537  }
538 
539  /// Tests whether the OS is Windows.
540  bool isOSWindows() const {
541  return getOS() == Triple::Win32;
542  }
543 
544  /// Tests whether the OS is NaCl (Native Client)
545  bool isOSNaCl() const {
546  return getOS() == Triple::NaCl;
547  }
548 
549  /// Tests whether the OS is Linux.
550  bool isOSLinux() const {
551  return getOS() == Triple::Linux;
552  }
553 
554  /// Tests whether the OS is kFreeBSD.
555  bool isOSKFreeBSD() const {
556  return getOS() == Triple::KFreeBSD;
557  }
558 
559  /// Tests whether the OS uses glibc.
560  bool isOSGlibc() const {
561  return getOS() == Triple::Linux || getOS() == Triple::KFreeBSD;
562  }
563 
564  /// Tests whether the OS uses the ELF binary format.
565  bool isOSBinFormatELF() const {
566  return getObjectFormat() == Triple::ELF;
567  }
568 
569  /// Tests whether the OS uses the COFF binary format.
570  bool isOSBinFormatCOFF() const {
571  return getObjectFormat() == Triple::COFF;
572  }
573 
574  /// Tests whether the environment is MachO.
575  bool isOSBinFormatMachO() const {
576  return getObjectFormat() == Triple::MachO;
577  }
578 
579  /// Tests whether the target is the PS4 CPU
580  bool isPS4CPU() const {
581  return getArch() == Triple::x86_64 &&
582  getVendor() == Triple::SCEI &&
583  getOS() == Triple::PS4;
584  }
585 
586  /// Tests whether the target is the PS4 platform
587  bool isPS4() const {
588  return getVendor() == Triple::SCEI &&
589  getOS() == Triple::PS4;
590  }
591 
592  /// Tests whether the target is Android
593  bool isAndroid() const { return getEnvironment() == Triple::Android; }
594 
595  /// Tests whether the environment is musl-libc
596  bool isMusl() const {
597  return getEnvironment() == Triple::Musl ||
600  }
601 
602  /// Tests whether the target is NVPTX (32- or 64-bit).
603  bool isNVPTX() const {
604  return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
605  }
606 
607  /// Tests wether the target supports comdat
608  bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
609 
610  /// @}
611  /// @name Mutators
612  /// @{
613 
614  /// setArch - Set the architecture (first) component of the triple
615  /// to a known type.
616  void setArch(ArchType Kind);
617 
618  /// setVendor - Set the vendor (second) component of the triple to a
619  /// known type.
620  void setVendor(VendorType Kind);
621 
622  /// setOS - Set the operating system (third) component of the triple
623  /// to a known type.
624  void setOS(OSType Kind);
625 
626  /// setEnvironment - Set the environment (fourth) component of the triple
627  /// to a known type.
629 
630  /// setObjectFormat - Set the object file format
632 
633  /// setTriple - Set all components to the new triple \p Str.
634  void setTriple(const Twine &Str);
635 
636  /// setArchName - Set the architecture (first) component of the
637  /// triple by name.
638  void setArchName(StringRef Str);
639 
640  /// setVendorName - Set the vendor (second) component of the triple
641  /// by name.
642  void setVendorName(StringRef Str);
643 
644  /// setOSName - Set the operating system (third) component of the
645  /// triple by name.
646  void setOSName(StringRef Str);
647 
648  /// setEnvironmentName - Set the optional environment (fourth)
649  /// component of the triple by name.
650  void setEnvironmentName(StringRef Str);
651 
652  /// setOSAndEnvironmentName - Set the operating system and optional
653  /// environment components with a single string.
655 
656  /// @}
657  /// @name Helpers to build variants of a particular triple.
658  /// @{
659 
660  /// Form a triple with a 32-bit variant of the current architecture.
661  ///
662  /// This can be used to move across "families" of architectures where useful.
663  ///
664  /// \returns A new triple with a 32-bit architecture or an unknown
665  /// architecture if no such variant can be found.
667 
668  /// Form a triple with a 64-bit variant of the current architecture.
669  ///
670  /// This can be used to move across "families" of architectures where useful.
671  ///
672  /// \returns A new triple with a 64-bit architecture or an unknown
673  /// architecture if no such variant can be found.
675 
676  /// Form a triple with a big endian variant of the current architecture.
677  ///
678  /// This can be used to move across "families" of architectures where useful.
679  ///
680  /// \returns A new triple with a big endian architecture or an unknown
681  /// architecture if no such variant can be found.
683 
684  /// Form a triple with a little endian variant of the current architecture.
685  ///
686  /// This can be used to move across "families" of architectures where useful.
687  ///
688  /// \returns A new triple with a little endian architecture or an unknown
689  /// architecture if no such variant can be found.
691 
692  /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
693  ///
694  /// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
695  /// string then the triple's arch name is used.
697 
698  /// Tests whether the target triple is little endian.
699  ///
700  /// \returns true if the triple is little endian, false otherwise.
701  bool isLittleEndian() const;
702 
703  /// @}
704  /// @name Static helpers for IDs.
705  /// @{
706 
707  /// getArchTypeName - Get the canonical name for the \p Kind architecture.
709 
710  /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind
711  /// architecture. This is the prefix used by the architecture specific
712  /// builtins, and is suitable for passing to \see
713  /// Intrinsic::getIntrinsicForGCCBuiltin().
714  ///
715  /// \return - The architecture prefix, or 0 if none is defined.
717 
718  /// getVendorTypeName - Get the canonical name for the \p Kind vendor.
720 
721  /// getOSTypeName - Get the canonical name for the \p Kind operating system.
723 
724  /// getEnvironmentTypeName - Get the canonical name for the \p Kind
725  /// environment.
727 
728  /// @}
729  /// @name Static helpers for converting alternate architecture names.
730  /// @{
731 
732  /// getArchTypeForLLVMName - The canonical type for the given LLVM
733  /// architecture name (e.g., "x86").
735 
736  /// @}
737 };
738 
739 } // End llvm namespace
740 
741 
742 #endif
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:279
bool isOSKFreeBSD() const
Tests whether the OS is kFreeBSD.
Definition: Triple.h:555
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:312
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:575
static StringRef getVendorTypeName(VendorType Kind)
getVendorTypeName - Get the canonical name for the Kind vendor.
Definition: Triple.cpp:146
bool isOSContiki() const
Definition: Triple.h:496
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
Definition: Triple.cpp:1084
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1052
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:412
const std::string & str() const
Definition: Triple.h:339
bool isOSIAMCU() const
Definition: Triple.h:485
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
Definition: Triple.cpp:1088
bool isOSDragonFly() const
Definition: Triple.h:475
void setEnvironment(EnvironmentType Kind)
setEnvironment - Set the environment (fourth) component of the triple to a known type.
Definition: Triple.cpp:1092
llvm::Triple getBigEndianArchVariant() const
Form a triple with a big endian variant of the current architecture.
Definition: Triple.cpp:1338
bool supportsCOMDAT() const
Tests wether the target supports comdat.
Definition: Triple.h:608
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:593
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:540
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
Definition: Triple.h:529
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:427
bool isOSBitrig() const
Definition: Triple.h:481
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:300
void setVendorName(StringRef Str)
setVendorName - Set the vendor (second) component of the triple by name.
Definition: Triple.cpp:1119
Triple()
Default constructor is the same as an empty string and leaves all triple fields unknown.
Definition: Triple.h:238
bool isWindowsMSVCEnvironment() const
Checks if the environment could be MSVC.
Definition: Triple.h:501
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1202
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:550
bool isOSNaCl() const
Tests whether the OS is NaCl (Native Client)
Definition: Triple.h:545
StringRef getOSAndEnvironmentName() const
getOSAndEnvironmentName - Get the operating system and optional environment components as a single st...
Definition: Triple.cpp:924
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:270
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:441
static StringRef getOSTypeName(OSType Kind)
getOSTypeName - Get the canonical name for the Kind operating system.
Definition: Triple.cpp:169
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:273
bool isOSNetBSD() const
Definition: Triple.h:459
llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
Definition: Triple.cpp:1214
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:436
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
Definition: Triple.cpp:918
void setObjectFormat(ObjectFormatType Kind)
setObjectFormat - Set the object file format
Definition: Triple.cpp:1100
bool isWindowsGNUEnvironment() const
Definition: Triple.h:524
void setEnvironmentName(StringRef Str)
setEnvironmentName - Set the optional environment (fourth) component of the triple by name...
Definition: Triple.cpp:1131
const std::string & getTriple() const
Definition: Triple.h:341
bool isOSOpenBSD() const
Definition: Triple.h:463
void setTriple(const Twine &Str)
setTriple - Set all components to the new triple Str.
Definition: Triple.cpp:1076
static StringRef getArchTypePrefix(ArchType Kind)
getArchTypePrefix - Get the "prefix" canonical name for the Kind architecture.
Definition: Triple.cpp:77
StringRef getARMCPUForArch(StringRef Arch=StringRef()) const
Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
Definition: Triple.cpp:1467
bool isOSFuchsia() const
Definition: Triple.h:471
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:446
void setArchName(StringRef Str)
setArchName - Set the architecture (first) component of the triple by name.
Definition: Triple.cpp:1108
std::string normalize() const
Return the normalized form of this triple's string.
Definition: Triple.h:263
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1026
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:570
bool isWindowsCoreCLREnvironment() const
Definition: Triple.h:512
void setOSName(StringRef Str)
setOSName - Set the operating system (third) component of the triple by name.
Definition: Triple.cpp:1123
bool isOSSolaris() const
Definition: Triple.h:477
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:455
llvm::Triple getLittleEndianArchVariant() const
Form a triple with a little endian variant of the current architecture.
Definition: Triple.cpp:1392
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:974
StringRef getOSName() const
getOSName - Get the operating system (third) component of the triple.
Definition: Triple.cpp:912
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
Definition: Triple.cpp:249
bool isArch16Bit() const
Test whether the architecture is 16-bit.
Definition: Triple.cpp:1210
bool isGNUEnvironment() const
Definition: Triple.h:489
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:388
bool isWatchABI() const
Definition: Triple.h:450
bool isLittleEndian() const
Tests whether the target triple is little endian.
Definition: Triple.cpp:1424
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:603
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:565
llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
Definition: Triple.cpp:1276
void setOSAndEnvironmentName(StringRef Str)
setOSAndEnvironmentName - Set the operating system and optional environment components with a single ...
Definition: Triple.cpp:1136
bool isOSGlibc() const
Tests whether the OS uses glibc.
Definition: Triple.h:560
bool isWindowsCygwinEnvironment() const
Definition: Triple.h:520
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
Definition: Triple.cpp:903
bool isOSMSVCRT() const
Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
Definition: Triple.h:534
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:985
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
Definition: Triple.h:580
bool hasEnvironment() const
hasEnvironment - Does this triple have the optional environment (fourth) component?
Definition: Triple.h:283
bool isOSFreeBSD() const
Definition: Triple.h:467
bool isOSVersionLT(const Triple &Other) const
Definition: Triple.h:403
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:288
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ObjectFormatType
Definition: Triple.h:203
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition: Triple.h:508
bool isWindowsItaniumEnvironment() const
Definition: Triple.h:516
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
Definition: Triple.h:276
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
bool isMusl() const
Tests whether the environment is musl-libc.
Definition: Triple.h:596
bool isPS4() const
Tests whether the target is the PS4 platform.
Definition: Triple.h:587
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1206
bool operator==(const Triple &Other) const
Definition: Triple.h:245
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:964
StringRef getVendorName() const
getVendorName - Get the vendor (second) component of the triple.
Definition: Triple.cpp:907
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Definition: Triple.cpp:1080
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
getEnvironmentTypeName - Get the canonical name for the Kind environment.
Definition: Triple.cpp:208