[PATCH] D54215: [Triple] Add test for if triple is RISC-V

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 07:53:26 PDT 2019


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365327: [Triple] Add isRISCV function (authored by asb, committed by ).
Herald added a subscriber: lenary.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D54215?vs=172984&id=208415#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54215/new/

https://reviews.llvm.org/D54215

Files:
  llvm/trunk/include/llvm/ADT/Triple.h
  llvm/trunk/unittests/ADT/TripleTest.cpp


Index: llvm/trunk/include/llvm/ADT/Triple.h
===================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h
+++ llvm/trunk/include/llvm/ADT/Triple.h
@@ -725,6 +725,11 @@
     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();
Index: llvm/trunk/unittests/ADT/TripleTest.cpp
===================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp
+++ llvm/trunk/unittests/ADT/TripleTest.cpp
@@ -876,11 +876,13 @@
   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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54215.208415.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190708/aac3d614/attachment.bin>


More information about the llvm-commits mailing list