[yaml2obj/obj2yaml] - Do not trigger llvm_unreachable when dumping/parsing relocation...
[llvm-complete.git] / unittests / Target / AArch64 / TestStackOffset.cpp
blob240cec9f2d0b31fcf886eeff57bcc7ba31d59934
1 //===- TestStackOffset.cpp - StackOffset unit tests------------------------===//
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 "AArch64StackOffset.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 TEST(StackOffset, MixedSize) {
15 StackOffset A(1, MVT::i8);
16 EXPECT_EQ(1, A.getBytes());
18 StackOffset B(2, MVT::i32);
19 EXPECT_EQ(8, B.getBytes());
21 StackOffset C(2, MVT::v4i64);
22 EXPECT_EQ(64, C.getBytes());
25 TEST(StackOffset, Add) {
26 StackOffset A(1, MVT::i64);
27 StackOffset B(1, MVT::i32);
28 StackOffset C = A + B;
29 EXPECT_EQ(12, C.getBytes());
31 StackOffset D(1, MVT::i32);
32 D += A;
33 EXPECT_EQ(12, D.getBytes());
36 TEST(StackOffset, Sub) {
37 StackOffset A(1, MVT::i64);
38 StackOffset B(1, MVT::i32);
39 StackOffset C = A - B;
40 EXPECT_EQ(4, C.getBytes());
42 StackOffset D(1, MVT::i64);
43 D -= A;
44 EXPECT_EQ(0, D.getBytes());
47 TEST(StackOffset, isZero) {
48 StackOffset A(0, MVT::i64);
49 StackOffset B(0, MVT::i32);
50 EXPECT_TRUE(!A);
51 EXPECT_TRUE(!(A + B));
54 TEST(StackOffset, getForFrameOffset) {
55 StackOffset A(1, MVT::i64);
56 StackOffset B(1, MVT::i32);
57 int64_t ByteSized;
58 (A + B).getForFrameOffset(ByteSized);
59 EXPECT_EQ(12, ByteSized);