Skip to content

Commit

Permalink
add additional tests for DataLayoutUpgrade and move existing to prope…
Browse files Browse the repository at this point in the history
…r location
  • Loading branch information
lei137 committed Nov 28, 2024
1 parent ffe4547 commit 8a49c87
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
"e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64", "mips64el"),
"e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64");

// Check that PowerPC64 targets add -i128:128.
EXPECT_EQ(UpgradeDataLayoutString("e-m:e-i64:64-n32:64", "powerpc64le-linux"),
"e-m:e-i64:64-i128:128-n32:64");
EXPECT_EQ(UpgradeDataLayoutString(
"E-m:e-Fn32-i64:64-n32:64", "powerpc64-linux"),
"E-m:e-Fn32-i64:64-i128:128-n32:64");
EXPECT_EQ(UpgradeDataLayoutString(
"E-m:a-Fi64-i64:64-n32:64", "powerpc64-ibm-aix"),
"E-m:a-Fi64-i64:64-i128:128-n32:64");

// Check that SPIR && SPIRV targets add -G1 if it's not present.
EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32", "spir"), "e-p:32:32-G1");
EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32", "spir64"), "e-p:32:32-G1");
Expand All @@ -108,8 +118,6 @@ TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
"-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
"-n8:16:32:64-S128",
"x86_64-unknown-linux-gnu");
std::string DL2 = UpgradeDataLayoutString("e-m:e-i64:64-n32:64",
"powerpc64le-unknown-linux-gnu");
std::string DL3 = UpgradeDataLayoutString(
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32",
"aarch64--");
Expand All @@ -118,7 +126,6 @@ TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128"
"-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64"
"-f80:128:128-n8:16:32:64-S128");
EXPECT_EQ(DL2, "e-m:e-i64:64-i128:128-n32:64");
EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:"
"64-S128-Fn32");

Expand Down Expand Up @@ -153,6 +160,14 @@ TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
EXPECT_EQ(UpgradeDataLayoutString("G2", "spir64"), "G2");
EXPECT_EQ(UpgradeDataLayoutString("G2", "spirv32"), "G2");
EXPECT_EQ(UpgradeDataLayoutString("G2", "spirv64"), "G2");

// Check that PowerPC32 targets don't add -i128:128.
EXPECT_EQ(UpgradeDataLayoutString("e-m:e-i64:64-n32", "powerpcle-linux"),
"e-m:e-i64:64-n32");
EXPECT_EQ(UpgradeDataLayoutString("E-m:e-Fn32-i64:64-n32", "powerpc-linux"),
"E-m:e-Fn32-i64:64-n32");
EXPECT_EQ(UpgradeDataLayoutString("E-m:a-Fi64-i64:64-n32", "powerpc-aix"),
"E-m:a-Fi64-i64:64-n32");
}

TEST(DataLayoutUpgradeTest, EmptyDataLayout) {
Expand Down

0 comments on commit 8a49c87

Please sign in to comment.