summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-06-29 01:56:27 +0000
committerDavide Italiano <davide@freebsd.org>2016-06-29 01:56:27 +0000
commit941685e9f473873eba00e3df681f968656d2cc0e (patch)
tree2ea715e1f1706617d6717e70b2175f0f48f6a57e
parent5e64d3fb9480a48a70d28fb43244d4659354a844 (diff)
downloadbcm5719-llvm-941685e9f473873eba00e3df681f968656d2cc0e.tar.gz
bcm5719-llvm-941685e9f473873eba00e3df681f968656d2cc0e.zip
[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. llvm-svn: 274090
-rw-r--r--llvm/include/llvm/ADT/Triple.h5
-rw-r--r--llvm/lib/Support/Triple.cpp4
2 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 9154abd6eb3..83bf8163bd8 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/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/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 86c548f5612..71533df75d9 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud