Skip to content

Commit b54628f

Browse files
authored
[M68k] Fix encoding of CAS instructions (llvm#154481)
The immediate part of memory operands was not encoded.
1 parent 95a4c9c commit b54628f

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

llvm/lib/Target/M68k/M68kInstrAtomics.td

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class MxCASARIDOp<bits<2> size_encoding, MxType type>
6767
"cas."#type.Prefix#" $dc, $du, $mem"> {
6868
let Inst = (ascend
6969
(descend 0b00001, size_encoding, 0b011, MxEncAddrMode_p<"mem">.EA),
70-
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3))
70+
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3)),
71+
MxEncAddrMode_p<"mem">.Supplement
7172
);
7273
let Constraints = "$out = $dc";
7374
let mayLoad = 1;
@@ -84,7 +85,8 @@ class MxCASARIIOp<bits<2> size_encoding, MxType type>
8485
"cas."#type.Prefix#" $dc, $du, $mem"> {
8586
let Inst = (ascend
8687
(descend 0b00001, size_encoding, 0b011, MxEncAddrMode_f<"mem">.EA),
87-
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3))
88+
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3)),
89+
MxEncAddrMode_f<"mem">.Supplement
8890
);
8991
let Constraints = "$out = $dc";
9092
let mayLoad = 1;
@@ -100,8 +102,9 @@ class MxCASALOp<bits<2> size_encoding, MxType type>
100102
(ins type.ROp:$dc, type.ROp:$du, !cast<MxMemOp>("MxAL"#type.Size):$mem),
101103
"cas."#type.Prefix#" $dc, $du, $mem"> {
102104
let Inst = (ascend
103-
(descend 0b00001, size_encoding, 0b011, MxEncAddrMode_abs<"mem">.EA),
104-
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3))
105+
(descend 0b00001, size_encoding, 0b011, MxEncAddrMode_abs<"mem", true>.EA),
106+
(descend 0b0000000, (operand "$du", 3), 0b000, (operand "$dc", 3)),
107+
MxEncAddrMode_abs<"mem", true>.Supplement
105108
);
106109
let Constraints = "$out = $dc";
107110
let mayLoad = 1;

llvm/test/MC/M68k/Atomics/cas.s

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,39 @@ cas.l %d6, %d7, (%a4)
1515

1616
; Address Register Indirect with Displacement
1717
; CHECK: cas.b %d3, %d2, (5,%a2)
18-
; CHECK-SAME: ; encoding: [0x0a,0xea,0x00,0x83]
18+
; CHECK-SAME: ; encoding: [0x0a,0xea,0x00,0x83,0x00,0x05]
1919
cas.b %d3, %d2, (5, %a2)
2020

2121
; CHECK: cas.w %d4, %d5, (6,%a3)
22-
; CHECK-SAME: ; encoding: [0x0c,0xeb,0x01,0x44]
22+
; CHECK-SAME: ; encoding: [0x0c,0xeb,0x01,0x44,0x00,0x06]
2323
cas.w %d4, %d5, (6, %a3)
2424

2525
; CHECK: cas.l %d6, %d7, (7,%a4)
26-
; CHECK-SAME: ; encoding: [0x0e,0xec,0x01,0xc6]
26+
; CHECK-SAME: ; encoding: [0x0e,0xec,0x01,0xc6,0x00,0x07]
2727
cas.l %d6, %d7, (7, %a4)
2828

2929
; Address Register Indirect with Index (Scale = 1)
3030
; CHECK: cas.b %d3, %d2, (5,%a2,%d1)
31-
; CHECK-SAME: ; encoding: [0x0a,0xf2,0x00,0x83]
31+
; CHECK-SAME: ; encoding: [0x0a,0xf2,0x00,0x83,0x18,0x05]
3232
cas.b %d3, %d2, (5, %a2, %d1)
3333

3434
; CHECK: cas.w %d4, %d5, (6,%a3,%d1)
35-
; CHECK-SAME: ; encoding: [0x0c,0xf3,0x01,0x44]
35+
; CHECK-SAME: ; encoding: [0x0c,0xf3,0x01,0x44,0x18,0x06]
3636
cas.w %d4, %d5, (6, %a3, %d1)
3737

3838
; CHECK: cas.l %d6, %d7, (7,%a4,%d1)
39-
; CHECK-SAME: ; encoding: [0x0e,0xf4,0x01,0xc6]
39+
; CHECK-SAME: ; encoding: [0x0e,0xf4,0x01,0xc6,0x18,0x07]
4040
cas.l %d6, %d7, (7, %a4, %d1)
4141

4242
; Absolute Long Address
4343
; CHECK: cas.b %d3, %d2, $ffffffffffffffff
44-
; CHECK-SAME: ; encoding: [0x0a,0xf8,0x00,0x83]
44+
; CHECK-SAME: ; encoding: [0x0a,0xf9,0x00,0x83,0xff,0xff,0xff,0xff]
4545
cas.b %d3, %d2, $ffffffffffffffff
4646

4747
; CHECK: cas.w %d4, %d5, $ffffffffffffffff
48-
; CHECK-SAME: ; encoding: [0x0c,0xf8,0x01,0x44]
48+
; CHECK-SAME: ; encoding: [0x0c,0xf9,0x01,0x44,0xff,0xff,0xff,0xff]
4949
cas.w %d4, %d5, $ffffffffffffffff
5050

5151
; CHECK: cas.l %d6, %d7, $ffffffffffffffff
52-
; CHECK-SAME: ; encoding: [0x0e,0xf8,0x01,0xc6]
52+
; CHECK-SAME: ; encoding: [0x0e,0xf9,0x01,0xc6,0xff,0xff,0xff,0xff]
5353
cas.l %d6, %d7, $ffffffffffffffff

0 commit comments

Comments
 (0)