[llvm] fc85ccd - AMDGPU/MC: Simplify AsmParser for VOP3P
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 03:47:01 PST 2022
Author: Petar Avramovic
Date: 2022-12-05T12:45:39+01:00
New Revision: fc85ccd7b3cf7e6a7e7aef9e04c181df15b543e3
URL: https://github.com/llvm/llvm-project/commit/fc85ccd7b3cf7e6a7e7aef9e04c181df15b543e3
DIFF: https://github.com/llvm/llvm-project/commit/fc85ccd7b3cf7e6a7e7aef9e04c181df15b543e3.diff
LOG: AMDGPU/MC: Simplify AsmParser for VOP3P
Remove check that instruction has src_modifiers because
isRegOrImmWithInputMods essentially includes this check.
isMod is no longer used after the refactor. Also, was unreachable case
inside for loop. clamp and omod operands are handled after the loop.
Differential Revision: https://reviews.llvm.org/D139194
Added:
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 1fff896c10a8f..1adf2a75819a2 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -396,10 +396,6 @@ class AMDGPUOperand : public MCParsedAsmOperand {
bool isNegHi() const { return isImmTy(ImmTyNegHi); }
bool isHigh() const { return isImmTy(ImmTyHigh); }
- bool isMod() const {
- return isClampSI() || isOModSI();
- }
-
bool isRegOrImm() const {
return isReg() || isImm();
}
@@ -8213,29 +8209,16 @@ void AMDGPUAsmParser::cvtVOP3(MCInst &Inst, const OperandVector &Operands,
((AMDGPUOperand &)*Operands[I++]).addRegOperands(Inst, 1);
}
- if (AMDGPU::hasNamedOperand(Opc, AMDGPU::OpName::src0_modifiers)) {
- // This instruction has src modifiers
- for (unsigned E = Operands.size(); I != E; ++I) {
- AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[I]);
- if (isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
- Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
- } else if (Op.isImmModifier()) {
- OptionalIdx[Op.getImmTy()] = I;
- } else if (Op.isRegOrImm()) {
- Op.addRegOrImmOperands(Inst, 1);
- } else {
- llvm_unreachable("unhandled operand type");
- }
- }
- } else {
- // No src modifiers
- for (unsigned E = Operands.size(); I != E; ++I) {
- AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[I]);
- if (Op.isMod()) {
- OptionalIdx[Op.getImmTy()] = I;
- } else {
- Op.addRegOrImmOperands(Inst, 1);
- }
+ for (unsigned E = Operands.size(); I != E; ++I) {
+ AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[I]);
+ if (isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
+ Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
+ } else if (Op.isImmModifier()) {
+ OptionalIdx[Op.getImmTy()] = I;
+ } else if (Op.isRegOrImm()) {
+ Op.addRegOrImmOperands(Inst, 1);
+ } else {
+ llvm_unreachable("unhandled operand type");
}
}
@@ -8737,8 +8720,6 @@ void AMDGPUAsmParser::cvtVOP3DPP(MCInst &Inst, const OperandVector &Operands,
OptionalImmIndexMap OptionalIdx;
unsigned Opc = Inst.getOpcode();
const MCInstrDesc &Desc = MII.get(Inst.getOpcode());
- bool HasModifiers =
- AMDGPU::hasNamedOperand(Opc, AMDGPU::OpName::src0_modifiers);
// MAC instructions are special because they have 'old'
// operand which is not tied to dst (but assumed to be).
@@ -8780,14 +8761,12 @@ void AMDGPUAsmParser::cvtVOP3DPP(MCInst &Inst, const OperandVector &Operands,
// Add the register arguments
if (IsDPP8 && Op.isFI()) {
Fi = Op.getImm();
- } else if (HasModifiers &&
- isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
+ } else if (isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
} else if (Op.isReg()) {
Op.addRegOperands(Inst, 1);
} else if (Op.isImm() &&
Desc.OpInfo[Inst.getNumOperands()].RegClass != -1) {
- assert(!HasModifiers && "Case should be unreachable with modifiers");
assert(!Op.IsImmKindLiteral() && "Cannot use literal with DPP");
Op.addImmOperands(Inst, 1);
} else if (Op.isImm()) {
@@ -8829,9 +8808,6 @@ void AMDGPUAsmParser::cvtVOP3DPP(MCInst &Inst, const OperandVector &Operands,
void AMDGPUAsmParser::cvtDPP(MCInst &Inst, const OperandVector &Operands, bool IsDPP8) {
OptionalImmIndexMap OptionalIdx;
- unsigned Opc = Inst.getOpcode();
- bool HasModifiers =
- AMDGPU::hasNamedOperand(Opc, AMDGPU::OpName::src0_modifiers);
unsigned I = 1;
const MCInstrDesc &Desc = MII.get(Inst.getOpcode());
for (unsigned J = 0; J < Desc.getNumDefs(); ++J) {
@@ -8858,8 +8834,7 @@ void AMDGPUAsmParser::cvtDPP(MCInst &Inst, const OperandVector &Operands, bool I
if (IsDPP8) {
if (Op.isDPP8()) {
Op.addImmOperands(Inst, 1);
- } else if (HasModifiers &&
- isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
+ } else if (isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
Op.addRegWithFPInputModsOperands(Inst, 2);
} else if (Op.isFI()) {
Fi = Op.getImm();
@@ -8869,8 +8844,7 @@ void AMDGPUAsmParser::cvtDPP(MCInst &Inst, const OperandVector &Operands, bool I
llvm_unreachable("Invalid operand type");
}
} else {
- if (HasModifiers &&
- isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
+ if (isRegOrImmWithInputMods(Desc, Inst.getNumOperands())) {
Op.addRegWithFPInputModsOperands(Inst, 2);
} else if (Op.isReg()) {
Op.addRegOperands(Inst, 1);
More information about the llvm-commits
mailing list