@@ -165,9 +165,11 @@ def MxSize8 : MxSize<8, "b", "byte">;
165
165
def MxSize16 : MxSize<16, "w", "word">;
166
166
def MxSize32 : MxSize<32, "l", "long">;
167
167
168
- class MxOpClass<string name> : AsmOperandClass {
168
+ class MxOpClass<string name,
169
+ list<AsmOperandClass> superClasses = []> : AsmOperandClass {
169
170
let Name = name;
170
171
let ParserMethod = "parseMemOp";
172
+ let SuperClasses = superClasses;
171
173
}
172
174
173
175
def MxRegClass : MxOpClass<"Reg">;
@@ -176,7 +178,7 @@ def MxRegClass : MxOpClass<"Reg">;
176
178
// both ADD32dd and ADD32dr has {MCK_RegClass, MCK_RegClass} for
177
179
// their operands, which makes AsmParser unable to pick the correct
178
180
// one in a deterministic way.
179
- let RenderMethod = "addRegOperands", SuperClasses = [MxRegClass] in {
181
+ let RenderMethod = "addRegOperands", SuperClasses = [MxRegClass]in {
180
182
def MxARegClass : MxOpClass<"AReg">;
181
183
def MxDRegClass : MxOpClass<"DReg">;
182
184
}
@@ -317,19 +319,27 @@ def MxARII32_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize32, "f", "printA
317
319
// extended before it is used. The reference is classified as a data reference
318
320
// with the exception of the jump and jump-tosubroutine instructions.
319
321
def MxAddr : MxOpClass<"Addr">;
320
- def MxAS8 : MxMemOp<(ops OtherVT), MxSize8, "B", "printAS8Mem", MxAddr>;
321
- def MxAS16 : MxMemOp<(ops OtherVT), MxSize16, "B", "printAS16Mem", MxAddr>;
322
- def MxAS32 : MxMemOp<(ops OtherVT), MxSize32, "B", "printAS32Mem", MxAddr>;
322
+ let RenderMethod = "addAddrOperands" in {
323
+ // This hierarchy ensures Addr8 will always be parsed
324
+ // before other larger-width variants.
325
+ def MxAddr32 : MxOpClass<"Addr32", [MxAddr]>;
326
+ def MxAddr16 : MxOpClass<"Addr16", [MxAddr32]>;
327
+ def MxAddr8 : MxOpClass<"Addr8", [MxAddr16]>;
328
+ }
329
+
330
+ def MxAS8 : MxMemOp<(ops OtherVT), MxSize8, "B", "printAS8Mem", MxAddr8>;
331
+ def MxAS16 : MxMemOp<(ops OtherVT), MxSize16, "B", "printAS16Mem", MxAddr16>;
332
+ def MxAS32 : MxMemOp<(ops OtherVT), MxSize32, "B", "printAS32Mem", MxAddr32>;
323
333
324
334
// ABSOLUTE LONG ADDRESS. This addressing mode requires two words of extension.
325
335
// The address of the operand is developed by the concatenation of the extension
326
336
// words. The high order part of the address is the first extension word; the low
327
337
// order part of the address is the second extension word. The reference is
328
338
// classified as a data reference with the exception of the jump and jump
329
339
// to-subroutine instructions.
330
- def MxAL8 : MxMemOp<(ops OtherVT), MxSize8, "b", "printAL8Mem", MxAddr >;
331
- def MxAL16 : MxMemOp<(ops OtherVT), MxSize16, "b", "printAL16Mem", MxAddr >;
332
- def MxAL32 : MxMemOp<(ops OtherVT), MxSize32, "b", "printAL32Mem", MxAddr >;
340
+ def MxAL8 : MxMemOp<(ops OtherVT), MxSize8, "b", "printAL8Mem", MxAddr8 >;
341
+ def MxAL16 : MxMemOp<(ops OtherVT), MxSize16, "b", "printAL16Mem", MxAddr16 >;
342
+ def MxAL32 : MxMemOp<(ops OtherVT), MxSize32, "b", "printAL32Mem", MxAddr32 >;
333
343
334
344
def MxPCD : MxOpClass<"PCD">;
335
345
def MxPCI : MxOpClass<"PCI">;
@@ -383,16 +393,15 @@ def Mxi16imm : MxOp<i16, MxSize16, "i">;
383
393
def Mxi32imm : MxOp<i32, MxSize32, "i">;
384
394
} // OPERAND_IMMEDIATE
385
395
386
- let OperandType = "OPERAND_PCREL",
387
- ParserMatchClass = MxAddr,
388
- PrintMethod = "printPCRelImm" in {
389
-
396
+ class MxBrTargetOperand<int N> : Operand<OtherVT> {
397
+ let OperandType = "OPERAND_PCREL";
398
+ let PrintMethod = "printPCRelImm";
399
+ let ParserMatchClass = !cast<AsmOperandClass>("MxAddr"#N);
400
+ }
390
401
// Branch targets have OtherVT type and print as pc-relative values.
391
- def MxBrTarget8 : Operand<OtherVT>;
392
- def MxBrTarget16 : Operand<OtherVT>;
393
- def MxBrTarget32 : Operand<OtherVT>;
394
-
395
- } // OPERAND_PCREL
402
+ def MxBrTarget8 : MxBrTargetOperand<8>;
403
+ def MxBrTarget16 : MxBrTargetOperand<16>;
404
+ def MxBrTarget32 : MxBrTargetOperand<32>;
396
405
397
406
// Used with MOVEM
398
407
def MxMoveMask : MxOp<i16, MxSize16, "m"> {
0 commit comments