1- // ===- SystemZInstPrinter .cpp - Convert SystemZ MCInst to assembly syntax -== =//
1+ // =- SystemZInstPrinterCommon .cpp - Common SystemZ MCInst to assembly funcs - =//
22//
33// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44// See https://llvm.org/LICENSE.txt for license information.
55// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66//
77// ===----------------------------------------------------------------------===//
88
9- #include " SystemZInstPrinter .h"
9+ #include " SystemZInstPrinterCommon .h"
1010#include " llvm/MC/MCExpr.h"
1111#include " llvm/MC/MCInst.h"
1212#include " llvm/MC/MCRegister.h"
@@ -22,68 +22,49 @@ using namespace llvm;
2222
2323#define DEBUG_TYPE " asm-printer"
2424
25- #include " SystemZGenAsmWriter.inc"
26-
27- void SystemZInstPrinter::printAddress (const MCAsmInfo *MAI, MCRegister Base,
28- const MCOperand &DispMO, MCRegister Index,
29- raw_ostream &O) {
25+ void SystemZInstPrinterCommon::printAddress (const MCAsmInfo *MAI,
26+ MCRegister Base,
27+ const MCOperand &DispMO,
28+ MCRegister Index, raw_ostream &O) {
3029 printOperand (DispMO, MAI, O);
3130 if (Base || Index) {
3231 O << ' (' ;
3332 if (Index) {
34- printFormattedRegName (MAI , Index, O );
33+ printRegName (O , Index);
3534 O << ' ,' ;
3635 }
3736 if (Base)
38- printFormattedRegName (MAI , Base, O );
37+ printRegName (O , Base);
3938 else
4039 O << ' 0' ;
4140 O << ' )' ;
4241 }
4342}
4443
45- void SystemZInstPrinter::printOperand (const MCOperand &MO, const MCAsmInfo *MAI,
46- raw_ostream &O) {
44+ void SystemZInstPrinterCommon::printOperand (const MCOperand &MO,
45+ const MCAsmInfo *MAI,
46+ raw_ostream &O) {
4747 if (MO.isReg ()) {
4848 if (!MO.getReg ())
4949 O << ' 0' ;
5050 else
51- printFormattedRegName (MAI, MO.getReg (), O);
52- }
53- else if (MO.isImm ())
51+ printRegName (MAI, MO.getReg (), O);
52+ } else if (MO.isImm ())
5453 markup (O, Markup::Immediate) << MO.getImm ();
5554 else if (MO.isExpr ())
5655 MO.getExpr ()->print (O, MAI);
5756 else
5857 llvm_unreachable (" Invalid operand" );
5958}
6059
61- void SystemZInstPrinter::printFormattedRegName (const MCAsmInfo *MAI,
62- MCRegister Reg,
63- raw_ostream &O) const {
64- const char *RegName = getRegisterName (Reg);
65- if (MAI->getAssemblerDialect () == AD_HLASM) {
66- // Skip register prefix so that only register number is left
67- assert (isalpha (RegName[0 ]) && isdigit (RegName[1 ]));
68- markup (O, Markup::Register) << (RegName + 1 );
69- } else
70- markup (O, Markup::Register) << ' %' << RegName;
71- }
72-
73- void SystemZInstPrinter::printRegName (raw_ostream &O, MCRegister Reg) const {
60+ void SystemZInstPrinterCommon::printRegName (raw_ostream &O,
61+ MCRegister Reg) const {
7462 printFormattedRegName (&MAI, Reg, O);
7563}
7664
77- void SystemZInstPrinter::printInst (const MCInst *MI, uint64_t Address,
78- StringRef Annot, const MCSubtargetInfo &STI,
79- raw_ostream &O) {
80- printInstruction (MI, Address, O);
81- printAnnotation (O, Annot);
82- }
83-
8465template <unsigned N>
85- void SystemZInstPrinter ::printUImmOperand (const MCInst *MI, int OpNum,
86- raw_ostream &O) {
66+ void SystemZInstPrinterCommon ::printUImmOperand (const MCInst *MI, int OpNum,
67+ raw_ostream &O) {
8768 const MCOperand &MO = MI->getOperand (OpNum);
8869 if (MO.isExpr ()) {
8970 O << *MO.getExpr ();
@@ -95,8 +76,8 @@ void SystemZInstPrinter::printUImmOperand(const MCInst *MI, int OpNum,
9576}
9677
9778template <unsigned N>
98- void SystemZInstPrinter ::printSImmOperand (const MCInst *MI, int OpNum,
99- raw_ostream &O) {
79+ void SystemZInstPrinterCommon ::printSImmOperand (const MCInst *MI, int OpNum,
80+ raw_ostream &O) {
10081 const MCOperand &MO = MI->getOperand (OpNum);
10182 if (MO.isExpr ()) {
10283 O << *MO.getExpr ();
@@ -107,67 +88,67 @@ void SystemZInstPrinter::printSImmOperand(const MCInst *MI, int OpNum,
10788 markup (O, Markup::Immediate) << Value;
10889}
10990
110- void SystemZInstPrinter ::printU1ImmOperand (const MCInst *MI, int OpNum,
91+ void SystemZInstPrinterCommon ::printU1ImmOperand (const MCInst *MI, int OpNum,
11192 raw_ostream &O) {
11293 printUImmOperand<1 >(MI, OpNum, O);
11394}
11495
115- void SystemZInstPrinter ::printU2ImmOperand (const MCInst *MI, int OpNum,
96+ void SystemZInstPrinterCommon ::printU2ImmOperand (const MCInst *MI, int OpNum,
11697 raw_ostream &O) {
11798 printUImmOperand<2 >(MI, OpNum, O);
11899}
119100
120- void SystemZInstPrinter ::printU3ImmOperand (const MCInst *MI, int OpNum,
101+ void SystemZInstPrinterCommon ::printU3ImmOperand (const MCInst *MI, int OpNum,
121102 raw_ostream &O) {
122103 printUImmOperand<3 >(MI, OpNum, O);
123104}
124105
125- void SystemZInstPrinter ::printU4ImmOperand (const MCInst *MI, int OpNum,
106+ void SystemZInstPrinterCommon ::printU4ImmOperand (const MCInst *MI, int OpNum,
126107 raw_ostream &O) {
127108 printUImmOperand<4 >(MI, OpNum, O);
128109}
129110
130- void SystemZInstPrinter ::printS8ImmOperand (const MCInst *MI, int OpNum,
111+ void SystemZInstPrinterCommon ::printS8ImmOperand (const MCInst *MI, int OpNum,
131112 raw_ostream &O) {
132113 printSImmOperand<8 >(MI, OpNum, O);
133114}
134115
135- void SystemZInstPrinter ::printU8ImmOperand (const MCInst *MI, int OpNum,
116+ void SystemZInstPrinterCommon ::printU8ImmOperand (const MCInst *MI, int OpNum,
136117 raw_ostream &O) {
137118 printUImmOperand<8 >(MI, OpNum, O);
138119}
139120
140- void SystemZInstPrinter ::printU12ImmOperand (const MCInst *MI, int OpNum,
121+ void SystemZInstPrinterCommon ::printU12ImmOperand (const MCInst *MI, int OpNum,
141122 raw_ostream &O) {
142123 printUImmOperand<12 >(MI, OpNum, O);
143124}
144125
145- void SystemZInstPrinter ::printS16ImmOperand (const MCInst *MI, int OpNum,
126+ void SystemZInstPrinterCommon ::printS16ImmOperand (const MCInst *MI, int OpNum,
146127 raw_ostream &O) {
147128 printSImmOperand<16 >(MI, OpNum, O);
148129}
149130
150- void SystemZInstPrinter ::printU16ImmOperand (const MCInst *MI, int OpNum,
131+ void SystemZInstPrinterCommon ::printU16ImmOperand (const MCInst *MI, int OpNum,
151132 raw_ostream &O) {
152133 printUImmOperand<16 >(MI, OpNum, O);
153134}
154135
155- void SystemZInstPrinter ::printS32ImmOperand (const MCInst *MI, int OpNum,
136+ void SystemZInstPrinterCommon ::printS32ImmOperand (const MCInst *MI, int OpNum,
156137 raw_ostream &O) {
157138 printSImmOperand<32 >(MI, OpNum, O);
158139}
159140
160- void SystemZInstPrinter ::printU32ImmOperand (const MCInst *MI, int OpNum,
141+ void SystemZInstPrinterCommon ::printU32ImmOperand (const MCInst *MI, int OpNum,
161142 raw_ostream &O) {
162143 printUImmOperand<32 >(MI, OpNum, O);
163144}
164145
165- void SystemZInstPrinter ::printU48ImmOperand (const MCInst *MI, int OpNum,
146+ void SystemZInstPrinterCommon ::printU48ImmOperand (const MCInst *MI, int OpNum,
166147 raw_ostream &O) {
167148 printUImmOperand<48 >(MI, OpNum, O);
168149}
169150
170- void SystemZInstPrinter ::printPCRelOperand (const MCInst *MI, int OpNum,
151+ void SystemZInstPrinterCommon ::printPCRelOperand (const MCInst *MI, int OpNum,
171152 raw_ostream &O) {
172153 const MCOperand &MO = MI->getOperand (OpNum);
173154 if (MO.isImm ()) {
@@ -178,7 +159,7 @@ void SystemZInstPrinter::printPCRelOperand(const MCInst *MI, int OpNum,
178159 MO.getExpr ()->print (O, &MAI);
179160}
180161
181- void SystemZInstPrinter ::printPCRelTLSOperand (const MCInst *MI,
162+ void SystemZInstPrinterCommon ::printPCRelTLSOperand (const MCInst *MI,
182163 uint64_t Address, int OpNum,
183164 raw_ostream &O) {
184165 // Output the PC-relative operand.
@@ -202,24 +183,24 @@ void SystemZInstPrinter::printPCRelTLSOperand(const MCInst *MI,
202183 }
203184}
204185
205- void SystemZInstPrinter ::printOperand (const MCInst *MI, int OpNum,
186+ void SystemZInstPrinterCommon ::printOperand (const MCInst *MI, int OpNum,
206187 raw_ostream &O) {
207188 printOperand (MI->getOperand (OpNum), &MAI, O);
208189}
209190
210- void SystemZInstPrinter ::printBDAddrOperand (const MCInst *MI, int OpNum,
191+ void SystemZInstPrinterCommon ::printBDAddrOperand (const MCInst *MI, int OpNum,
211192 raw_ostream &O) {
212193 printAddress (&MAI, MI->getOperand (OpNum).getReg (), MI->getOperand (OpNum + 1 ),
213194 0 , O);
214195}
215196
216- void SystemZInstPrinter ::printBDXAddrOperand (const MCInst *MI, int OpNum,
197+ void SystemZInstPrinterCommon ::printBDXAddrOperand (const MCInst *MI, int OpNum,
217198 raw_ostream &O) {
218199 printAddress (&MAI, MI->getOperand (OpNum).getReg (), MI->getOperand (OpNum + 1 ),
219200 MI->getOperand (OpNum + 2 ).getReg (), O);
220201}
221202
222- void SystemZInstPrinter ::printBDLAddrOperand (const MCInst *MI, int OpNum,
203+ void SystemZInstPrinterCommon ::printBDLAddrOperand (const MCInst *MI, int OpNum,
223204 raw_ostream &O) {
224205 unsigned Base = MI->getOperand (OpNum).getReg ();
225206 const MCOperand &DispMO = MI->getOperand (OpNum + 1 );
@@ -233,7 +214,7 @@ void SystemZInstPrinter::printBDLAddrOperand(const MCInst *MI, int OpNum,
233214 O << ' )' ;
234215}
235216
236- void SystemZInstPrinter ::printBDRAddrOperand (const MCInst *MI, int OpNum,
217+ void SystemZInstPrinterCommon ::printBDRAddrOperand (const MCInst *MI, int OpNum,
237218 raw_ostream &O) {
238219 unsigned Base = MI->getOperand (OpNum).getReg ();
239220 const MCOperand &DispMO = MI->getOperand (OpNum + 1 );
@@ -248,13 +229,13 @@ void SystemZInstPrinter::printBDRAddrOperand(const MCInst *MI, int OpNum,
248229 O << ' )' ;
249230}
250231
251- void SystemZInstPrinter ::printBDVAddrOperand (const MCInst *MI, int OpNum,
232+ void SystemZInstPrinterCommon ::printBDVAddrOperand (const MCInst *MI, int OpNum,
252233 raw_ostream &O) {
253234 printAddress (&MAI, MI->getOperand (OpNum).getReg (), MI->getOperand (OpNum + 1 ),
254235 MI->getOperand (OpNum + 2 ).getReg (), O);
255236}
256237
257- void SystemZInstPrinter ::printCond4Operand (const MCInst *MI, int OpNum,
238+ void SystemZInstPrinterCommon ::printCond4Operand (const MCInst *MI, int OpNum,
258239 raw_ostream &O) {
259240 static const char *const CondNames[] = {
260241 " o" , " h" , " nle" , " l" , " nhe" , " lh" , " ne" ,
0 commit comments