1 //===- ConstantRangeTest.cpp - ConstantRange tests ------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/IR/DataLayout.h"
10 #include "llvm/IR/LLVMContext.h"
11 #include "llvm/IR/Type.h"
12 #include "gtest/gtest.h"
18 TEST(DataLayoutTest
, FunctionPtrAlign
) {
19 EXPECT_EQ(MaybeAlign(0), DataLayout("").getFunctionPtrAlign());
20 EXPECT_EQ(MaybeAlign(1), DataLayout("Fi8").getFunctionPtrAlign());
21 EXPECT_EQ(MaybeAlign(2), DataLayout("Fi16").getFunctionPtrAlign());
22 EXPECT_EQ(MaybeAlign(4), DataLayout("Fi32").getFunctionPtrAlign());
23 EXPECT_EQ(MaybeAlign(8), DataLayout("Fi64").getFunctionPtrAlign());
24 EXPECT_EQ(MaybeAlign(1), DataLayout("Fn8").getFunctionPtrAlign());
25 EXPECT_EQ(MaybeAlign(2), DataLayout("Fn16").getFunctionPtrAlign());
26 EXPECT_EQ(MaybeAlign(4), DataLayout("Fn32").getFunctionPtrAlign());
27 EXPECT_EQ(MaybeAlign(8), DataLayout("Fn64").getFunctionPtrAlign());
28 EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent
, \
29 DataLayout("").getFunctionPtrAlignType());
30 EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent
, \
31 DataLayout("Fi8").getFunctionPtrAlignType());
32 EXPECT_EQ(DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign
, \
33 DataLayout("Fn8").getFunctionPtrAlignType());
34 EXPECT_EQ(DataLayout("Fi8"), DataLayout("Fi8"));
35 EXPECT_NE(DataLayout("Fi8"), DataLayout("Fi16"));
36 EXPECT_NE(DataLayout("Fi8"), DataLayout("Fn8"));
38 DataLayout
a(""), b("Fi8"), c("Fn8");
49 TEST(DataLayoutTest
, ValueOrABITypeAlignment
) {
50 const DataLayout
DL("Fi8");
52 Type
*const FourByteAlignType
= Type::getInt32Ty(Context
);
54 DL
.getValueOrABITypeAlignment(MaybeAlign(16), FourByteAlignType
));
56 DL
.getValueOrABITypeAlignment(MaybeAlign(), FourByteAlignType
));
59 } // anonymous namespace