[Clang][MIPS] Send correct architecture for MinGW toolchains (#121042)
[llvm-project.git] / llvm / unittests / Target / AArch64 / AArch64InstPrinterTest.cpp
blob4dfc0bcb0dc4c5e5854a02f6add6b30b4e96fb78
1 //===- AArch64InstPrinterTest.cpp - AArch64InstPrinter 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 "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"
22 using namespace llvm;
24 class AArch64InstPrinterTest : public AArch64InstPrinter {
25 public:
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) {
36 MCAsmInfo MAI;
37 MCInstrInfo MII;
38 MCRegisterInfo MRI;
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);
44 MCInst MI;
46 MI.addOperand(MCOperand::createExpr(MCConstantExpr::create(value, Ctx)));
48 std::string str;
49 raw_string_ostream O(str);
50 AArch64InstPrinterTest(MAI, MII, MRI).printAlignedLabel(&MI, 0, 0, STI, O);
51 return str;
54 TEST(AArch64InstPrinterTest, PrintAlignedLabel) {
55 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0x0), "0x0");
56 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0xffffffff001200eb),
57 "0xffffffff001200eb");
58 EXPECT_EQ(AArch64InstPrinterTestPrintAlignedLabel(0x7c01445bcc10f),
59 "0x7c01445bcc10f");