Skip to content

Commit b3de316

Browse files
committed
[M68k][MC] Make immediate operands relocatable
Sometimes memory addresses are treated as immediate values. Thus immediate operands have to be relocatable. Differential Revision: https://reviews.llvm.org/D137902
1 parent c40b158 commit b3de316

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

llvm/lib/Target/M68k/M68kInstrFormats.td

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,13 @@ class MxEncAddrMode_i<string opnd_name, int size> : MxEncMemOp {
326326
// Immediate
327327
let Supplement =
328328
!cond(
329-
!eq(size, 8) : (descend 0b00000000, (operand "$"#opnd_name, 8)),
330-
!eq(size, 16) : (operand "$"#opnd_name, 16),
331-
!eq(size, 32) : (ascend (slice "$"#opnd_name, 31, 16),
332-
(slice "$"#opnd_name, 15, 0))
329+
!eq(size, 8) : (descend 0b00000000, (operand "$"#opnd_name, 8,
330+
(encoder "encodeRelocImm<8>"))),
331+
!eq(size, 16) : (operand "$"#opnd_name, 16,
332+
(encoder "encodeRelocImm<16>")),
333+
!eq(size, 32) : (operand "$"#opnd_name, 32,
334+
(encoder "encodeRelocImm<32>"),
335+
(decoder "DecodeImm32"))
333336
);
334337
}
335338

llvm/test/MC/M68k/Relocations/data-abs.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@
77
; INSTR: move.l dst, %d0
88
; FIXUP: fixup A - offset: 2, value: dst, kind: FK_Data_4
99
move.l dst, %d0
10+
11+
; Relocating immediate values
12+
13+
; RELOC: R_68K_8 str8 0x0
14+
; INSTR: move.b #str8, (4,%sp)
15+
; FIXUP: fixup A - offset: 3, value: str8, kind: FK_Data_1
16+
move.b #str8, (4,%sp)
17+
18+
; RELOC: R_68K_16 str16 0x0
19+
; INSTR: move.w #str16, (4,%sp)
20+
; FIXUP: fixup A - offset: 2, value: str16, kind: FK_Data_2
21+
move.w #str16, (4,%sp)
22+
23+
; RELOC: R_68K_32 str32 0x0
24+
; INSTR: move.l #str32, (4,%sp)
25+
; FIXUP: fixup A - offset: 2, value: str32, kind: FK_Data_4
26+
move.l #str32, (4,%sp)

0 commit comments

Comments
 (0)