1 //===-- AMDGPUInstPrinter.cpp - AMDGPU MC Inst -> ASM ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #include "AMDGPUInstPrinter.h"
12 #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
13 #include "llvm/MC/MCInst.h"
17 void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
19 printInstruction(MI, OS);
21 printAnnotation(OS, Annot);
24 void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
27 const MCOperand &Op = MI->getOperand(OpNo);
29 switch (Op.getReg()) {
30 // This is the default predicate state, so we don't need to print it.
31 case AMDGPU::PRED_SEL_OFF: break;
32 default: O << getRegisterName(Op.getReg()); break;
34 } else if (Op.isImm()) {
36 } else if (Op.isFPImm()) {
39 assert(!"unknown operand type in printOperand");
43 void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
45 printOperand(MI, OpNo, O);
47 printOperand(MI, OpNo + 1, O);
50 void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
51 raw_ostream &O, StringRef Asm) {
52 const MCOperand &Op = MI->getOperand(OpNo);
54 if (Op.getImm() == 1) {
59 void AMDGPUInstPrinter::printAbs(const MCInst *MI, unsigned OpNo,
61 printIfSet(MI, OpNo, O, "|");
64 void AMDGPUInstPrinter::printClamp(const MCInst *MI, unsigned OpNo,
66 printIfSet(MI, OpNo, O, "_SAT");
69 void AMDGPUInstPrinter::printLiteral(const MCInst *MI, unsigned OpNo,
76 L.i = MI->getOperand(OpNo).getImm();
77 O << L.i << "(" << L.f << ")";
80 void AMDGPUInstPrinter::printLast(const MCInst *MI, unsigned OpNo,
82 printIfSet(MI, OpNo, O, " *");
85 void AMDGPUInstPrinter::printNeg(const MCInst *MI, unsigned OpNo,
87 printIfSet(MI, OpNo, O, "-");
90 void AMDGPUInstPrinter::printOMOD(const MCInst *MI, unsigned OpNo,
92 switch (MI->getOperand(OpNo).getImm()) {
106 void AMDGPUInstPrinter::printRel(const MCInst *MI, unsigned OpNo,
108 printIfSet(MI, OpNo, O, "+");
111 void AMDGPUInstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
113 printIfSet(MI, OpNo, O, "ExecMask,");
116 void AMDGPUInstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
118 printIfSet(MI, OpNo, O, "Pred,");
121 void AMDGPUInstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
123 const MCOperand &Op = MI->getOperand(OpNo);
124 if (Op.getImm() == 0) {
129 void AMDGPUInstPrinter::printSel(const MCInst *MI, unsigned OpNo,
131 const char * chans = "XYZW";
132 int sel = MI->getOperand(OpNo).getImm();
141 O << cb << "[" << sel << "]";
142 } else if (sel >= 448) {
145 } else if (sel >= 0){
150 O << "." << chans[chan];
153 #include "AMDGPUGenAsmWriter.inc"