diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/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 { diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp --- a/llvm/unittests/TargetParser/TripleTest.cpp +++ b/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());