aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ADT
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-02-06 20:46:33 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-02-06 20:46:33 +0000
commit7d5a289f2d7d75c29df4c17856ab54dd28dec508 (patch)
treed64645784013e08a3bb39c9f33d02a457cc40877 /unittests/ADT
parentfccf0623ee35e0bbbbf0ba963a5500b7fd87fa11 (diff)
downloadexternal_llvm-7d5a289f2d7d75c29df4c17856ab54dd28dec508.zip
external_llvm-7d5a289f2d7d75c29df4c17856ab54dd28dec508.tar.gz
external_llvm-7d5a289f2d7d75c29df4c17856ab54dd28dec508.tar.bz2
Introduce helpers to compute the 32-bit varaints and 64-bit variants of
some architectures. These are useful for interacting with multiarch or bi-arch GCC (or GCC-based) toolchains. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149895 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r--unittests/ADT/TripleTest.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp
index 28bb928..b95107d 100644
--- a/unittests/ADT/TripleTest.cpp
+++ b/unittests/ADT/TripleTest.cpp
@@ -324,4 +324,66 @@ TEST(TripleTest, BitWidthPredicates) {
EXPECT_TRUE(T.isArch64Bit());
}
+TEST(TripleTest, BitWidthArchVariants) {
+ Triple T;
+ EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::UnknownArch);
+ EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::arm);
+ EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::mips);
+ EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::mipsel);
+ EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::ppc);
+ EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::ptx32);
+ EXPECT_EQ(Triple::ptx32, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::ptx64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::sparc);
+ EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::x86);
+ EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::mips64);
+ EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::mips64el);
+ EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::ppc64);
+ EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::ptx64);
+ EXPECT_EQ(Triple::ptx32, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::ptx64, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::sparcv9);
+ EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
+
+ T.setArch(Triple::x86_64);
+ EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
+ EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
+}
+
}