28 using namespace llvm::AMDGPU;
33 printInstruction(MI, STI, OS);
34 printAnnotation(OS, Annot);
37 void AMDGPUInstPrinter::printU4ImmOperand(
const MCInst *
MI,
unsigned OpNo,
43 void AMDGPUInstPrinter::printU8ImmOperand(
const MCInst *MI,
unsigned OpNo,
48 void AMDGPUInstPrinter::printU16ImmOperand(
const MCInst *MI,
unsigned OpNo,
55 O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
57 printU32ImmOperand(MI, OpNo, STI, O);
60 void AMDGPUInstPrinter::printU4ImmDecOperand(
const MCInst *MI,
unsigned OpNo,
65 void AMDGPUInstPrinter::printU8ImmDecOperand(
const MCInst *MI,
unsigned OpNo,
70 void AMDGPUInstPrinter::printU16ImmDecOperand(
const MCInst *MI,
unsigned OpNo,
75 void AMDGPUInstPrinter::printS16ImmDecOperand(
const MCInst *MI,
unsigned OpNo,
80 void AMDGPUInstPrinter::printU32ImmOperand(
const MCInst *MI,
unsigned OpNo,
86 void AMDGPUInstPrinter::printNamedBit(
const MCInst *MI,
unsigned OpNo,
93 void AMDGPUInstPrinter::printOffen(
const MCInst *MI,
unsigned OpNo,
95 printNamedBit(MI, OpNo, O,
"offen");
98 void AMDGPUInstPrinter::printIdxen(
const MCInst *MI,
unsigned OpNo,
100 printNamedBit(MI, OpNo, O,
"idxen");
103 void AMDGPUInstPrinter::printAddr64(
const MCInst *MI,
unsigned OpNo,
105 printNamedBit(MI, OpNo, O,
"addr64");
108 void AMDGPUInstPrinter::printMBUFOffset(
const MCInst *MI,
unsigned OpNo,
112 printU16ImmDecOperand(MI, OpNo, O);
116 void AMDGPUInstPrinter::printOffset(
const MCInst *MI,
unsigned OpNo,
121 O << ((OpNo == 0)?
"offset:" :
" offset:");
122 printU16ImmDecOperand(MI, OpNo, O);
126 void AMDGPUInstPrinter::printOffsetS13(
const MCInst *MI,
unsigned OpNo,
131 O << ((OpNo == 0)?
"offset:" :
" offset:");
132 printS16ImmDecOperand(MI, OpNo, O);
136 void AMDGPUInstPrinter::printOffset0(
const MCInst *MI,
unsigned OpNo,
141 printU8ImmDecOperand(MI, OpNo, O);
145 void AMDGPUInstPrinter::printOffset1(
const MCInst *MI,
unsigned OpNo,
150 printU8ImmDecOperand(MI, OpNo, O);
154 void AMDGPUInstPrinter::printSMRDOffset8(
const MCInst *MI,
unsigned OpNo,
157 printU32ImmOperand(MI, OpNo, STI, O);
160 void AMDGPUInstPrinter::printSMRDOffset20(
const MCInst *MI,
unsigned OpNo,
163 printU32ImmOperand(MI, OpNo, STI, O);
166 void AMDGPUInstPrinter::printSMRDLiteralOffset(
const MCInst *MI,
unsigned OpNo,
169 printU32ImmOperand(MI, OpNo, STI, O);
172 void AMDGPUInstPrinter::printGDS(
const MCInst *MI,
unsigned OpNo,
174 printNamedBit(MI, OpNo, O,
"gds");
177 void AMDGPUInstPrinter::printGLC(
const MCInst *MI,
unsigned OpNo,
179 printNamedBit(MI, OpNo, O,
"glc");
182 void AMDGPUInstPrinter::printSLC(
const MCInst *MI,
unsigned OpNo,
184 printNamedBit(MI, OpNo, O,
"slc");
187 void AMDGPUInstPrinter::printTFE(
const MCInst *MI,
unsigned OpNo,
189 printNamedBit(MI, OpNo, O,
"tfe");
192 void AMDGPUInstPrinter::printDMask(
const MCInst *MI,
unsigned OpNo,
196 printU16ImmOperand(MI, OpNo, STI, O);
200 void AMDGPUInstPrinter::printUNorm(
const MCInst *MI,
unsigned OpNo,
202 printNamedBit(MI, OpNo, O,
"unorm");
205 void AMDGPUInstPrinter::printDA(
const MCInst *MI,
unsigned OpNo,
207 printNamedBit(MI, OpNo, O,
"da");
210 void AMDGPUInstPrinter::printR128(
const MCInst *MI,
unsigned OpNo,
212 printNamedBit(MI, OpNo, O,
"r128");
215 void AMDGPUInstPrinter::printLWE(
const MCInst *MI,
unsigned OpNo,
217 printNamedBit(MI, OpNo, O,
"lwe");
220 void AMDGPUInstPrinter::printExpCompr(
const MCInst *MI,
unsigned OpNo,
227 void AMDGPUInstPrinter::printExpVM(
const MCInst *MI,
unsigned OpNo,
234 void AMDGPUInstPrinter::printDFMT(
const MCInst *MI,
unsigned OpNo,
239 printU8ImmDecOperand(MI, OpNo, O);
243 void AMDGPUInstPrinter::printNFMT(
const MCInst *MI,
unsigned OpNo,
248 printU8ImmDecOperand(MI, OpNo, O);
267 case AMDGPU::FLAT_SCR:
288 case AMDGPU::EXEC_LO:
291 case AMDGPU::EXEC_HI:
294 case AMDGPU::FLAT_SCR_LO:
295 O <<
"flat_scratch_lo";
297 case AMDGPU::FLAT_SCR_HI:
298 O <<
"flat_scratch_hi";
302 case AMDGPU::SCRATCH_WAVE_OFFSET_REG:
303 case AMDGPU::PRIVATE_RSRC_REG:
367 O <<
'[' << RegIdx <<
':' << (RegIdx + NumRegs - 1) <<
']';
370 void AMDGPUInstPrinter::printVOPDst(
const MCInst *MI,
unsigned OpNo,
384 void AMDGPUInstPrinter::printImmediate16(
uint32_t Imm,
387 int16_t SImm =
static_cast<int16_t
>(Imm);
388 if (SImm >= -16 && SImm <= 64) {
395 else if (Imm == 0xBC00)
397 else if (Imm == 0x3800)
399 else if (Imm == 0xB800)
401 else if (Imm == 0x4000)
403 else if (Imm == 0xC000)
405 else if (Imm == 0x4400)
407 else if (Imm == 0xC400)
409 else if (Imm == 0x3118) {
413 O << formatHex(static_cast<uint64_t>(Imm));
416 void AMDGPUInstPrinter::printImmediateV216(
uint32_t Imm,
419 uint16_t Lo16 =
static_cast<uint16_t
>(Imm);
420 printImmediate16(Lo16, STI, O);
423 void AMDGPUInstPrinter::printImmediate32(
uint32_t Imm,
426 int32_t SImm =
static_cast<int32_t
>(Imm);
427 if (SImm >= -16 && SImm <= 64) {
450 else if (Imm == 0x3e22f983 &&
454 O << formatHex(static_cast<uint64_t>(Imm));
457 void AMDGPUInstPrinter::printImmediate64(uint64_t Imm,
460 int64_t SImm =
static_cast<int64_t
>(Imm);
461 if (SImm >= -16 && SImm <= 64) {
484 else if (Imm == 0x3fc45f306dc9c882 &&
492 O << formatHex(static_cast<uint64_t>(Imm));
496 void AMDGPUInstPrinter::printOperand(
const MCInst *MI,
unsigned OpNo,
500 O <<
"/*Missing OP" << OpNo <<
"*/";
508 case AMDGPU::PRED_SEL_OFF:
515 }
else if (Op.
isImm()) {
523 printImmediate32(Op.
getImm(), STI, O);
529 printImmediate64(Op.
getImm(), STI, O);
535 printImmediate16(Op.
getImm(), STI, O);
539 printImmediateV216(Op.
getImm(), STI, O);
543 O << formatDec(Op.
getImm());
548 O <<
"/*invalid immediate*/";
565 else if (RCBits == 64)
578 void AMDGPUInstPrinter::printOperandAndFPInputMods(
const MCInst *MI,
587 bool NegMnemo =
false;
605 if (InputModifiers & SISrcMods::ABS)
613 void AMDGPUInstPrinter::printOperandAndIntInputMods(
const MCInst *MI,
621 if (InputModifiers & SISrcMods::SEXT)
625 void AMDGPUInstPrinter::printDPPCtrl(
const MCInst *MI,
unsigned OpNo,
631 O << formatDec(Imm & 0x3) <<
',';
632 O << formatDec((Imm & 0xc) >> 2) <<
',';
633 O << formatDec((Imm & 0x30) >> 4) <<
',';
634 O << formatDec((Imm & 0xc0) >> 6) <<
']';
635 }
else if ((Imm >= 0x101) && (Imm <= 0x10f)) {
637 printU4ImmDecOperand(MI, OpNo, O);
638 }
else if ((Imm >= 0x111) && (Imm <= 0x11f)) {
640 printU4ImmDecOperand(MI, OpNo, O);
641 }
else if ((Imm >= 0x121) && (Imm <= 0x12f)) {
643 printU4ImmDecOperand(MI, OpNo, O);
644 }
else if (Imm == 0x130) {
646 }
else if (Imm == 0x134) {
648 }
else if (Imm == 0x138) {
650 }
else if (Imm == 0x13c) {
652 }
else if (Imm == 0x140) {
654 }
else if (Imm == 0x141) {
655 O <<
" row_half_mirror";
656 }
else if (Imm == 0x142) {
657 O <<
" row_bcast:15";
658 }
else if (Imm == 0x143) {
659 O <<
" row_bcast:31";
665 void AMDGPUInstPrinter::printRowMask(
const MCInst *MI,
unsigned OpNo,
669 printU4ImmOperand(MI, OpNo, STI, O);
672 void AMDGPUInstPrinter::printBankMask(
const MCInst *MI,
unsigned OpNo,
676 printU4ImmOperand(MI, OpNo, STI, O);
679 void AMDGPUInstPrinter::printBoundCtrl(
const MCInst *MI,
unsigned OpNo,
684 O <<
" bound_ctrl:0";
688 void AMDGPUInstPrinter::printSDWASel(
const MCInst *MI,
unsigned OpNo,
705 void AMDGPUInstPrinter::printSDWADstSel(
const MCInst *MI,
unsigned OpNo,
709 printSDWASel(MI, OpNo, O);
712 void AMDGPUInstPrinter::printSDWASrc0Sel(
const MCInst *MI,
unsigned OpNo,
716 printSDWASel(MI, OpNo, O);
719 void AMDGPUInstPrinter::printSDWASrc1Sel(
const MCInst *MI,
unsigned OpNo,
723 printSDWASel(MI, OpNo, O);
726 void AMDGPUInstPrinter::printSDWADstUnused(
const MCInst *MI,
unsigned OpNo,
741 template <
unsigned N>
742 void AMDGPUInstPrinter::printExpSrcN(
const MCInst *MI,
unsigned OpNo,
753 if (
N == 1 ||
N == 2)
765 void AMDGPUInstPrinter::printExpSrc0(
const MCInst *MI,
unsigned OpNo,
768 printExpSrcN<0>(
MI, OpNo, STI, O);
771 void AMDGPUInstPrinter::printExpSrc1(
const MCInst *MI,
unsigned OpNo,
774 printExpSrcN<1>(
MI, OpNo, STI, O);
777 void AMDGPUInstPrinter::printExpSrc2(
const MCInst *MI,
unsigned OpNo,
780 printExpSrcN<2>(
MI, OpNo, STI, O);
783 void AMDGPUInstPrinter::printExpSrc3(
const MCInst *MI,
unsigned OpNo,
786 printExpSrcN<3>(
MI, OpNo, STI, O);
789 void AMDGPUInstPrinter::printExpTgt(
const MCInst *MI,
unsigned OpNo,
801 else if (Tgt >= 12 && Tgt <= 15)
802 O <<
" pos" << Tgt - 12;
803 else if (Tgt >= 32 && Tgt <= 63)
804 O <<
" param" << Tgt - 32;
807 O <<
" invalid_target_" << Tgt;
814 for (
int I = 0;
I < NumOps; ++
I) {
815 if (!!(Ops[
I] & Mod) != DefaultValue)
828 for (
int OpName : { AMDGPU::OpName::src0_modifiers,
829 AMDGPU::OpName::src1_modifiers,
830 AMDGPU::OpName::src2_modifiers }) {
842 for (
int I = 0;
I < NumOps; ++
I) {
846 O << !!(Ops[
I] & Mod);
852 void AMDGPUInstPrinter::printOpSel(
const MCInst *MI,
unsigned,
858 void AMDGPUInstPrinter::printOpSelHi(
const MCInst *MI,
unsigned OpNo,
864 void AMDGPUInstPrinter::printNegLo(
const MCInst *MI,
unsigned OpNo,
870 void AMDGPUInstPrinter::printNegHi(
const MCInst *MI,
unsigned OpNo,
876 void AMDGPUInstPrinter::printInterpSlot(
const MCInst *MI,
unsigned OpNum,
891 O <<
"invalid_param_" << Imm;
895 void AMDGPUInstPrinter::printInterpAttr(
const MCInst *MI,
unsigned OpNum,
902 void AMDGPUInstPrinter::printInterpAttrChan(
const MCInst *MI,
unsigned OpNum,
906 O <<
'.' <<
"xyzw"[Chan & 0x3];
909 void AMDGPUInstPrinter::printVGPRIndexMode(
const MCInst *MI,
unsigned OpNo,
931 void AMDGPUInstPrinter::printMemOperand(
const MCInst *MI,
unsigned OpNo,
939 void AMDGPUInstPrinter::printIfSet(
const MCInst *MI,
unsigned OpNo,
951 void AMDGPUInstPrinter::printIfSet(
const MCInst *MI,
unsigned OpNo,
959 void AMDGPUInstPrinter::printAbs(
const MCInst *MI,
unsigned OpNo,
961 printIfSet(MI, OpNo, O,
'|');
964 void AMDGPUInstPrinter::printClamp(
const MCInst *MI,
unsigned OpNo,
966 printIfSet(MI, OpNo, O,
"_SAT");
969 void AMDGPUInstPrinter::printClampSI(
const MCInst *MI,
unsigned OpNo,
976 void AMDGPUInstPrinter::printOModSI(
const MCInst *MI,
unsigned OpNo,
988 void AMDGPUInstPrinter::printLiteral(
const MCInst *MI,
unsigned OpNo,
994 int64_t Imm = Op.
getImm();
1002 void AMDGPUInstPrinter::printLast(
const MCInst *MI,
unsigned OpNo,
1004 printIfSet(MI, OpNo, O,
"*",
" ");
1007 void AMDGPUInstPrinter::printNeg(
const MCInst *MI,
unsigned OpNo,
1009 printIfSet(MI, OpNo, O,
'-');
1012 void AMDGPUInstPrinter::printOMOD(
const MCInst *MI,
unsigned OpNo,
1028 void AMDGPUInstPrinter::printRel(
const MCInst *MI,
unsigned OpNo,
1030 printIfSet(MI, OpNo, O,
'+');
1033 void AMDGPUInstPrinter::printUpdateExecMask(
const MCInst *MI,
unsigned OpNo,
1036 printIfSet(MI, OpNo, O,
"ExecMask,");
1039 void AMDGPUInstPrinter::printUpdatePred(
const MCInst *MI,
unsigned OpNo,
1042 printIfSet(MI, OpNo, O,
"Pred,");
1045 void AMDGPUInstPrinter::printWrite(
const MCInst *MI,
unsigned OpNo,
1053 void AMDGPUInstPrinter::printSel(
const MCInst *MI,
unsigned OpNo,
1055 const char * chans =
"XYZW";
1065 O << cb <<
'[' << sel <<
']';
1066 }
else if (sel >= 448) {
1069 }
else if (sel >= 0){
1074 O <<
'.' << chans[chan];
1077 void AMDGPUInstPrinter::printBankSwizzle(
const MCInst *MI,
unsigned OpNo,
1081 switch (BankSwizzle) {
1083 O <<
"BS:VEC_021/SCL_122";
1086 O <<
"BS:VEC_120/SCL_212";
1089 O <<
"BS:VEC_102/SCL_221";
1102 void AMDGPUInstPrinter::printRSel(
const MCInst *MI,
unsigned OpNo,
1132 void AMDGPUInstPrinter::printCT(
const MCInst *MI,
unsigned OpNo,
1147 void AMDGPUInstPrinter::printKCache(
const MCInst *MI,
unsigned OpNo,
1150 if (KCacheMode > 0) {
1152 O <<
"CB" << KCacheBank <<
':';
1154 int LineSize = (KCacheMode == 1) ? 16 : 32;
1155 O << KCacheAddr * 16 <<
'-' << KCacheAddr * 16 + LineSize;
1159 void AMDGPUInstPrinter::printSendMsg(
const MCInst *MI,
unsigned OpNo,
1162 using namespace llvm::AMDGPU::SendMsg;
1201 const uint16_t OrMask,
1202 const uint16_t XorMask,
1206 uint16_t Probe0 = ((0 & AndMask) | OrMask) ^ XorMask;
1207 uint16_t Probe1 = ((
BITMASK_MASK & AndMask) | OrMask) ^ XorMask;
1212 uint16_t p0 = Probe0 &
Mask;
1213 uint16_t p1 = Probe1 &
Mask;
1233 void AMDGPUInstPrinter::printSwizzle(
const MCInst *MI,
unsigned OpNo,
1248 for (
auto i = 0; i <
LANE_NUM; ++i) {
1265 O <<
"swizzle(" << IdSymbolic[
ID_SWAP];
1267 O << formatDec(XorMask);
1271 OrMask == 0 && XorMask > 0 &&
1276 O << formatDec(XorMask + 1);
1282 if (GroupSize > 1 &&
1284 OrMask < GroupSize &&
1289 O << formatDec(GroupSize);
1291 O << formatDec(OrMask);
1302 printU16ImmDecOperand(MI, OpNo, O);
1306 void AMDGPUInstPrinter::printWaitFlag(
const MCInst *MI,
unsigned OpNo,
1313 unsigned Vmcnt, Expcnt, Lgkmcnt;
1316 bool NeedSpace =
false;
1319 O <<
"vmcnt(" << Vmcnt <<
')';
1326 O <<
"expcnt(" << Expcnt <<
')';
1333 O <<
"lgkmcnt(" << Lgkmcnt <<
')';
1337 void AMDGPUInstPrinter::printHwreg(
const MCInst *MI,
unsigned OpNo,
1339 using namespace llvm::AMDGPU::Hwreg;
1348 O << IdSymbolic[
Id];
1353 O <<
", " <<
Offset <<
", " << Width;
1358 #include "AMDGPUGenAsmWriter.inc"
constexpr bool isUInt< 32 >(uint64_t x)
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
float BitsToFloat(uint32_t Bits)
This function takes a 32-bit integer and returns the bit equivalent float.
static std::vector< std::pair< int, unsigned > > Swizzle(std::vector< std::pair< int, unsigned >> Src, R600InstrInfo::BankSwizzle Swz)
constexpr bool isInt< 16 >(int64_t x)
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
static void printRegOperand(unsigned RegNo, raw_ostream &O, const MCRegisterInfo &MRI)
static void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod, raw_ostream &O)
Base class for the full range of assembler expressions which are needed for parsing.
const char *const IdSymbolic[]
uint8_t OperandType
Information about the type of the operand.
static std::string getRegisterName(const TargetRegisterInfo *TRI, unsigned Reg)
unsigned getReg() const
Returns the register number.
Instances of this class represent a single low-level machine instruction.
uint32_t FloatToBits(float Float)
This function takes a float and returns the bit equivalent 32-bit integer.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
const MCExpr * getExpr() const
unsigned const MachineRegisterInfo * MRI
void decodeWaitcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt)
Decodes Vmcnt, Expcnt and Lgkmcnt from given Waitcnt for given isa Version, and writes decoded values...
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
const char *const IdSymbolic[]
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Instruction set architecture version.
Operands with register or inline constant.
unsigned getLgkmcntBitMask(const IsaInfo::IsaVersion &Version)
unsigned countPopulation(T Value)
Count the number of set bits in a value.
bool contains(unsigned Reg) const
contains - Return true if the specified register is included in this register class.
static bool allOpsDefaultValue(const int *Ops, int NumOps, int Mod)
unsigned getExpcntBitMask(const IsaInfo::IsaVersion &Version)
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
uint64_t DoubleToBits(double Double)
This function takes a double and returns the bit equivalent 64-bit integer.
unsigned getOpcode() const
const char *const OpSysSymbolic[]
llvm_unreachable("Unknown RegBank!")
const char *const OpGsSymbolic[]
Provides AMDGPU specific target descriptions.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
unsigned getNumOperands() const
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
static void printSwizzleBitmask(const uint16_t AndMask, const uint16_t OrMask, const uint16_t XorMask, raw_ostream &O)
MCSubtargetInfo - Generic base class for all target subtargets.
unsigned getVmcntBitMask(const IsaInfo::IsaVersion &Version)
constexpr bool isUInt< 16 >(uint64_t x)
Operands with register or 32-bit immediate.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
const MCOperandInfo * OpInfo
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Instances of this class represent operands of the MCInst class.
IsaVersion getIsaVersion(const FeatureBitset &Features)
const MCOperand & getOperand(unsigned i) const