Skip to content

Commit f127217

Browse files
committed
AMDGPU: Add version of isImmOperandLegal for MCInstrDesc
This avoids the need for a pre-constructed instruction, at least for the first argument.
1 parent 1b86547 commit f127217

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4572,9 +4572,8 @@ static bool compareMachineOp(const MachineOperand &Op0,
45724572
}
45734573
}
45744574

4575-
bool SIInstrInfo::isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
4575+
bool SIInstrInfo::isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
45764576
const MachineOperand &MO) const {
4577-
const MCInstrDesc &InstDesc = MI.getDesc();
45784577
const MCOperandInfo &OpInfo = InstDesc.operands()[OpNo];
45794578

45804579
assert(MO.isImm() || MO.isTargetIndex() || MO.isFI() || MO.isGlobal());
@@ -4586,17 +4585,17 @@ bool SIInstrInfo::isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
45864585
return false;
45874586

45884587
if (MO.isImm() && isInlineConstant(MO, OpInfo)) {
4589-
if (isMAI(MI) && ST.hasMFMAInlineLiteralBug() &&
4590-
OpNo ==(unsigned)AMDGPU::getNamedOperandIdx(MI.getOpcode(),
4591-
AMDGPU::OpName::src2))
4588+
if (isMAI(InstDesc) && ST.hasMFMAInlineLiteralBug() &&
4589+
OpNo == (unsigned)AMDGPU::getNamedOperandIdx(InstDesc.getOpcode(),
4590+
AMDGPU::OpName::src2))
45924591
return false;
45934592
return RI.opCanUseInlineConstant(OpInfo.OperandType);
45944593
}
45954594

45964595
if (!RI.opCanUseLiteralConstant(OpInfo.OperandType))
45974596
return false;
45984597

4599-
if (!isVOP3(MI) || !AMDGPU::isSISrcOperand(InstDesc, OpNo))
4598+
if (!isVOP3(InstDesc) || !AMDGPU::isSISrcOperand(InstDesc, OpNo))
46004599
return true;
46014600

46024601
return ST.hasVOP3Literal();

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,13 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
533533
return get(Opcode).TSFlags & SIInstrFlags::VOP2;
534534
}
535535

536-
static bool isVOP3(const MachineInstr &MI) {
537-
return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
536+
static bool isVOP3(const MCInstrDesc &Desc) {
537+
return Desc.TSFlags & SIInstrFlags::VOP3;
538538
}
539539

540-
bool isVOP3(uint16_t Opcode) const {
541-
return get(Opcode).TSFlags & SIInstrFlags::VOP3;
542-
}
540+
static bool isVOP3(const MachineInstr &MI) { return isVOP3(MI.getDesc()); }
541+
542+
bool isVOP3(uint16_t Opcode) const { return isVOP3(get(Opcode)); }
543543

544544
static bool isSDWA(const MachineInstr &MI) {
545545
return MI.getDesc().TSFlags & SIInstrFlags::SDWA;
@@ -841,13 +841,13 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
841841
return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
842842
}
843843

844-
static bool isMAI(const MachineInstr &MI) {
845-
return MI.getDesc().TSFlags & SIInstrFlags::IsMAI;
844+
static bool isMAI(const MCInstrDesc &Desc) {
845+
return Desc.TSFlags & SIInstrFlags::IsMAI;
846846
}
847847

848-
bool isMAI(uint16_t Opcode) const {
849-
return get(Opcode).TSFlags & SIInstrFlags::IsMAI;
850-
}
848+
static bool isMAI(const MachineInstr &MI) { return isMAI(MI.getDesc()); }
849+
850+
bool isMAI(uint16_t Opcode) const { return isMAI(get(Opcode)); }
851851

852852
static bool isMFMA(const MachineInstr &MI) {
853853
return isMAI(MI) && MI.getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32_e64 &&
@@ -1180,9 +1180,14 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
11801180
return isInlineConstant(*MO.getParent(), MO.getOperandNo());
11811181
}
11821182

1183-
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
1183+
bool isImmOperandLegal(const MCInstrDesc &InstDesc, unsigned OpNo,
11841184
const MachineOperand &MO) const;
11851185

1186+
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
1187+
const MachineOperand &MO) const {
1188+
return isImmOperandLegal(MI.getDesc(), OpNo, MO);
1189+
}
1190+
11861191
/// Check if this immediate value can be used for AV_MOV_B64_IMM_PSEUDO.
11871192
bool isLegalAV64PseudoImm(uint64_t Imm) const;
11881193

0 commit comments

Comments
 (0)