[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / unittests / Bitcode / DataLayoutUpgradeTest.cpp
blobc92418136e5718b5736ef68646332831f0c830a6
1 //===- DataLayoutUpgradeTest.cpp - Tests for DataLayout upgrades ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/IR/AutoUpgrade.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 namespace {
16 TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
17 std::string DL1 =
18 UpgradeDataLayoutString("e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128",
19 "x86_64-unknown-linux-gnu");
20 std::string DL2 = UpgradeDataLayoutString(
21 "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32", "i686-pc-windows-msvc");
22 std::string DL3 = UpgradeDataLayoutString("e-m:o-i64:64-i128:128-n32:64-S128",
23 "x86_64-apple-macosx");
24 EXPECT_EQ(DL1, "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64"
25 "-f80:128-n8:16:32:64-S128");
26 EXPECT_EQ(DL2, "e-m:w-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64"
27 "-f80:32-n8:16:32-S32");
28 EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128"
29 "-n32:64-S128");
32 TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
33 std::string DL1 = UpgradeDataLayoutString(
34 "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32"
35 "-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
36 "-n8:16:32:64-S128",
37 "x86_64-unknown-linux-gnu");
38 std::string DL2 = UpgradeDataLayoutString("e-p:32:32", "i686-apple-darwin9");
39 std::string DL3 = UpgradeDataLayoutString("e-m:e-i64:64-n32:64",
40 "powerpc64le-unknown-linux-gnu");
41 std::string DL4 =
42 UpgradeDataLayoutString("e-m:o-i64:64-i128:128-n32:64-S128", "aarch64--");
43 EXPECT_EQ(DL1, "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
44 "-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64"
45 "-f80:128:128-n8:16:32:64-S128");
46 EXPECT_EQ(DL2, "e-p:32:32");
47 EXPECT_EQ(DL3, "e-m:e-i64:64-n32:64");
48 EXPECT_EQ(DL4, "e-m:o-i64:64-i128:128-n32:64-S128");
51 TEST(DataLayoutUpgradeTest, EmptyDataLayout) {
52 std::string DL1 = UpgradeDataLayoutString("", "x86_64-unknown-linux-gnu");
53 std::string DL2 = UpgradeDataLayoutString(
54 "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128", "");
55 EXPECT_EQ(DL1, "");
56 EXPECT_EQ(DL2, "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128");
59 } // end namespace