Skip to content

Commit 79f52af

Browse files
committed
[AMDGPU] Make getInstSizeInBytes more generic
NFC. This check mainly handles size affecting literals. Make it check all explicit operands instead of a few by name. Also make the isLiteral check handle the KIMM operands, see https://reviews.llvm.org/D111067 Change-Id: I1a362d55b2a10f5c74d445272e8b7829a8b77597 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D113318 Change-Id: Ie6c688f30a71e0335d1c6dd1ff65019bd7ce684e
1 parent ce4fa93 commit 79f52af

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,6 +3471,9 @@ bool SIInstrInfo::isInlineConstant(const MachineOperand &MO,
34713471
uint32_t Trunc = static_cast<uint32_t>(Imm);
34723472
return AMDGPU::isInlinableLiteralV216(Trunc, ST.hasInv2PiInlineImm());
34733473
}
3474+
case AMDGPU::OPERAND_KIMM32:
3475+
case AMDGPU::OPERAND_KIMM16:
3476+
return false;
34743477
default:
34753478
llvm_unreachable("invalid bitwidth");
34763479
}
@@ -7307,31 +7310,19 @@ unsigned SIInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
73077310
return Size;
73087311
}
73097312

7310-
// 4-byte instructions may have a 32-bit literal encoded after them. Check
7311-
// operands that coud ever be literals.
7313+
// Instructions may have a 32-bit literal encoded after them. Check
7314+
// operands that could ever be literals.
73127315
if (isVALU(MI) || isSALU(MI)) {
7313-
int Src0Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0);
7314-
if (Src0Idx == -1)
7315-
return DescSize; // No operands.
7316-
7317-
if (isLiteralConstantLike(MI.getOperand(Src0Idx), Desc.OpInfo[Src0Idx]))
7318-
return isVOP3(MI) ? 12 : (DescSize + 4);
7319-
7320-
int Src1Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src1);
7321-
if (Src1Idx == -1)
7322-
return DescSize;
7323-
7324-
if (isLiteralConstantLike(MI.getOperand(Src1Idx), Desc.OpInfo[Src1Idx]))
7325-
return isVOP3(MI) ? 12 : (DescSize + 4);
7326-
7327-
int Src2Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src2);
7328-
if (Src2Idx == -1)
7316+
if (isDPP(MI))
73297317
return DescSize;
7330-
7331-
if (isLiteralConstantLike(MI.getOperand(Src2Idx), Desc.OpInfo[Src2Idx]))
7332-
return isVOP3(MI) ? 12 : (DescSize + 4);
7333-
7334-
return DescSize;
7318+
bool HasLiteral = false;
7319+
for (int I = 0, E = MI.getNumExplicitOperands(); I != E; ++I) {
7320+
if (isLiteralConstant(MI, I)) {
7321+
HasLiteral = true;
7322+
break;
7323+
}
7324+
}
7325+
return HasLiteral ? DescSize + 4 : DescSize;
73357326
}
73367327

73377328
// Check whether we have extra NSA words.

0 commit comments

Comments
 (0)