[llvm] r274090 - [Triple] Add isLittleEndian().

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 18:56:27 PDT 2016


Author: davide
Date: Tue Jun 28 20:56:27 2016
New Revision: 274090

URL: http://llvm.org/viewvc/llvm-project?rev=274090&view=rev
Log:
[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.

Modified:
    llvm/trunk/include/llvm/ADT/Triple.h
    llvm/trunk/lib/Support/Triple.cpp

Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=274090&r1=274089&r2=274090&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Tue Jun 28 20:56:27 2016
@@ -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.
   /// @{

Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=274090&r1=274089&r2=274090&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Tue Jun 28 20:56:27 2016
@@ -1406,6 +1406,10 @@ Triple Triple::getLittleEndianArchVarian
   return T;
 }
 
+bool Triple::isLittleEndian() const {
+  return *this == getLittleEndianArchVariant();
+}
+
 StringRef Triple::getARMCPUForArch(StringRef MArch) const {
   if (MArch.empty())
     MArch = getArchName();




More information about the llvm-commits mailing list