[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / llvm / unittests / CodeGen / GlobalISel / GIMatchTableExecutorTest.cpp
blob5a811d795928809187f726e86a0797796287d0de
1 //===- GIMatchTableExecutorTest.cpp ---------------------------------------===//
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/CodeGen/GlobalISel/GIMatchTableExecutor.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 TEST(GlobalISelLEB128Test, fastDecodeULEB128) {
15 #define EXPECT_DECODE_ULEB128_EQ(EXPECTED, VALUE) \
16 do { \
17 uint64_t ActualSize = 0; \
18 uint64_t Actual = GIMatchTableExecutor::fastDecodeULEB128( \
19 reinterpret_cast<const uint8_t *>(VALUE), ActualSize); \
20 EXPECT_EQ(sizeof(VALUE) - 1, ActualSize); \
21 EXPECT_EQ(EXPECTED, Actual); \
22 } while (0)
24 EXPECT_DECODE_ULEB128_EQ(0u, "\x00");
25 EXPECT_DECODE_ULEB128_EQ(1u, "\x01");
26 EXPECT_DECODE_ULEB128_EQ(63u, "\x3f");
27 EXPECT_DECODE_ULEB128_EQ(64u, "\x40");
28 EXPECT_DECODE_ULEB128_EQ(0x7fu, "\x7f");
29 EXPECT_DECODE_ULEB128_EQ(0x80u, "\x80\x01");
30 EXPECT_DECODE_ULEB128_EQ(0x81u, "\x81\x01");
31 EXPECT_DECODE_ULEB128_EQ(0x90u, "\x90\x01");
32 EXPECT_DECODE_ULEB128_EQ(0xffu, "\xff\x01");
33 EXPECT_DECODE_ULEB128_EQ(0x100u, "\x80\x02");
34 EXPECT_DECODE_ULEB128_EQ(0x101u, "\x81\x02");
35 EXPECT_DECODE_ULEB128_EQ(4294975616ULL, "\x80\xc1\x80\x80\x10");
37 // Decode ULEB128 with extra padding bytes
38 EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x00");
39 EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x80\x00");
40 EXPECT_DECODE_ULEB128_EQ(0x7fu, "\xff\x00");
41 EXPECT_DECODE_ULEB128_EQ(0x7fu, "\xff\x80\x00");
42 EXPECT_DECODE_ULEB128_EQ(0x80u, "\x80\x81\x00");
43 EXPECT_DECODE_ULEB128_EQ(0x80u, "\x80\x81\x80\x00");
44 EXPECT_DECODE_ULEB128_EQ(0x80u, "\x80\x81\x80\x80\x80\x80\x80\x80\x80\x00");
45 EXPECT_DECODE_ULEB128_EQ(0x80000000'00000000ul,
46 "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x01");
48 #undef EXPECT_DECODE_ULEB128_EQ