50void AMDGPUInstPrinter::printU16ImmOperand(
const MCInst *
MI,
unsigned OpNo,
61 int64_t Imm =
Op.getImm();
62 if (isInt<16>(Imm) || isUInt<16>(Imm))
63 O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
65 printU32ImmOperand(
MI, OpNo, STI, O);
68void AMDGPUInstPrinter::printU16ImmDecOperand(
const MCInst *
MI,
unsigned OpNo,
73void AMDGPUInstPrinter::printU32ImmOperand(
const MCInst *
MI,
unsigned OpNo,
76 O <<
formatHex(
MI->getOperand(OpNo).getImm() & 0xffffffff);
79void AMDGPUInstPrinter::printNamedBit(
const MCInst *
MI,
unsigned OpNo,
81 if (
MI->getOperand(OpNo).getImm()) {
86void AMDGPUInstPrinter::printOffset(
const MCInst *
MI,
unsigned OpNo,
99 printU16ImmDecOperand(
MI, OpNo, O);
103void AMDGPUInstPrinter::printFlatOffset(
const MCInst *
MI,
unsigned OpNo,
118 printU16ImmDecOperand(
MI, OpNo, O);
122void AMDGPUInstPrinter::printSMRDOffset8(
const MCInst *
MI,
unsigned OpNo,
125 printU32ImmOperand(
MI, OpNo, STI, O);
128void AMDGPUInstPrinter::printSMEMOffset(
const MCInst *
MI,
unsigned OpNo,
134void AMDGPUInstPrinter::printSMRDLiteralOffset(
const MCInst *
MI,
unsigned OpNo,
137 printU32ImmOperand(
MI, OpNo, STI, O);
140void AMDGPUInstPrinter::printCPol(
const MCInst *
MI,
unsigned OpNo,
142 auto Imm =
MI->getOperand(OpNo).getImm();
148 printTH(
MI, TH, Scope, O);
149 printScope(Scope, O);
165 O <<
" /* unexpected cache policy bit */";
168void AMDGPUInstPrinter::printTH(
const MCInst *
MI, int64_t TH, int64_t Scope,
174 const unsigned Opcode =
MI->getOpcode();
202 O << (IsStore ?
"TH_STORE_" :
"TH_LOAD_");
212 : (IsStore ?
"RT_WB" :
"LU"));
233void AMDGPUInstPrinter::printScope(int64_t Scope,
raw_ostream &O) {
251void AMDGPUInstPrinter::printDim(
const MCInst *
MI,
unsigned OpNo,
253 unsigned Dim =
MI->getOperand(OpNo).getImm();
254 O <<
" dim:SQ_RSRC_IMG_";
263void AMDGPUInstPrinter::printR128A16(
const MCInst *
MI,
unsigned OpNo,
266 printNamedBit(
MI, OpNo, O,
"a16");
268 printNamedBit(
MI, OpNo, O,
"r128");
271void AMDGPUInstPrinter::printFORMAT(
const MCInst *
MI,
unsigned OpNo,
276void AMDGPUInstPrinter::printSymbolicFormat(
const MCInst *
MI,
285 unsigned Val =
MI->getOperand(OpNo).getImm();
287 if (Val == UFMT_DEFAULT)
292 O <<
" format:" << Val;
295 if (Val == DFMT_NFMT_DEFAULT)
302 if (Dfmt != DFMT_DEFAULT) {
304 if (Nfmt != NFMT_DEFAULT) {
308 if (Nfmt != NFMT_DEFAULT) {
313 O <<
" format:" << Val;
324 case AMDGPU::PRIVATE_RSRC_REG:
334void AMDGPUInstPrinter::printVOPDst(
const MCInst *
MI,
unsigned OpNo,
336 auto Opcode =
MI->getOpcode();
354 printRegularOperand(
MI, OpNo, STI, O);
360 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
361 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
362 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
363 case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
364 case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
365 case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
366 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx10:
367 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx10:
368 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx10:
369 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx10:
370 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx10:
371 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx10:
372 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx11:
373 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx11:
374 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx11:
375 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx11:
376 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx11:
377 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx11:
378 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx11:
379 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx11:
380 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx11:
381 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx12:
382 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx12:
383 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx12:
384 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx12:
385 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx12:
386 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx12:
387 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx12:
388 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx12:
389 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx12:
390 printDefaultVccOperand(
false, STI, O);
395void AMDGPUInstPrinter::printVINTRPDst(
const MCInst *
MI,
unsigned OpNo,
402 printRegularOperand(
MI, OpNo, STI, O);
405void AMDGPUInstPrinter::printImmediateInt16(
uint32_t Imm,
408 int32_t SImm =
static_cast<int32_t
>(
Imm);
414 if (printImmediateFloat32(Imm, STI, O))
417 O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
424 else if (Imm == 0xBC00)
426 else if (Imm == 0x3800)
428 else if (Imm == 0xB800)
430 else if (Imm == 0x4000)
432 else if (Imm == 0xC000)
434 else if (Imm == 0x4400)
436 else if (Imm == 0xC400)
438 else if (Imm == 0x3118 && STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
450 else if (Imm == 0xBF80)
452 else if (Imm == 0x3F00)
454 else if (Imm == 0xBF00)
456 else if (Imm == 0x4000)
458 else if (Imm == 0xC000)
460 else if (Imm == 0x4080)
462 else if (Imm == 0xC080)
464 else if (Imm == 0x3E22 && STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
472void AMDGPUInstPrinter::printImmediateBF16(
uint32_t Imm,
475 int16_t SImm =
static_cast<int16_t
>(
Imm);
484 O << formatHex(static_cast<uint64_t>(Imm));
487void AMDGPUInstPrinter::printImmediateF16(
uint32_t Imm,
490 int16_t SImm =
static_cast<int16_t
>(
Imm);
504void AMDGPUInstPrinter::printImmediateV216(
uint32_t Imm, uint8_t OpType,
507 int32_t SImm =
static_cast<int32_t
>(
Imm);
517 if (printImmediateFloat32(Imm, STI, O))
523 if (isUInt<16>(Imm) &&
530 if (isUInt<16>(Imm) &&
538 O << formatHex(static_cast<uint64_t>(Imm));
541bool AMDGPUInstPrinter::printImmediateFloat32(
uint32_t Imm,
544 if (Imm == llvm::bit_cast<uint32_t>(0.0f))
546 else if (Imm == llvm::bit_cast<uint32_t>(1.0f))
548 else if (Imm == llvm::bit_cast<uint32_t>(-1.0f))
550 else if (Imm == llvm::bit_cast<uint32_t>(0.5f))
552 else if (Imm == llvm::bit_cast<uint32_t>(-0.5f))
554 else if (Imm == llvm::bit_cast<uint32_t>(2.0f))
556 else if (Imm == llvm::bit_cast<uint32_t>(-2.0f))
558 else if (Imm == llvm::bit_cast<uint32_t>(4.0f))
560 else if (Imm == llvm::bit_cast<uint32_t>(-4.0f))
562 else if (Imm == 0x3e22f983 &&
563 STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
571void AMDGPUInstPrinter::printImmediate32(
uint32_t Imm,
574 int32_t SImm =
static_cast<int32_t
>(
Imm);
580 if (printImmediateFloat32(Imm, STI, O))
583 O << formatHex(static_cast<uint64_t>(Imm));
586void AMDGPUInstPrinter::printImmediate64(
uint64_t Imm,
589 int64_t SImm =
static_cast<int64_t
>(
Imm);
590 if (SImm >= -16 && SImm <= 64) {
595 if (Imm == llvm::bit_cast<uint64_t>(0.0))
597 else if (Imm == llvm::bit_cast<uint64_t>(1.0))
599 else if (Imm == llvm::bit_cast<uint64_t>(-1.0))
601 else if (Imm == llvm::bit_cast<uint64_t>(0.5))
603 else if (Imm == llvm::bit_cast<uint64_t>(-0.5))
605 else if (Imm == llvm::bit_cast<uint64_t>(2.0))
607 else if (Imm == llvm::bit_cast<uint64_t>(-2.0))
609 else if (Imm == llvm::bit_cast<uint64_t>(4.0))
611 else if (Imm == llvm::bit_cast<uint64_t>(-4.0))
613 else if (Imm == 0x3fc45f306dc9c882 &&
614 STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
615 O <<
"0.15915494309189532";
618 O << formatHex(static_cast<uint64_t>(
Hi_32(Imm)));
620 assert(isUInt<32>(Imm) || isInt<32>(Imm));
624 O << formatHex(static_cast<uint64_t>(Imm));
628void AMDGPUInstPrinter::printBLGP(
const MCInst *
MI,
unsigned OpNo,
631 unsigned Imm =
MI->getOperand(OpNo).getImm();
636 switch (
MI->getOpcode()) {
637 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_acd:
638 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_vcd:
639 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_acd:
640 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_vcd:
641 O <<
" neg:[" << (
Imm & 1) <<
',' << ((Imm >> 1) & 1) <<
','
642 << ((Imm >> 2) & 1) <<
']';
647 O <<
" blgp:" <<
Imm;
650void AMDGPUInstPrinter::printDefaultVccOperand(
bool FirstOperand,
664 unsigned OpNo)
const {
668 (
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
669 Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO));
673void AMDGPUInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
676 unsigned Opc =
MI->getOpcode();
685 (
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
686 Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO)))
687 printDefaultVccOperand(
true, STI, O);
689 printRegularOperand(
MI, OpNo, STI, O);
693void AMDGPUInstPrinter::printRegularOperand(
const MCInst *
MI,
unsigned OpNo,
698 if (OpNo >=
MI->getNumOperands()) {
699 O <<
"/*Missing OP" << OpNo <<
"*/";
710 int RCID =
Desc.operands()[OpNo].RegClass;
716 <<
"\' register class*/";
719 }
else if (
Op.isImm()) {
720 const uint8_t OpTy =
Desc.operands()[OpNo].OperandType;
735 printImmediate32(
Op.getImm(), STI, O);
739 printImmediate64(
Op.getImm(), STI, O,
false);
744 printImmediate64(
Op.getImm(), STI, O,
true);
749 printImmediateInt16(
Op.getImm(), STI, O);
755 printImmediateF16(
Op.getImm(), STI, O);
761 printImmediateBF16(
Op.getImm(), STI, O);
772 printImmediateV216(
Op.getImm(), OpTy, STI, O);
781 printImmediate32(
Op.getImm(), STI, O);
782 O <<
"/*Invalid immediate*/";
789 }
else if (
Op.isDFPImm()) {
790 double Value = bit_cast<double>(
Op.getDFPImm());
796 int RCID =
Desc.operands()[OpNo].RegClass;
799 printImmediate32(llvm::bit_cast<uint32_t>((
float)
Value), STI, O);
800 else if (RCBits == 64)
801 printImmediate64(llvm::bit_cast<uint64_t>(
Value), STI, O,
true);
805 }
else if (
Op.isExpr()) {
813 switch (
MI->getOpcode()) {
816 case AMDGPU::V_CNDMASK_B32_e32_gfx10:
817 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
818 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
819 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
820 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx10:
821 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx10:
822 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx10:
823 case AMDGPU::V_CNDMASK_B32_dpp8_gfx10:
824 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx10:
825 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx10:
826 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx10:
827 case AMDGPU::V_CNDMASK_B32_e32_gfx11:
828 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx11:
829 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx11:
830 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx11:
831 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx11:
832 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx11:
833 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx11:
834 case AMDGPU::V_CNDMASK_B32_dpp8_gfx11:
835 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx11:
836 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx11:
837 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx11:
838 case AMDGPU::V_CNDMASK_B32_e32_gfx12:
839 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx12:
840 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx12:
841 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx12:
842 case AMDGPU::V_CNDMASK_B32_dpp_gfx12:
843 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx12:
844 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx12:
845 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx12:
846 case AMDGPU::V_CNDMASK_B32_dpp8_gfx12:
847 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx12:
848 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx12:
849 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx12:
851 case AMDGPU::V_CNDMASK_B32_e32_gfx6_gfx7:
852 case AMDGPU::V_CNDMASK_B32_e32_vi:
854 AMDGPU::OpName::src1))
855 printDefaultVccOperand(OpNo == 0, STI, O);
863 if ((
int)OpNo == SOffsetIdx)
864 printSymbolicFormat(
MI, STI, O);
868void AMDGPUInstPrinter::printOperandAndFPInputMods(
const MCInst *
MI,
873 if (needsImpliedVcc(
Desc, OpNo))
874 printDefaultVccOperand(
true, STI, O);
876 unsigned InputModifiers =
MI->getOperand(OpNo).getImm();
881 bool NegMnemo =
false;
884 if (OpNo + 1 <
MI->getNumOperands() &&
887 NegMnemo =
Op.isImm() ||
Op.isDFPImm();
898 printRegularOperand(
MI, OpNo + 1, STI, O);
907 switch (
MI->getOpcode()) {
911 case AMDGPU::V_CNDMASK_B32_sdwa_gfx10:
912 case AMDGPU::V_CNDMASK_B32_dpp_gfx10:
913 case AMDGPU::V_CNDMASK_B32_dpp_gfx11:
916 printDefaultVccOperand(OpNo == 0, STI, O);
921void AMDGPUInstPrinter::printOperandAndIntInputMods(
const MCInst *
MI,
926 if (needsImpliedVcc(
Desc, OpNo))
927 printDefaultVccOperand(
true, STI, O);
929 unsigned InputModifiers =
MI->getOperand(OpNo).getImm();
932 printRegularOperand(
MI, OpNo + 1, STI, O);
937 switch (
MI->getOpcode()) {
940 case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
941 case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
942 case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
944 AMDGPU::OpName::src1))
945 printDefaultVccOperand(OpNo == 0, STI, O);
950void AMDGPUInstPrinter::printDPP8(
const MCInst *
MI,
unsigned OpNo,
956 unsigned Imm =
MI->getOperand(OpNo).getImm();
958 for (
size_t i = 1; i < 8; ++i) {
959 O <<
',' <<
formatDec((Imm >> (3 * i)) & 0x7);
964void AMDGPUInstPrinter::printDPPCtrl(
const MCInst *
MI,
unsigned OpNo,
967 using namespace AMDGPU::DPP;
969 unsigned Imm =
MI->getOperand(OpNo).getImm();
973 O <<
" /* DP ALU dpp only supports row_newbcast */";
976 if (Imm <= DppCtrl::QUAD_PERM_LAST) {
982 }
else if ((Imm >= DppCtrl::ROW_SHL_FIRST) &&
983 (Imm <= DppCtrl::ROW_SHL_LAST)) {
984 O <<
"row_shl:" <<
formatDec(Imm - DppCtrl::ROW_SHL0);
985 }
else if ((Imm >= DppCtrl::ROW_SHR_FIRST) &&
986 (Imm <= DppCtrl::ROW_SHR_LAST)) {
987 O <<
"row_shr:" <<
formatDec(Imm - DppCtrl::ROW_SHR0);
988 }
else if ((Imm >= DppCtrl::ROW_ROR_FIRST) &&
989 (Imm <= DppCtrl::ROW_ROR_LAST)) {
990 O <<
"row_ror:" <<
formatDec(Imm - DppCtrl::ROW_ROR0);
991 }
else if (Imm == DppCtrl::WAVE_SHL1) {
993 O <<
"/* wave_shl is not supported starting from GFX10 */";
997 }
else if (Imm == DppCtrl::WAVE_ROL1) {
999 O <<
"/* wave_rol is not supported starting from GFX10 */";
1003 }
else if (Imm == DppCtrl::WAVE_SHR1) {
1005 O <<
"/* wave_shr is not supported starting from GFX10 */";
1009 }
else if (Imm == DppCtrl::WAVE_ROR1) {
1011 O <<
"/* wave_ror is not supported starting from GFX10 */";
1015 }
else if (Imm == DppCtrl::ROW_MIRROR) {
1017 }
else if (Imm == DppCtrl::ROW_HALF_MIRROR) {
1018 O <<
"row_half_mirror";
1019 }
else if (Imm == DppCtrl::BCAST15) {
1021 O <<
"/* row_bcast is not supported starting from GFX10 */";
1024 O <<
"row_bcast:15";
1025 }
else if (Imm == DppCtrl::BCAST31) {
1027 O <<
"/* row_bcast is not supported starting from GFX10 */";
1030 O <<
"row_bcast:31";
1031 }
else if ((Imm >= DppCtrl::ROW_SHARE_FIRST) &&
1032 (Imm <= DppCtrl::ROW_SHARE_LAST)) {
1034 O <<
"row_newbcast:";
1038 O <<
" /* row_newbcast/row_share is not supported on ASICs earlier "
1039 "than GFX90A/GFX10 */";
1042 O <<
formatDec(Imm - DppCtrl::ROW_SHARE_FIRST);
1043 }
else if ((Imm >= DppCtrl::ROW_XMASK_FIRST) &&
1044 (Imm <= DppCtrl::ROW_XMASK_LAST)) {
1046 O <<
"/* row_xmask is not supported on ASICs earlier than GFX10 */";
1049 O <<
"row_xmask:" <<
formatDec(Imm - DppCtrl::ROW_XMASK_FIRST);
1051 O <<
"/* Invalid dpp_ctrl value */";
1055void AMDGPUInstPrinter::printDppBoundCtrl(
const MCInst *
MI,
unsigned OpNo,
1058 unsigned Imm =
MI->getOperand(OpNo).getImm();
1060 O <<
" bound_ctrl:1";
1064void AMDGPUInstPrinter::printDppFI(
const MCInst *
MI,
unsigned OpNo,
1067 unsigned Imm =
MI->getOperand(OpNo).getImm();
1068 if (Imm == DPP_FI_1 || Imm == DPP8_FI_1) {
1073void AMDGPUInstPrinter::printSDWASel(
const MCInst *
MI,
unsigned OpNo,
1077 unsigned Imm =
MI->getOperand(OpNo).getImm();
1079 case SdwaSel::BYTE_0:
O <<
"BYTE_0";
break;
1080 case SdwaSel::BYTE_1:
O <<
"BYTE_1";
break;
1081 case SdwaSel::BYTE_2:
O <<
"BYTE_2";
break;
1082 case SdwaSel::BYTE_3:
O <<
"BYTE_3";
break;
1083 case SdwaSel::WORD_0:
O <<
"WORD_0";
break;
1084 case SdwaSel::WORD_1:
O <<
"WORD_1";
break;
1085 case SdwaSel::DWORD:
O <<
"DWORD";
break;
1090void AMDGPUInstPrinter::printSDWADstSel(
const MCInst *
MI,
unsigned OpNo,
1094 printSDWASel(
MI, OpNo, O);
1097void AMDGPUInstPrinter::printSDWASrc0Sel(
const MCInst *
MI,
unsigned OpNo,
1101 printSDWASel(
MI, OpNo, O);
1104void AMDGPUInstPrinter::printSDWASrc1Sel(
const MCInst *
MI,
unsigned OpNo,
1108 printSDWASel(
MI, OpNo, O);
1111void AMDGPUInstPrinter::printSDWADstUnused(
const MCInst *
MI,
unsigned OpNo,
1117 unsigned Imm =
MI->getOperand(OpNo).getImm();
1119 case DstUnused::UNUSED_PAD:
O <<
"UNUSED_PAD";
break;
1120 case DstUnused::UNUSED_SEXT:
O <<
"UNUSED_SEXT";
break;
1121 case DstUnused::UNUSED_PRESERVE:
O <<
"UNUSED_PRESERVE";
break;
1126void AMDGPUInstPrinter::printExpSrcN(
const MCInst *
MI,
unsigned OpNo,
1129 unsigned Opc =
MI->getOpcode();
1131 unsigned En =
MI->getOperand(EnIdx).getImm();
1136 if (
MI->getOperand(ComprIdx).getImm())
1137 OpNo = OpNo -
N +
N / 2;
1145void AMDGPUInstPrinter::printExpSrc0(
const MCInst *
MI,
unsigned OpNo,
1148 printExpSrcN(
MI, OpNo, STI, O, 0);
1151void AMDGPUInstPrinter::printExpSrc1(
const MCInst *
MI,
unsigned OpNo,
1154 printExpSrcN(
MI, OpNo, STI, O, 1);
1157void AMDGPUInstPrinter::printExpSrc2(
const MCInst *
MI,
unsigned OpNo,
1160 printExpSrcN(
MI, OpNo, STI, O, 2);
1163void AMDGPUInstPrinter::printExpSrc3(
const MCInst *
MI,
unsigned OpNo,
1166 printExpSrcN(
MI, OpNo, STI, O, 3);
1169void AMDGPUInstPrinter::printExpTgt(
const MCInst *
MI,
unsigned OpNo,
1175 unsigned Id =
MI->getOperand(OpNo).getImm() & ((1 << 6) - 1);
1180 O <<
' ' << TgtName;
1184 O <<
" invalid_target_" <<
Id;
1189 bool IsPacked,
bool HasDstSel) {
1192 for (
int I = 0;
I < NumOps; ++
I) {
1193 if (!!(Ops[
I] &
Mod) != DefaultValue)
1203void AMDGPUInstPrinter::printPackedModifier(
const MCInst *
MI,
1207 unsigned Opc =
MI->getOpcode();
1211 std::pair<int, int> MOps[] = {
1212 {AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src0},
1213 {AMDGPU::OpName::src1_modifiers, AMDGPU::OpName::src1},
1214 {AMDGPU::OpName::src2_modifiers, AMDGPU::OpName::src2}};
1217 for (
auto [SrcMod, Src] : MOps) {
1223 (ModIdx != -1) ?
MI->getOperand(ModIdx).getImm() : DefaultValue;
1233 {AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src1_modifiers,
1234 AMDGPU::OpName::src2_modifiers}) {
1237 Ops[NumOps++] =
MI->getOperand(
Idx).getImm();
1239 Ops[NumOps++] = DefaultValue;
1243 const bool HasDstSel =
1255 for (
int I = 0;
I < NumOps; ++
I) {
1259 O << !!(Ops[
I] &
Mod);
1269void AMDGPUInstPrinter::printOpSel(
const MCInst *
MI,
unsigned,
1272 unsigned Opc =
MI->getOpcode();
1276 unsigned Mod =
MI->getOperand(SrcMod).getImm();
1279 if (Index0 || Index1)
1280 O <<
" op_sel:[" << Index0 <<
',' << Index1 <<
']';
1289 O <<
" op_sel:[" << FI <<
',' << BC <<
']';
1296void AMDGPUInstPrinter::printOpSelHi(
const MCInst *
MI,
unsigned OpNo,
1302void AMDGPUInstPrinter::printNegLo(
const MCInst *
MI,
unsigned OpNo,
1308void AMDGPUInstPrinter::printNegHi(
const MCInst *
MI,
unsigned OpNo,
1314void AMDGPUInstPrinter::printIndexKey8bit(
const MCInst *
MI,
unsigned OpNo,
1317 auto Imm =
MI->getOperand(OpNo).getImm() & 0x7;
1321 O <<
" index_key:" <<
Imm;
1324void AMDGPUInstPrinter::printIndexKey16bit(
const MCInst *
MI,
unsigned OpNo,
1327 auto Imm =
MI->getOperand(OpNo).getImm() & 0x7;
1331 O <<
" index_key:" <<
Imm;
1334void AMDGPUInstPrinter::printInterpSlot(
const MCInst *
MI,
unsigned OpNum,
1337 unsigned Imm =
MI->getOperand(OpNum).getImm();
1349 O <<
"invalid_param_" <<
Imm;
1353void AMDGPUInstPrinter::printInterpAttr(
const MCInst *
MI,
unsigned OpNum,
1356 unsigned Attr =
MI->getOperand(OpNum).getImm();
1357 O <<
"attr" << Attr;
1360void AMDGPUInstPrinter::printInterpAttrChan(
const MCInst *
MI,
unsigned OpNum,
1363 unsigned Chan =
MI->getOperand(OpNum).getImm();
1364 O <<
'.' <<
"xyzw"[Chan & 0x3];
1367void AMDGPUInstPrinter::printGPRIdxMode(
const MCInst *
MI,
unsigned OpNo,
1371 unsigned Val =
MI->getOperand(OpNo).getImm();
1373 if ((Val & ~ENABLE_MASK) != 0) {
1374 O << formatHex(static_cast<uint64_t>(Val));
1377 bool NeedComma =
false;
1378 for (
unsigned ModeId = ID_MIN; ModeId <=
ID_MAX; ++ModeId) {
1379 if (Val & (1 << ModeId)) {
1390void AMDGPUInstPrinter::printMemOperand(
const MCInst *
MI,
unsigned OpNo,
1393 printRegularOperand(
MI, OpNo, STI, O);
1395 printRegularOperand(
MI, OpNo + 1, STI, O);
1403 if (
Op.getImm() == 1) {
1414 if (
Op.getImm() == 1)
1421 int Imm =
MI->getOperand(OpNo).getImm();
1435 const unsigned Imm16 =
MI->getOperand(OpNo).getImm();
1440 decodeMsg(Imm16, MsgId, OpId,
StreamId, STI);
1442 StringRef MsgName = getMsgName(MsgId, STI);
1444 if (!MsgName.
empty() && isValidMsgOp(MsgId, OpId, STI) &&
1445 isValidMsgStream(MsgId, OpId,
StreamId, STI)) {
1446 O <<
"sendmsg(" << MsgName;
1447 if (msgRequiresOp(MsgId, STI)) {
1448 O <<
", " << getMsgOpName(MsgId, OpId, STI);
1449 if (msgSupportsStream(MsgId, OpId, STI)) {
1454 }
else if (encodeMsg(MsgId, OpId,
StreamId) == Imm16) {
1455 O <<
"sendmsg(" << MsgId <<
", " << OpId <<
", " <<
StreamId <<
')';
1467 uint16_t Probe0 = ((0 & AndMask) | OrMask) ^ XorMask;
1468 uint16_t Probe1 = ((BITMASK_MASK & AndMask) | OrMask) ^ XorMask;
1472 for (
unsigned Mask = 1 << (BITMASK_WIDTH - 1); Mask > 0; Mask >>= 1) {
1499 uint16_t Imm =
MI->getOperand(OpNo).getImm();
1506 if ((Imm & QUAD_PERM_ENC_MASK) == QUAD_PERM_ENC) {
1508 O <<
"swizzle(" << IdSymbolic[ID_QUAD_PERM];
1509 for (
unsigned I = 0;
I < LANE_NUM; ++
I) {
1516 }
else if ((Imm & BITMASK_PERM_ENC_MASK) == BITMASK_PERM_ENC) {
1518 uint16_t AndMask = (Imm >> BITMASK_AND_SHIFT) & BITMASK_MASK;
1519 uint16_t OrMask = (Imm >> BITMASK_OR_SHIFT) & BITMASK_MASK;
1520 uint16_t XorMask = (Imm >> BITMASK_XOR_SHIFT) & BITMASK_MASK;
1522 if (AndMask == BITMASK_MAX && OrMask == 0 &&
llvm::popcount(XorMask) == 1) {
1524 O <<
"swizzle(" << IdSymbolic[ID_SWAP];
1529 }
else if (AndMask == BITMASK_MAX && OrMask == 0 && XorMask > 0 &&
1532 O <<
"swizzle(" << IdSymbolic[ID_REVERSE];
1539 uint16_t GroupSize = BITMASK_MAX - AndMask + 1;
1540 if (GroupSize > 1 &&
1542 OrMask < GroupSize &&
1545 O <<
"swizzle(" << IdSymbolic[ID_BROADCAST];
1553 O <<
"swizzle(" << IdSymbolic[ID_BITMASK_PERM];
1560 printU16ImmDecOperand(
MI, OpNo, O);
1569 unsigned SImm16 =
MI->getOperand(OpNo).getImm();
1570 unsigned Vmcnt, Expcnt, Lgkmcnt;
1576 bool PrintAll = IsDefaultVmcnt && IsDefaultExpcnt && IsDefaultLgkmcnt;
1578 bool NeedSpace =
false;
1580 if (!IsDefaultVmcnt || PrintAll) {
1581 O <<
"vmcnt(" << Vmcnt <<
')';
1585 if (!IsDefaultExpcnt || PrintAll) {
1588 O <<
"expcnt(" << Expcnt <<
')';
1592 if (!IsDefaultLgkmcnt || PrintAll) {
1595 O <<
"lgkmcnt(" << Lgkmcnt <<
')';
1604 uint64_t Imm16 =
MI->getOperand(OpNo).getImm() & 0xffff;
1606 bool HasNonDefaultVal =
false;
1607 if (isSymbolicDepCtrEncoding(Imm16, HasNonDefaultVal, STI)) {
1612 bool NeedSpace =
false;
1613 while (decodeDepCtr(Imm16,
Id,
Name, Val, IsDefault, STI)) {
1614 if (!IsDefault || !HasNonDefaultVal) {
1617 O <<
Name <<
'(' << Val <<
')';
1629 const char *BadInstId =
"/* invalid instid value */";
1630 static const std::array<const char *, 12> InstIds = {
1631 "NO_DEP",
"VALU_DEP_1",
"VALU_DEP_2",
1632 "VALU_DEP_3",
"VALU_DEP_4",
"TRANS32_DEP_1",
1633 "TRANS32_DEP_2",
"TRANS32_DEP_3",
"FMA_ACCUM_CYCLE_1",
1634 "SALU_CYCLE_1",
"SALU_CYCLE_2",
"SALU_CYCLE_3"};
1636 const char *BadInstSkip =
"/* invalid instskip value */";
1637 static const std::array<const char *, 6> InstSkips = {
1638 "SAME",
"NEXT",
"SKIP_1",
"SKIP_2",
"SKIP_3",
"SKIP_4"};
1640 unsigned SImm16 =
MI->getOperand(OpNo).getImm();
1641 const char *Prefix =
"";
1643 unsigned Value = SImm16 & 0xF;
1645 const char *
Name =
Value < InstIds.size() ? InstIds[
Value] : BadInstId;
1646 O << Prefix <<
"instid0(" <<
Name <<
')';
1650 Value = (SImm16 >> 4) & 7;
1653 Value < InstSkips.size() ? InstSkips[
Value] : BadInstSkip;
1654 O << Prefix <<
"instskip(" <<
Name <<
')';
1658 Value = (SImm16 >> 7) & 0xF;
1660 const char *
Name =
Value < InstIds.size() ? InstIds[
Value] : BadInstId;
1661 O << Prefix <<
"instid1(" <<
Name <<
')';
1672 unsigned Val =
MI->getOperand(OpNo).getImm();
1673 auto [
Id,
Offset, Width] = HwregEncoding::decode(Val);
1677 if (!HwRegName.
empty()) {
1682 if (Width != HwregSize::Default ||
Offset != HwregOffset::Default)
1683 O <<
", " <<
Offset <<
", " << Width;
1690 uint16_t Imm =
MI->getOperand(OpNo).getImm();
1698void AMDGPUInstPrinter::printNamedInt(
const MCInst *
MI,
unsigned OpNo,
1701 bool PrintInHex,
bool AlwaysPrint) {
1702 int64_t V =
MI->getOperand(OpNo).getImm();
1703 if (AlwaysPrint || V != 0)
1707#include "AMDGPUGenAsmWriter.inc"
unsigned const MachineRegisterInfo * MRI
static void printSwizzleBitmask(const uint16_t AndMask, const uint16_t OrMask, const uint16_t XorMask, raw_ostream &O)
static bool printImmediateBFloat16(uint32_t Imm, const MCSubtargetInfo &STI, raw_ostream &O)
static bool allOpsDefaultValue(const int *Ops, int NumOps, int Mod, bool IsPacked, bool HasDstSel)
static bool printImmediateFP16(uint32_t Imm, const MCSubtargetInfo &STI, raw_ostream &O)
Provides AMDGPU specific target descriptions.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
static const char * getRegisterName(MCRegister Reg)
static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O, StringRef Asm, StringRef Default="")
void printDepCtr(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegName(raw_ostream &OS, MCRegister Reg) const override
Print the assembler register name.
static void printRegOperand(unsigned RegNo, raw_ostream &O, const MCRegisterInfo &MRI)
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printSWaitCnt(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printSDelayALU(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
This class represents an Operation in the Expression.
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
Base class for the full range of assembler expressions which are needed for parsing.
format_object< int64_t > formatHex(int64_t Value) const
format_object< int64_t > formatDec(int64_t Value) const
Utility functions to print decimal/hexadecimal values.
const MCRegisterInfo & MRI
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
bool mayStore() const
Return true if this instruction could possibly modify memory.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Instances of this class represent operands of the MCInst class.
MCRegisterClass - Base class of TargetRegisterClass.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
const char * getRegClassName(const MCRegisterClass *Class) const
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI)
bool getTgtName(unsigned Id, StringRef &Name, int &Index)
const char *const IdSymbolic[]
void decodeWaitcnt(const 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...
bool isVOPCAsmOnly(unsigned Opc)
LLVM_READNONE bool isLegalDPALU_DPPControl(unsigned DC)
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST)
For pre-GFX12 FLAT instructions the offset must be positive; MSB is ignored and forced to zero.
unsigned mc2PseudoReg(unsigned Reg)
Convert hardware register Reg to a pseudo register.
bool isGFX12Plus(const MCSubtargetInfo &STI)
bool isGFX940(const MCSubtargetInfo &STI)
IsaVersion getIsaVersion(StringRef GPU)
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
bool isDPALU_DPP(const MCInstrDesc &OpDesc)
bool isSI(const MCSubtargetInfo &STI)
bool getVOP3IsSingle(unsigned Opc)
bool getVOP1IsSingle(unsigned Opc)
bool isGFX90A(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
bool isGFX12(const MCSubtargetInfo &STI)
unsigned getVmcntBitMask(const IsaVersion &Version)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, uint64_t NamedIdx)
LLVM_READNONE bool isInlinableIntLiteral(int64_t Literal)
Is this literal inlinable, and not one of the values intended for floating point values.
unsigned getLgkmcntBitMask(const IsaVersion &Version)
unsigned getExpcntBitMask(const IsaVersion &Version)
bool isInlineValue(unsigned Reg)
bool isGFX10Plus(const MCSubtargetInfo &STI)
@ OPERAND_REG_INLINE_C_V2INT32
@ OPERAND_REG_INLINE_C_FP64
@ OPERAND_REG_INLINE_C_BF16
@ OPERAND_REG_INLINE_C_V2BF16
@ OPERAND_REG_IMM_V2INT16
@ OPERAND_REG_INLINE_AC_V2FP16
@ OPERAND_REG_IMM_INT32
Operands with register or 32-bit immediate.
@ OPERAND_REG_IMM_BF16_DEFERRED
@ OPERAND_REG_INLINE_C_INT64
@ OPERAND_REG_INLINE_AC_BF16
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
@ OPERAND_REG_INLINE_AC_INT16
Operands with an AccVGPR register or inline constant.
@ OPERAND_REG_INLINE_C_V2FP16
@ OPERAND_REG_INLINE_AC_V2INT16
@ OPERAND_REG_INLINE_AC_FP16
@ OPERAND_REG_INLINE_AC_INT32
@ OPERAND_REG_INLINE_AC_FP32
@ OPERAND_REG_INLINE_AC_V2BF16
@ OPERAND_REG_IMM_V2INT32
@ OPERAND_REG_INLINE_C_FP32
@ OPERAND_REG_INLINE_C_INT32
@ OPERAND_REG_INLINE_C_V2INT16
@ OPERAND_REG_INLINE_AC_FP64
@ OPERAND_REG_INLINE_C_FP16
@ OPERAND_REG_INLINE_C_V2FP32
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
@ OPERAND_REG_IMM_FP32_DEFERRED
@ OPERAND_REG_IMM_FP16_DEFERRED
bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc)
unsigned getRegBitWidth(const TargetRegisterClass &RC)
Get the size in bits of a register from the register class RC.
bool isCI(const MCSubtargetInfo &STI)
bool getVOP2IsSingle(unsigned Opc)
bool isPermlane16(unsigned Opc)
Reg
All possible values of the reg field in the ModR/M byte.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
This is an optimization pass for GlobalISel generic memory operations.
int popcount(T Value) noexcept
Count the number of set bits in a value.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
@ Mod
The access may modify the value stored in memory.
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
@ Default
The result values are uniform if and only if all operands are uniform.
Instruction set architecture version.
Description of the encoding of one expression Op.