2012-12-12 05:25:42 +08:00
|
|
|
//===-- AMDGPUInstPrinter.cpp - AMDGPU MC Inst -> ASM ---------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
// \file
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPUInstPrinter.h"
|
2016-10-01 01:01:40 +08:00
|
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "SIDefines.h"
|
2016-05-27 01:00:33 +08:00
|
|
|
#include "Utils/AMDGPUAsmUtils.h"
|
2016-10-01 01:01:40 +08:00
|
|
|
#include "Utils/AMDGPUBaseInfo.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"
|
2016-12-13 06:23:53 +08:00
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
2014-12-18 05:04:08 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2014-04-16 06:32:49 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2016-10-01 01:01:40 +08:00
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2016-12-13 06:23:53 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2014-04-16 06:32:49 +08:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
2015-12-26 06:10:01 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-12-13 06:23:53 +08:00
|
|
|
#include <cassert>
|
2016-04-14 00:18:41 +08:00
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
using namespace llvm;
|
2016-10-01 01:01:40 +08:00
|
|
|
using namespace llvm::AMDGPU;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
2015-03-28 04:36:02 +08:00
|
|
|
StringRef Annot, const MCSubtargetInfo &STI) {
|
2013-05-03 05:52:30 +08:00
|
|
|
OS.flush();
|
2016-09-27 22:42:48 +08:00
|
|
|
printInstruction(MI, STI, OS);
|
2012-12-12 05:25:42 +08:00
|
|
|
printAnnotation(OS, Annot);
|
|
|
|
}
|
|
|
|
|
2016-03-09 20:29:31 +08:00
|
|
|
void AMDGPUInstPrinter::printU4ImmOperand(const MCInst *MI, unsigned OpNo,
|
2016-10-13 02:00:51 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-09-27 22:42:48 +08:00
|
|
|
raw_ostream &O) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xf);
|
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:49 +08:00
|
|
|
void AMDGPUInstPrinter::printU8ImmOperand(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
raw_ostream &O) {
|
2014-04-16 06:32:49 +08:00
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2014-04-16 06:32:49 +08:00
|
|
|
raw_ostream &O) {
|
2016-12-10 08:39:12 +08:00
|
|
|
// It's possible to end up with a 32-bit literal used with a 16-bit operand
|
|
|
|
// with ignored high bits. Print as 32-bit anyway in that case.
|
|
|
|
int64_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (isInt<16>(Imm) || isUInt<16>(Imm))
|
|
|
|
O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
|
|
|
|
else
|
|
|
|
printU32ImmOperand(MI, OpNo, STI, O);
|
2014-04-16 06:32:49 +08:00
|
|
|
}
|
|
|
|
|
2016-03-09 20:29:31 +08:00
|
|
|
void AMDGPUInstPrinter::printU4ImmDecOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatDec(MI->getOperand(OpNo).getImm() & 0xf);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-11-28 01:14:35 +08:00
|
|
|
void AMDGPUInstPrinter::printS13ImmDecOperand(const MCInst *MI, unsigned OpNo,
|
2019-05-01 06:08:23 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2017-06-21 03:54:14 +08:00
|
|
|
raw_ostream &O) {
|
2019-05-01 06:08:23 +08:00
|
|
|
// GFX10: Address offset is 12-bit signed byte offset.
|
|
|
|
if (AMDGPU::isGFX10(STI)) {
|
|
|
|
O << formatDec(SignExtend32<12>(MI->getOperand(OpNo).getImm()));
|
|
|
|
} else {
|
|
|
|
O << formatDec(SignExtend32<13>(MI->getOperand(OpNo).getImm()));
|
|
|
|
}
|
2017-06-21 03:54:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 22:42:48 +08:00
|
|
|
void AMDGPUInstPrinter::printU32ImmOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
O << formatHex(MI->getOperand(OpNo).getImm() & 0xffffffff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printNamedBit(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O, StringRef BitName) {
|
2016-02-26 17:51:05 +08:00
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << ' ' << BitName;
|
2016-02-26 17:51:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 22:48:12 +08:00
|
|
|
void AMDGPUInstPrinter::printOffen(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "offen");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printIdxen(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "idxen");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printAddr64(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "addr64");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printMBUFOffset(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
|
|
|
O << " offset:";
|
2014-12-03 11:12:13 +08:00
|
|
|
printU16ImmDecOperand(MI, OpNo, O);
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printOffset(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2014-10-11 06:16:07 +08:00
|
|
|
uint16_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm != 0) {
|
2017-04-07 21:07:13 +08:00
|
|
|
O << ((OpNo == 0)? "offset:" : " offset:");
|
2014-10-11 06:16:07 +08:00
|
|
|
printU16ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-21 03:54:14 +08:00
|
|
|
void AMDGPUInstPrinter::printOffsetS13(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
uint16_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm != 0) {
|
|
|
|
O << ((OpNo == 0)? "offset:" : " offset:");
|
2019-05-01 06:08:23 +08:00
|
|
|
printS13ImmDecOperand(MI, OpNo, STI, O);
|
2017-06-21 03:54:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printOffset0(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2015-04-08 09:09:19 +08:00
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
|
|
|
O << " offset0:";
|
|
|
|
printU8ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
2014-10-11 06:16:07 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printOffset1(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2015-04-08 09:09:19 +08:00
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
|
|
|
O << " offset1:";
|
|
|
|
printU8ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
2014-10-11 06:16:07 +08:00
|
|
|
}
|
|
|
|
|
2016-11-01 00:07:39 +08:00
|
|
|
void AMDGPUInstPrinter::printSMRDOffset8(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printU32ImmOperand(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSMRDOffset20(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-29 17:02:30 +08:00
|
|
|
raw_ostream &O) {
|
2016-09-27 22:42:48 +08:00
|
|
|
printU32ImmOperand(MI, OpNo, STI, O);
|
2016-04-29 17:02:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-29 17:02:30 +08:00
|
|
|
raw_ostream &O) {
|
2016-09-27 22:42:48 +08:00
|
|
|
printU32ImmOperand(MI, OpNo, STI, O);
|
2016-04-29 17:02:30 +08:00
|
|
|
}
|
|
|
|
|
2015-03-10 02:49:54 +08:00
|
|
|
void AMDGPUInstPrinter::printGDS(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "gds");
|
2015-03-10 02:49:54 +08:00
|
|
|
}
|
|
|
|
|
2019-05-01 06:08:23 +08:00
|
|
|
void AMDGPUInstPrinter::printDLC(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
|
|
|
if (AMDGPU::isGFX10(STI))
|
|
|
|
printNamedBit(MI, OpNo, O, "dlc");
|
|
|
|
}
|
|
|
|
|
2014-08-05 22:48:12 +08:00
|
|
|
void AMDGPUInstPrinter::printGLC(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "glc");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSLC(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "slc");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printTFE(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "tfe");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printDMask(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
if (MI->getOperand(OpNo).getImm()) {
|
|
|
|
O << " dmask:";
|
2016-09-27 22:42:48 +08:00
|
|
|
printU16ImmOperand(MI, OpNo, STI, O);
|
2016-02-26 17:51:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 00:32:58 +08:00
|
|
|
void AMDGPUInstPrinter::printDim(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
|
|
|
unsigned Dim = MI->getOperand(OpNo).getImm();
|
|
|
|
O << " dim:SQ_RSRC_IMG_";
|
|
|
|
|
|
|
|
const AMDGPU::MIMGDimInfo *DimInfo = AMDGPU::getMIMGDimInfoByEncoding(Dim);
|
|
|
|
if (DimInfo)
|
|
|
|
O << DimInfo->AsmSuffix;
|
|
|
|
else
|
|
|
|
O << Dim;
|
|
|
|
}
|
|
|
|
|
2016-02-26 17:51:05 +08:00
|
|
|
void AMDGPUInstPrinter::printUNorm(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "unorm");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printDA(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "da");
|
|
|
|
}
|
|
|
|
|
2018-08-28 23:07:30 +08:00
|
|
|
void AMDGPUInstPrinter::printR128A16(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2018-08-28 23:07:30 +08:00
|
|
|
if (STI.hasFeature(AMDGPU::FeatureR128A16))
|
|
|
|
printNamedBit(MI, OpNo, O, "a16");
|
|
|
|
else
|
|
|
|
printNamedBit(MI, OpNo, O, "r128");
|
2016-02-26 17:51:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printLWE(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-02-26 17:51:05 +08:00
|
|
|
printNamedBit(MI, OpNo, O, "lwe");
|
AMDGPU: Turn D16 for MIMG instructions into a regular operand
Summary:
This allows us to reduce the number of different machine instruction
opcodes, which reduces the table sizes and helps flatten the TableGen
multiclass hierarchies.
We can do this because for each hardware MIMG opcode, we have a full set
of IMAGE_xxx_Vn_Vm machine instructions for all required sizes of vdata
and vaddr registers. Instead of having separate D16 machine instructions,
a packed D16 instructions loading e.g. 4 components can simply use the
same V2 opcode variant that non-D16 instructions use.
We still require a TSFlag for D16 buffer instructions, because the
D16-ness of buffer instructions is part of the opcode. Renaming the flag
should help avoid future confusion.
The one non-obvious code change is that for gather4 instructions, the
disassembler can no longer automatically decide whether to use a V2 or
a V4 variant. The existing logic which choose the correct variant for
other MIMG instruction is extended to cover gather4 as well.
As a bonus, some of the assembler error messages are now more helpful
(e.g., complaining about a wrong data size instead of a non-existing
instruction).
While we're at it, delete a whole bunch of dead legacy TableGen code.
Change-Id: I89b02c2841c06f95e662541433e597f5d4553978
Reviewers: arsenm, rampitec, kzhuravl, artem.tamazov, dp, rtaylor
Subscribers: wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D47434
llvm-svn: 335222
2018-06-21 21:36:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printD16(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
|
|
|
printNamedBit(MI, OpNo, O, "d16");
|
2014-08-05 22:48:12 +08:00
|
|
|
}
|
|
|
|
|
2016-12-06 04:31:49 +08:00
|
|
|
void AMDGPUInstPrinter::printExpCompr(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " compr";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpVM(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " vm";
|
|
|
|
}
|
|
|
|
|
[AMDGPU] New tbuffer intrinsics
Summary:
This commit adds new intrinsics
llvm.amdgcn.raw.tbuffer.load
llvm.amdgcn.struct.tbuffer.load
llvm.amdgcn.raw.tbuffer.store
llvm.amdgcn.struct.tbuffer.store
with the following changes from the llvm.amdgcn.tbuffer.* intrinsics:
* there are separate raw and struct versions: raw does not have an index
arg and sets idxen=0 in the instruction, and struct always sets
idxen=1 in the instruction even if the index is 0, to allow for the
fact that gfx9 does bounds checking differently depending on whether
idxen is set;
* there is a combined format arg (dfmt+nfmt)
* there is a combined cachepolicy arg (glc+slc)
* there are now only two offset args: one for the offset that is
included in bounds checking and swizzling, to be split between the
instruction's voffset and immoffset fields, and one for the offset
that is excluded from bounds checking and swizzling, to go into the
instruction's soffset field.
The AMDISD::TBUFFER_* SD nodes always have an index operand, all three
offset operands, combined format operand, combined cachepolicy operand,
and an extra idxen operand.
The tbuffer pseudo- and real instructions now also have a combined
format operand.
The obsolescent llvm.amdgcn.tbuffer.* and llvm.SI.tbuffer.store
intrinsics continue to work.
V2: Separate raw and struct intrinsics.
V3: Moved extract_glc and extract_slc defs to a more sensible place.
V4: Rebased on D49995.
V5: Only two separate offset args instead of three.
V6: Pseudo- and real instructions have joint format operand.
V7: Restored optionality of dfmt and nfmt in assembler.
V8: Addressed minor review comments.
Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D49026
Change-Id: If22ad77e349fac3a5d2f72dda53c010377d470d4
llvm-svn: 340268
2018-08-21 19:06:05 +08:00
|
|
|
void AMDGPUInstPrinter::printFORMAT(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (unsigned Val = MI->getOperand(OpNo).getImm()) {
|
2019-05-02 00:32:58 +08:00
|
|
|
if (AMDGPU::isGFX10(STI))
|
|
|
|
O << " format:" << Val;
|
|
|
|
else {
|
|
|
|
O << " dfmt:" << (Val & 15);
|
|
|
|
O << ", nfmt:" << (Val >> 4);
|
|
|
|
}
|
2017-06-23 00:29:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 22:42:48 +08:00
|
|
|
void AMDGPUInstPrinter::printRegOperand(unsigned RegNo, raw_ostream &O,
|
2015-04-08 09:09:26 +08:00
|
|
|
const MCRegisterInfo &MRI) {
|
2016-09-27 22:42:48 +08:00
|
|
|
switch (RegNo) {
|
2013-11-12 10:35:51 +08:00
|
|
|
case AMDGPU::VCC:
|
|
|
|
O << "vcc";
|
|
|
|
return;
|
2019-06-03 21:51:24 +08:00
|
|
|
case AMDGPU::SRC_VCCZ:
|
|
|
|
O << "src_vccz";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_EXECZ:
|
|
|
|
O << "src_execz";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_SCC:
|
|
|
|
O << "src_scc";
|
2013-11-12 10:35:51 +08:00
|
|
|
return;
|
|
|
|
case AMDGPU::EXEC:
|
|
|
|
O << "exec";
|
|
|
|
return;
|
|
|
|
case AMDGPU::M0:
|
|
|
|
O << "m0";
|
|
|
|
return;
|
2019-04-25 01:28:30 +08:00
|
|
|
case AMDGPU::SGPR_NULL:
|
|
|
|
O << "null";
|
|
|
|
return;
|
2014-09-15 23:41:53 +08:00
|
|
|
case AMDGPU::FLAT_SCR:
|
|
|
|
O << "flat_scratch";
|
|
|
|
return;
|
2018-01-10 22:22:19 +08:00
|
|
|
case AMDGPU::XNACK_MASK:
|
|
|
|
O << "xnack_mask";
|
|
|
|
return;
|
2019-03-20 23:40:52 +08:00
|
|
|
case AMDGPU::SRC_SHARED_BASE:
|
|
|
|
O << "src_shared_base";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_SHARED_LIMIT:
|
|
|
|
O << "src_shared_limit";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_PRIVATE_BASE:
|
|
|
|
O << "src_private_base";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_PRIVATE_LIMIT:
|
|
|
|
O << "src_private_limit";
|
|
|
|
return;
|
|
|
|
case AMDGPU::SRC_POPS_EXITING_WAVE_ID:
|
|
|
|
O << "src_pops_exiting_wave_id";
|
|
|
|
return;
|
2019-02-08 22:57:37 +08:00
|
|
|
case AMDGPU::LDS_DIRECT:
|
|
|
|
O << "src_lds_direct";
|
|
|
|
return;
|
2014-09-15 23:41:53 +08:00
|
|
|
case AMDGPU::VCC_LO:
|
|
|
|
O << "vcc_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::VCC_HI:
|
|
|
|
O << "vcc_hi";
|
|
|
|
return;
|
2016-04-14 00:18:41 +08:00
|
|
|
case AMDGPU::TBA_LO:
|
|
|
|
O << "tba_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::TBA_HI:
|
|
|
|
O << "tba_hi";
|
|
|
|
return;
|
|
|
|
case AMDGPU::TMA_LO:
|
|
|
|
O << "tma_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::TMA_HI:
|
|
|
|
O << "tma_hi";
|
|
|
|
return;
|
2014-09-15 23:41:53 +08:00
|
|
|
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;
|
2018-01-10 22:22:19 +08:00
|
|
|
case AMDGPU::XNACK_MASK_LO:
|
|
|
|
O << "xnack_mask_lo";
|
|
|
|
return;
|
|
|
|
case AMDGPU::XNACK_MASK_HI:
|
|
|
|
O << "xnack_mask_hi";
|
|
|
|
return;
|
2017-07-25 02:06:15 +08:00
|
|
|
case AMDGPU::FP_REG:
|
|
|
|
case AMDGPU::SP_REG:
|
|
|
|
case AMDGPU::SCRATCH_WAVE_OFFSET_REG:
|
|
|
|
case AMDGPU::PRIVATE_RSRC_REG:
|
|
|
|
llvm_unreachable("pseudo-register should not ever be emitted");
|
2019-06-03 21:51:24 +08:00
|
|
|
case AMDGPU::SCC:
|
|
|
|
llvm_unreachable("pseudo scc should not ever be emitted");
|
2013-11-12 10:35:51 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-07-06 06:06:56 +08:00
|
|
|
// The low 8 bits of the encoding value is the register index, for both VGPRs
|
|
|
|
// and SGPRs.
|
2016-09-27 22:42:48 +08:00
|
|
|
unsigned RegIdx = MRI.getEncodingValue(RegNo) & ((1 << 8) - 1);
|
2014-04-16 06:32:42 +08:00
|
|
|
|
2016-07-06 06:06:56 +08:00
|
|
|
unsigned NumRegs;
|
2016-09-27 22:42:48 +08:00
|
|
|
if (MRI.getRegClass(AMDGPU::VGPR_32RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 'v';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 1;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_32RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 's';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 1;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_64RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O <<'v';
|
2016-04-14 00:18:41 +08:00
|
|
|
NumRegs = 2;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_64RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 's';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 2;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_128RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 'v';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 4;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_128RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 's';
|
2016-04-30 01:04:50 +08:00
|
|
|
NumRegs = 4;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_96RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 'v';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 3;
|
2019-04-16 04:42:18 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SReg_96RegClassID).contains(RegNo)) {
|
|
|
|
O << 's';
|
|
|
|
NumRegs = 3;
|
2019-03-22 18:11:21 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_160RegClassID).contains(RegNo)) {
|
|
|
|
O << 'v';
|
|
|
|
NumRegs = 5;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_256RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 'v';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 8;
|
2017-12-22 23:18:06 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_256RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 's';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 8;
|
2016-09-27 22:42:48 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::VReg_512RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 'v';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 16;
|
2017-12-22 23:18:06 +08:00
|
|
|
} else if (MRI.getRegClass(AMDGPU::SGPR_512RegClassID).contains(RegNo)) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << 's';
|
2014-04-16 06:32:42 +08:00
|
|
|
NumRegs = 16;
|
|
|
|
} else {
|
2016-09-27 22:42:48 +08:00
|
|
|
O << getRegisterName(RegNo);
|
2013-11-12 10:35:51 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-16 06:32:42 +08:00
|
|
|
if (NumRegs == 1) {
|
2016-07-06 06:06:56 +08:00
|
|
|
O << RegIdx;
|
2013-11-12 10:35:51 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-06 06:06:56 +08:00
|
|
|
O << '[' << RegIdx << ':' << (RegIdx + NumRegs - 1) << ']';
|
2013-11-12 10:35:51 +08:00
|
|
|
}
|
|
|
|
|
2015-03-13 05:34:22 +08:00
|
|
|
void AMDGPUInstPrinter::printVOPDst(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2019-04-27 07:16:16 +08:00
|
|
|
if (OpNo == 0) {
|
|
|
|
if (MII.get(MI->getOpcode()).TSFlags & SIInstrFlags::VOP3)
|
|
|
|
O << "_e64 ";
|
|
|
|
else if (MII.get(MI->getOpcode()).TSFlags & SIInstrFlags::DPP)
|
|
|
|
O << "_dpp ";
|
|
|
|
else if (MII.get(MI->getOpcode()).TSFlags & SIInstrFlags::SDWA)
|
|
|
|
O << "_sdwa ";
|
|
|
|
else
|
|
|
|
O << "_e32 ";
|
|
|
|
}
|
2015-03-13 05:34:22 +08:00
|
|
|
|
2016-09-27 22:42:48 +08:00
|
|
|
printOperand(MI, OpNo, STI, O);
|
2019-04-27 07:16:16 +08:00
|
|
|
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default: break;
|
|
|
|
|
|
|
|
case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
|
|
|
|
case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
|
|
|
|
case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
|
|
|
|
case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
|
|
|
|
case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
|
|
|
|
case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
|
|
|
|
printDefaultVccOperand(1, STI, O);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-13 05:34:22 +08:00
|
|
|
}
|
|
|
|
|
2018-03-17 00:38:04 +08:00
|
|
|
void AMDGPUInstPrinter::printVINTRPDst(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
|
|
|
if (AMDGPU::isSI(STI) || AMDGPU::isCI(STI))
|
|
|
|
O << " ";
|
|
|
|
else
|
|
|
|
O << "_e32 ";
|
|
|
|
|
|
|
|
printOperand(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
2016-12-10 08:39:12 +08:00
|
|
|
void AMDGPUInstPrinter::printImmediate16(uint32_t Imm,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
int16_t SImm = static_cast<int16_t>(Imm);
|
|
|
|
if (SImm >= -16 && SImm <= 64) {
|
|
|
|
O << SImm;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Imm == 0x3C00)
|
|
|
|
O<< "1.0";
|
|
|
|
else if (Imm == 0xBC00)
|
|
|
|
O<< "-1.0";
|
|
|
|
else if (Imm == 0x3800)
|
|
|
|
O<< "0.5";
|
|
|
|
else if (Imm == 0xB800)
|
|
|
|
O<< "-0.5";
|
|
|
|
else if (Imm == 0x4000)
|
|
|
|
O<< "2.0";
|
|
|
|
else if (Imm == 0xC000)
|
|
|
|
O<< "-2.0";
|
|
|
|
else if (Imm == 0x4400)
|
|
|
|
O<< "4.0";
|
|
|
|
else if (Imm == 0xC400)
|
|
|
|
O<< "-4.0";
|
|
|
|
else if (Imm == 0x3118) {
|
|
|
|
assert(STI.getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm]);
|
|
|
|
O << "0.15915494";
|
|
|
|
} else
|
|
|
|
O << formatHex(static_cast<uint64_t>(Imm));
|
|
|
|
}
|
|
|
|
|
2017-02-28 02:49:11 +08:00
|
|
|
void AMDGPUInstPrinter::printImmediateV216(uint32_t Imm,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
uint16_t Lo16 = static_cast<uint16_t>(Imm);
|
|
|
|
printImmediate16(Lo16, STI, O);
|
|
|
|
}
|
|
|
|
|
2016-10-29 12:05:06 +08:00
|
|
|
void AMDGPUInstPrinter::printImmediate32(uint32_t Imm,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2014-04-16 06:32:49 +08:00
|
|
|
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";
|
2016-10-29 12:05:06 +08:00
|
|
|
else if (Imm == 0x3e22f983 &&
|
|
|
|
STI.getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm])
|
2016-11-15 08:04:33 +08:00
|
|
|
O << "0.15915494";
|
2014-12-18 05:04:08 +08:00
|
|
|
else
|
2014-09-18 01:32:13 +08:00
|
|
|
O << formatHex(static_cast<uint64_t>(Imm));
|
2014-12-18 05:04:08 +08:00
|
|
|
}
|
|
|
|
|
2016-10-29 12:05:06 +08:00
|
|
|
void AMDGPUInstPrinter::printImmediate64(uint64_t Imm,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2014-12-18 05:04:08 +08:00
|
|
|
int64_t SImm = static_cast<int64_t>(Imm);
|
|
|
|
if (SImm >= -16 && SImm <= 64) {
|
|
|
|
O << SImm;
|
|
|
|
return;
|
2014-04-16 06:32:49 +08:00
|
|
|
}
|
2014-12-18 05:04:08 +08:00
|
|
|
|
|
|
|
if (Imm == DoubleToBits(0.0))
|
|
|
|
O << "0.0";
|
|
|
|
else if (Imm == DoubleToBits(1.0))
|
|
|
|
O << "1.0";
|
|
|
|
else if (Imm == DoubleToBits(-1.0))
|
|
|
|
O << "-1.0";
|
|
|
|
else if (Imm == DoubleToBits(0.5))
|
|
|
|
O << "0.5";
|
|
|
|
else if (Imm == DoubleToBits(-0.5))
|
|
|
|
O << "-0.5";
|
|
|
|
else if (Imm == DoubleToBits(2.0))
|
|
|
|
O << "2.0";
|
|
|
|
else if (Imm == DoubleToBits(-2.0))
|
|
|
|
O << "-2.0";
|
|
|
|
else if (Imm == DoubleToBits(4.0))
|
|
|
|
O << "4.0";
|
|
|
|
else if (Imm == DoubleToBits(-4.0))
|
|
|
|
O << "-4.0";
|
2016-10-29 12:05:06 +08:00
|
|
|
else if (Imm == 0x3fc45f306dc9c882 &&
|
|
|
|
STI.getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm])
|
2019-01-18 23:17:17 +08:00
|
|
|
O << "0.15915494309189532";
|
2015-10-24 02:07:58 +08:00
|
|
|
else {
|
AMDGPU] Assembler: better support for immediate literals in assembler.
Summary:
Prevously assembler parsed all literals as either 32-bit integers or 32-bit floating-point values. Because of this we couldn't support f64 literals.
E.g. in instruction "v_fract_f64 v[0:1], 0.5", literal 0.5 was encoded as 32-bit literal 0x3f000000, which is incorrect and will be interpreted as 3.0517578125E-5 instead of 0.5. Correct encoding is inline constant 240 (optimal) or 32-bit literal 0x3FE00000 at least.
With this change the way immediate literals are parsed is changed. All literals are always parsed as 64-bit values either integer or floating-point. Then we convert parsed literals to correct form based on information about type of operand parsed (was literal floating or binary) and type of expected instruction operands (is this f32/64 or b32/64 instruction).
Here are rules how we convert literals:
- We parsed fp literal:
- Instruction expects 64-bit operand:
- If parsed literal is inlinable (e.g. v_fract_f64_e32 v[0:1], 0.5)
- then we do nothing this literal
- Else if literal is not-inlinable but instruction requires to inline it (e.g. this is e64 encoding, v_fract_f64_e64 v[0:1], 1.5)
- report error
- Else literal is not-inlinable but we can encode it as additional 32-bit literal constant
- If instruction expect fp operand type (f64)
- Check if low 32 bits of literal are zeroes (e.g. v_fract_f64 v[0:1], 1.5)
- If so then do nothing
- Else (e.g. v_fract_f64 v[0:1], 3.1415)
- report warning that low 32 bits will be set to zeroes and precision will be lost
- set low 32 bits of literal to zeroes
- Instruction expects integer operand type (e.g. s_mov_b64_e32 s[0:1], 1.5)
- report error as it is unclear how to encode this literal
- Instruction expects 32-bit operand:
- Convert parsed 64 bit fp literal to 32 bit fp. Allow lose of precision but not overflow or underflow
- Is this literal inlinable and are we required to inline literal (e.g. v_trunc_f32_e64 v0, 0.5)
- do nothing
- Else report error
- Do nothing. We can encode any other 32-bit fp literal (e.g. v_trunc_f32 v0, 10000000.0)
- Parsed binary literal:
- Is this literal inlinable (e.g. v_trunc_f32_e32 v0, 35)
- do nothing
- Else, are we required to inline this literal (e.g. v_trunc_f32_e64 v0, 35)
- report error
- Else, literal is not-inlinable and we are not required to inline it
- Are high 32 bit of literal zeroes or same as sign bit (32 bit)
- do nothing (e.g. v_trunc_f32 v0, 0xdeadbeef)
- Else
- report error (e.g. v_trunc_f32 v0, 0x123456789abcdef0)
For this change it is required that we know operand types of instruction (are they f32/64 or b32/64). I added several new register operands (they extend previous register operands) and set operand types to corresponding types:
'''
enum OperandType {
OPERAND_REG_IMM32_INT,
OPERAND_REG_IMM32_FP,
OPERAND_REG_INLINE_C_INT,
OPERAND_REG_INLINE_C_FP,
}
'''
This is not working yet:
- Several tests are failing
- Problems with predicate methods for inline immediates
- LLVM generated assembler parts try to select e64 encoding before e32.
More changes are required for several AsmOperands.
Reviewers: vpykhtin, tstellarAMD
Subscribers: arsenm, kzhuravl, artem.tamazov
Differential Revision: https://reviews.llvm.org/D22922
llvm-svn: 281050
2016-09-09 22:44:04 +08:00
|
|
|
assert(isUInt<32>(Imm) || Imm == 0x3fc45f306dc9c882);
|
2015-10-24 02:07:58 +08:00
|
|
|
|
|
|
|
// In rare situations, we will have a 32-bit literal in a 64-bit
|
|
|
|
// operand. This is technically allowed for the encoding of s_mov_b64.
|
|
|
|
O << formatHex(static_cast<uint64_t>(Imm));
|
|
|
|
}
|
2014-04-16 06:32:49 +08:00
|
|
|
}
|
|
|
|
|
2019-04-27 07:16:16 +08:00
|
|
|
void AMDGPUInstPrinter::printDefaultVccOperand(unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (OpNo > 0)
|
|
|
|
O << ", ";
|
|
|
|
printRegOperand(AMDGPU::VCC, O, MRI);
|
|
|
|
if (OpNo == 0)
|
|
|
|
O << ", ";
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2012-12-12 05:25:42 +08:00
|
|
|
raw_ostream &O) {
|
2019-04-27 07:16:16 +08:00
|
|
|
const MCInstrDesc &Desc = MII.get(MI->getOpcode());
|
|
|
|
if (OpNo == 0 && (Desc.TSFlags & SIInstrFlags::VOPC) &&
|
|
|
|
(Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
|
|
|
|
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO)))
|
|
|
|
printDefaultVccOperand(OpNo, STI, O);
|
|
|
|
|
2016-08-15 18:56:48 +08:00
|
|
|
if (OpNo >= MI->getNumOperands()) {
|
|
|
|
O << "/*Missing OP" << OpNo << "*/";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
if (Op.isReg()) {
|
AMDGPU: Add R600InstPrinter class
Summary:
This is step towards separating the GCN and R600 tablegen'd code.
This is a little awkward for now, because the R600 functions won't have the
MCSubtargetInfo parameter, so we need to have AMDMGPUInstPrinter
delegate to R600InstPrinter, but once the tablegen'd code is split,
we will be able to drop the delegation and use R600InstPrinter directly.
Reviewers: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D36444
llvm-svn: 311128
2017-08-18 06:20:04 +08:00
|
|
|
printRegOperand(Op.getReg(), O, MRI);
|
2012-12-12 05:25:42 +08:00
|
|
|
} else if (Op.isImm()) {
|
2016-12-10 08:39:12 +08:00
|
|
|
switch (Desc.OpInfo[OpNo].OperandType) {
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_INT32:
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_FP32:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
|
|
|
|
case MCOI::OPERAND_IMMEDIATE:
|
2016-10-29 12:05:06 +08:00
|
|
|
printImmediate32(Op.getImm(), STI, O);
|
2016-12-10 08:39:12 +08:00
|
|
|
break;
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_INT64:
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_FP64:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
|
|
|
|
printImmediate64(Op.getImm(), STI, O);
|
|
|
|
break;
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_INT16:
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_FP16:
|
|
|
|
printImmediate16(Op.getImm(), STI, O);
|
|
|
|
break;
|
2019-05-02 12:01:39 +08:00
|
|
|
case AMDGPU::OPERAND_REG_IMM_V2INT16:
|
|
|
|
case AMDGPU::OPERAND_REG_IMM_V2FP16:
|
|
|
|
if (!isUInt<16>(Op.getImm()) &&
|
|
|
|
STI.getFeatureBits()[AMDGPU::FeatureVOP3Literal]) {
|
|
|
|
printImmediate32(Op.getImm(), STI, O);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LLVM_FALLTHROUGH;
|
2017-02-28 02:49:11 +08:00
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
|
|
|
|
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
|
|
|
|
printImmediateV216(Op.getImm(), STI, O);
|
|
|
|
break;
|
2016-12-10 08:39:12 +08:00
|
|
|
case MCOI::OPERAND_UNKNOWN:
|
|
|
|
case MCOI::OPERAND_PCREL:
|
|
|
|
O << formatDec(Op.getImm());
|
|
|
|
break;
|
|
|
|
case MCOI::OPERAND_REGISTER:
|
|
|
|
// FIXME: This should be removed and handled somewhere else. Seems to come
|
|
|
|
// from a disassembler bug.
|
|
|
|
O << "/*invalid immediate*/";
|
|
|
|
break;
|
|
|
|
default:
|
2014-12-18 05:04:08 +08:00
|
|
|
// We hit this for the immediate instruction bits that don't yet have a
|
|
|
|
// custom printer.
|
2016-12-10 08:39:12 +08:00
|
|
|
llvm_unreachable("unexpected immediate operand type");
|
2014-12-18 05:04:08 +08:00
|
|
|
}
|
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";
|
2014-12-18 05:04:08 +08:00
|
|
|
else {
|
|
|
|
const MCInstrDesc &Desc = MII.get(MI->getOpcode());
|
2016-10-20 01:40:36 +08:00
|
|
|
int RCID = Desc.OpInfo[OpNo].RegClass;
|
|
|
|
unsigned RCBits = AMDGPU::getRegBitWidth(MRI.getRegClass(RCID));
|
|
|
|
if (RCBits == 32)
|
2016-10-29 12:05:06 +08:00
|
|
|
printImmediate32(FloatToBits(Op.getFPImm()), STI, O);
|
2016-10-20 01:40:36 +08:00
|
|
|
else if (RCBits == 64)
|
2016-10-29 12:05:06 +08:00
|
|
|
printImmediate64(DoubleToBits(Op.getFPImm()), STI, O);
|
2014-12-18 05:04:08 +08:00
|
|
|
else
|
|
|
|
llvm_unreachable("Invalid register class size");
|
|
|
|
}
|
2013-02-21 23:17:22 +08:00
|
|
|
} else if (Op.isExpr()) {
|
|
|
|
const MCExpr *Exp = Op.getExpr();
|
2015-06-09 08:31:39 +08:00
|
|
|
Exp->print(O, &MAI);
|
2012-12-12 05:25:42 +08:00
|
|
|
} else {
|
2016-03-01 21:57:29 +08:00
|
|
|
O << "/*INV_OP*/";
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
2019-04-27 07:16:16 +08:00
|
|
|
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default: break;
|
|
|
|
|
|
|
|
case AMDGPU::V_CNDMASK_B32_e32_gfx10:
|
|
|
|
case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
|
|
|
|
case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
|
|
|
|
case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
|
|
|
|
|
|
|
|
case AMDGPU::V_CNDMASK_B32_e32_gfx6_gfx7:
|
|
|
|
case AMDGPU::V_CNDMASK_B32_e32_vi:
|
|
|
|
if ((int)OpNo == AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::src1))
|
|
|
|
printDefaultVccOperand(OpNo, STI, O);
|
|
|
|
break;
|
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2016-06-10 17:57:59 +08:00
|
|
|
void AMDGPUInstPrinter::printOperandAndFPInputMods(const MCInst *MI,
|
2016-09-27 22:42:48 +08:00
|
|
|
unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2014-05-11 03:18:33 +08:00
|
|
|
unsigned InputModifiers = MI->getOperand(OpNo).getImm();
|
2017-03-20 22:50:35 +08:00
|
|
|
|
|
|
|
// Use 'neg(...)' instead of '-' to avoid ambiguity.
|
|
|
|
// This is important for integer literals because
|
|
|
|
// -1 is not the same value as neg(1).
|
|
|
|
bool NegMnemo = false;
|
|
|
|
|
|
|
|
if (InputModifiers & SISrcMods::NEG) {
|
|
|
|
if (OpNo + 1 < MI->getNumOperands() &&
|
|
|
|
(InputModifiers & SISrcMods::ABS) == 0) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo + 1);
|
|
|
|
NegMnemo = Op.isImm() || Op.isFPImm();
|
|
|
|
}
|
|
|
|
if (NegMnemo) {
|
|
|
|
O << "neg(";
|
|
|
|
} else {
|
|
|
|
O << '-';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-29 23:50:26 +08:00
|
|
|
if (InputModifiers & SISrcMods::ABS)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '|';
|
2016-09-27 22:42:48 +08:00
|
|
|
printOperand(MI, OpNo + 1, STI, O);
|
2014-09-29 23:50:26 +08:00
|
|
|
if (InputModifiers & SISrcMods::ABS)
|
2014-09-22 01:27:28 +08:00
|
|
|
O << '|';
|
2017-03-20 22:50:35 +08:00
|
|
|
|
|
|
|
if (NegMnemo) {
|
|
|
|
O << ')';
|
|
|
|
}
|
2014-05-11 03:18:33 +08:00
|
|
|
}
|
|
|
|
|
2016-06-10 17:57:59 +08:00
|
|
|
void AMDGPUInstPrinter::printOperandAndIntInputMods(const MCInst *MI,
|
2016-09-27 22:42:48 +08:00
|
|
|
unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2016-06-10 17:57:59 +08:00
|
|
|
unsigned InputModifiers = MI->getOperand(OpNo).getImm();
|
|
|
|
if (InputModifiers & SISrcMods::SEXT)
|
|
|
|
O << "sext(";
|
2016-09-27 22:42:48 +08:00
|
|
|
printOperand(MI, OpNo + 1, STI, O);
|
2016-06-10 17:57:59 +08:00
|
|
|
if (InputModifiers & SISrcMods::SEXT)
|
|
|
|
O << ')';
|
2019-04-27 07:16:16 +08:00
|
|
|
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default: break;
|
|
|
|
|
|
|
|
case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
|
|
|
|
case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
|
|
|
|
case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
|
|
|
|
if ((int)OpNo + 1 == AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::src1))
|
|
|
|
printDefaultVccOperand(OpNo, STI, O);
|
|
|
|
break;
|
|
|
|
}
|
2016-06-10 17:57:59 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printDPPCtrl(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2018-05-09 00:53:02 +08:00
|
|
|
using namespace AMDGPU::DPP;
|
|
|
|
|
2016-03-09 20:29:31 +08:00
|
|
|
unsigned Imm = MI->getOperand(OpNo).getImm();
|
2018-05-09 00:53:02 +08:00
|
|
|
if (Imm <= DppCtrl::QUAD_PERM_LAST) {
|
2016-03-18 23:35:51 +08:00
|
|
|
O << " quad_perm:[";
|
2016-07-06 06:06:56 +08:00
|
|
|
O << formatDec(Imm & 0x3) << ',';
|
|
|
|
O << formatDec((Imm & 0xc) >> 2) << ',';
|
|
|
|
O << formatDec((Imm & 0x30) >> 4) << ',';
|
|
|
|
O << formatDec((Imm & 0xc0) >> 6) << ']';
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if ((Imm >= DppCtrl::ROW_SHL_FIRST) &&
|
|
|
|
(Imm <= DppCtrl::ROW_SHL_LAST)) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_shl:";
|
|
|
|
printU4ImmDecOperand(MI, OpNo, O);
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if ((Imm >= DppCtrl::ROW_SHR_FIRST) &&
|
|
|
|
(Imm <= DppCtrl::ROW_SHR_LAST)) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_shr:";
|
|
|
|
printU4ImmDecOperand(MI, OpNo, O);
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if ((Imm >= DppCtrl::ROW_ROR_FIRST) &&
|
|
|
|
(Imm <= DppCtrl::ROW_ROR_LAST)) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_ror:";
|
|
|
|
printU4ImmDecOperand(MI, OpNo, O);
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::WAVE_SHL1) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " wave_shl:1";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::WAVE_ROL1) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " wave_rol:1";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::WAVE_SHR1) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " wave_shr:1";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::WAVE_ROR1) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " wave_ror:1";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::ROW_MIRROR) {
|
2016-03-18 23:35:51 +08:00
|
|
|
O << " row_mirror";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::ROW_HALF_MIRROR) {
|
2016-03-18 23:35:51 +08:00
|
|
|
O << " row_half_mirror";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::BCAST15) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_bcast:15";
|
2018-05-09 00:53:02 +08:00
|
|
|
} else if (Imm == DppCtrl::BCAST31) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_bcast:31";
|
|
|
|
} else {
|
2018-05-09 00:53:02 +08:00
|
|
|
O << " /* Invalid dpp_ctrl value */";
|
2016-03-09 20:29:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printRowMask(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " row_mask:";
|
2016-10-13 02:00:51 +08:00
|
|
|
printU4ImmOperand(MI, OpNo, STI, O);
|
2016-03-09 20:29:31 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printBankMask(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2016-03-09 20:29:31 +08:00
|
|
|
O << " bank_mask:";
|
2016-10-13 02:00:51 +08:00
|
|
|
printU4ImmOperand(MI, OpNo, STI, O);
|
2016-03-09 20:29:31 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 17:02:30 +08:00
|
|
|
void AMDGPUInstPrinter::printBoundCtrl(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2016-03-09 20:29:31 +08:00
|
|
|
unsigned Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm) {
|
|
|
|
O << " bound_ctrl:0"; // XXX - this syntax is used in sp3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-26 21:33:56 +08:00
|
|
|
void AMDGPUInstPrinter::printSDWASel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
2016-10-07 22:46:06 +08:00
|
|
|
using namespace llvm::AMDGPU::SDWA;
|
|
|
|
|
2016-04-26 21:33:56 +08:00
|
|
|
unsigned Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (Imm) {
|
2016-10-07 22:46:06 +08:00
|
|
|
case SdwaSel::BYTE_0: O << "BYTE_0"; break;
|
|
|
|
case SdwaSel::BYTE_1: O << "BYTE_1"; break;
|
|
|
|
case SdwaSel::BYTE_2: O << "BYTE_2"; break;
|
|
|
|
case SdwaSel::BYTE_3: O << "BYTE_3"; break;
|
|
|
|
case SdwaSel::WORD_0: O << "WORD_0"; break;
|
|
|
|
case SdwaSel::WORD_1: O << "WORD_1"; break;
|
|
|
|
case SdwaSel::DWORD: O << "DWORD"; break;
|
2016-04-26 21:33:56 +08:00
|
|
|
default: llvm_unreachable("Invalid SDWA data select operand");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSDWADstSel(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-26 21:33:56 +08:00
|
|
|
raw_ostream &O) {
|
|
|
|
O << "dst_sel:";
|
|
|
|
printSDWASel(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSDWASrc0Sel(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-26 21:33:56 +08:00
|
|
|
raw_ostream &O) {
|
|
|
|
O << "src0_sel:";
|
|
|
|
printSDWASel(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSDWASrc1Sel(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-26 21:33:56 +08:00
|
|
|
raw_ostream &O) {
|
|
|
|
O << "src1_sel:";
|
|
|
|
printSDWASel(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSDWADstUnused(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2016-04-26 21:33:56 +08:00
|
|
|
raw_ostream &O) {
|
2016-10-07 22:46:06 +08:00
|
|
|
using namespace llvm::AMDGPU::SDWA;
|
|
|
|
|
2016-04-26 21:33:56 +08:00
|
|
|
O << "dst_unused:";
|
|
|
|
unsigned Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (Imm) {
|
2016-10-07 22:46:06 +08:00
|
|
|
case DstUnused::UNUSED_PAD: O << "UNUSED_PAD"; break;
|
|
|
|
case DstUnused::UNUSED_SEXT: O << "UNUSED_SEXT"; break;
|
|
|
|
case DstUnused::UNUSED_PRESERVE: O << "UNUSED_PRESERVE"; break;
|
2016-04-26 21:33:56 +08:00
|
|
|
default: llvm_unreachable("Invalid SDWA dest_unused operand");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-06 04:31:49 +08:00
|
|
|
template <unsigned N>
|
|
|
|
void AMDGPUInstPrinter::printExpSrcN(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2017-02-23 04:37:12 +08:00
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
int EnIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::en);
|
2016-12-06 04:31:49 +08:00
|
|
|
unsigned En = MI->getOperand(EnIdx).getImm();
|
|
|
|
|
2017-02-23 04:37:12 +08:00
|
|
|
int ComprIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::compr);
|
|
|
|
|
|
|
|
// If compr is set, print as src0, src0, src1, src1
|
|
|
|
if (MI->getOperand(ComprIdx).getImm()) {
|
|
|
|
if (N == 1 || N == 2)
|
|
|
|
--OpNo;
|
|
|
|
else if (N == 3)
|
|
|
|
OpNo -= 2;
|
|
|
|
}
|
2016-12-06 04:31:49 +08:00
|
|
|
|
|
|
|
if (En & (1 << N))
|
|
|
|
printRegOperand(MI->getOperand(OpNo).getReg(), O, MRI);
|
|
|
|
else
|
|
|
|
O << "off";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpSrc0(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printExpSrcN<0>(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpSrc1(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printExpSrcN<1>(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpSrc2(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printExpSrcN<2>(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpSrc3(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printExpSrcN<3>(MI, OpNo, STI, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printExpTgt(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
// This is really a 6 bit field.
|
|
|
|
uint32_t Tgt = MI->getOperand(OpNo).getImm() & ((1 << 6) - 1);
|
|
|
|
|
|
|
|
if (Tgt <= 7)
|
|
|
|
O << " mrt" << Tgt;
|
|
|
|
else if (Tgt == 8)
|
|
|
|
O << " mrtz";
|
|
|
|
else if (Tgt == 9)
|
|
|
|
O << " null";
|
2019-05-09 05:23:37 +08:00
|
|
|
else if ((Tgt >= 12 && Tgt <= 15) || (Tgt == 16 && AMDGPU::isGFX10(STI)))
|
2016-12-06 04:31:49 +08:00
|
|
|
O << " pos" << Tgt - 12;
|
2019-05-09 05:23:37 +08:00
|
|
|
else if (AMDGPU::isGFX10(STI) && Tgt == 20)
|
|
|
|
O << " prim";
|
2016-12-06 04:31:49 +08:00
|
|
|
else if (Tgt >= 32 && Tgt <= 63)
|
|
|
|
O << " param" << Tgt - 32;
|
|
|
|
else {
|
|
|
|
// Reserved values 10, 11
|
|
|
|
O << " invalid_target_" << Tgt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
static bool allOpsDefaultValue(const int* Ops, int NumOps, int Mod,
|
2017-11-17 23:15:40 +08:00
|
|
|
bool IsPacked, bool HasDstSel) {
|
|
|
|
int DefaultValue = IsPacked && (Mod == SISrcMods::OP_SEL_1);
|
2017-02-28 02:49:11 +08:00
|
|
|
|
|
|
|
for (int I = 0; I < NumOps; ++I) {
|
|
|
|
if (!!(Ops[I] & Mod) != DefaultValue)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
if (HasDstSel && (Ops[0] & SISrcMods::DST_OP_SEL) != 0)
|
|
|
|
return false;
|
|
|
|
|
2017-02-28 02:49:11 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
void AMDGPUInstPrinter::printPackedModifier(const MCInst *MI,
|
|
|
|
StringRef Name,
|
|
|
|
unsigned Mod,
|
|
|
|
raw_ostream &O) {
|
2017-02-28 02:49:11 +08:00
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
int NumOps = 0;
|
|
|
|
int Ops[3];
|
|
|
|
|
|
|
|
for (int OpName : { AMDGPU::OpName::src0_modifiers,
|
|
|
|
AMDGPU::OpName::src1_modifiers,
|
|
|
|
AMDGPU::OpName::src2_modifiers }) {
|
|
|
|
int Idx = AMDGPU::getNamedOperandIdx(Opc, OpName);
|
|
|
|
if (Idx == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Ops[NumOps++] = MI->getOperand(Idx).getImm();
|
|
|
|
}
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
const bool HasDstSel =
|
|
|
|
NumOps > 0 &&
|
|
|
|
Mod == SISrcMods::OP_SEL_0 &&
|
|
|
|
MII.get(MI->getOpcode()).TSFlags & SIInstrFlags::VOP3_OPSEL;
|
|
|
|
|
2017-11-17 23:15:40 +08:00
|
|
|
const bool IsPacked =
|
|
|
|
MII.get(MI->getOpcode()).TSFlags & SIInstrFlags::IsPacked;
|
|
|
|
|
|
|
|
if (allOpsDefaultValue(Ops, NumOps, Mod, IsPacked, HasDstSel))
|
2017-02-28 02:49:11 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
O << Name;
|
|
|
|
for (int I = 0; I < NumOps; ++I) {
|
|
|
|
if (I != 0)
|
|
|
|
O << ',';
|
|
|
|
|
|
|
|
O << !!(Ops[I] & Mod);
|
|
|
|
}
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
if (HasDstSel) {
|
|
|
|
O << ',' << !!(Ops[0] & SISrcMods::DST_OP_SEL);
|
|
|
|
}
|
|
|
|
|
2017-02-28 02:49:11 +08:00
|
|
|
O << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printOpSel(const MCInst *MI, unsigned,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2019-06-13 01:52:51 +08:00
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
if (Opc == AMDGPU::V_PERMLANE16_B32_gfx10 ||
|
|
|
|
Opc == AMDGPU::V_PERMLANEX16_B32_gfx10) {
|
|
|
|
auto FIN = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0_modifiers);
|
|
|
|
auto BCN = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src1_modifiers);
|
|
|
|
unsigned FI = !!(MI->getOperand(FIN).getImm() & SISrcMods::OP_SEL_0);
|
|
|
|
unsigned BC = !!(MI->getOperand(BCN).getImm() & SISrcMods::OP_SEL_0);
|
|
|
|
if (FI || BC)
|
|
|
|
O << " op_sel:[" << FI << ',' << BC << ']';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-28 02:49:11 +08:00
|
|
|
printPackedModifier(MI, " op_sel:[", SISrcMods::OP_SEL_0, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printOpSelHi(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printPackedModifier(MI, " op_sel_hi:[", SISrcMods::OP_SEL_1, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printNegLo(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printPackedModifier(MI, " neg_lo:[", SISrcMods::NEG, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printNegHi(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printPackedModifier(MI, " neg_hi:[", SISrcMods::NEG_HI, O);
|
|
|
|
}
|
|
|
|
|
2016-12-06 04:31:49 +08:00
|
|
|
void AMDGPUInstPrinter::printInterpSlot(const MCInst *MI, unsigned OpNum,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2013-02-15 03:03:25 +08:00
|
|
|
raw_ostream &O) {
|
2016-12-06 04:31:49 +08:00
|
|
|
unsigned Imm = MI->getOperand(OpNum).getImm();
|
2016-12-10 08:23:12 +08:00
|
|
|
switch (Imm) {
|
|
|
|
case 0:
|
|
|
|
O << "p10";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
O << "p20";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
O << "p0";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
O << "invalid_param_" << Imm;
|
2013-02-15 03:03:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-15 00:36:12 +08:00
|
|
|
void AMDGPUInstPrinter::printInterpAttr(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned Attr = MI->getOperand(OpNum).getImm();
|
|
|
|
O << "attr" << Attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printInterpAttrChan(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned Chan = MI->getOperand(OpNum).getImm();
|
|
|
|
O << '.' << "xyzw"[Chan & 0x3];
|
|
|
|
}
|
|
|
|
|
2016-10-13 02:00:51 +08:00
|
|
|
void AMDGPUInstPrinter::printVGPRIndexMode(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2019-02-27 21:12:12 +08:00
|
|
|
using namespace llvm::AMDGPU::VGPRIndexMode;
|
2016-10-13 02:00:51 +08:00
|
|
|
unsigned Val = MI->getOperand(OpNo).getImm();
|
|
|
|
|
2019-02-27 21:12:12 +08:00
|
|
|
if ((Val & ~ENABLE_MASK) != 0) {
|
|
|
|
O << " " << formatHex(static_cast<uint64_t>(Val));
|
|
|
|
} else {
|
|
|
|
O << " gpr_idx(";
|
|
|
|
bool NeedComma = false;
|
|
|
|
for (unsigned ModeId = ID_MIN; ModeId <= ID_MAX; ++ModeId) {
|
|
|
|
if (Val & (1 << ModeId)) {
|
|
|
|
if (NeedComma)
|
|
|
|
O << ',';
|
|
|
|
O << IdSymbolic[ModeId];
|
|
|
|
NeedComma = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
O << ')';
|
|
|
|
}
|
2016-10-13 02:00:51 +08:00
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2012-12-12 05:25:42 +08:00
|
|
|
raw_ostream &O) {
|
2016-09-27 22:42:48 +08:00
|
|
|
printOperand(MI, OpNo, STI, O);
|
2012-12-12 05:25:42 +08:00
|
|
|
O << ", ";
|
2016-09-27 22:42:48 +08:00
|
|
|
printOperand(MI, OpNo + 1, STI, O);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-06 06:06:56 +08:00
|
|
|
void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O, char Asm) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
assert(Op.isImm());
|
|
|
|
if (Op.getImm() == 1)
|
|
|
|
O << Asm;
|
|
|
|
}
|
|
|
|
|
2017-08-07 21:14:12 +08:00
|
|
|
void AMDGPUInstPrinter::printHigh(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " high";
|
|
|
|
}
|
|
|
|
|
2014-10-01 03:49:48 +08:00
|
|
|
void AMDGPUInstPrinter::printClampSI(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2014-10-01 03:49:48 +08:00
|
|
|
raw_ostream &O) {
|
|
|
|
if (MI->getOperand(OpNo).getImm())
|
|
|
|
O << " clamp";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printOModSI(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
2014-10-01 03:49:48 +08:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2014-01-27 15:20:44 +08:00
|
|
|
void AMDGPUInstPrinter::printSendMsg(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2014-01-27 15:20:44 +08:00
|
|
|
raw_ostream &O) {
|
2016-05-07 01:48:48 +08:00
|
|
|
using namespace llvm::AMDGPU::SendMsg;
|
|
|
|
|
|
|
|
const unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
|
|
|
const unsigned Id = SImm16 & ID_MASK_;
|
|
|
|
do {
|
2019-04-25 01:28:30 +08:00
|
|
|
if (Id == ID_INTERRUPT ||
|
|
|
|
(Id == ID_GS_ALLOC_REQ && !AMDGPU::isSI(STI) && !AMDGPU::isCI(STI) &&
|
|
|
|
!AMDGPU::isVI(STI))) {
|
2016-05-07 01:48:48 +08:00
|
|
|
if ((SImm16 & ~ID_MASK_) != 0) // Unused/unknown bits must be 0.
|
|
|
|
break;
|
|
|
|
O << "sendmsg(" << IdSymbolic[Id] << ')';
|
|
|
|
return;
|
2014-01-27 15:20:44 +08:00
|
|
|
}
|
2016-05-07 01:48:48 +08:00
|
|
|
if (Id == ID_GS || Id == ID_GS_DONE) {
|
|
|
|
if ((SImm16 & ~(ID_MASK_|OP_GS_MASK_|STREAM_ID_MASK_)) != 0) // Unused/unknown bits must be 0.
|
|
|
|
break;
|
|
|
|
const unsigned OpGs = (SImm16 & OP_GS_MASK_) >> OP_SHIFT_;
|
|
|
|
const unsigned StreamId = (SImm16 & STREAM_ID_MASK_) >> STREAM_ID_SHIFT_;
|
|
|
|
if (OpGs == OP_GS_NOP && Id != ID_GS_DONE) // NOP to be used for GS_DONE only.
|
|
|
|
break;
|
|
|
|
if (OpGs == OP_GS_NOP && StreamId != 0) // NOP does not use/define stream id bits.
|
|
|
|
break;
|
|
|
|
O << "sendmsg(" << IdSymbolic[Id] << ", " << OpGsSymbolic[OpGs];
|
|
|
|
if (OpGs != OP_GS_NOP) { O << ", " << StreamId; }
|
|
|
|
O << ')';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Id == ID_SYSMSG) {
|
|
|
|
if ((SImm16 & ~(ID_MASK_|OP_SYS_MASK_)) != 0) // Unused/unknown bits must be 0.
|
|
|
|
break;
|
|
|
|
const unsigned OpSys = (SImm16 & OP_SYS_MASK_) >> OP_SHIFT_;
|
|
|
|
if (! (OP_SYS_FIRST_ <= OpSys && OpSys < OP_SYS_LAST_)) // Unused/unknown.
|
|
|
|
break;
|
|
|
|
O << "sendmsg(" << IdSymbolic[Id] << ", " << OpSysSymbolic[OpSys] << ')';
|
|
|
|
return;
|
|
|
|
}
|
2016-12-13 06:23:53 +08:00
|
|
|
} while (false);
|
2016-05-07 01:48:48 +08:00
|
|
|
O << SImm16; // Unknown simm16 code.
|
2014-01-27 15:20:44 +08:00
|
|
|
}
|
|
|
|
|
2017-06-01 00:26:47 +08:00
|
|
|
static void printSwizzleBitmask(const uint16_t AndMask,
|
|
|
|
const uint16_t OrMask,
|
|
|
|
const uint16_t XorMask,
|
|
|
|
raw_ostream &O) {
|
|
|
|
using namespace llvm::AMDGPU::Swizzle;
|
|
|
|
|
|
|
|
uint16_t Probe0 = ((0 & AndMask) | OrMask) ^ XorMask;
|
|
|
|
uint16_t Probe1 = ((BITMASK_MASK & AndMask) | OrMask) ^ XorMask;
|
|
|
|
|
|
|
|
O << "\"";
|
|
|
|
|
|
|
|
for (unsigned Mask = 1 << (BITMASK_WIDTH - 1); Mask > 0; Mask >>= 1) {
|
|
|
|
uint16_t p0 = Probe0 & Mask;
|
|
|
|
uint16_t p1 = Probe1 & Mask;
|
|
|
|
|
|
|
|
if (p0 == p1) {
|
|
|
|
if (p0 == 0) {
|
|
|
|
O << "0";
|
|
|
|
} else {
|
|
|
|
O << "1";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (p0 == 0) {
|
|
|
|
O << "p";
|
|
|
|
} else {
|
|
|
|
O << "i";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
O << "\"";
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUInstPrinter::printSwizzle(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
using namespace llvm::AMDGPU::Swizzle;
|
|
|
|
|
|
|
|
uint16_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
O << " offset:";
|
|
|
|
|
|
|
|
if ((Imm & QUAD_PERM_ENC_MASK) == QUAD_PERM_ENC) {
|
|
|
|
|
|
|
|
O << "swizzle(" << IdSymbolic[ID_QUAD_PERM];
|
2019-03-12 00:49:32 +08:00
|
|
|
for (unsigned I = 0; I < LANE_NUM; ++I) {
|
2017-06-01 00:26:47 +08:00
|
|
|
O << ",";
|
|
|
|
O << formatDec(Imm & LANE_MASK);
|
|
|
|
Imm >>= LANE_SHIFT;
|
|
|
|
}
|
|
|
|
O << ")";
|
|
|
|
|
|
|
|
} else if ((Imm & BITMASK_PERM_ENC_MASK) == BITMASK_PERM_ENC) {
|
|
|
|
|
|
|
|
uint16_t AndMask = (Imm >> BITMASK_AND_SHIFT) & BITMASK_MASK;
|
|
|
|
uint16_t OrMask = (Imm >> BITMASK_OR_SHIFT) & BITMASK_MASK;
|
|
|
|
uint16_t XorMask = (Imm >> BITMASK_XOR_SHIFT) & BITMASK_MASK;
|
|
|
|
|
|
|
|
if (AndMask == BITMASK_MAX &&
|
|
|
|
OrMask == 0 &&
|
|
|
|
countPopulation(XorMask) == 1) {
|
|
|
|
|
|
|
|
O << "swizzle(" << IdSymbolic[ID_SWAP];
|
|
|
|
O << ",";
|
|
|
|
O << formatDec(XorMask);
|
|
|
|
O << ")";
|
|
|
|
|
|
|
|
} else if (AndMask == BITMASK_MAX &&
|
|
|
|
OrMask == 0 && XorMask > 0 &&
|
|
|
|
isPowerOf2_64(XorMask + 1)) {
|
|
|
|
|
|
|
|
O << "swizzle(" << IdSymbolic[ID_REVERSE];
|
|
|
|
O << ",";
|
|
|
|
O << formatDec(XorMask + 1);
|
|
|
|
O << ")";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
uint16_t GroupSize = BITMASK_MAX - AndMask + 1;
|
|
|
|
if (GroupSize > 1 &&
|
|
|
|
isPowerOf2_64(GroupSize) &&
|
|
|
|
OrMask < GroupSize &&
|
|
|
|
XorMask == 0) {
|
|
|
|
|
|
|
|
O << "swizzle(" << IdSymbolic[ID_BROADCAST];
|
|
|
|
O << ",";
|
|
|
|
O << formatDec(GroupSize);
|
|
|
|
O << ",";
|
|
|
|
O << formatDec(OrMask);
|
|
|
|
O << ")";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
O << "swizzle(" << IdSymbolic[ID_BITMASK_PERM];
|
|
|
|
O << ",";
|
|
|
|
printSwizzleBitmask(AndMask, OrMask, XorMask, O);
|
|
|
|
O << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printU16ImmDecOperand(MI, OpNo, O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-14 01:56:28 +08:00
|
|
|
void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2013-10-14 01:56:28 +08:00
|
|
|
raw_ostream &O) {
|
2018-09-13 02:50:47 +08:00
|
|
|
AMDGPU::IsaVersion ISA = AMDGPU::getIsaVersion(STI.getCPU());
|
2016-10-01 01:01:40 +08:00
|
|
|
|
2013-10-14 01:56:28 +08:00
|
|
|
unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
2016-10-12 02:58:22 +08:00
|
|
|
unsigned Vmcnt, Expcnt, Lgkmcnt;
|
2017-02-08 22:05:23 +08:00
|
|
|
decodeWaitcnt(ISA, SImm16, Vmcnt, Expcnt, Lgkmcnt);
|
2014-09-26 09:09:46 +08:00
|
|
|
|
|
|
|
bool NeedSpace = false;
|
|
|
|
|
2017-02-08 22:05:23 +08:00
|
|
|
if (Vmcnt != getVmcntBitMask(ISA)) {
|
2014-09-26 09:09:46 +08:00
|
|
|
O << "vmcnt(" << Vmcnt << ')';
|
|
|
|
NeedSpace = true;
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:05:23 +08:00
|
|
|
if (Expcnt != getExpcntBitMask(ISA)) {
|
2014-09-26 09:09:46 +08:00
|
|
|
if (NeedSpace)
|
|
|
|
O << ' ';
|
|
|
|
O << "expcnt(" << Expcnt << ')';
|
|
|
|
NeedSpace = true;
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:05:23 +08:00
|
|
|
if (Lgkmcnt != getLgkmcntBitMask(ISA)) {
|
2014-09-26 09:09:46 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-04-25 22:13:51 +08:00
|
|
|
void AMDGPUInstPrinter::printHwreg(const MCInst *MI, unsigned OpNo,
|
2016-09-27 22:42:48 +08:00
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2016-05-27 01:00:33 +08:00
|
|
|
using namespace llvm::AMDGPU::Hwreg;
|
|
|
|
|
2016-04-25 22:13:51 +08:00
|
|
|
unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
2016-05-27 01:00:33 +08:00
|
|
|
const unsigned Id = (SImm16 & ID_MASK_) >> ID_SHIFT_;
|
|
|
|
const unsigned Offset = (SImm16 & OFFSET_MASK_) >> OFFSET_SHIFT_;
|
|
|
|
const unsigned Width = ((SImm16 & WIDTH_M1_MASK_) >> WIDTH_M1_SHIFT_) + 1;
|
2016-04-25 22:13:51 +08:00
|
|
|
|
2016-04-27 23:17:03 +08:00
|
|
|
O << "hwreg(";
|
2018-01-16 02:49:15 +08:00
|
|
|
unsigned Last = ID_SYMBOLIC_LAST_;
|
|
|
|
if (AMDGPU::isSI(STI) || AMDGPU::isCI(STI) || AMDGPU::isVI(STI))
|
|
|
|
Last = ID_SYMBOLIC_FIRST_GFX9_;
|
2019-04-25 01:28:30 +08:00
|
|
|
else if (AMDGPU::isGFX9(STI))
|
|
|
|
Last = ID_SYMBOLIC_FIRST_GFX10_;
|
2018-01-16 02:49:15 +08:00
|
|
|
if (ID_SYMBOLIC_FIRST_ <= Id && Id < Last && IdSymbolic[Id]) {
|
2016-05-27 01:00:33 +08:00
|
|
|
O << IdSymbolic[Id];
|
|
|
|
} else {
|
|
|
|
O << Id;
|
|
|
|
}
|
|
|
|
if (Width != WIDTH_M1_DEFAULT_ + 1 || Offset != OFFSET_DEFAULT_) {
|
2016-04-27 23:17:03 +08:00
|
|
|
O << ", " << Offset << ", " << Width;
|
2016-04-25 22:13:51 +08:00
|
|
|
}
|
2016-04-27 23:17:03 +08:00
|
|
|
O << ')';
|
2016-04-25 22:13:51 +08:00
|
|
|
}
|
|
|
|
|
[AMDGPU] Add support for immediate operand for S_ENDPGM
Summary:
Add support for immediate operand in S_ENDPGM
Change-Id: I0c56a076a10980f719fb2a8f16407e9c301013f6
Reviewers: alexshap
Subscribers: qcolombet, arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, tpr, t-tye, eraman, arphaman, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59213
llvm-svn: 355902
2019-03-12 17:52:58 +08:00
|
|
|
void AMDGPUInstPrinter::printEndpgm(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) {
|
|
|
|
uint16_t Imm = MI->getOperand(OpNo).getImm();
|
|
|
|
if (Imm == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
O << formatDec(Imm);
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "AMDGPUGenAsmWriter.inc"
|
AMDGPU: Add R600InstPrinter class
Summary:
This is step towards separating the GCN and R600 tablegen'd code.
This is a little awkward for now, because the R600 functions won't have the
MCSubtargetInfo parameter, so we need to have AMDMGPUInstPrinter
delegate to R600InstPrinter, but once the tablegen'd code is split,
we will be able to drop the delegation and use R600InstPrinter directly.
Reviewers: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D36444
llvm-svn: 311128
2017-08-18 06:20:04 +08:00
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
void R600InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
2019-03-31 22:49:00 +08:00
|
|
|
StringRef Annot, const MCSubtargetInfo &STI) {
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
O.flush();
|
|
|
|
printInstruction(MI, O);
|
|
|
|
printAnnotation(O, Annot);
|
|
|
|
}
|
|
|
|
|
AMDGPU: Add R600InstPrinter class
Summary:
This is step towards separating the GCN and R600 tablegen'd code.
This is a little awkward for now, because the R600 functions won't have the
MCSubtargetInfo parameter, so we need to have AMDMGPUInstPrinter
delegate to R600InstPrinter, but once the tablegen'd code is split,
we will be able to drop the delegation and use R600InstPrinter directly.
Reviewers: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D36444
llvm-svn: 311128
2017-08-18 06:20:04 +08:00
|
|
|
void R600InstPrinter::printAbs(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, '|');
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printBankSwizzle(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
int BankSwizzle = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (BankSwizzle) {
|
|
|
|
case 1:
|
|
|
|
O << "BS:VEC_021/SCL_122";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
O << "BS:VEC_120/SCL_212";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
O << "BS:VEC_102/SCL_221";
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
O << "BS:VEC_201";
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
O << "BS:VEC_210";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printClamp(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, "_SAT");
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printCT(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned CT = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (CT) {
|
|
|
|
case 0:
|
|
|
|
O << 'U';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
O << 'N';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::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();
|
|
|
|
O << "CB" << KCacheBank << ':';
|
|
|
|
int KCacheAddr = MI->getOperand(OpNo + 2).getImm();
|
|
|
|
int LineSize = (KCacheMode == 1) ? 16 : 32;
|
|
|
|
O << KCacheAddr * 16 << '-' << KCacheAddr * 16 + LineSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printLast(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, "*", " ");
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printLiteral(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
assert(Op.isImm() || Op.isExpr());
|
|
|
|
if (Op.isImm()) {
|
|
|
|
int64_t Imm = Op.getImm();
|
|
|
|
O << Imm << '(' << BitsToFloat(Imm) << ')';
|
|
|
|
}
|
|
|
|
if (Op.isExpr()) {
|
|
|
|
Op.getExpr()->print(O << '@', &MAI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printNeg(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, '-');
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::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 R600InstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
printOperand(MI, OpNo, O);
|
|
|
|
O << ", ";
|
|
|
|
printOperand(MI, OpNo + 1, O);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
if (OpNo >= MI->getNumOperands()) {
|
|
|
|
O << "/*Missing OP" << OpNo << "*/";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
case R600::PRED_SEL_OFF:
|
AMDGPU: Add R600InstPrinter class
Summary:
This is step towards separating the GCN and R600 tablegen'd code.
This is a little awkward for now, because the R600 functions won't have the
MCSubtargetInfo parameter, so we need to have AMDMGPUInstPrinter
delegate to R600InstPrinter, but once the tablegen'd code is split,
we will be able to drop the delegation and use R600InstPrinter directly.
Reviewers: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D36444
llvm-svn: 311128
2017-08-18 06:20:04 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
O << getRegisterName(Op.getReg());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (Op.isImm()) {
|
|
|
|
O << Op.getImm();
|
|
|
|
} else if (Op.isFPImm()) {
|
|
|
|
// We special case 0.0 because otherwise it will be printed as an integer.
|
|
|
|
if (Op.getFPImm() == 0.0)
|
|
|
|
O << "0.0";
|
|
|
|
else {
|
|
|
|
O << Op.getFPImm();
|
|
|
|
}
|
|
|
|
} else if (Op.isExpr()) {
|
|
|
|
const MCExpr *Exp = Op.getExpr();
|
|
|
|
Exp->print(O, &MAI);
|
|
|
|
} else {
|
|
|
|
O << "/*INV_OP*/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printRel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, '+');
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printRSel(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
unsigned Sel = MI->getOperand(OpNo).getImm();
|
|
|
|
switch (Sel) {
|
|
|
|
case 0:
|
|
|
|
O << 'X';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
O << 'Y';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
O << 'Z';
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
O << 'W';
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
O << '0';
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
O << '1';
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
O << '_';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, "ExecMask,");
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
AMDGPUInstPrinter::printIfSet(MI, OpNo, O, "Pred,");
|
|
|
|
}
|
|
|
|
|
|
|
|
void R600InstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
if (Op.getImm() == 0) {
|
|
|
|
O << " (MASKED)";
|
|
|
|
}
|
|
|
|
}
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
|
|
|
|
#include "R600GenAsmWriter.inc"
|