diff options
author | Lang Hames <lhames@gmail.com> | 2024-02-17 13:21:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-17 13:21:38 -0800 |
commit | 80c25daca8f8282ceabd2a5bb567203e0dcf8374 (patch) | |
tree | 36352016b4be295570aafb5ab880f5412e253b99 /llvm/unittests/TargetParser | |
parent | f81f7a57664bd7dccd5e179ed01155efbc8ff481 (diff) | |
download | llvm-80c25daca8f8282ceabd2a5bb567203e0dcf8374.zip llvm-80c25daca8f8282ceabd2a5bb567203e0dcf8374.tar.gz llvm-80c25daca8f8282ceabd2a5bb567203e0dcf8374.tar.bz2 |
[TargetParser] Expose Triple::getArchPointerBitWidth. (#82086)
The getArchPointerBitWidth method provides direct access to the pointer
size for arithmetic or switch statements, instead of requiring clients
to use the isArch16Bit / isArch32Bit / isArch64Bit predicates.
Diffstat (limited to 'llvm/unittests/TargetParser')
-rw-r--r-- | llvm/unittests/TargetParser/TripleTest.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp index 4db54a0..e1e1bbd 100644 --- a/llvm/unittests/TargetParser/TripleTest.cpp +++ b/llvm/unittests/TargetParser/TripleTest.cpp @@ -1205,86 +1205,102 @@ TEST(TripleTest, MutateName) { EXPECT_EQ("i386-pc-darwin", T.getTriple()); } -TEST(TripleTest, BitWidthPredicates) { +TEST(TripleTest, BitWidthChecks) { Triple T; EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 0U); T.setArch(Triple::arm); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::hexagon); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::mips); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::mips64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::msp430); EXPECT_TRUE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 16U); T.setArch(Triple::ppc); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::ppc64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::x86); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::x86_64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::amdil); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::amdil64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::hsail); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::hsail64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::spir); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 32U); T.setArch(Triple::spir64); EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + EXPECT_EQ(T.getArchPointerBitWidth(), 64U); T.setArch(Triple::spirv); EXPECT_FALSE(T.isArch16Bit()); |