[llvm] b3de316 - [M68k][MC] Make immediate operands relocatable

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 22:02:59 PST 2023


Author: Min-Yih Hsu
Date: 2023-01-24T21:59:24-08:00
New Revision: b3de316420374536def0cc3bfb7d317db9fc830c

URL: https://github.com/llvm/llvm-project/commit/b3de316420374536def0cc3bfb7d317db9fc830c
DIFF: https://github.com/llvm/llvm-project/commit/b3de316420374536def0cc3bfb7d317db9fc830c.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Target/M68k/M68kInstrFormats.td
    llvm/test/MC/M68k/Relocations/data-abs.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/M68k/M68kInstrFormats.td b/llvm/lib/Target/M68k/M68kInstrFormats.td
index 2071a169545a..2343af09788e 100644
--- a/llvm/lib/Target/M68k/M68kInstrFormats.td
+++ b/llvm/lib/Target/M68k/M68kInstrFormats.td
@@ -326,10 +326,13 @@ class MxEncAddrMode_i<string opnd_name, int size> : MxEncMemOp {
   // Immediate
   let Supplement =
     !cond(
-      !eq(size, 8)  : (descend 0b00000000, (operand "$"#opnd_name, 8)),
-      !eq(size, 16) : (operand "$"#opnd_name, 16),
-      !eq(size, 32) : (ascend (slice "$"#opnd_name, 31, 16),
-                              (slice "$"#opnd_name, 15, 0))
+      !eq(size, 8)  : (descend 0b00000000, (operand "$"#opnd_name, 8,
+	                   (encoder "encodeRelocImm<8>"))),
+      !eq(size, 16) : (operand "$"#opnd_name, 16,
+                           (encoder "encodeRelocImm<16>")),
+      !eq(size, 32) : (operand "$"#opnd_name, 32,
+                           (encoder "encodeRelocImm<32>"),
+                           (decoder "DecodeImm32"))
     );
 }
 

diff  --git a/llvm/test/MC/M68k/Relocations/data-abs.s b/llvm/test/MC/M68k/Relocations/data-abs.s
index b8e678404a5f..b15007d8da36 100644
--- a/llvm/test/MC/M68k/Relocations/data-abs.s
+++ b/llvm/test/MC/M68k/Relocations/data-abs.s
@@ -7,3 +7,20 @@
 ; INSTR: move.l dst, %d0
 ; FIXUP: fixup A - offset: 2, value: dst, kind: FK_Data_4
 move.l	dst, %d0
+
+; Relocating immediate values
+
+; RELOC: R_68K_8 str8 0x0
+; INSTR: move.b  #str8,  (4,%sp)
+; FIXUP: fixup A - offset: 3, value: str8, kind: FK_Data_1
+move.b  #str8,  (4,%sp)
+
+; RELOC: R_68K_16 str16 0x0
+; INSTR: move.w  #str16,  (4,%sp)
+; FIXUP: fixup A - offset: 2, value: str16, kind: FK_Data_2
+move.w  #str16, (4,%sp)
+
+; RELOC: R_68K_32 str32 0x0
+; INSTR: move.l  #str32,  (4,%sp)
+; FIXUP: fixup A - offset: 2, value: str32, kind: FK_Data_4
+move.l  #str32, (4,%sp)


        


More information about the llvm-commits mailing list