From: Davide Italiano Date: Wed, 29 Jun 2016 01:56:27 +0000 (+0000) Subject: [Triple] Add isLittleEndian(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=997e1fa9b4ce31dce6cff42980080f23361baff8;p=llvm [Triple] Add isLittleEndian(). This allows us to query about the endianness without having to look at DataLayout. The API will be used (and tested) in lld, in order to find out the endianness of BitcodeFiles. Briefly discussed with Rafael. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274090 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 9154abd6eb3..83bf8163bd8 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -676,6 +676,11 @@ public: /// string then the triple's arch name is used. StringRef getARMCPUForArch(StringRef Arch = StringRef()) const; + /// Tests whether the target triple is little endian. + /// + /// \returns true if the triple is little endian, false otherwise. + bool isLittleEndian() const; + /// @} /// @name Static helpers for IDs. /// @{ diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 86c548f5612..71533df75d9 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -1406,6 +1406,10 @@ Triple Triple::getLittleEndianArchVariant() const { return T; } +bool Triple::isLittleEndian() const { + return *this == getLittleEndianArchVariant(); +} + StringRef Triple::getARMCPUForArch(StringRef MArch) const { if (MArch.empty()) MArch = getArchName();