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 const MCOperand &Op = MI->getOperand(OpNo);
109 if (Op.getImm() != 0) {
110 O << " + " << Op.getImm();
114 void AMDGPUInstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
116 printIfSet(MI, OpNo, O, "ExecMask,");
119 void AMDGPUInstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
121 printIfSet(MI, OpNo, O, "Pred,");
124 void AMDGPUInstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
126 const MCOperand &Op = MI->getOperand(OpNo);
127 if (Op.getImm() == 0) {
132 void AMDGPUInstPrinter::printSel(const MCInst *MI, unsigned OpNo,
134 const char * chans = "XYZW";
135 int sel = MI->getOperand(OpNo).getImm();
144 O << cb << "[" << sel << "]";
145 } else if (sel >= 448) {
148 } else if (sel >= 0){
153 O << "." << chans[chan];
156 #include "AMDGPUGenAsmWriter.inc"