Author: Weining Lu Date: 2023-07-17T20:34:35+08:00 New Revision: a926a2660a7f1942261bb15a0553d7f3999456d1
URL: https://github.com/llvm/llvm-project/commit/a926a2660a7f1942261bb15a0553d7f3999456d1 DIFF: https://github.com/llvm/llvm-project/commit/a926a2660a7f1942261bb15a0553d7f3999456d1.diff LOG: [Triple] Add llvm::Triple::isLoongArch{32,64} Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D155163 Added: Modified: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp llvm/include/llvm/TargetParser/Triple.h llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/unittests/TargetParser/TripleTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp index 332b1d4d77f4ad..fe880f796cc024 100644 --- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp +++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp @@ -140,7 +140,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D, // 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()) diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index e496f5dba393c1..79ccd644a50b0c 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -863,10 +863,14 @@ class Triple { : 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 { diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 216a43a7e7c8a8..071d18f80a5e0c 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -492,7 +492,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, 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(); diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp index feed6473a9e60f..a63bd092d40c0b 100644 --- a/llvm/unittests/TargetParser/TripleTest.cpp +++ b/llvm/unittests/TargetParser/TripleTest.cpp @@ -1243,12 +1243,14 @@ TEST(TripleTest, BitWidthPredicates) { 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()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits