[llvm] r365327 - [Triple] Add isRISCV function
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 07:52:36 PDT 2019
Author: asb
Date: Mon Jul 8 07:52:36 2019
New Revision: 365327
URL: http://llvm.org/viewvc/llvm-project?rev=365327&view=rev
Log:
[Triple] Add isRISCV function
This matches isARM, isThumb, isAArch64 and similar helpers. Future commits
which clean-up code that currently checks for Triple::riscv32 ||
Triple::riscv64.
Differential Revision: https://reviews.llvm.org/D54215
Patch by Simon Cook.
Test case added by Alex Bradbury.
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/unittests/ADT/TripleTest.cpp
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=365327&r1=365326&r2=365327&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Mon Jul 8 07:52:36 2019
@@ -725,6 +725,11 @@ public:
return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
}
+ /// Tests whether the target is RISC-V (32- and 64-bit).
+ bool isRISCV() const {
+ return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
+ }
+
/// Tests whether the target supports comdat
bool supportsCOMDAT() const {
return !isOSBinFormatMachO();
Modified: llvm/trunk/unittests/ADT/TripleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=365327&r1=365326&r2=365327&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp (original)
+++ llvm/trunk/unittests/ADT/TripleTest.cpp Mon Jul 8 07:52:36 2019
@@ -876,11 +876,13 @@ TEST(TripleTest, BitWidthPredicates) {
EXPECT_FALSE(T.isArch16Bit());
EXPECT_TRUE(T.isArch32Bit());
EXPECT_FALSE(T.isArch64Bit());
+ EXPECT_TRUE(T.isRISCV());
T.setArch(Triple::riscv64);
EXPECT_FALSE(T.isArch16Bit());
EXPECT_FALSE(T.isArch32Bit());
EXPECT_TRUE(T.isArch64Bit());
+ EXPECT_TRUE(T.isRISCV());
}
TEST(TripleTest, BitWidthArchVariants) {
More information about the llvm-commits
mailing list