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

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 10:45:50 PDT 2016


On Tue, Jun 28, 2016 at 7:10 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> So, while I described it as a cute hack, I didn't mean it to be used
> as the actual implementation, just for prototyping :-)
>
> This will fail on ARM for example. You probably have to implement
> isLittleEndian directly and use it for early return in
> getLittleEndianArchVariant/getBigEndianArchVariant.
>
> Cheers,
> Rafael
>

I'm sorry Rafael. I tried to address your concerns here
http://reviews.llvm.org/D21846
PTAL

>
> On 28 June 2016 at 21:56, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> 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();
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list