]> granicus.if.org Git - llvm/commitdiff
[Triple] Add isLittleEndian().
authorDavide Italiano <davide@freebsd.org>
Wed, 29 Jun 2016 01:56:27 +0000 (01:56 +0000)
committerDavide Italiano <davide@freebsd.org>
Wed, 29 Jun 2016 01:56:27 +0000 (01:56 +0000)
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

include/llvm/ADT/Triple.h
lib/Support/Triple.cpp

index 9154abd6eb30033f7196057dc96566b1d5934f89..83bf8163bd8f1bb0e86b8b23a554b80cc79624df 100644 (file)
@@ -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.
   /// @{
index 86c548f561208376c1f211677ce63c973f5f3dfe..71533df75d9ec589b44fed8e44fb637e607353ad 100644 (file)
@@ -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();