LLVM API Documentation

llvm::Triple Class Reference

#include <Triple.h>

Collaboration diagram for llvm::Triple:
[legend]

List of all members.

Public Types

enum  ArchType {
  UnknownArch, alpha, arm, bfin,
  cellspu, mips, mipsel, msp430,
  pic16, ppc, ppc64, sparc,
  systemz, tce, thumb, x86,
  x86_64, xcore, InvalidArch
}
enum  VendorType { UnknownVendor, Apple, PC }
enum  OSType {
  UnknownOS, AuroraUX, Cygwin, Darwin,
  DragonFly, FreeBSD, Linux, MinGW32,
  MinGW64, NetBSD, OpenBSD, Solaris,
  Win32
}

Public Member Functions

Constructors
 Triple ()
 Triple (const StringRef &Str)
 Triple (const char *ArchStr, const char *VendorStr, const char *OSStr)
Typed Component Access
ArchType getArch () const
 getArch - Get the parsed architecture type of this triple.
VendorType getVendor () const
 getVendor - Get the parsed vendor type of this triple.
OSType getOS () const
 getOS - Get the parsed operating system type of this triple.
bool hasEnvironment () const
Direct Component Access
const std::string & getTriple () const
StringRef getArchName () const
StringRef getVendorName () const
 getVendorName - Get the vendor (second) component of the triple.
StringRef getOSName () const
StringRef getEnvironmentName () const
StringRef getOSAndEnvironmentName () const
void getDarwinNumber (unsigned &Maj, unsigned &Min, unsigned &Revision) const
unsigned getDarwinMajorNumber () const
Mutators
void setArch (ArchType Kind)
void setVendor (VendorType Kind)
void setOS (OSType Kind)
void setTriple (const Twine &Str)
 setTriple - Set all components to the new triple
void setArchName (const StringRef &Str)
void setVendorName (const StringRef &Str)
void setOSName (const StringRef &Str)
void setEnvironmentName (const StringRef &Str)
void setOSAndEnvironmentName (const StringRef &Str)

Static Public Member Functions

Static helpers for IDs.
static const char * getArchTypeName (ArchType Kind)
static const char * getVendorTypeName (VendorType Kind)
static const char * getOSTypeName (OSType Kind)
 getOSTypeName - Get the canonical name for the
static ArchType getArchTypeForLLVMName (const StringRef &Str)


Detailed Description

Triple - Helper class for working with target triples.

Target triples are strings in the format of: ARCHITECTURE-VENDOR-OPERATING_SYSTEM or ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT

This class is used for clients which want to support arbitrary target triples, but also want to implement certain special behavior for particular targets. This class isolates the mapping from the components of the target triple to well known IDs.

At its core the Triple class is designed to be a wrapper for a triple string; it does not normally change or normalize the triple string, instead it provides additional APIs to parse normalized parts out of the triple.

One curiosity this implies is that for some odd triples the results of, e.g., getOSName() can be very different from the result of getOS(). For example, for 'i386-mingw32', getOS() will return MinGW32, but since getOSName() is purely based on the string structure that will return the empty string.

Clients should generally avoid using getOSName() and related APIs unless they are familiar with the triple format (this is particularly true when rewriting a triple).

See autoconf/config.guess for a glimpse into what they look like in practice.

Definition at line 48 of file Triple.h.


Member Enumeration Documentation

Enumerator:
UnknownArch 
alpha 
arm 
bfin 
cellspu 
mips 
mipsel 
msp430 
pic16 
ppc 
ppc64 
sparc 
systemz 
tce 
thumb 
x86 
x86_64 
xcore 
InvalidArch 

Definition at line 50 of file Triple.h.

Enumerator:
UnknownVendor 
Apple 
PC 

Definition at line 73 of file Triple.h.

Enumerator:
UnknownOS 
AuroraUX 
Cygwin 
Darwin 
DragonFly 
FreeBSD 
Linux 
MinGW32 
MinGW64 
NetBSD 
OpenBSD 
Solaris 
Win32 

Definition at line 79 of file Triple.h.


Constructor & Destructor Documentation

llvm::Triple::Triple (  )  [inline]

Definition at line 115 of file Triple.h.

llvm::Triple::Triple ( const StringRef &  Str  )  [inline, explicit]

Definition at line 116 of file Triple.h.

llvm::Triple::Triple ( const char *  ArchStr,
const char *  VendorStr,
const char *  OSStr 
) [inline, explicit]

Definition at line 117 of file Triple.h.


Member Function Documentation

ArchType llvm::Triple::getArch (  )  const [inline]

getArch - Get the parsed architecture type of this triple.

Definition at line 130 of file Triple.h.

Referenced by createTargetAsmInfo(), and llvm::X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo().

VendorType llvm::Triple::getVendor (  )  const [inline]

getVendor - Get the parsed vendor type of this triple.

Definition at line 136 of file Triple.h.

OSType llvm::Triple::getOS (  )  const [inline]

getOS - Get the parsed operating system type of this triple.

Definition at line 142 of file Triple.h.

Referenced by createTargetAsmInfo(), getDarwinNumber(), and llvm::X86ELFTargetAsmInfo::X86ELFTargetAsmInfo().

bool llvm::Triple::hasEnvironment (  )  const [inline]

hasEnvironment - Does this triple have the optional environment (fourth) component?

Definition at line 149 of file Triple.h.

References getEnvironmentName().

Referenced by setOSName().

const std::string& llvm::Triple::getTriple (  )  const [inline]

Definition at line 157 of file Triple.h.

StringRef Triple::getArchName (  )  const

getArchName - Get the architecture (first) component of the triple.

Definition at line 221 of file Triple.cpp.

References llvm::StringRef::split().

Referenced by setEnvironmentName(), setOSAndEnvironmentName(), setOSName(), and setVendorName().

StringRef Triple::getVendorName (  )  const

getVendorName - Get the vendor (second) component of the triple.

Definition at line 225 of file Triple.cpp.

References llvm::StringRef::split().

Referenced by setArchName(), setEnvironmentName(), setOSAndEnvironmentName(), and setOSName().

StringRef Triple::getOSName (  )  const

getOSName - Get the operating system (third) component of the triple.

Definition at line 230 of file Triple.cpp.

References llvm::StringRef::split().

Referenced by getDarwinNumber(), and setEnvironmentName().

StringRef Triple::getEnvironmentName (  )  const

getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.

Definition at line 236 of file Triple.cpp.

References llvm::StringRef::split().

Referenced by hasEnvironment(), and setOSName().

StringRef Triple::getOSAndEnvironmentName (  )  const

getOSAndEnvironmentName - Get the operating system and optional environment components as a single string (separated by a '-' if the environment component is present).

Definition at line 242 of file Triple.cpp.

References llvm::StringRef::split().

Referenced by setArchName(), and setVendorName().

void Triple::getDarwinNumber ( unsigned &  Maj,
unsigned &  Min,
unsigned &  Revision 
) const

getDarwinNumber - Parse the 'darwin number' out of the specific target triple. For example, if we have darwin8.5 return 8,5,0. If any entry is not defined, return 0's. This requires that the triple have an OSType of darwin before it is called.

getDarwinNumber - Parse the 'darwin number' out of the specific target triple. For example, if we have darwin8.5 return 8,5,0. If any entry is not defined, return 0's. This requires that the triple have an OSType of darwin before it is called.

Definition at line 268 of file Triple.cpp.

References Darwin, EatNumber(), getOS(), getOSName(), llvm::StringRef::startswith(), and llvm::StringRef::substr().

Referenced by getDarwinMajorNumber().

unsigned llvm::Triple::getDarwinMajorNumber (  )  const [inline]

getDarwinMajorNumber - Return just the major version number, this is specialized because it is a common query.

Definition at line 188 of file Triple.h.

References getDarwinNumber().

Referenced by llvm::X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo().

void Triple::setArch ( ArchType  Kind  ) 

setArch - Set the architecture (first) component of the triple to a known type.

Definition at line 317 of file Triple.cpp.

References getArchTypeName(), and setArchName().

void Triple::setVendor ( VendorType  Kind  ) 

setVendor - Set the vendor (second) component of the triple to a known type.

Definition at line 321 of file Triple.cpp.

References getVendorTypeName(), and setVendorName().

void Triple::setOS ( OSType  Kind  ) 

setOS - Set the operating system (third) component of the triple to a known type.

Definition at line 325 of file Triple.cpp.

References getOSTypeName(), and setOSName().

void Triple::setTriple ( const Twine &  Str  ) 

setTriple - Set all components to the new triple

  • Str.

Definition at line 312 of file Triple.cpp.

References InvalidArch, and llvm::Twine::str().

Referenced by setArchName(), setEnvironmentName(), setOSAndEnvironmentName(), setOSName(), and setVendorName().

void Triple::setArchName ( const StringRef &  Str  ) 

setArchName - Set the architecture (first) component of the triple by name.

Definition at line 329 of file Triple.cpp.

References getOSAndEnvironmentName(), getVendorName(), setTriple(), and llvm::SmallString< InternalLen >::str().

Referenced by setArch().

void Triple::setVendorName ( const StringRef &  Str  ) 

setVendorName - Set the vendor (second) component of the triple by name.

Definition at line 340 of file Triple.cpp.

References getArchName(), getOSAndEnvironmentName(), and setTriple().

Referenced by setVendor().

void Triple::setOSName ( const StringRef &  Str  ) 

setOSName - Set the operating system (third) component of the triple by name.

Definition at line 344 of file Triple.cpp.

References getArchName(), getEnvironmentName(), getVendorName(), hasEnvironment(), and setTriple().

Referenced by setOS().

void Triple::setEnvironmentName ( const StringRef &  Str  ) 

setEnvironmentName - Set the optional environment (fourth) component of the triple by name.

Definition at line 352 of file Triple.cpp.

References getArchName(), getOSName(), getVendorName(), and setTriple().

void Triple::setOSAndEnvironmentName ( const StringRef &  Str  ) 

setOSAndEnvironmentName - Set the operating system and optional environment components with a single string.

Definition at line 357 of file Triple.cpp.

References getArchName(), getVendorName(), and setTriple().

const char * Triple::getArchTypeName ( ArchType  Kind  )  [static]

getArchTypeName - Get the canonical name for the

  • Kind architecture.

Definition at line 20 of file Triple.cpp.

References alpha, arm, bfin, cellspu, InvalidArch, mips, mipsel, msp430, pic16, ppc, ppc64, sparc, systemz, tce, thumb, UnknownArch, x86, x86_64, and xcore.

Referenced by setArch().

const char * Triple::getVendorTypeName ( VendorType  Kind  )  [static]

getVendorTypeName - Get the canonical name for the

  • Kind vendor.

Definition at line 47 of file Triple.cpp.

References Apple, PC, and UnknownVendor.

Referenced by setVendor().

const char * Triple::getOSTypeName ( OSType  Kind  )  [static]

getOSTypeName - Get the canonical name for the

  • Kind vendor.

Definition at line 58 of file Triple.cpp.

References AuroraUX, Cygwin, Darwin, DragonFly, FreeBSD, Linux, MinGW32, MinGW64, NetBSD, OpenBSD, Solaris, UnknownOS, and Win32.

Referenced by setOS().

Triple::ArchType Triple::getArchTypeForLLVMName ( const StringRef &  Str  )  [static]

getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").

Definition at line 79 of file Triple.cpp.

References alpha, arm, bfin, cellspu, mips, mipsel, msp430, pic16, ppc, ppc64, sparc, systemz, tce, thumb, UnknownArch, x86, x86_64, and xcore.

Referenced by llvm::JIT::selectTarget().


The documentation for this class was generated from the following files: