@@ -4572,33 +4572,43 @@ static bool compareMachineOp(const MachineOperand &Op0,
45724572 }
45734573}
45744574
4575- bool SIInstrInfo::isImmOperandLegal (const MCInstrDesc &InstDesc, unsigned OpNo,
4576- const MachineOperand &MO) const {
4577- const MCOperandInfo &OpInfo = InstDesc.operands ()[OpNo];
4578-
4579- assert (MO.isImm () || MO.isTargetIndex () || MO.isFI () || MO.isGlobal ());
4580-
4575+ bool SIInstrInfo::isLiteralOperandLegal (const MCInstrDesc &InstDesc,
4576+ const MCOperandInfo &OpInfo) const {
45814577 if (OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE)
45824578 return true ;
45834579
4584- if (OpInfo.RegClass < 0 )
4580+ if (!RI. opCanUseLiteralConstant ( OpInfo.OperandType ) )
45854581 return false ;
45864582
4587- if (MO.isImm () && isInlineConstant (MO, OpInfo)) {
4583+ if (!isVOP3 (InstDesc) || !AMDGPU::isSISrcOperand (OpInfo))
4584+ return true ;
4585+
4586+ return ST.hasVOP3Literal ();
4587+ }
4588+
4589+ bool SIInstrInfo::isImmOperandLegal (const MCInstrDesc &InstDesc, unsigned OpNo,
4590+ int64_t ImmVal) const {
4591+ const MCOperandInfo &OpInfo = InstDesc.operands ()[OpNo];
4592+ if (isInlineConstant (ImmVal, OpInfo.OperandType )) {
45884593 if (isMAI (InstDesc) && ST.hasMFMAInlineLiteralBug () &&
45894594 OpNo == (unsigned )AMDGPU::getNamedOperandIdx (InstDesc.getOpcode (),
45904595 AMDGPU::OpName::src2))
45914596 return false ;
45924597 return RI.opCanUseInlineConstant (OpInfo.OperandType );
45934598 }
45944599
4595- if (!RI. opCanUseLiteralConstant ( OpInfo. OperandType ))
4596- return false ;
4600+ return isLiteralOperandLegal (InstDesc, OpInfo);
4601+ }
45974602
4598- if (!isVOP3 (InstDesc) || !AMDGPU::isSISrcOperand (InstDesc, OpNo))
4599- return true ;
4603+ bool SIInstrInfo::isImmOperandLegal (const MCInstrDesc &InstDesc, unsigned OpNo,
4604+ const MachineOperand &MO) const {
4605+ if (MO.isImm ())
4606+ return isImmOperandLegal (InstDesc, OpNo, MO.getImm ());
46004607
4601- return ST.hasVOP3Literal ();
4608+ assert ((MO.isTargetIndex () || MO.isFI () || MO.isGlobal ()) &&
4609+ " unexpected imm-like operand kind" );
4610+ const MCOperandInfo &OpInfo = InstDesc.operands ()[OpNo];
4611+ return isLiteralOperandLegal (InstDesc, OpInfo);
46024612}
46034613
46044614bool SIInstrInfo::isLegalAV64PseudoImm (uint64_t Imm) const {
@@ -6268,7 +6278,7 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
62686278 return false ;
62696279 }
62706280 }
6271- } else if (AMDGPU::isSISrcOperand (InstDesc, i ) &&
6281+ } else if (AMDGPU::isSISrcOperand (InstDesc. operands ()[i] ) &&
62726282 !isInlineConstant (Op, InstDesc.operands ()[i])) {
62736283 // The same literal may be used multiple times.
62746284 if (!UsedLiteral)
0 commit comments