@@ -373,7 +373,7 @@ class AMDGPUOperand : public MCParsedAsmOperand {
373
373
bool isOffen () const { return isImmTy (ImmTyOffen); }
374
374
bool isIdxen () const { return isImmTy (ImmTyIdxen); }
375
375
bool isAddr64 () const { return isImmTy (ImmTyAddr64); }
376
- bool isOffset () const { return isImmTy (ImmTyOffset) && isUInt< 16 >( getImm ()) ; }
376
+ bool isOffset () const { return isImmTy (ImmTyOffset); }
377
377
bool isOffset0 () const { return isImmTy (ImmTyOffset0) && isUInt<8 >(getImm ()); }
378
378
bool isOffset1 () const { return isImmTy (ImmTyOffset1) && isUInt<8 >(getImm ()); }
379
379
bool isSMEMOffsetMod () const { return isImmTy (ImmTySMEMOffsetMod); }
@@ -1666,6 +1666,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
1666
1666
SMLoc getInstLoc (const OperandVector &Operands) const ;
1667
1667
1668
1668
bool validateInstruction (const MCInst &Inst, const SMLoc &IDLoc, const OperandVector &Operands);
1669
+ bool validateOffset (const MCInst &Inst, const OperandVector &Operands);
1669
1670
bool validateFlatOffset (const MCInst &Inst, const OperandVector &Operands);
1670
1671
bool validateSMEMOffset (const MCInst &Inst, const OperandVector &Operands);
1671
1672
bool validateSOPLiteral (const MCInst &Inst) const ;
@@ -4143,6 +4144,40 @@ SMLoc AMDGPUAsmParser::getFlatOffsetLoc(const OperandVector &Operands) const {
4143
4144
return getLoc ();
4144
4145
}
4145
4146
4147
+ bool AMDGPUAsmParser::validateOffset (const MCInst &Inst,
4148
+ const OperandVector &Operands) {
4149
+ auto Opcode = Inst.getOpcode ();
4150
+ auto OpNum = AMDGPU::getNamedOperandIdx (Opcode, AMDGPU::OpName::offset);
4151
+ if (OpNum == -1 )
4152
+ return true ;
4153
+
4154
+ uint64_t TSFlags = MII.get (Inst.getOpcode ()).TSFlags ;
4155
+ if ((TSFlags & SIInstrFlags::FLAT))
4156
+ return validateFlatOffset (Inst, Operands);
4157
+
4158
+ if ((TSFlags & SIInstrFlags::SMRD))
4159
+ return validateSMEMOffset (Inst, Operands);
4160
+
4161
+ const auto &Op = Inst.getOperand (OpNum);
4162
+ if (isGFX12Plus () &&
4163
+ (TSFlags & (SIInstrFlags::MUBUF | SIInstrFlags::MTBUF))) {
4164
+ const unsigned OffsetSize = 24 ;
4165
+ if (!isIntN (OffsetSize, Op.getImm ())) {
4166
+ Error (getFlatOffsetLoc (Operands),
4167
+ Twine (" expected a " ) + Twine (OffsetSize) + " -bit signed offset" );
4168
+ return false ;
4169
+ }
4170
+ } else {
4171
+ const unsigned OffsetSize = 16 ;
4172
+ if (!isUIntN (OffsetSize, Op.getImm ())) {
4173
+ Error (getFlatOffsetLoc (Operands),
4174
+ Twine (" expected a " ) + Twine (OffsetSize) + " -bit unsigned offset" );
4175
+ return false ;
4176
+ }
4177
+ }
4178
+ return true ;
4179
+ }
4180
+
4146
4181
bool AMDGPUAsmParser::validateFlatOffset (const MCInst &Inst,
4147
4182
const OperandVector &Operands) {
4148
4183
uint64_t TSFlags = MII.get (Inst.getOpcode ()).TSFlags ;
@@ -4800,10 +4835,7 @@ bool AMDGPUAsmParser::validateInstruction(const MCInst &Inst,
4800
4835
if (!validateMovrels (Inst, Operands)) {
4801
4836
return false ;
4802
4837
}
4803
- if (!validateFlatOffset (Inst, Operands)) {
4804
- return false ;
4805
- }
4806
- if (!validateSMEMOffset (Inst, Operands)) {
4838
+ if (!validateOffset (Inst, Operands)) {
4807
4839
return false ;
4808
4840
}
4809
4841
if (!validateMAIAccWrite (Inst, Operands)) {
0 commit comments