1 //===- AArch64InstPrinterTest.cpp - AArch64InstPrinter unit 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/MC/MCAsmInfo.h"
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/MC/MCInst.h"
13 #include "llvm/MC/MCInstrInfo.h"
14 #include "llvm/MC/MCRegisterInfo.h"
15 #include "llvm/MC/MCSubtargetInfo.h"
16 #include "llvm/Support/raw_ostream.h"
18 #include "MCTargetDesc/AArch64InstPrinter.h"
20 #include "gtest/gtest.h"
24 class AArch64InstPrinterTest
: public AArch64InstPrinter
{
26 AArch64InstPrinterTest(const MCAsmInfo
&MAI
, const MCInstrInfo
&MII
,
27 const MCRegisterInfo
&MRI
)
28 : AArch64InstPrinter(MAI
, MII
, MRI
) {}
29 void printAlignedLabel(const MCInst
*MI
, uint64_t Address
, unsigned OpNum
,
30 const MCSubtargetInfo
&STI
, raw_ostream
&O
) {
31 AArch64InstPrinter::printAlignedLabel(MI
, Address
, OpNum
, STI
, O
);
35 static std::string
AArch64InstPrinterTestPrintAlignedLabel(uint64_t value
) {
39 MCSubtargetInfo
STI(Triple(""), "", "", "", {},
40 ArrayRef((SubtargetFeatureKV
*)NULL
, (size_t)0),
41 ArrayRef((SubtargetSubTypeKV
*)NULL
, (size_t)0), NULL
,
42 NULL
, NULL
, NULL
, NULL
, NULL
);
43 MCContext
Ctx(Triple(""), &MAI
, &MRI
, &STI
);
46 MI
.addOperand(MCOperand::createExpr(MCConstantExpr::create(value
, Ctx
)));
49 raw_string_ostream
O(str
);
50 AArch64InstPrinterTest(MAI
, MII
, MRI
).printAlignedLabel(&MI
, 0, 0, STI
, O
);
54 TEST(AArch64InstPrinterTest
, PrintAlignedLabel
) {
55 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0x0), "0x0");
56 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0xffffffff001200eb),
57 "0xffffffff001200eb");
58 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0x7c01445bcc10f),