49void AMDGPUInstPrinter::printU16ImmOperand(
const MCInst *
MI,
unsigned OpNo,
60 int64_t Imm =
Op.getImm();
61 if (isInt<16>(Imm) || isUInt<16>(Imm))
62 O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
64 printU32ImmOperand(
MI, OpNo, STI, O);
67void AMDGPUInstPrinter::printU16ImmDecOperand(
const MCInst *
MI,
unsigned OpNo,
72void AMDGPUInstPrinter::printU32ImmOperand(
const MCInst *
MI,
unsigned OpNo,
75 O <<
formatHex(
MI->getOperand(OpNo).getImm() & 0xffffffff);
78void AMDGPUInstPrinter::printNamedBit(
const MCInst *
MI,
unsigned OpNo,
80 if (
MI->getOperand(OpNo).getImm()) {
85void AMDGPUInstPrinter::printOffset(
const MCInst *
MI,
unsigned OpNo,
98 printU16ImmDecOperand(
MI, OpNo, O);
102void AMDGPUInstPrinter::printFlatOffset(
const MCInst *
MI,
unsigned OpNo,
117 printU16ImmDecOperand(
MI, OpNo, O);
121void AMDGPUInstPrinter::printSMRDOffset8(
const MCInst *
MI,
unsigned OpNo,
124 printU32ImmOperand(
MI, OpNo, STI, O);
127void AMDGPUInstPrinter::printSMEMOffset(
const MCInst *
MI,
unsigned OpNo,
133void AMDGPUInstPrinter::printSMRDLiteralOffset(
const MCInst *
MI,
unsigned OpNo,
136 printU32ImmOperand(
MI, OpNo, STI, O);
139void AMDGPUInstPrinter::printCPol(
const MCInst *
MI,
unsigned OpNo,
141 auto Imm =
MI->getOperand(OpNo).getImm();
147 printTH(
MI, TH, Scope, O);
148 printScope(Scope, O);
164 O <<
" /* unexpected cache policy bit */";
167void AMDGPUInstPrinter::printTH(
const MCInst *
MI, int64_t TH, int64_t Scope,
173 const unsigned Opcode =
MI->getOpcode();
201 O << (IsStore ?
"TH_STORE_" :
"TH_LOAD_");
211 : (IsStore ?
"RT_WB" :
"LU"));
232void AMDGPUInstPrinter::printScope(int64_t Scope,
raw_ostream &O) {
248void AMDGPUInstPrinter::printDim(
const MCInst *
MI,
unsigned OpNo,
250 unsigned Dim =
MI->getOperand(OpNo).getImm();
251 O <<
" dim:SQ_RSRC_IMG_";
260void AMDGPUInstPrinter::printR128A16(
const MCInst *
MI,
unsigned OpNo,
263 printNamedBit(
MI, OpNo, O,
"a16");
265 printNamedBit(
MI, OpNo, O,
"r128");
268void AMDGPUInstPrinter::printFORMAT(
const MCInst *
MI,
unsigned OpNo,
273void AMDGPUInstPrinter::printSymbolicFormat(
const MCInst *
MI,
282 unsigned Val =
MI->getOperand(OpNo).getImm();
284 if (Val == UFMT_DEFAULT)
289 O <<
" format:" << Val;
292 if (Val == DFMT_NFMT_DEFAULT)
299 if (Dfmt != DFMT_DEFAULT) {
301 if (Nfmt != NFMT_DEFAULT) {
305 if (Nfmt != NFMT_DEFAULT) {
310 O <<
" format:" << Val;
321 case AMDGPU::PRIVATE_RSRC_REG:
331void AMDGPUInstPrinter::printVOPDst(
const MCInst *
MI,
unsigned OpNo,
333 auto Opcode =
MI->getOpcode();
351 printRegularOperand(
MI, OpNo, STI, O);
357 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
358 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
359 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
360 case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
361 case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
362 case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
363 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx10:
364 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx10:
365 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx10:
366 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx10:
367 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx10:
368 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx10:
369 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx11:
370 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx11:
371 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx11:
372 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx11:
373 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx11:
374 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx11:
375 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx11:
376 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx11:
377 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx11:
378 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx12:
379 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx12:
380 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx12:
381 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx12:
382 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx12:
383 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx12:
384 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx12:
385 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx12:
386 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx12:
387 printDefaultVccOperand(
false, STI, O);
392void AMDGPUInstPrinter::printVINTRPDst(
const MCInst *
MI,
unsigned OpNo,
399 printRegularOperand(
MI, OpNo, STI, O);
402void AMDGPUInstPrinter::printImmediateInt16(
uint32_t Imm,
405 int32_t SImm =
static_cast<int32_t
>(
Imm);
411 if (printImmediateFloat32(Imm, STI, O))
414 O << formatHex(static_cast<uint64_t>(Imm & 0xffff));
421 else if (Imm == 0xBC00)
423 else if (Imm == 0x3800)
425 else if (Imm == 0xB800)
427 else if (Imm == 0x4000)
429 else if (Imm == 0xC000)
431 else if (Imm == 0x4400)
433 else if (Imm == 0xC400)
435 else if (Imm == 0x3118 && STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
447 else if (Imm == 0xBF80)
449 else if (Imm == 0x3F00)
451 else if (Imm == 0xBF00)
453 else if (Imm == 0x4000)
455 else if (Imm == 0xC000)
457 else if (Imm == 0x4080)
459 else if (Imm == 0xC080)
461 else if (Imm == 0x3E22 && STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
469void AMDGPUInstPrinter::printImmediateBF16(
uint32_t Imm,
472 int16_t SImm =
static_cast<int16_t
>(
Imm);
481 O << formatHex(static_cast<uint64_t>(Imm));
484void AMDGPUInstPrinter::printImmediateF16(
uint32_t Imm,
487 int16_t SImm =
static_cast<int16_t
>(
Imm);
501void AMDGPUInstPrinter::printImmediateV216(
uint32_t Imm,
uint8_t OpType,
504 int32_t SImm =
static_cast<int32_t
>(
Imm);
514 if (printImmediateFloat32(Imm, STI, O))
520 if (isUInt<16>(Imm) &&
527 if (isUInt<16>(Imm) &&
535 O << formatHex(static_cast<uint64_t>(Imm));
538bool AMDGPUInstPrinter::printImmediateFloat32(
uint32_t Imm,
541 if (Imm == llvm::bit_cast<uint32_t>(0.0f))
543 else if (Imm == llvm::bit_cast<uint32_t>(1.0f))
545 else if (Imm == llvm::bit_cast<uint32_t>(-1.0f))
547 else if (Imm == llvm::bit_cast<uint32_t>(0.5f))
549 else if (Imm == llvm::bit_cast<uint32_t>(-0.5f))
551 else if (Imm == llvm::bit_cast<uint32_t>(2.0f))
553 else if (Imm == llvm::bit_cast<uint32_t>(-2.0f))
555 else if (Imm == llvm::bit_cast<uint32_t>(4.0f))
557 else if (Imm == llvm::bit_cast<uint32_t>(-4.0f))
559 else if (Imm == 0x3e22f983 &&
560 STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
568void AMDGPUInstPrinter::printImmediate32(
uint32_t Imm,
571 int32_t SImm =
static_cast<int32_t
>(
Imm);
577 if (printImmediateFloat32(Imm, STI, O))
580 O << formatHex(static_cast<uint64_t>(Imm));
583void AMDGPUInstPrinter::printImmediate64(
uint64_t Imm,
586 int64_t SImm =
static_cast<int64_t
>(
Imm);
587 if (SImm >= -16 && SImm <= 64) {
592 if (Imm == llvm::bit_cast<uint64_t>(0.0))
594 else if (Imm == llvm::bit_cast<uint64_t>(1.0))
596 else if (Imm == llvm::bit_cast<uint64_t>(-1.0))
598 else if (Imm == llvm::bit_cast<uint64_t>(0.5))
600 else if (Imm == llvm::bit_cast<uint64_t>(-0.5))
602 else if (Imm == llvm::bit_cast<uint64_t>(2.0))
604 else if (Imm == llvm::bit_cast<uint64_t>(-2.0))
606 else if (Imm == llvm::bit_cast<uint64_t>(4.0))
608 else if (Imm == llvm::bit_cast<uint64_t>(-4.0))
610 else if (Imm == 0x3fc45f306dc9c882 &&
611 STI.
hasFeature(AMDGPU::FeatureInv2PiInlineImm))
612 O <<
"0.15915494309189532";
615 O << formatHex(static_cast<uint64_t>(
Hi_32(Imm)));
617 assert(isUInt<32>(Imm) || isInt<32>(Imm));
621 O << formatHex(static_cast<uint64_t>(Imm));
625void AMDGPUInstPrinter::printBLGP(
const MCInst *
MI,
unsigned OpNo,
628 unsigned Imm =
MI->getOperand(OpNo).getImm();
633 switch (
MI->getOpcode()) {
634 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_acd:
635 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_vcd:
636 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_acd:
637 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_vcd:
638 O <<
" neg:[" << (
Imm & 1) <<
',' << ((Imm >> 1) & 1) <<
','
639 << ((Imm >> 2) & 1) <<
']';
644 O <<
" blgp:" <<
Imm;
647void AMDGPUInstPrinter::printDefaultVccOperand(
bool FirstOperand,
661 unsigned OpNo)
const {
665 (
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
666 Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO));
670void AMDGPUInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
673 unsigned Opc =
MI->getOpcode();
682 (
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
683 Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO)))
684 printDefaultVccOperand(
true, STI, O);
686 printRegularOperand(
MI, OpNo, STI, O);
690void AMDGPUInstPrinter::printRegularOperand(
const MCInst *
MI,
unsigned OpNo,
695 if (OpNo >=
MI->getNumOperands()) {
696 O <<
"/*Missing OP" << OpNo <<
"*/";
707 int RCID =
Desc.operands()[OpNo].RegClass;
713 <<
"\' register class*/";
716 }
else if (
Op.isImm()) {
717 const uint8_t OpTy =
Desc.operands()[OpNo].OperandType;
732 printImmediate32(
Op.getImm(), STI, O);
736 printImmediate64(
Op.getImm(), STI, O,
false);
741 printImmediate64(
Op.getImm(), STI, O,
true);
746 printImmediateInt16(
Op.getImm(), STI, O);
752 printImmediateF16(
Op.getImm(), STI, O);
758 printImmediateBF16(
Op.getImm(), STI, O);
769 printImmediateV216(
Op.getImm(), OpTy, STI, O);
778 printImmediate32(
Op.getImm(), STI, O);
779 O <<
"/*Invalid immediate*/";
786 }
else if (
Op.isDFPImm()) {
787 double Value = bit_cast<double>(
Op.getDFPImm());
793 int RCID =
Desc.operands()[OpNo].RegClass;
796 printImmediate32(llvm::bit_cast<uint32_t>((
float)
Value), STI, O);
797 else if (RCBits == 64)
798 printImmediate64(llvm::bit_cast<uint64_t>(
Value), STI, O,
true);
802 }
else if (
Op.isExpr()) {
810 switch (
MI->getOpcode()) {
813 case AMDGPU::V_CNDMASK_B32_e32_gfx10:
814 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx10:
815 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx10:
816 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
817 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx10:
818 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx10:
819 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx10:
820 case AMDGPU::V_CNDMASK_B32_dpp8_gfx10:
821 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx10:
822 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx10:
823 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx10:
824 case AMDGPU::V_CNDMASK_B32_e32_gfx11:
825 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx11:
826 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx11:
827 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx11:
828 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx11:
829 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx11:
830 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx11:
831 case AMDGPU::V_CNDMASK_B32_dpp8_gfx11:
832 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx11:
833 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx11:
834 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx11:
835 case AMDGPU::V_CNDMASK_B32_e32_gfx12:
836 case AMDGPU::V_ADD_CO_CI_U32_e32_gfx12:
837 case AMDGPU::V_SUB_CO_CI_U32_e32_gfx12:
838 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx12:
839 case AMDGPU::V_CNDMASK_B32_dpp_gfx12:
840 case AMDGPU::V_ADD_CO_CI_U32_dpp_gfx12:
841 case AMDGPU::V_SUB_CO_CI_U32_dpp_gfx12:
842 case AMDGPU::V_SUBREV_CO_CI_U32_dpp_gfx12:
843 case AMDGPU::V_CNDMASK_B32_dpp8_gfx12:
844 case AMDGPU::V_ADD_CO_CI_U32_dpp8_gfx12:
845 case AMDGPU::V_SUB_CO_CI_U32_dpp8_gfx12:
846 case AMDGPU::V_SUBREV_CO_CI_U32_dpp8_gfx12:
848 case AMDGPU::V_CNDMASK_B32_e32_gfx6_gfx7:
849 case AMDGPU::V_CNDMASK_B32_e32_vi:
851 AMDGPU::OpName::src1))
852 printDefaultVccOperand(OpNo == 0, STI, O);
860 if ((
int)OpNo == SOffsetIdx)
861 printSymbolicFormat(
MI, STI, O);
865void AMDGPUInstPrinter::printOperandAndFPInputMods(
const MCInst *
MI,
870 if (needsImpliedVcc(
Desc, OpNo))
871 printDefaultVccOperand(
true, STI, O);
873 unsigned InputModifiers =
MI->getOperand(OpNo).getImm();
878 bool NegMnemo =
false;
881 if (OpNo + 1 <
MI->getNumOperands() &&
884 NegMnemo =
Op.isImm() ||
Op.isDFPImm();
895 printRegularOperand(
MI, OpNo + 1, STI, O);
904 switch (
MI->getOpcode()) {
908 case AMDGPU::V_CNDMASK_B32_sdwa_gfx10:
909 case AMDGPU::V_CNDMASK_B32_dpp_gfx10:
910 case AMDGPU::V_CNDMASK_B32_dpp_gfx11:
913 printDefaultVccOperand(OpNo == 0, STI, O);
918void AMDGPUInstPrinter::printOperandAndIntInputMods(
const MCInst *
MI,
923 if (needsImpliedVcc(
Desc, OpNo))
924 printDefaultVccOperand(
true, STI, O);
926 unsigned InputModifiers =
MI->getOperand(OpNo).getImm();
929 printRegularOperand(
MI, OpNo + 1, STI, O);
934 switch (
MI->getOpcode()) {
937 case AMDGPU::V_ADD_CO_CI_U32_sdwa_gfx10:
938 case AMDGPU::V_SUB_CO_CI_U32_sdwa_gfx10:
939 case AMDGPU::V_SUBREV_CO_CI_U32_sdwa_gfx10:
941 AMDGPU::OpName::src1))
942 printDefaultVccOperand(OpNo == 0, STI, O);
947void AMDGPUInstPrinter::printDPP8(
const MCInst *
MI,
unsigned OpNo,
953 unsigned Imm =
MI->getOperand(OpNo).getImm();
955 for (
size_t i = 1; i < 8; ++i) {
956 O <<
',' <<
formatDec((Imm >> (3 * i)) & 0x7);
961void AMDGPUInstPrinter::printDPPCtrl(
const MCInst *
MI,
unsigned OpNo,
964 using namespace AMDGPU::DPP;
966 unsigned Imm =
MI->getOperand(OpNo).getImm();
970 O <<
" /* DP ALU dpp only supports row_newbcast */";
973 if (Imm <= DppCtrl::QUAD_PERM_LAST) {
979 }
else if ((Imm >= DppCtrl::ROW_SHL_FIRST) &&
980 (Imm <= DppCtrl::ROW_SHL_LAST)) {
981 O <<
"row_shl:" <<
formatDec(Imm - DppCtrl::ROW_SHL0);
982 }
else if ((Imm >= DppCtrl::ROW_SHR_FIRST) &&
983 (Imm <= DppCtrl::ROW_SHR_LAST)) {
984 O <<
"row_shr:" <<
formatDec(Imm - DppCtrl::ROW_SHR0);
985 }
else if ((Imm >= DppCtrl::ROW_ROR_FIRST) &&
986 (Imm <= DppCtrl::ROW_ROR_LAST)) {
987 O <<
"row_ror:" <<
formatDec(Imm - DppCtrl::ROW_ROR0);
988 }
else if (Imm == DppCtrl::WAVE_SHL1) {
990 O <<
"/* wave_shl is not supported starting from GFX10 */";
994 }
else if (Imm == DppCtrl::WAVE_ROL1) {
996 O <<
"/* wave_rol is not supported starting from GFX10 */";
1000 }
else if (Imm == DppCtrl::WAVE_SHR1) {
1002 O <<
"/* wave_shr is not supported starting from GFX10 */";
1006 }
else if (Imm == DppCtrl::WAVE_ROR1) {
1008 O <<
"/* wave_ror is not supported starting from GFX10 */";
1012 }
else if (Imm == DppCtrl::ROW_MIRROR) {
1014 }
else if (Imm == DppCtrl::ROW_HALF_MIRROR) {
1015 O <<
"row_half_mirror";
1016 }
else if (Imm == DppCtrl::BCAST15) {
1018 O <<
"/* row_bcast is not supported starting from GFX10 */";
1021 O <<
"row_bcast:15";
1022 }
else if (Imm == DppCtrl::BCAST31) {
1024 O <<
"/* row_bcast is not supported starting from GFX10 */";
1027 O <<
"row_bcast:31";
1028 }
else if ((Imm >= DppCtrl::ROW_SHARE_FIRST) &&
1029 (Imm <= DppCtrl::ROW_SHARE_LAST)) {
1031 O <<
"row_newbcast:";
1035 O <<
" /* row_newbcast/row_share is not supported on ASICs earlier "
1036 "than GFX90A/GFX10 */";
1039 O <<
formatDec(Imm - DppCtrl::ROW_SHARE_FIRST);
1040 }
else if ((Imm >= DppCtrl::ROW_XMASK_FIRST) &&
1041 (Imm <= DppCtrl::ROW_XMASK_LAST)) {
1043 O <<
"/* row_xmask is not supported on ASICs earlier than GFX10 */";
1046 O <<
"row_xmask:" <<
formatDec(Imm - DppCtrl::ROW_XMASK_FIRST);
1048 O <<
"/* Invalid dpp_ctrl value */";
1052void AMDGPUInstPrinter::printDppBoundCtrl(
const MCInst *
MI,
unsigned OpNo,
1055 unsigned Imm =
MI->getOperand(OpNo).getImm();
1057 O <<
" bound_ctrl:1";
1061void AMDGPUInstPrinter::printDppFI(
const MCInst *
MI,
unsigned OpNo,
1064 unsigned Imm =
MI->getOperand(OpNo).getImm();
1065 if (Imm == DPP_FI_1 || Imm == DPP8_FI_1) {
1070void AMDGPUInstPrinter::printSDWASel(
const MCInst *
MI,
unsigned OpNo,
1074 unsigned Imm =
MI->getOperand(OpNo).getImm();
1076 case SdwaSel::BYTE_0:
O <<
"BYTE_0";
break;
1077 case SdwaSel::BYTE_1:
O <<
"BYTE_1";
break;
1078 case SdwaSel::BYTE_2:
O <<
"BYTE_2";
break;
1079 case SdwaSel::BYTE_3:
O <<
"BYTE_3";
break;
1080 case SdwaSel::WORD_0:
O <<
"WORD_0";
break;
1081 case SdwaSel::WORD_1:
O <<
"WORD_1";
break;
1082 case SdwaSel::DWORD:
O <<
"DWORD";
break;
1087void AMDGPUInstPrinter::printSDWADstSel(
const MCInst *
MI,
unsigned OpNo,
1091 printSDWASel(
MI, OpNo, O);
1094void AMDGPUInstPrinter::printSDWASrc0Sel(
const MCInst *
MI,
unsigned OpNo,
1098 printSDWASel(
MI, OpNo, O);
1101void AMDGPUInstPrinter::printSDWASrc1Sel(
const MCInst *
MI,
unsigned OpNo,
1105 printSDWASel(
MI, OpNo, O);
1108void AMDGPUInstPrinter::printSDWADstUnused(
const MCInst *
MI,
unsigned OpNo,
1114 unsigned Imm =
MI->getOperand(OpNo).getImm();
1116 case DstUnused::UNUSED_PAD:
O <<
"UNUSED_PAD";
break;
1117 case DstUnused::UNUSED_SEXT:
O <<
"UNUSED_SEXT";
break;
1118 case DstUnused::UNUSED_PRESERVE:
O <<
"UNUSED_PRESERVE";
break;
1123void AMDGPUInstPrinter::printExpSrcN(
const MCInst *
MI,
unsigned OpNo,
1126 unsigned Opc =
MI->getOpcode();
1128 unsigned En =
MI->getOperand(EnIdx).getImm();
1133 if (
MI->getOperand(ComprIdx).getImm())
1134 OpNo = OpNo -
N +
N / 2;
1142void AMDGPUInstPrinter::printExpSrc0(
const MCInst *
MI,
unsigned OpNo,
1145 printExpSrcN(
MI, OpNo, STI, O, 0);
1148void AMDGPUInstPrinter::printExpSrc1(
const MCInst *
MI,
unsigned OpNo,
1151 printExpSrcN(
MI, OpNo, STI, O, 1);
1154void AMDGPUInstPrinter::printExpSrc2(
const MCInst *
MI,
unsigned OpNo,
1157 printExpSrcN(
MI, OpNo, STI, O, 2);
1160void AMDGPUInstPrinter::printExpSrc3(
const MCInst *
MI,
unsigned OpNo,
1163 printExpSrcN(
MI, OpNo, STI, O, 3);
1166void AMDGPUInstPrinter::printExpTgt(
const MCInst *
MI,
unsigned OpNo,
1172 unsigned Id =
MI->getOperand(OpNo).getImm() & ((1 << 6) - 1);
1177 O <<
' ' << TgtName;
1181 O <<
" invalid_target_" <<
Id;
1186 bool IsPacked,
bool HasDstSel) {
1189 for (
int I = 0;
I < NumOps; ++
I) {
1190 if (!!(Ops[
I] &
Mod) != DefaultValue)
1200void AMDGPUInstPrinter::printPackedModifier(
const MCInst *
MI,
1204 unsigned Opc =
MI->getOpcode();
1208 std::pair<int, int> MOps[] = {
1209 {AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src0},
1210 {AMDGPU::OpName::src1_modifiers, AMDGPU::OpName::src1},
1211 {AMDGPU::OpName::src2_modifiers, AMDGPU::OpName::src2}};
1214 for (
auto [SrcMod, Src] : MOps) {
1220 (ModIdx != -1) ?
MI->getOperand(ModIdx).getImm() : DefaultValue;
1230 {AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src1_modifiers,
1231 AMDGPU::OpName::src2_modifiers}) {
1234 Ops[NumOps++] =
MI->getOperand(
Idx).getImm();
1236 Ops[NumOps++] = DefaultValue;
1240 const bool HasDstSel =
1252 for (
int I = 0;
I < NumOps; ++
I) {
1256 O << !!(Ops[
I] &
Mod);
1266void AMDGPUInstPrinter::printOpSel(
const MCInst *
MI,
unsigned,
1269 unsigned Opc =
MI->getOpcode();
1273 unsigned Mod =
MI->getOperand(SrcMod).getImm();
1276 if (Index0 || Index1)
1277 O <<
" op_sel:[" << Index0 <<
',' << Index1 <<
']';
1286 O <<
" op_sel:[" << FI <<
',' << BC <<
']';
1293void AMDGPUInstPrinter::printOpSelHi(
const MCInst *
MI,
unsigned OpNo,
1299void AMDGPUInstPrinter::printNegLo(
const MCInst *
MI,
unsigned OpNo,
1305void AMDGPUInstPrinter::printNegHi(
const MCInst *
MI,
unsigned OpNo,
1311void AMDGPUInstPrinter::printIndexKey8bit(
const MCInst *
MI,
unsigned OpNo,
1314 auto Imm =
MI->getOperand(OpNo).getImm() & 0x7;
1318 O <<
" index_key:" <<
Imm;
1321void AMDGPUInstPrinter::printIndexKey16bit(
const MCInst *
MI,
unsigned OpNo,
1324 auto Imm =
MI->getOperand(OpNo).getImm() & 0x7;
1328 O <<
" index_key:" <<
Imm;
1331void AMDGPUInstPrinter::printInterpSlot(
const MCInst *
MI,
unsigned OpNum,
1334 unsigned Imm =
MI->getOperand(OpNum).getImm();
1346 O <<
"invalid_param_" <<
Imm;
1350void AMDGPUInstPrinter::printInterpAttr(
const MCInst *
MI,
unsigned OpNum,
1353 unsigned Attr =
MI->getOperand(OpNum).getImm();
1354 O <<
"attr" << Attr;
1357void AMDGPUInstPrinter::printInterpAttrChan(
const MCInst *
MI,
unsigned OpNum,
1360 unsigned Chan =
MI->getOperand(OpNum).getImm();
1361 O <<
'.' <<
"xyzw"[Chan & 0x3];
1364void AMDGPUInstPrinter::printGPRIdxMode(
const MCInst *
MI,
unsigned OpNo,
1368 unsigned Val =
MI->getOperand(OpNo).getImm();
1370 if ((Val & ~ENABLE_MASK) != 0) {
1371 O << formatHex(static_cast<uint64_t>(Val));
1374 bool NeedComma =
false;
1375 for (
unsigned ModeId = ID_MIN; ModeId <=
ID_MAX; ++ModeId) {
1376 if (Val & (1 << ModeId)) {
1387void AMDGPUInstPrinter::printMemOperand(
const MCInst *
MI,
unsigned OpNo,
1390 printRegularOperand(
MI, OpNo, STI, O);
1392 printRegularOperand(
MI, OpNo + 1, STI, O);
1400 if (
Op.getImm() == 1) {
1411 if (
Op.getImm() == 1)
1418 int Imm =
MI->getOperand(OpNo).getImm();
1432 const unsigned Imm16 =
MI->getOperand(OpNo).getImm();
1437 decodeMsg(Imm16, MsgId, OpId,
StreamId, STI);
1439 StringRef MsgName = getMsgName(MsgId, STI);
1441 if (!MsgName.
empty() && isValidMsgOp(MsgId, OpId, STI) &&
1442 isValidMsgStream(MsgId, OpId,
StreamId, STI)) {
1443 O <<
"sendmsg(" << MsgName;
1444 if (msgRequiresOp(MsgId, STI)) {
1445 O <<
", " << getMsgOpName(MsgId, OpId, STI);
1446 if (msgSupportsStream(MsgId, OpId, STI)) {
1451 }
else if (encodeMsg(MsgId, OpId,
StreamId) == Imm16) {
1452 O <<
"sendmsg(" << MsgId <<
", " << OpId <<
", " <<
StreamId <<
')';
1464 uint16_t Probe0 = ((0 & AndMask) | OrMask) ^ XorMask;
1465 uint16_t Probe1 = ((BITMASK_MASK & AndMask) | OrMask) ^ XorMask;
1469 for (
unsigned Mask = 1 << (BITMASK_WIDTH - 1); Mask > 0; Mask >>= 1) {
1496 uint16_t Imm =
MI->getOperand(OpNo).getImm();
1505 if (Imm >= FFT_MODE_LO) {
1506 O <<
"swizzle(" << IdSymbolic[ID_FFT] <<
',' << (Imm & FFT_SWIZZLE_MASK)
1508 }
else if (Imm >= ROTATE_MODE_LO) {
1509 O <<
"swizzle(" << IdSymbolic[ID_ROTATE] <<
','
1510 << ((Imm >> ROTATE_DIR_SHIFT) & ROTATE_DIR_MASK) <<
','
1511 << ((Imm >> ROTATE_SIZE_SHIFT) & ROTATE_SIZE_MASK) <<
')';
1517 if ((Imm & QUAD_PERM_ENC_MASK) == QUAD_PERM_ENC) {
1518 O <<
"swizzle(" << IdSymbolic[ID_QUAD_PERM];
1519 for (
unsigned I = 0;
I < LANE_NUM; ++
I) {
1526 }
else if ((Imm & BITMASK_PERM_ENC_MASK) == BITMASK_PERM_ENC) {
1528 uint16_t AndMask = (Imm >> BITMASK_AND_SHIFT) & BITMASK_MASK;
1529 uint16_t OrMask = (Imm >> BITMASK_OR_SHIFT) & BITMASK_MASK;
1530 uint16_t XorMask = (Imm >> BITMASK_XOR_SHIFT) & BITMASK_MASK;
1532 if (AndMask == BITMASK_MAX && OrMask == 0 &&
llvm::popcount(XorMask) == 1) {
1534 O <<
"swizzle(" << IdSymbolic[ID_SWAP];
1539 }
else if (AndMask == BITMASK_MAX && OrMask == 0 && XorMask > 0 &&
1542 O <<
"swizzle(" << IdSymbolic[ID_REVERSE];
1549 uint16_t GroupSize = BITMASK_MAX - AndMask + 1;
1550 if (GroupSize > 1 &&
1552 OrMask < GroupSize &&
1555 O <<
"swizzle(" << IdSymbolic[ID_BROADCAST];
1563 O <<
"swizzle(" << IdSymbolic[ID_BITMASK_PERM];
1570 printU16ImmDecOperand(
MI, OpNo, O);
1579 unsigned SImm16 =
MI->getOperand(OpNo).getImm();
1580 unsigned Vmcnt, Expcnt, Lgkmcnt;
1586 bool PrintAll = IsDefaultVmcnt && IsDefaultExpcnt && IsDefaultLgkmcnt;
1588 bool NeedSpace =
false;
1590 if (!IsDefaultVmcnt || PrintAll) {
1591 O <<
"vmcnt(" << Vmcnt <<
')';
1595 if (!IsDefaultExpcnt || PrintAll) {
1598 O <<
"expcnt(" << Expcnt <<
')';
1602 if (!IsDefaultLgkmcnt || PrintAll) {
1605 O <<
"lgkmcnt(" << Lgkmcnt <<
')';
1614 uint64_t Imm16 =
MI->getOperand(OpNo).getImm() & 0xffff;
1616 bool HasNonDefaultVal =
false;
1617 if (isSymbolicDepCtrEncoding(Imm16, HasNonDefaultVal, STI)) {
1622 bool NeedSpace =
false;
1623 while (decodeDepCtr(Imm16,
Id,
Name, Val, IsDefault, STI)) {
1624 if (!IsDefault || !HasNonDefaultVal) {
1627 O <<
Name <<
'(' << Val <<
')';
1639 const char *BadInstId =
"/* invalid instid value */";
1640 static const std::array<const char *, 12> InstIds = {
1641 "NO_DEP",
"VALU_DEP_1",
"VALU_DEP_2",
1642 "VALU_DEP_3",
"VALU_DEP_4",
"TRANS32_DEP_1",
1643 "TRANS32_DEP_2",
"TRANS32_DEP_3",
"FMA_ACCUM_CYCLE_1",
1644 "SALU_CYCLE_1",
"SALU_CYCLE_2",
"SALU_CYCLE_3"};
1646 const char *BadInstSkip =
"/* invalid instskip value */";
1647 static const std::array<const char *, 6> InstSkips = {
1648 "SAME",
"NEXT",
"SKIP_1",
"SKIP_2",
"SKIP_3",
"SKIP_4"};
1650 unsigned SImm16 =
MI->getOperand(OpNo).getImm();
1651 const char *Prefix =
"";
1653 unsigned Value = SImm16 & 0xF;
1655 const char *
Name =
Value < InstIds.size() ? InstIds[
Value] : BadInstId;
1656 O << Prefix <<
"instid0(" <<
Name <<
')';
1660 Value = (SImm16 >> 4) & 7;
1663 Value < InstSkips.size() ? InstSkips[
Value] : BadInstSkip;
1664 O << Prefix <<
"instskip(" <<
Name <<
')';
1668 Value = (SImm16 >> 7) & 0xF;
1670 const char *
Name =
Value < InstIds.size() ? InstIds[
Value] : BadInstId;
1671 O << Prefix <<
"instid1(" <<
Name <<
')';
1682 unsigned Val =
MI->getOperand(OpNo).getImm();
1683 auto [
Id,
Offset, Width] = HwregEncoding::decode(Val);
1687 if (!HwRegName.
empty()) {
1692 if (Width != HwregSize::Default ||
Offset != HwregOffset::Default)
1693 O <<
", " <<
Offset <<
", " << Width;
1700 uint16_t Imm =
MI->getOperand(OpNo).getImm();
1708void AMDGPUInstPrinter::printNamedInt(
const MCInst *
MI,
unsigned OpNo,
1711 bool PrintInHex,
bool AlwaysPrint) {
1712 int64_t V =
MI->getOperand(OpNo).getImm();
1713 if (AlwaysPrint || V != 0)
1717void AMDGPUInstPrinter::printBitOp3(
const MCInst *
MI,
unsigned OpNo,
1720 uint8_t Imm =
MI->getOperand(OpNo).getImm();
1728 O << formatHex(static_cast<uint64_t>(Imm));
1731#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)
static void printRegOperand(MCRegister Reg, raw_ostream &O, const MCRegisterInfo &MRI)
void printRegName(raw_ostream &OS, MCRegister Reg) override
Print the assembler register name.
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.
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 isGFX9Plus(const MCSubtargetInfo &STI)
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.
MCRegister mc2PseudoReg(MCRegister Reg)
Convert hardware register Reg to a pseudo register.
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.