diff options
author | Duncan Sands <baldrick@free.fr> | 2010-09-16 08:25:48 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-09-16 08:25:48 +0000 |
commit | 5754a4525625a67a6c9b4f63512ea9db6997bf05 (patch) | |
tree | 3ab92259598e2da0ef7444ede8c7a8a56b86a94c /include/llvm/ADT/Triple.h | |
parent | dd2fdd81bca3fd99ae769771892cd92ddeb33145 (diff) | |
download | external_llvm-5754a4525625a67a6c9b4f63512ea9db6997bf05.zip external_llvm-5754a4525625a67a6c9b4f63512ea9db6997bf05.tar.gz external_llvm-5754a4525625a67a6c9b4f63512ea9db6997bf05.tar.bz2 |
Add better support for environment portion of triple. Original patch by
Cameron Esfahani, tweaked to use array_lengthof.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Triple.h')
-rw-r--r-- | include/llvm/ADT/Triple.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 0b80bb5..60f622d 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -95,6 +95,9 @@ public: Haiku, Minix }; + enum EnvironmentType { + UnknownEnvironment + }; private: std::string Data; @@ -108,10 +111,14 @@ private: /// The parsed OS type. mutable OSType OS; + /// The parsed Environment type. + mutable EnvironmentType Environment; + bool isInitialized() const { return Arch != InvalidArch; } static ArchType ParseArch(StringRef ArchName); static VendorType ParseVendor(StringRef VendorName); static OSType ParseOS(StringRef OSName); + static EnvironmentType ParseEnvironment(StringRef EnvironmentName); void Parse() const; public: @@ -128,6 +135,17 @@ public: Data += OSStr; } + explicit Triple(StringRef ArchStr, StringRef VendorStr, StringRef OSStr, + StringRef EnvironmentStr) + : Data(ArchStr), Arch(InvalidArch) { + Data += '-'; + Data += VendorStr; + Data += '-'; + Data += OSStr; + Data += '-'; + Data += EnvironmentStr; + } + /// @} /// @name Normalization /// @{ @@ -166,6 +184,12 @@ public: return getEnvironmentName() != ""; } + /// getEnvironment - Get the parsed environment type of this triple. + EnvironmentType getEnvironment() const { + if (!isInitialized()) Parse(); + return Environment; + } + /// @} /// @name Direct Component Access /// @{ @@ -225,6 +249,10 @@ public: /// to a known type. void setOS(OSType Kind); + /// setEnvironment - Set the environment (fourth) component of the triple + /// to a known type. + void setEnvironment(EnvironmentType Kind); + /// setTriple - Set all components to the new triple \arg Str. void setTriple(const Twine &Str); @@ -272,9 +300,14 @@ public: /// vendor. static const char *getVendorTypeName(VendorType Kind); - /// getOSTypeName - Get the canonical name for the \arg Kind vendor. + /// getOSTypeName - Get the canonical name for the \arg Kind operating + /// system. static const char *getOSTypeName(OSType Kind); + /// getEnvironmentTypeName - Get the canonical name for the \arg Kind + /// environment. + static const char *getEnvironmentTypeName(EnvironmentType Kind); + /// @} /// @name Static helpers for converting alternate architecture names. /// @{ |