[PATCH] D155163: [Triple] Add llvm::Triple::isLoongArch{32,64}

Lu Weining via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 17 05:35:15 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa926a2660a7f: [Triple] Add llvm::Triple::isLoongArch{32,64} (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155163

Files:
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/unittests/TargetParser/TripleTest.cpp


Index: llvm/unittests/TargetParser/TripleTest.cpp
===================================================================
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -1243,12 +1243,14 @@
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
   EXPECT_TRUE(T.isLoongArch());
+  EXPECT_TRUE(T.isLoongArch32());
 
   T.setArch(Triple::loongarch64);
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
   EXPECT_TRUE(T.isLoongArch());
+  EXPECT_TRUE(T.isLoongArch64());
 
   T.setArch(Triple::dxil);
   EXPECT_FALSE(T.isArch16Bit());
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -492,7 +492,7 @@
   bool IsMIPS64 = TargetTriple.isMIPS64();
   bool IsArmOrThumb = TargetTriple.isARM() || TargetTriple.isThumb();
   bool IsAArch64 = TargetTriple.getArch() == Triple::aarch64;
-  bool IsLoongArch64 = TargetTriple.getArch() == Triple::loongarch64;
+  bool IsLoongArch64 = TargetTriple.isLoongArch64();
   bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64;
   bool IsWindows = TargetTriple.isOSWindows();
   bool IsFuchsia = TargetTriple.isOSFuchsia();
Index: llvm/include/llvm/TargetParser/Triple.h
===================================================================
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -863,10 +863,14 @@
                : PointerWidth == 64;
   }
 
+  /// Tests whether the target is 32-bit LoongArch.
+  bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
+
+  /// Tests whether the target is 64-bit LoongArch.
+  bool isLoongArch64() const { return getArch() == Triple::loongarch64; }
+
   /// Tests whether the target is LoongArch (32- and 64-bit).
-  bool isLoongArch() const {
-    return getArch() == Triple::loongarch32 || getArch() == Triple::loongarch64;
-  }
+  bool isLoongArch() const { return isLoongArch32() || isLoongArch64(); }
 
   /// Tests whether the target is MIPS 32-bit (little and big endian).
   bool isMIPS32() const {
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -140,7 +140,7 @@
   // TODO: handle -march=native and -mtune=xx.
 
   // Select a default arch name.
-  if (ArchName.empty() && Triple.getArch() == llvm::Triple::loongarch64)
+  if (ArchName.empty() && Triple.isLoongArch64())
     ArchName = "loongarch64";
 
   if (!ArchName.empty())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155163.540972.patch
Type: text/x-patch
Size: 2775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230717/cc70a77c/attachment.bin>


More information about the cfe-commits mailing list