xref: /minix3/external/bsd/llvm/dist/llvm/lib/Target/R600/InstPrinter/AMDGPUInstPrinter.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===-- AMDGPUInstPrinter.cpp - AMDGPU MC Inst -> ASM ---------------------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc // \file
9f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc #include "AMDGPUInstPrinter.h"
12f4a2713aSLionel Sambuc #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
13*0a6a1f1dSLionel Sambuc #include "SIDefines.h"
14f4a2713aSLionel Sambuc #include "llvm/MC/MCExpr.h"
15f4a2713aSLionel Sambuc #include "llvm/MC/MCInst.h"
16*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCInstrInfo.h"
17*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCRegisterInfo.h"
18*0a6a1f1dSLionel Sambuc #include "llvm/Support/MathExtras.h"
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc using namespace llvm;
21f4a2713aSLionel Sambuc 
printInst(const MCInst * MI,raw_ostream & OS,StringRef Annot)22f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
23f4a2713aSLionel Sambuc                              StringRef Annot) {
24f4a2713aSLionel Sambuc   OS.flush();
25f4a2713aSLionel Sambuc   printInstruction(MI, OS);
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc   printAnnotation(OS, Annot);
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc 
printU8ImmOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)30*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printU8ImmOperand(const MCInst *MI, unsigned OpNo,
31*0a6a1f1dSLionel Sambuc                                            raw_ostream &O) {
32*0a6a1f1dSLionel Sambuc   O << formatHex(MI->getOperand(OpNo).getImm() & 0xff);
33*0a6a1f1dSLionel Sambuc }
34*0a6a1f1dSLionel Sambuc 
printU16ImmOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)35*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
36*0a6a1f1dSLionel Sambuc                                            raw_ostream &O) {
37*0a6a1f1dSLionel Sambuc   O << formatHex(MI->getOperand(OpNo).getImm() & 0xffff);
38*0a6a1f1dSLionel Sambuc }
39*0a6a1f1dSLionel Sambuc 
printU32ImmOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)40*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printU32ImmOperand(const MCInst *MI, unsigned OpNo,
41*0a6a1f1dSLionel Sambuc                                            raw_ostream &O) {
42*0a6a1f1dSLionel Sambuc   O << formatHex(MI->getOperand(OpNo).getImm() & 0xffffffff);
43*0a6a1f1dSLionel Sambuc }
44*0a6a1f1dSLionel Sambuc 
printU8ImmDecOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)45*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printU8ImmDecOperand(const MCInst *MI, unsigned OpNo,
46*0a6a1f1dSLionel Sambuc                                              raw_ostream &O) {
47*0a6a1f1dSLionel Sambuc   O << formatDec(MI->getOperand(OpNo).getImm() & 0xff);
48*0a6a1f1dSLionel Sambuc }
49*0a6a1f1dSLionel Sambuc 
printU16ImmDecOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)50*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printU16ImmDecOperand(const MCInst *MI, unsigned OpNo,
51*0a6a1f1dSLionel Sambuc                                               raw_ostream &O) {
52*0a6a1f1dSLionel Sambuc   O << formatDec(MI->getOperand(OpNo).getImm() & 0xffff);
53*0a6a1f1dSLionel Sambuc }
54*0a6a1f1dSLionel Sambuc 
printOffen(const MCInst * MI,unsigned OpNo,raw_ostream & O)55*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printOffen(const MCInst *MI, unsigned OpNo,
56*0a6a1f1dSLionel Sambuc                                    raw_ostream &O) {
57*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
58*0a6a1f1dSLionel Sambuc     O << " offen";
59*0a6a1f1dSLionel Sambuc }
60*0a6a1f1dSLionel Sambuc 
printIdxen(const MCInst * MI,unsigned OpNo,raw_ostream & O)61*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printIdxen(const MCInst *MI, unsigned OpNo,
62*0a6a1f1dSLionel Sambuc                                    raw_ostream &O) {
63*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
64*0a6a1f1dSLionel Sambuc     O << " idxen";
65*0a6a1f1dSLionel Sambuc }
66*0a6a1f1dSLionel Sambuc 
printAddr64(const MCInst * MI,unsigned OpNo,raw_ostream & O)67*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printAddr64(const MCInst *MI, unsigned OpNo,
68*0a6a1f1dSLionel Sambuc                                     raw_ostream &O) {
69*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
70*0a6a1f1dSLionel Sambuc     O << " addr64";
71*0a6a1f1dSLionel Sambuc }
72*0a6a1f1dSLionel Sambuc 
printMBUFOffset(const MCInst * MI,unsigned OpNo,raw_ostream & O)73*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printMBUFOffset(const MCInst *MI, unsigned OpNo,
74*0a6a1f1dSLionel Sambuc                                         raw_ostream &O) {
75*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm()) {
76*0a6a1f1dSLionel Sambuc     O << " offset:";
77*0a6a1f1dSLionel Sambuc     printU16ImmDecOperand(MI, OpNo, O);
78*0a6a1f1dSLionel Sambuc   }
79*0a6a1f1dSLionel Sambuc }
80*0a6a1f1dSLionel Sambuc 
printDSOffset(const MCInst * MI,unsigned OpNo,raw_ostream & O)81*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printDSOffset(const MCInst *MI, unsigned OpNo,
82*0a6a1f1dSLionel Sambuc                                       raw_ostream &O) {
83*0a6a1f1dSLionel Sambuc   uint16_t Imm = MI->getOperand(OpNo).getImm();
84*0a6a1f1dSLionel Sambuc   if (Imm != 0) {
85*0a6a1f1dSLionel Sambuc     O << " offset:";
86*0a6a1f1dSLionel Sambuc     printU16ImmDecOperand(MI, OpNo, O);
87*0a6a1f1dSLionel Sambuc   }
88*0a6a1f1dSLionel Sambuc }
89*0a6a1f1dSLionel Sambuc 
printDSOffset0(const MCInst * MI,unsigned OpNo,raw_ostream & O)90*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printDSOffset0(const MCInst *MI, unsigned OpNo,
91*0a6a1f1dSLionel Sambuc                                         raw_ostream &O) {
92*0a6a1f1dSLionel Sambuc   O << " offset0:";
93*0a6a1f1dSLionel Sambuc   printU8ImmDecOperand(MI, OpNo, O);
94*0a6a1f1dSLionel Sambuc }
95*0a6a1f1dSLionel Sambuc 
printDSOffset1(const MCInst * MI,unsigned OpNo,raw_ostream & O)96*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printDSOffset1(const MCInst *MI, unsigned OpNo,
97*0a6a1f1dSLionel Sambuc                                         raw_ostream &O) {
98*0a6a1f1dSLionel Sambuc   O << " offset1:";
99*0a6a1f1dSLionel Sambuc   printU8ImmDecOperand(MI, OpNo, O);
100*0a6a1f1dSLionel Sambuc }
101*0a6a1f1dSLionel Sambuc 
printGLC(const MCInst * MI,unsigned OpNo,raw_ostream & O)102*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printGLC(const MCInst *MI, unsigned OpNo,
103*0a6a1f1dSLionel Sambuc                                  raw_ostream &O) {
104*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
105*0a6a1f1dSLionel Sambuc     O << " glc";
106*0a6a1f1dSLionel Sambuc }
107*0a6a1f1dSLionel Sambuc 
printSLC(const MCInst * MI,unsigned OpNo,raw_ostream & O)108*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printSLC(const MCInst *MI, unsigned OpNo,
109*0a6a1f1dSLionel Sambuc                                  raw_ostream &O) {
110*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
111*0a6a1f1dSLionel Sambuc     O << " slc";
112*0a6a1f1dSLionel Sambuc }
113*0a6a1f1dSLionel Sambuc 
printTFE(const MCInst * MI,unsigned OpNo,raw_ostream & O)114*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printTFE(const MCInst *MI, unsigned OpNo,
115*0a6a1f1dSLionel Sambuc                                  raw_ostream &O) {
116*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
117*0a6a1f1dSLionel Sambuc     O << " tfe";
118*0a6a1f1dSLionel Sambuc }
119*0a6a1f1dSLionel Sambuc 
printRegOperand(unsigned reg,raw_ostream & O)120f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printRegOperand(unsigned reg, raw_ostream &O) {
121f4a2713aSLionel Sambuc   switch (reg) {
122f4a2713aSLionel Sambuc   case AMDGPU::VCC:
123f4a2713aSLionel Sambuc     O << "vcc";
124f4a2713aSLionel Sambuc     return;
125f4a2713aSLionel Sambuc   case AMDGPU::SCC:
126f4a2713aSLionel Sambuc     O << "scc";
127f4a2713aSLionel Sambuc     return;
128f4a2713aSLionel Sambuc   case AMDGPU::EXEC:
129f4a2713aSLionel Sambuc     O << "exec";
130f4a2713aSLionel Sambuc     return;
131f4a2713aSLionel Sambuc   case AMDGPU::M0:
132f4a2713aSLionel Sambuc     O << "m0";
133f4a2713aSLionel Sambuc     return;
134*0a6a1f1dSLionel Sambuc   case AMDGPU::FLAT_SCR:
135*0a6a1f1dSLionel Sambuc     O << "flat_scratch";
136*0a6a1f1dSLionel Sambuc     return;
137*0a6a1f1dSLionel Sambuc   case AMDGPU::VCC_LO:
138*0a6a1f1dSLionel Sambuc     O << "vcc_lo";
139*0a6a1f1dSLionel Sambuc     return;
140*0a6a1f1dSLionel Sambuc   case AMDGPU::VCC_HI:
141*0a6a1f1dSLionel Sambuc     O << "vcc_hi";
142*0a6a1f1dSLionel Sambuc     return;
143*0a6a1f1dSLionel Sambuc   case AMDGPU::EXEC_LO:
144*0a6a1f1dSLionel Sambuc     O << "exec_lo";
145*0a6a1f1dSLionel Sambuc     return;
146*0a6a1f1dSLionel Sambuc   case AMDGPU::EXEC_HI:
147*0a6a1f1dSLionel Sambuc     O << "exec_hi";
148*0a6a1f1dSLionel Sambuc     return;
149*0a6a1f1dSLionel Sambuc   case AMDGPU::FLAT_SCR_LO:
150*0a6a1f1dSLionel Sambuc     O << "flat_scratch_lo";
151*0a6a1f1dSLionel Sambuc     return;
152*0a6a1f1dSLionel Sambuc   case AMDGPU::FLAT_SCR_HI:
153*0a6a1f1dSLionel Sambuc     O << "flat_scratch_hi";
154*0a6a1f1dSLionel Sambuc     return;
155f4a2713aSLionel Sambuc   default:
156f4a2713aSLionel Sambuc     break;
157f4a2713aSLionel Sambuc   }
158f4a2713aSLionel Sambuc 
159*0a6a1f1dSLionel Sambuc   char Type;
160*0a6a1f1dSLionel Sambuc   unsigned NumRegs;
161f4a2713aSLionel Sambuc 
162*0a6a1f1dSLionel Sambuc   if (MRI.getRegClass(AMDGPU::VGPR_32RegClassID).contains(reg)) {
163*0a6a1f1dSLionel Sambuc     Type = 'v';
164*0a6a1f1dSLionel Sambuc     NumRegs = 1;
165*0a6a1f1dSLionel Sambuc   } else  if (MRI.getRegClass(AMDGPU::SGPR_32RegClassID).contains(reg)) {
166*0a6a1f1dSLionel Sambuc     Type = 's';
167*0a6a1f1dSLionel Sambuc     NumRegs = 1;
168*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::VReg_64RegClassID).contains(reg)) {
169*0a6a1f1dSLionel Sambuc     Type = 'v';
170*0a6a1f1dSLionel Sambuc     NumRegs = 2;
171*0a6a1f1dSLionel Sambuc   } else  if (MRI.getRegClass(AMDGPU::SReg_64RegClassID).contains(reg)) {
172*0a6a1f1dSLionel Sambuc     Type = 's';
173*0a6a1f1dSLionel Sambuc     NumRegs = 2;
174*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::VReg_128RegClassID).contains(reg)) {
175*0a6a1f1dSLionel Sambuc     Type = 'v';
176*0a6a1f1dSLionel Sambuc     NumRegs = 4;
177*0a6a1f1dSLionel Sambuc   } else  if (MRI.getRegClass(AMDGPU::SReg_128RegClassID).contains(reg)) {
178*0a6a1f1dSLionel Sambuc     Type = 's';
179*0a6a1f1dSLionel Sambuc     NumRegs = 4;
180*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::VReg_96RegClassID).contains(reg)) {
181*0a6a1f1dSLionel Sambuc     Type = 'v';
182*0a6a1f1dSLionel Sambuc     NumRegs = 3;
183*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::VReg_256RegClassID).contains(reg)) {
184*0a6a1f1dSLionel Sambuc     Type = 'v';
185*0a6a1f1dSLionel Sambuc     NumRegs = 8;
186*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::SReg_256RegClassID).contains(reg)) {
187*0a6a1f1dSLionel Sambuc     Type = 's';
188*0a6a1f1dSLionel Sambuc     NumRegs = 8;
189*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::VReg_512RegClassID).contains(reg)) {
190*0a6a1f1dSLionel Sambuc     Type = 'v';
191*0a6a1f1dSLionel Sambuc     NumRegs = 16;
192*0a6a1f1dSLionel Sambuc   } else if (MRI.getRegClass(AMDGPU::SReg_512RegClassID).contains(reg)) {
193*0a6a1f1dSLionel Sambuc     Type = 's';
194*0a6a1f1dSLionel Sambuc     NumRegs = 16;
195*0a6a1f1dSLionel Sambuc   } else {
196*0a6a1f1dSLionel Sambuc     O << getRegisterName(reg);
197f4a2713aSLionel Sambuc     return;
198f4a2713aSLionel Sambuc   }
199f4a2713aSLionel Sambuc 
200*0a6a1f1dSLionel Sambuc   // The low 8 bits of the encoding value is the register index, for both VGPRs
201*0a6a1f1dSLionel Sambuc   // and SGPRs.
202*0a6a1f1dSLionel Sambuc   unsigned RegIdx = MRI.getEncodingValue(reg) & ((1 << 8) - 1);
203*0a6a1f1dSLionel Sambuc   if (NumRegs == 1) {
204*0a6a1f1dSLionel Sambuc     O << Type << RegIdx;
205f4a2713aSLionel Sambuc     return;
206f4a2713aSLionel Sambuc   }
207f4a2713aSLionel Sambuc 
208*0a6a1f1dSLionel Sambuc   O << Type << '[' << RegIdx << ':' << (RegIdx + NumRegs - 1) << ']';
209*0a6a1f1dSLionel Sambuc }
210*0a6a1f1dSLionel Sambuc 
printImmediate32(uint32_t Imm,raw_ostream & O)211*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printImmediate32(uint32_t Imm, raw_ostream &O) {
212*0a6a1f1dSLionel Sambuc   int32_t SImm = static_cast<int32_t>(Imm);
213*0a6a1f1dSLionel Sambuc   if (SImm >= -16 && SImm <= 64) {
214*0a6a1f1dSLionel Sambuc     O << SImm;
215f4a2713aSLionel Sambuc     return;
216f4a2713aSLionel Sambuc   }
217f4a2713aSLionel Sambuc 
218*0a6a1f1dSLionel Sambuc   if (Imm == FloatToBits(0.0f))
219*0a6a1f1dSLionel Sambuc     O << "0.0";
220*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(1.0f))
221*0a6a1f1dSLionel Sambuc     O << "1.0";
222*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(-1.0f))
223*0a6a1f1dSLionel Sambuc     O << "-1.0";
224*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(0.5f))
225*0a6a1f1dSLionel Sambuc     O << "0.5";
226*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(-0.5f))
227*0a6a1f1dSLionel Sambuc     O << "-0.5";
228*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(2.0f))
229*0a6a1f1dSLionel Sambuc     O << "2.0";
230*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(-2.0f))
231*0a6a1f1dSLionel Sambuc     O << "-2.0";
232*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(4.0f))
233*0a6a1f1dSLionel Sambuc     O << "4.0";
234*0a6a1f1dSLionel Sambuc   else if (Imm == FloatToBits(-4.0f))
235*0a6a1f1dSLionel Sambuc     O << "-4.0";
236*0a6a1f1dSLionel Sambuc   else
237*0a6a1f1dSLionel Sambuc     O << formatHex(static_cast<uint64_t>(Imm));
238f4a2713aSLionel Sambuc }
239*0a6a1f1dSLionel Sambuc 
printImmediate64(uint64_t Imm,raw_ostream & O)240*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printImmediate64(uint64_t Imm, raw_ostream &O) {
241*0a6a1f1dSLionel Sambuc   int64_t SImm = static_cast<int64_t>(Imm);
242*0a6a1f1dSLionel Sambuc   if (SImm >= -16 && SImm <= 64) {
243*0a6a1f1dSLionel Sambuc     O << SImm;
244*0a6a1f1dSLionel Sambuc     return;
245*0a6a1f1dSLionel Sambuc   }
246*0a6a1f1dSLionel Sambuc 
247*0a6a1f1dSLionel Sambuc   if (Imm == DoubleToBits(0.0))
248*0a6a1f1dSLionel Sambuc     O << "0.0";
249*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(1.0))
250*0a6a1f1dSLionel Sambuc     O << "1.0";
251*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(-1.0))
252*0a6a1f1dSLionel Sambuc     O << "-1.0";
253*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(0.5))
254*0a6a1f1dSLionel Sambuc     O << "0.5";
255*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(-0.5))
256*0a6a1f1dSLionel Sambuc     O << "-0.5";
257*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(2.0))
258*0a6a1f1dSLionel Sambuc     O << "2.0";
259*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(-2.0))
260*0a6a1f1dSLionel Sambuc     O << "-2.0";
261*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(4.0))
262*0a6a1f1dSLionel Sambuc     O << "4.0";
263*0a6a1f1dSLionel Sambuc   else if (Imm == DoubleToBits(-4.0))
264*0a6a1f1dSLionel Sambuc     O << "-4.0";
265*0a6a1f1dSLionel Sambuc   else
266*0a6a1f1dSLionel Sambuc     llvm_unreachable("64-bit literal constants not supported");
267f4a2713aSLionel Sambuc }
268f4a2713aSLionel Sambuc 
printOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)269f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
270f4a2713aSLionel Sambuc                                      raw_ostream &O) {
271f4a2713aSLionel Sambuc 
272f4a2713aSLionel Sambuc   const MCOperand &Op = MI->getOperand(OpNo);
273f4a2713aSLionel Sambuc   if (Op.isReg()) {
274f4a2713aSLionel Sambuc     switch (Op.getReg()) {
275f4a2713aSLionel Sambuc     // This is the default predicate state, so we don't need to print it.
276f4a2713aSLionel Sambuc     case AMDGPU::PRED_SEL_OFF:
277f4a2713aSLionel Sambuc       break;
278f4a2713aSLionel Sambuc 
279f4a2713aSLionel Sambuc     default:
280f4a2713aSLionel Sambuc       printRegOperand(Op.getReg(), O);
281f4a2713aSLionel Sambuc       break;
282f4a2713aSLionel Sambuc     }
283f4a2713aSLionel Sambuc   } else if (Op.isImm()) {
284*0a6a1f1dSLionel Sambuc     const MCInstrDesc &Desc = MII.get(MI->getOpcode());
285*0a6a1f1dSLionel Sambuc     int RCID = Desc.OpInfo[OpNo].RegClass;
286*0a6a1f1dSLionel Sambuc     if (RCID != -1) {
287*0a6a1f1dSLionel Sambuc       const MCRegisterClass &ImmRC = MRI.getRegClass(RCID);
288*0a6a1f1dSLionel Sambuc       if (ImmRC.getSize() == 4)
289*0a6a1f1dSLionel Sambuc         printImmediate32(Op.getImm(), O);
290*0a6a1f1dSLionel Sambuc       else if (ImmRC.getSize() == 8)
291*0a6a1f1dSLionel Sambuc         printImmediate64(Op.getImm(), O);
292*0a6a1f1dSLionel Sambuc       else
293*0a6a1f1dSLionel Sambuc         llvm_unreachable("Invalid register class size");
294*0a6a1f1dSLionel Sambuc     } else if (Desc.OpInfo[OpNo].OperandType == MCOI::OPERAND_IMMEDIATE) {
295*0a6a1f1dSLionel Sambuc       printImmediate32(Op.getImm(), O);
296*0a6a1f1dSLionel Sambuc     } else {
297*0a6a1f1dSLionel Sambuc       // We hit this for the immediate instruction bits that don't yet have a
298*0a6a1f1dSLionel Sambuc       // custom printer.
299*0a6a1f1dSLionel Sambuc       // TODO: Eventually this should be unnecessary.
300*0a6a1f1dSLionel Sambuc       O << formatDec(Op.getImm());
301*0a6a1f1dSLionel Sambuc     }
302f4a2713aSLionel Sambuc   } else if (Op.isFPImm()) {
303*0a6a1f1dSLionel Sambuc     // We special case 0.0 because otherwise it will be printed as an integer.
304*0a6a1f1dSLionel Sambuc     if (Op.getFPImm() == 0.0)
305*0a6a1f1dSLionel Sambuc       O << "0.0";
306*0a6a1f1dSLionel Sambuc     else {
307*0a6a1f1dSLionel Sambuc       const MCInstrDesc &Desc = MII.get(MI->getOpcode());
308*0a6a1f1dSLionel Sambuc       const MCRegisterClass &ImmRC = MRI.getRegClass(Desc.OpInfo[OpNo].RegClass);
309*0a6a1f1dSLionel Sambuc 
310*0a6a1f1dSLionel Sambuc       if (ImmRC.getSize() == 4)
311*0a6a1f1dSLionel Sambuc         printImmediate32(FloatToBits(Op.getFPImm()), O);
312*0a6a1f1dSLionel Sambuc       else if (ImmRC.getSize() == 8)
313*0a6a1f1dSLionel Sambuc         printImmediate64(DoubleToBits(Op.getFPImm()), O);
314*0a6a1f1dSLionel Sambuc       else
315*0a6a1f1dSLionel Sambuc         llvm_unreachable("Invalid register class size");
316*0a6a1f1dSLionel Sambuc     }
317f4a2713aSLionel Sambuc   } else if (Op.isExpr()) {
318f4a2713aSLionel Sambuc     const MCExpr *Exp = Op.getExpr();
319f4a2713aSLionel Sambuc     Exp->print(O);
320f4a2713aSLionel Sambuc   } else {
321*0a6a1f1dSLionel Sambuc     llvm_unreachable("unknown operand type in printOperand");
322f4a2713aSLionel Sambuc   }
323f4a2713aSLionel Sambuc }
324f4a2713aSLionel Sambuc 
printOperandAndMods(const MCInst * MI,unsigned OpNo,raw_ostream & O)325*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printOperandAndMods(const MCInst *MI, unsigned OpNo,
326*0a6a1f1dSLionel Sambuc                                             raw_ostream &O) {
327*0a6a1f1dSLionel Sambuc   unsigned InputModifiers = MI->getOperand(OpNo).getImm();
328*0a6a1f1dSLionel Sambuc   if (InputModifiers & SISrcMods::NEG)
329*0a6a1f1dSLionel Sambuc     O << '-';
330*0a6a1f1dSLionel Sambuc   if (InputModifiers & SISrcMods::ABS)
331*0a6a1f1dSLionel Sambuc     O << '|';
332*0a6a1f1dSLionel Sambuc   printOperand(MI, OpNo + 1, O);
333*0a6a1f1dSLionel Sambuc   if (InputModifiers & SISrcMods::ABS)
334*0a6a1f1dSLionel Sambuc     O << '|';
335*0a6a1f1dSLionel Sambuc }
336*0a6a1f1dSLionel Sambuc 
printInterpSlot(const MCInst * MI,unsigned OpNum,raw_ostream & O)337f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printInterpSlot(const MCInst *MI, unsigned OpNum,
338f4a2713aSLionel Sambuc                                         raw_ostream &O) {
339f4a2713aSLionel Sambuc   unsigned Imm = MI->getOperand(OpNum).getImm();
340f4a2713aSLionel Sambuc 
341f4a2713aSLionel Sambuc   if (Imm == 2) {
342f4a2713aSLionel Sambuc     O << "P0";
343f4a2713aSLionel Sambuc   } else if (Imm == 1) {
344f4a2713aSLionel Sambuc     O << "P20";
345f4a2713aSLionel Sambuc   } else if (Imm == 0) {
346f4a2713aSLionel Sambuc     O << "P10";
347f4a2713aSLionel Sambuc   } else {
348*0a6a1f1dSLionel Sambuc     llvm_unreachable("Invalid interpolation parameter slot");
349f4a2713aSLionel Sambuc   }
350f4a2713aSLionel Sambuc }
351f4a2713aSLionel Sambuc 
printMemOperand(const MCInst * MI,unsigned OpNo,raw_ostream & O)352f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
353f4a2713aSLionel Sambuc                                         raw_ostream &O) {
354f4a2713aSLionel Sambuc   printOperand(MI, OpNo, O);
355f4a2713aSLionel Sambuc   O  << ", ";
356f4a2713aSLionel Sambuc   printOperand(MI, OpNo + 1, O);
357f4a2713aSLionel Sambuc }
358f4a2713aSLionel Sambuc 
printIfSet(const MCInst * MI,unsigned OpNo,raw_ostream & O,StringRef Asm,StringRef Default)359f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
360f4a2713aSLionel Sambuc                                    raw_ostream &O, StringRef Asm,
361f4a2713aSLionel Sambuc                                    StringRef Default) {
362f4a2713aSLionel Sambuc   const MCOperand &Op = MI->getOperand(OpNo);
363f4a2713aSLionel Sambuc   assert(Op.isImm());
364f4a2713aSLionel Sambuc   if (Op.getImm() == 1) {
365f4a2713aSLionel Sambuc     O << Asm;
366f4a2713aSLionel Sambuc   } else {
367f4a2713aSLionel Sambuc     O << Default;
368f4a2713aSLionel Sambuc   }
369f4a2713aSLionel Sambuc }
370f4a2713aSLionel Sambuc 
printAbs(const MCInst * MI,unsigned OpNo,raw_ostream & O)371f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printAbs(const MCInst *MI, unsigned OpNo,
372f4a2713aSLionel Sambuc                                  raw_ostream &O) {
373f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "|");
374f4a2713aSLionel Sambuc }
375f4a2713aSLionel Sambuc 
printClamp(const MCInst * MI,unsigned OpNo,raw_ostream & O)376f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printClamp(const MCInst *MI, unsigned OpNo,
377f4a2713aSLionel Sambuc                                    raw_ostream &O) {
378f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "_SAT");
379f4a2713aSLionel Sambuc }
380f4a2713aSLionel Sambuc 
printClampSI(const MCInst * MI,unsigned OpNo,raw_ostream & O)381*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printClampSI(const MCInst *MI, unsigned OpNo,
382*0a6a1f1dSLionel Sambuc                                      raw_ostream &O) {
383*0a6a1f1dSLionel Sambuc   if (MI->getOperand(OpNo).getImm())
384*0a6a1f1dSLionel Sambuc     O << " clamp";
385*0a6a1f1dSLionel Sambuc }
386*0a6a1f1dSLionel Sambuc 
printOModSI(const MCInst * MI,unsigned OpNo,raw_ostream & O)387*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printOModSI(const MCInst *MI, unsigned OpNo,
388*0a6a1f1dSLionel Sambuc                                      raw_ostream &O) {
389*0a6a1f1dSLionel Sambuc   int Imm = MI->getOperand(OpNo).getImm();
390*0a6a1f1dSLionel Sambuc   if (Imm == SIOutMods::MUL2)
391*0a6a1f1dSLionel Sambuc     O << " mul:2";
392*0a6a1f1dSLionel Sambuc   else if (Imm == SIOutMods::MUL4)
393*0a6a1f1dSLionel Sambuc     O << " mul:4";
394*0a6a1f1dSLionel Sambuc   else if (Imm == SIOutMods::DIV2)
395*0a6a1f1dSLionel Sambuc     O << " div:2";
396*0a6a1f1dSLionel Sambuc }
397*0a6a1f1dSLionel Sambuc 
printLiteral(const MCInst * MI,unsigned OpNo,raw_ostream & O)398f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printLiteral(const MCInst *MI, unsigned OpNo,
399f4a2713aSLionel Sambuc                                      raw_ostream &O) {
400*0a6a1f1dSLionel Sambuc   int32_t Imm = MI->getOperand(OpNo).getImm();
401*0a6a1f1dSLionel Sambuc   O << Imm << '(' << BitsToFloat(Imm) << ')';
402f4a2713aSLionel Sambuc }
403f4a2713aSLionel Sambuc 
printLast(const MCInst * MI,unsigned OpNo,raw_ostream & O)404f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printLast(const MCInst *MI, unsigned OpNo,
405f4a2713aSLionel Sambuc                                   raw_ostream &O) {
406f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O.indent(25 - O.GetNumBytesInBuffer()), "*", " ");
407f4a2713aSLionel Sambuc }
408f4a2713aSLionel Sambuc 
printNeg(const MCInst * MI,unsigned OpNo,raw_ostream & O)409f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printNeg(const MCInst *MI, unsigned OpNo,
410f4a2713aSLionel Sambuc                                  raw_ostream &O) {
411f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "-");
412f4a2713aSLionel Sambuc }
413f4a2713aSLionel Sambuc 
printOMOD(const MCInst * MI,unsigned OpNo,raw_ostream & O)414f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printOMOD(const MCInst *MI, unsigned OpNo,
415f4a2713aSLionel Sambuc                                   raw_ostream &O) {
416f4a2713aSLionel Sambuc   switch (MI->getOperand(OpNo).getImm()) {
417f4a2713aSLionel Sambuc   default: break;
418f4a2713aSLionel Sambuc   case 1:
419f4a2713aSLionel Sambuc     O << " * 2.0";
420f4a2713aSLionel Sambuc     break;
421f4a2713aSLionel Sambuc   case 2:
422f4a2713aSLionel Sambuc     O << " * 4.0";
423f4a2713aSLionel Sambuc     break;
424f4a2713aSLionel Sambuc   case 3:
425f4a2713aSLionel Sambuc     O << " / 2.0";
426f4a2713aSLionel Sambuc     break;
427f4a2713aSLionel Sambuc   }
428f4a2713aSLionel Sambuc }
429f4a2713aSLionel Sambuc 
printRel(const MCInst * MI,unsigned OpNo,raw_ostream & O)430f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printRel(const MCInst *MI, unsigned OpNo,
431f4a2713aSLionel Sambuc                                  raw_ostream &O) {
432f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "+");
433f4a2713aSLionel Sambuc }
434f4a2713aSLionel Sambuc 
printUpdateExecMask(const MCInst * MI,unsigned OpNo,raw_ostream & O)435f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
436f4a2713aSLionel Sambuc                                             raw_ostream &O) {
437f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "ExecMask,");
438f4a2713aSLionel Sambuc }
439f4a2713aSLionel Sambuc 
printUpdatePred(const MCInst * MI,unsigned OpNo,raw_ostream & O)440f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
441f4a2713aSLionel Sambuc                                         raw_ostream &O) {
442f4a2713aSLionel Sambuc   printIfSet(MI, OpNo, O, "Pred,");
443f4a2713aSLionel Sambuc }
444f4a2713aSLionel Sambuc 
printWrite(const MCInst * MI,unsigned OpNo,raw_ostream & O)445f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
446f4a2713aSLionel Sambuc                                        raw_ostream &O) {
447f4a2713aSLionel Sambuc   const MCOperand &Op = MI->getOperand(OpNo);
448f4a2713aSLionel Sambuc   if (Op.getImm() == 0) {
449f4a2713aSLionel Sambuc     O << " (MASKED)";
450f4a2713aSLionel Sambuc   }
451f4a2713aSLionel Sambuc }
452f4a2713aSLionel Sambuc 
printSel(const MCInst * MI,unsigned OpNo,raw_ostream & O)453f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printSel(const MCInst *MI, unsigned OpNo,
454f4a2713aSLionel Sambuc                                   raw_ostream &O) {
455f4a2713aSLionel Sambuc   const char * chans = "XYZW";
456f4a2713aSLionel Sambuc   int sel = MI->getOperand(OpNo).getImm();
457f4a2713aSLionel Sambuc 
458f4a2713aSLionel Sambuc   int chan = sel & 3;
459f4a2713aSLionel Sambuc   sel >>= 2;
460f4a2713aSLionel Sambuc 
461f4a2713aSLionel Sambuc   if (sel >= 512) {
462f4a2713aSLionel Sambuc     sel -= 512;
463f4a2713aSLionel Sambuc     int cb = sel >> 12;
464f4a2713aSLionel Sambuc     sel &= 4095;
465*0a6a1f1dSLionel Sambuc     O << cb << '[' << sel << ']';
466f4a2713aSLionel Sambuc   } else if (sel >= 448) {
467f4a2713aSLionel Sambuc     sel -= 448;
468f4a2713aSLionel Sambuc     O << sel;
469f4a2713aSLionel Sambuc   } else if (sel >= 0){
470f4a2713aSLionel Sambuc     O << sel;
471f4a2713aSLionel Sambuc   }
472f4a2713aSLionel Sambuc 
473f4a2713aSLionel Sambuc   if (sel >= 0)
474*0a6a1f1dSLionel Sambuc     O << '.' << chans[chan];
475f4a2713aSLionel Sambuc }
476f4a2713aSLionel Sambuc 
printBankSwizzle(const MCInst * MI,unsigned OpNo,raw_ostream & O)477f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printBankSwizzle(const MCInst *MI, unsigned OpNo,
478f4a2713aSLionel Sambuc                                          raw_ostream &O) {
479f4a2713aSLionel Sambuc   int BankSwizzle = MI->getOperand(OpNo).getImm();
480f4a2713aSLionel Sambuc   switch (BankSwizzle) {
481f4a2713aSLionel Sambuc   case 1:
482f4a2713aSLionel Sambuc     O << "BS:VEC_021/SCL_122";
483f4a2713aSLionel Sambuc     break;
484f4a2713aSLionel Sambuc   case 2:
485f4a2713aSLionel Sambuc     O << "BS:VEC_120/SCL_212";
486f4a2713aSLionel Sambuc     break;
487f4a2713aSLionel Sambuc   case 3:
488f4a2713aSLionel Sambuc     O << "BS:VEC_102/SCL_221";
489f4a2713aSLionel Sambuc     break;
490f4a2713aSLionel Sambuc   case 4:
491f4a2713aSLionel Sambuc     O << "BS:VEC_201";
492f4a2713aSLionel Sambuc     break;
493f4a2713aSLionel Sambuc   case 5:
494f4a2713aSLionel Sambuc     O << "BS:VEC_210";
495f4a2713aSLionel Sambuc     break;
496f4a2713aSLionel Sambuc   default:
497f4a2713aSLionel Sambuc     break;
498f4a2713aSLionel Sambuc   }
499f4a2713aSLionel Sambuc   return;
500f4a2713aSLionel Sambuc }
501f4a2713aSLionel Sambuc 
printRSel(const MCInst * MI,unsigned OpNo,raw_ostream & O)502f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printRSel(const MCInst *MI, unsigned OpNo,
503f4a2713aSLionel Sambuc                                   raw_ostream &O) {
504f4a2713aSLionel Sambuc   unsigned Sel = MI->getOperand(OpNo).getImm();
505f4a2713aSLionel Sambuc   switch (Sel) {
506f4a2713aSLionel Sambuc   case 0:
507*0a6a1f1dSLionel Sambuc     O << 'X';
508f4a2713aSLionel Sambuc     break;
509f4a2713aSLionel Sambuc   case 1:
510*0a6a1f1dSLionel Sambuc     O << 'Y';
511f4a2713aSLionel Sambuc     break;
512f4a2713aSLionel Sambuc   case 2:
513*0a6a1f1dSLionel Sambuc     O << 'Z';
514f4a2713aSLionel Sambuc     break;
515f4a2713aSLionel Sambuc   case 3:
516*0a6a1f1dSLionel Sambuc     O << 'W';
517f4a2713aSLionel Sambuc     break;
518f4a2713aSLionel Sambuc   case 4:
519*0a6a1f1dSLionel Sambuc     O << '0';
520f4a2713aSLionel Sambuc     break;
521f4a2713aSLionel Sambuc   case 5:
522*0a6a1f1dSLionel Sambuc     O << '1';
523f4a2713aSLionel Sambuc     break;
524f4a2713aSLionel Sambuc   case 7:
525*0a6a1f1dSLionel Sambuc     O << '_';
526f4a2713aSLionel Sambuc     break;
527f4a2713aSLionel Sambuc   default:
528f4a2713aSLionel Sambuc     break;
529f4a2713aSLionel Sambuc   }
530f4a2713aSLionel Sambuc }
531f4a2713aSLionel Sambuc 
printCT(const MCInst * MI,unsigned OpNo,raw_ostream & O)532f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printCT(const MCInst *MI, unsigned OpNo,
533f4a2713aSLionel Sambuc                                   raw_ostream &O) {
534f4a2713aSLionel Sambuc   unsigned CT = MI->getOperand(OpNo).getImm();
535f4a2713aSLionel Sambuc   switch (CT) {
536f4a2713aSLionel Sambuc   case 0:
537*0a6a1f1dSLionel Sambuc     O << 'U';
538f4a2713aSLionel Sambuc     break;
539f4a2713aSLionel Sambuc   case 1:
540*0a6a1f1dSLionel Sambuc     O << 'N';
541f4a2713aSLionel Sambuc     break;
542f4a2713aSLionel Sambuc   default:
543f4a2713aSLionel Sambuc     break;
544f4a2713aSLionel Sambuc   }
545f4a2713aSLionel Sambuc }
546f4a2713aSLionel Sambuc 
printKCache(const MCInst * MI,unsigned OpNo,raw_ostream & O)547f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printKCache(const MCInst *MI, unsigned OpNo,
548f4a2713aSLionel Sambuc                                     raw_ostream &O) {
549f4a2713aSLionel Sambuc   int KCacheMode = MI->getOperand(OpNo).getImm();
550f4a2713aSLionel Sambuc   if (KCacheMode > 0) {
551f4a2713aSLionel Sambuc     int KCacheBank = MI->getOperand(OpNo - 2).getImm();
552*0a6a1f1dSLionel Sambuc     O << "CB" << KCacheBank << ':';
553f4a2713aSLionel Sambuc     int KCacheAddr = MI->getOperand(OpNo + 2).getImm();
554f4a2713aSLionel Sambuc     int LineSize = (KCacheMode == 1) ? 16 : 32;
555*0a6a1f1dSLionel Sambuc     O << KCacheAddr * 16 << '-' << KCacheAddr * 16 + LineSize;
556f4a2713aSLionel Sambuc   }
557f4a2713aSLionel Sambuc }
558f4a2713aSLionel Sambuc 
printSendMsg(const MCInst * MI,unsigned OpNo,raw_ostream & O)559*0a6a1f1dSLionel Sambuc void AMDGPUInstPrinter::printSendMsg(const MCInst *MI, unsigned OpNo,
560*0a6a1f1dSLionel Sambuc                                      raw_ostream &O) {
561*0a6a1f1dSLionel Sambuc   unsigned SImm16 = MI->getOperand(OpNo).getImm();
562*0a6a1f1dSLionel Sambuc   unsigned Msg = SImm16 & 0xF;
563*0a6a1f1dSLionel Sambuc   if (Msg == 2 || Msg == 3) {
564*0a6a1f1dSLionel Sambuc     unsigned Op = (SImm16 >> 4) & 0xF;
565*0a6a1f1dSLionel Sambuc     if (Msg == 3)
566*0a6a1f1dSLionel Sambuc       O << "Gs_done(";
567*0a6a1f1dSLionel Sambuc     else
568*0a6a1f1dSLionel Sambuc       O << "Gs(";
569*0a6a1f1dSLionel Sambuc     if (Op == 0) {
570*0a6a1f1dSLionel Sambuc       O << "nop";
571*0a6a1f1dSLionel Sambuc     } else {
572*0a6a1f1dSLionel Sambuc       unsigned Stream = (SImm16 >> 8) & 0x3;
573*0a6a1f1dSLionel Sambuc       if (Op == 1)
574*0a6a1f1dSLionel Sambuc 	O << "cut";
575*0a6a1f1dSLionel Sambuc       else if (Op == 2)
576*0a6a1f1dSLionel Sambuc 	O << "emit";
577*0a6a1f1dSLionel Sambuc       else if (Op == 3)
578*0a6a1f1dSLionel Sambuc 	O << "emit-cut";
579*0a6a1f1dSLionel Sambuc       O << " stream " << Stream;
580*0a6a1f1dSLionel Sambuc     }
581*0a6a1f1dSLionel Sambuc     O << "), [m0] ";
582*0a6a1f1dSLionel Sambuc   } else if (Msg == 1)
583*0a6a1f1dSLionel Sambuc     O << "interrupt ";
584*0a6a1f1dSLionel Sambuc   else if (Msg == 15)
585*0a6a1f1dSLionel Sambuc     O << "system ";
586*0a6a1f1dSLionel Sambuc   else
587*0a6a1f1dSLionel Sambuc     O << "unknown(" << Msg << ") ";
588*0a6a1f1dSLionel Sambuc }
589*0a6a1f1dSLionel Sambuc 
printWaitFlag(const MCInst * MI,unsigned OpNo,raw_ostream & O)590f4a2713aSLionel Sambuc void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
591f4a2713aSLionel Sambuc                                       raw_ostream &O) {
592f4a2713aSLionel Sambuc   // Note: Mask values are taken from SIInsertWaits.cpp and not from ISA docs
593f4a2713aSLionel Sambuc   // SIInsertWaits.cpp bits usage does not match ISA docs description but it
594f4a2713aSLionel Sambuc   // works so it might be a misprint in docs.
595f4a2713aSLionel Sambuc   unsigned SImm16 = MI->getOperand(OpNo).getImm();
596f4a2713aSLionel Sambuc   unsigned Vmcnt = SImm16 & 0xF;
597f4a2713aSLionel Sambuc   unsigned Expcnt = (SImm16 >> 4) & 0xF;
598f4a2713aSLionel Sambuc   unsigned Lgkmcnt = (SImm16 >> 8) & 0xF;
599*0a6a1f1dSLionel Sambuc 
600*0a6a1f1dSLionel Sambuc   bool NeedSpace = false;
601*0a6a1f1dSLionel Sambuc 
602*0a6a1f1dSLionel Sambuc   if (Vmcnt != 0xF) {
603*0a6a1f1dSLionel Sambuc     O << "vmcnt(" << Vmcnt << ')';
604*0a6a1f1dSLionel Sambuc     NeedSpace = true;
605*0a6a1f1dSLionel Sambuc   }
606*0a6a1f1dSLionel Sambuc 
607*0a6a1f1dSLionel Sambuc   if (Expcnt != 0x7) {
608*0a6a1f1dSLionel Sambuc     if (NeedSpace)
609*0a6a1f1dSLionel Sambuc       O << ' ';
610*0a6a1f1dSLionel Sambuc     O << "expcnt(" << Expcnt << ')';
611*0a6a1f1dSLionel Sambuc     NeedSpace = true;
612*0a6a1f1dSLionel Sambuc   }
613*0a6a1f1dSLionel Sambuc 
614*0a6a1f1dSLionel Sambuc   if (Lgkmcnt != 0x7) {
615*0a6a1f1dSLionel Sambuc     if (NeedSpace)
616*0a6a1f1dSLionel Sambuc       O << ' ';
617*0a6a1f1dSLionel Sambuc     O << "lgkmcnt(" << Lgkmcnt << ')';
618*0a6a1f1dSLionel Sambuc   }
619f4a2713aSLionel Sambuc }
620f4a2713aSLionel Sambuc 
621f4a2713aSLionel Sambuc #include "AMDGPUGenAsmWriter.inc"
622