2012-12-12 05:25:42 +08:00
|
|
|
//===-- AMDGPUInstPrinter.cpp - AMDGPU MC Inst -> ASM ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
// \file
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPUInstPrinter.h"
|
2014-09-29 23:50:26 +08:00
|
|
|
#include "SIDefines.h"
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
2013-02-21 23:17:22 +08:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2013-05-24 01:10:37 +08:00
|
|
|
#include "llvm/MC/MCInst.h"
|
2014-04-16 06:32:49 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
|
|
|
StringRef Annot) {
|
2013-05-03 05:52:30 +08:00
|
|
|
OS.flush();
|
2012-12-12 05:25:42 +08:00
|
|
|
printInstruction(MI, OS);
|
|
|
|
|
|
|
|
printAnnotation(OS, Annot);
|
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:49 +08:00
|
|
|
void AMDGPUInstPrinter::printU8ImmOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xffff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printU32ImmOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xffffffff);
|
|
|
|
}
|
|
|
|
|
2014-10-11 06:16:07 +08:00
|
|
|
void AMDGPUInstPrinter::printU8ImmDecOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatDec(MI->getOperand(OpNo).getImm() & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printU16ImmDecOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatDec(MI->getOperand(OpNo).getImm() & 0xffff);
|
|
|
|
}
|
|
|
|
|
2014-08-05 22:48:12 +08:00
|
|
|
void AMDGPUInstPrinter::printOffen(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " offen";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printIdxen(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " idxen";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printAddr64(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " addr64";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printMBUFOffset(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
|
|
|
O << " offset:";
|
|
|
|
printU16ImmOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-11 06:16:07 +08:00
|
|
|
void AMDGPUInstPrinter::printDSOffset(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
uint16_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm != 0) {
|
|
|
|
O << " offset:";
|
|
|
|
printU16ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printDSOffset0(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << " offset0:";
|
|
|
|
printU8ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printDSOffset1(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << " offset1:";
|
|
|
|
printU8ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
|
2014-08-05 22:48:12 +08:00
|
|
|
void AMDGPUInstPrinter::printGLC(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " glc";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSLC(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " slc";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printTFE(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " tfe";
|
|
|
|
}
|
|
|
|
|
2013-11-12 10:35:51 +08:00
|
|
|
void AMDGPUInstPrinter::printRegOperand(unsigned reg, raw_ostream &O) {
|
|
|
|
switch (reg) {
|
|
|
|
case AMDGPU::VCC:
|
|
|
|
O << "vcc";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SCC:
|
|
|
|
O << "scc";
|
|
|
|
return;
|
|
|
|
case AMDGPU::EXEC:
|
|
|
|
O << "exec";
|
|
|
|
return;
|
|
|
|
case AMDGPU::M0:
|
|
|
|
O << "m0";
|
|
|
|
return;
|
2014-09-15 23:41:53 +08:00
|
|
|
case AMDGPU::FLAT_SCR:
|
|
|
|
O << "flat_scratch";
|
|
|
|
return;
|
|
|
|
case AMDGPU::VCC_LO:
|
|
|
|
O << "vcc_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::VCC_HI:
|
|
|
|
O << "vcc_hi";
|
|
|
|
return;
|
|
|
|
case AMDGPU::EXEC_LO:
|
|
|
|
O << "exec_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::EXEC_HI:
|
|
|
|
O << "exec_hi";
|
|
|
|
return;
|
|
|
|
case AMDGPU::FLAT_SCR_LO:
|
|
|
|
O << "flat_scratch_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::FLAT_SCR_HI:
|
|
|
|
O << "flat_scratch_hi";
|
|
|
|
return;
|
2013-11-12 10:35:51 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:42 +08:00
|
|
|
char Type;
|
|
|
|
unsigned NumRegs;
|
|
|
|
|
|
|
|
if (MRI.getRegClass(AMDGPU::VGPR_32RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 1;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_32RegClassID).contains(reg)) {
|
|
|
|
Type = 's';
|
|
|
|
NumRegs = 1;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_64RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 2;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::SReg_64RegClassID).contains(reg)) {
|
|
|
|
Type = 's';
|
|
|
|
NumRegs = 2;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_128RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 4;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::SReg_128RegClassID).contains(reg)) {
|
|
|
|
Type = 's';
|
|
|
|
NumRegs = 4;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_96RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 3;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_256RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 8;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::SReg_256RegClassID).contains(reg)) {
|
|
|
|
Type = 's';
|
|
|
|
NumRegs = 8;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_512RegClassID).contains(reg)) {
|
|
|
|
Type = 'v';
|
|
|
|
NumRegs = 16;
|
|
|
|
} else if (MRI.getRegClass(AMDGPU::SReg_512RegClassID).contains(reg)) {
|
|
|
|
Type = 's';
|
|
|
|
NumRegs = 16;
|
|
|
|
} else {
|
|
|
|
O << getRegisterName(reg);
|
2013-11-12 10:35:51 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-24 02:00:26 +08:00
|
|
|
// The low 8 bits of the encoding value is the register index, for both VGPRs
|
|
|
|
// and SGPRs.
|
|
|
|
unsigned RegIdx = MRI.getEncodingValue(reg) & ((1 << 8) - 1);
|
2014-04-16 06:32:42 +08:00
|
|
|
if (NumRegs == 1) {
|
|
|
|
O << Type << RegIdx;
|
2013-11-12 10:35:51 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:42 +08:00
|
|
|
O << Type << '[' << RegIdx << ':' << (RegIdx + NumRegs - 1) << ']';
|
2013-11-12 10:35:51 +08:00
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:49 +08:00
|
|
|
void AMDGPUInstPrinter::printImmediate(uint32_t Imm, raw_ostream &O) {
|
|
|
|
int32_t SImm = static_cast<int32_t>(Imm);
|
|
|
|
if (SImm >= -16 && SImm <= 64) {
|
|
|
|
O << SImm;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-18 01:32:13 +08:00
|
|
|
if (Imm == FloatToBits(0.0f))
|
|
|
|
O << "0.0";
|
|
|
|
else if (Imm == FloatToBits(1.0f))
|
|
|
|
O << "1.0";
|
|
|
|
else if (Imm == FloatToBits(-1.0f))
|
|
|
|
O << "-1.0";
|
|
|
|
else if (Imm == FloatToBits(0.5f))
|
|
|
|
O << "0.5";
|
|
|
|
else if (Imm == FloatToBits(-0.5f))
|
|
|
|
O << "-0.5";
|
|
|
|
else if (Imm == FloatToBits(2.0f))
|
|
|
|
O << "2.0";
|
|
|
|
else if (Imm == FloatToBits(-2.0f))
|
|
|
|
O << "-2.0";
|
|
|
|
else if (Imm == FloatToBits(4.0f))
|
|
|
|
O << "4.0";
|
|
|
|
else if (Imm == FloatToBits(-4.0f))
|
|
|
|
O << "-4.0";
|
|
|
|
else {
|
|
|
|
O << formatHex(static_cast<uint64_t>(Imm));
|
2014-04-16 06:32:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
if (Op.isReg()) {
|
|
|
|
switch (Op.getReg()) {
|
|
|
|
// This is the default predicate state, so we don't need to print it.
|
2013-11-12 10:35:51 +08:00
|
|
|
case AMDGPU::PRED_SEL_OFF:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printRegOperand(Op.getReg(), O);
|
|
|
|
break;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
} else if (Op.isImm()) {
|
2014-04-16 06:32:49 +08:00
|
|
|
printImmediate(Op.getImm(), O);
|
2012-12-12 05:25:42 +08:00
|
|
|
} else if (Op.isFPImm()) {
|
2014-09-18 01:32:13 +08:00
|
|
|
|
|
|
|
// We special case 0.0 because otherwise it will be printed as an integer.
|
|
|
|
if (Op.getFPImm() == 0.0)
|
|
|
|
O << "0.0";
|
|
|
|
else
|
|
|
|
printImmediate(FloatToBits(Op.getFPImm()), O);
|
2013-02-21 23:17:22 +08:00
|
|
|
} else if (Op.isExpr()) {
|
|
|
|
const MCExpr *Exp = Op.getExpr();
|
|
|
|
Exp->print(O);
|
2012-12-12 05:25:42 +08:00
|
|
|
} else {
|
2014-09-22 01:27:31 +08:00
|
|
|
llvm_unreachable("unknown operand type in printOperand");
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-11 03:18:33 +08:00
|
|
|
void AMDGPUInstPrinter::printOperandAndMods(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned InputModifiers = MI->getOperand(OpNo).getImm();
|
2014-09-29 23:50:26 +08:00
|
|
|
if (InputModifiers & SISrcMods::NEG)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '-';
|
2014-09-29 23:50:26 +08:00
|
|
|
if (InputModifiers & SISrcMods::ABS)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '|';
|
2014-05-11 03:18:33 +08:00
|
|
|
printOperand(MI, OpNo + 1, O);
|
2014-09-29 23:50:26 +08:00
|
|
|
if (InputModifiers & SISrcMods::ABS)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '|';
|
2014-05-11 03:18:33 +08:00
|
|
|
}
|
|
|
|
|
2013-02-15 03:03:25 +08:00
|
|
|
void AMDGPUInstPrinter::printInterpSlot(const MCInst *MI, unsigned OpNum,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned Imm = MI->getOperand(OpNum).getImm();
|
|
|
|
|
|
|
|
if (Imm == 2) {
|
|
|
|
O << "P0";
|
|
|
|
} else if (Imm == 1) {
|
|
|
|
O << "P20";
|
|
|
|
} else if (Imm == 0) {
|
|
|
|
O << "P10";
|
|
|
|
} else {
|
2014-09-22 01:27:31 +08:00
|
|
|
llvm_unreachable("Invalid interpolation parameter slot");
|
2013-02-15 03:03:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printOperand(MI, OpNo, O);
|
|
|
|
O << ", ";
|
|
|
|
printOperand(MI, OpNo + 1, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
|
2013-05-03 05:52:30 +08:00
|
|
|
raw_ostream &O, StringRef Asm,
|
|
|
|
StringRef Default) {
|
2012-12-12 05:25:42 +08:00
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
assert(Op.isImm());
|
|
|
|
if (Op.getImm() == 1) {
|
|
|
|
O << Asm;
|
2013-05-03 05:52:30 +08:00
|
|
|
} else {
|
|
|
|
O << Default;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printAbs(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printIfSet(MI, OpNo, O, "|");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printClamp(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printIfSet(MI, OpNo, O, "_SAT");
|
|
|
|
}
|
|
|
|
|
2014-10-01 03:49:48 +08:00
|
|
|
void AMDGPUInstPrinter::printClampSI(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " clamp";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printOModSI(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
int Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm == SIOutMods::MUL2)
|
|
|
|
O << " mul:2";
|
|
|
|
else if (Imm == SIOutMods::MUL4)
|
|
|
|
O << " mul:4";
|
|
|
|
else if (Imm == SIOutMods::DIV2)
|
|
|
|
O << " div:2";
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
void AMDGPUInstPrinter::printLiteral(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2014-06-24 02:00:24 +08:00
|
|
|
int32_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
O << Imm << '(' << BitsToFloat(Imm) << ')';
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printLast(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2013-05-18 00:49:49 +08:00
|
|
|
printIfSet(MI, OpNo, O.indent(25 - O.GetNumBytesInBuffer()), "*", " ");
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printNeg(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printIfSet(MI, OpNo, O, "-");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printOMOD(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
switch (MI->getOperand(OpNo).getImm()) {
|
|
|
|
default: break;
|
|
|
|
case 1:
|
|
|
|
O << " * 2.0";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
O << " * 4.0";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
O << " / 2.0";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printRel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2013-02-07 01:32:29 +08:00
|
|
|
printIfSet(MI, OpNo, O, "+");
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printIfSet(MI, OpNo, O, "ExecMask,");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printIfSet(MI, OpNo, O, "Pred,");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
if (Op.getImm() == 0) {
|
|
|
|
O << " (MASKED)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-23 10:09:06 +08:00
|
|
|
void AMDGPUInstPrinter::printSel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const char * chans = "XYZW";
|
|
|
|
int sel = MI->getOperand(OpNo).getImm();
|
|
|
|
|
|
|
|
int chan = sel & 3;
|
|
|
|
sel >>= 2;
|
|
|
|
|
|
|
|
if (sel >= 512) {
|
|
|
|
sel -= 512;
|
|
|
|
int cb = sel >> 12;
|
|
|
|
sel &= 4095;
|
2014-09-22 01:27:28 +08:00
|
|
|
O << cb << '[' << sel << ']';
|
2013-01-23 10:09:06 +08:00
|
|
|
} else if (sel >= 448) {
|
|
|
|
sel -= 448;
|
|
|
|
O << sel;
|
|
|
|
} else if (sel >= 0){
|
|
|
|
O << sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sel >= 0)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '.' << chans[chan];
|
2013-01-23 10:09:06 +08:00
|
|
|
}
|
|
|
|
|
2013-05-03 05:52:30 +08:00
|
|
|
void AMDGPUInstPrinter::printBankSwizzle(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
int BankSwizzle = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (BankSwizzle) {
|
|
|
|
case 1:
|
2013-06-30 03:32:29 +08:00
|
|
|
O << "BS:VEC_021/SCL_122";
|
2013-05-03 05:52:30 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-06-30 03:32:29 +08:00
|
|
|
O << "BS:VEC_120/SCL_212";
|
2013-05-03 05:52:30 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-06-30 03:32:29 +08:00
|
|
|
O << "BS:VEC_102/SCL_221";
|
2013-05-03 05:52:30 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
O << "BS:VEC_201";
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
O << "BS:VEC_210";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-18 00:50:20 +08:00
|
|
|
void AMDGPUInstPrinter::printRSel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned Sel = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (Sel) {
|
|
|
|
case 0:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'X';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'Y';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'Z';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'W';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '0';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '1';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 7:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '_';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printCT(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned CT = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (CT) {
|
|
|
|
case 0:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'U';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-09-22 01:27:28 +08:00
|
|
|
O << 'N';
|
2013-05-18 00:50:20 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-03 05:52:40 +08:00
|
|
|
void AMDGPUInstPrinter::printKCache(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
int KCacheMode = MI->getOperand(OpNo).getImm();
|
|
|
|
if (KCacheMode > 0) {
|
|
|
|
int KCacheBank = MI->getOperand(OpNo - 2).getImm();
|
2014-09-22 01:27:28 +08:00
|
|
|
O << "CB" << KCacheBank << ':';
|
2013-05-03 05:52:40 +08:00
|
|
|
int KCacheAddr = MI->getOperand(OpNo + 2).getImm();
|
2014-09-22 01:27:28 +08:00
|
|
|
int LineSize = (KCacheMode == 1) ? 16 : 32;
|
|
|
|
O << KCacheAddr * 16 << '-' << KCacheAddr * 16 + LineSize;
|
2013-05-03 05:52:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 15:20:44 +08:00
|
|
|
void AMDGPUInstPrinter::printSendMsg(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
|
|
|
unsigned Msg = SImm16 & 0xF;
|
|
|
|
if (Msg == 2 || Msg == 3) {
|
|
|
|
unsigned Op = (SImm16 >> 4) & 0xF;
|
|
|
|
if (Msg == 3)
|
|
|
|
O << "Gs_done(";
|
|
|
|
else
|
|
|
|
O << "Gs(";
|
|
|
|
if (Op == 0) {
|
|
|
|
O << "nop";
|
|
|
|
} else {
|
|
|
|
unsigned Stream = (SImm16 >> 8) & 0x3;
|
|
|
|
if (Op == 1)
|
|
|
|
O << "cut";
|
|
|
|
else if (Op == 2)
|
|
|
|
O << "emit";
|
|
|
|
else if (Op == 3)
|
|
|
|
O << "emit-cut";
|
|
|
|
O << " stream " << Stream;
|
|
|
|
}
|
|
|
|
O << "), [m0] ";
|
|
|
|
} else if (Msg == 1)
|
|
|
|
O << "interrupt ";
|
|
|
|
else if (Msg == 15)
|
|
|
|
O << "system ";
|
|
|
|
else
|
|
|
|
O << "unknown(" << Msg << ") ";
|
|
|
|
}
|
|
|
|
|
2013-10-14 01:56:28 +08:00
|
|
|
void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
// Note: Mask values are taken from SIInsertWaits.cpp and not from ISA docs
|
|
|
|
// SIInsertWaits.cpp bits usage does not match ISA docs description but it
|
|
|
|
// works so it might be a misprint in docs.
|
|
|
|
unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
|
|
|
unsigned Vmcnt = SImm16 & 0xF;
|
|
|
|
unsigned Expcnt = (SImm16 >> 4) & 0xF;
|
|
|
|
unsigned Lgkmcnt = (SImm16 >> 8) & 0xF;
|
2014-09-26 09:09:46 +08:00
|
|
|
|
|
|
|
bool NeedSpace = false;
|
|
|
|
|
|
|
|
if (Vmcnt != 0xF) {
|
|
|
|
O << "vmcnt(" << Vmcnt << ')';
|
|
|
|
NeedSpace = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Expcnt != 0x7) {
|
|
|
|
if (NeedSpace)
|
|
|
|
O << ' ';
|
|
|
|
O << "expcnt(" << Expcnt << ')';
|
|
|
|
NeedSpace = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Lgkmcnt != 0x7) {
|
|
|
|
if (NeedSpace)
|
|
|
|
O << ' ';
|
2014-09-22 01:27:28 +08:00
|
|
|
O << "lgkmcnt(" << Lgkmcnt << ')';
|
2014-09-26 09:09:46 +08:00
|
|
|
}
|
2013-10-14 01:56:28 +08:00
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "AMDGPUGenAsmWriter.inc"
|