Skip to content

Commit 2576a81

Browse files
committed
[AMDGPU][AsmParser] Eliminate custom predicates for named-bit operands.
isGDS() and isTFE() need special treatment, because they may be both named-bit and token operands. Part of #62629.
1 parent 12bf423 commit 2576a81

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstructions.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ def InstFlag : OperandWithDefaultOps <i32, (ops (i32 0))>;
125125

126126
def i1imm_0 : OperandWithDefaultOps<i1, (ops (i1 0))>;
127127

128-
class CustomOperandClass<string name, bit optional, string parserMethod,
129-
string defaultMethod>
128+
class CustomOperandClass<string name, bit optional, string predicateMethod,
129+
string parserMethod, string defaultMethod>
130130
: AsmOperandClass {
131131
let Name = name;
132-
let PredicateMethod = "is"#name;
132+
let PredicateMethod = predicateMethod;
133133
let ParserMethod = parserMethod;
134134
let RenderMethod = "addImmOperands";
135135
let IsOptional = optional;
@@ -138,14 +138,16 @@ class CustomOperandClass<string name, bit optional, string parserMethod,
138138

139139
class CustomOperandProps<bit optional = 0, string name = NAME> {
140140
string ImmTy = "ImmTy"#name;
141+
string PredicateMethod = "is"#name;
141142
string ParserMethod = "parse"#name;
142143
string DefaultValue = "0";
143144
string DefaultMethod = "[this]() { return "#
144145
"AMDGPUOperand::CreateImm(this, "#DefaultValue#", SMLoc(), "#
145146
"AMDGPUOperand::"#ImmTy#"); }";
146147
string PrintMethod = "print"#name;
147148
AsmOperandClass ParserMatchClass =
148-
CustomOperandClass<name, optional, ParserMethod, DefaultMethod>;
149+
CustomOperandClass<name, optional, PredicateMethod, ParserMethod,
150+
DefaultMethod>;
149151
string OperandType = "OPERAND_IMMEDIATE";
150152
}
151153

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,25 +356,20 @@ class AMDGPUOperand : public MCParsedAsmOperand {
356356
return isImm() && Imm.Type == ImmT;
357357
}
358358

359+
template <ImmTy Ty> bool isImmTy() const { return isImmTy(Ty); }
360+
359361
bool isImmLiteral() const { return isImmTy(ImmTyNone); }
360362

361363
bool isImmModifier() const {
362364
return isImm() && Imm.Type != ImmTyNone;
363365
}
364366

365-
bool isClampSI() const { return isImmTy(ImmTyClampSI); }
366367
bool isOModSI() const { return isImmTy(ImmTyOModSI); }
367368
bool isDMask() const { return isImmTy(ImmTyDMask); }
368369
bool isDim() const { return isImmTy(ImmTyDim); }
369-
bool isUNorm() const { return isImmTy(ImmTyUNorm); }
370-
bool isDA() const { return isImmTy(ImmTyDA); }
371370
bool isR128A16() const { return isImmTy(ImmTyR128A16); }
372-
bool isA16() const { return isImmTy(ImmTyA16); }
373-
bool isLWE() const { return isImmTy(ImmTyLWE); }
374371
bool isOff() const { return isImmTy(ImmTyOff); }
375372
bool isExpTgt() const { return isImmTy(ImmTyExpTgt); }
376-
bool isExpVM() const { return isImmTy(ImmTyExpVM); }
377-
bool isExpCompr() const { return isImmTy(ImmTyExpCompr); }
378373
bool isOffen() const { return isImmTy(ImmTyOffen); }
379374
bool isIdxen() const { return isImmTy(ImmTyIdxen); }
380375
bool isAddr64() const { return isImmTy(ImmTyAddr64); }
@@ -387,7 +382,6 @@ class AMDGPUOperand : public MCParsedAsmOperand {
387382
bool isLDS() const { return isImmTy(ImmTyLDS); }
388383
bool isCPol() const { return isImmTy(ImmTyCPol); }
389384
bool isTFE() const { return isImmTy(ImmTyTFE); }
390-
bool isD16() const { return isImmTy(ImmTyD16); }
391385
bool isFORMAT() const { return isImmTy(ImmTyFORMAT) && isUInt<7>(getImm()); }
392386
bool isDppBankMask() const { return isImmTy(ImmTyDppBankMask); }
393387
bool isDppRowMask() const { return isImmTy(ImmTyDppRowMask); }
@@ -404,7 +398,6 @@ class AMDGPUOperand : public MCParsedAsmOperand {
404398
bool isOpSelHi() const { return isImmTy(ImmTyOpSelHi); }
405399
bool isNegLo() const { return isImmTy(ImmTyNegLo); }
406400
bool isNegHi() const { return isImmTy(ImmTyNegHi); }
407-
bool isHigh() const { return isImmTy(ImmTyHigh); }
408401

409402
bool isRegOrImm() const {
410403
return isReg() || isImm();

llvm/lib/Target/AMDGPU/SIInstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME,
10451045

10461046
class NamedBitOperand<string Id, string Name = NAME>
10471047
: CustomOperand<i1, 1, Name> {
1048+
let PredicateMethod = "isImmTy<AMDGPUOperand::"#ImmTy#">";
10481049
let ParserMethod =
10491050
"[this](OperandVector &Operands) -> ParseStatus { "#
10501051
"return parseNamedBit(\""#Id#"\", Operands, AMDGPUOperand::"#ImmTy#"); }";
@@ -1056,6 +1057,7 @@ class NamedBitOperand<string Id, string Name = NAME>
10561057
class DefaultOperand<CustomOperand Op, int Value>
10571058
: OperandWithDefaultOps<Op.Type, (ops (Op.Type Value))>,
10581059
CustomOperandProps<1, Op.ParserMatchClass.Name> {
1060+
let PredicateMethod = Op.ParserMatchClass.PredicateMethod;
10591061
let ParserMethod = Op.ParserMatchClass.ParserMethod;
10601062
let PrintMethod = Op.PrintMethod;
10611063
}

0 commit comments

Comments
 (0)