[PATCH] D125444: [M68k] Add MC support for link/unlk

Sheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 20:11:05 PDT 2022


0x59616e created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
0x59616e requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125444

Files:
  llvm/lib/Target/M68k/M68kInstrData.td
  llvm/test/MC/Disassembler/M68k/data.txt
  llvm/test/MC/M68k/Data/Classes/MxLink.s


Index: llvm/test/MC/M68k/Data/Classes/MxLink.s
===================================================================
--- /dev/null
+++ llvm/test/MC/M68k/Data/Classes/MxLink.s
@@ -0,0 +1,13 @@
+; RUN: llvm-mc -assemble --show-encoding -triple=m68k %s | FileCheck %s
+
+# CHECK:      link.w %a2, #1023
+# CHECK-SAME: encoding: [0x4e,0x52,0x03,0xff]
+link.w %a2, #1023
+
+# CHECK:      link.l %a1, #1073741823
+# CHECK-SAME: encoding: [0x48,0x09,0x3f,0xff,0xff,0xff]
+link.l %a1, #1073741823
+
+# CHECK:      unlk %a5
+# CHECK-SAME: encoding: [0x4e,0x5d]
+unlk %a5
\ No newline at end of file
Index: llvm/test/MC/Disassembler/M68k/data.txt
===================================================================
--- llvm/test/MC/Disassembler/M68k/data.txt
+++ llvm/test/MC/Disassembler/M68k/data.txt
@@ -2,5 +2,15 @@
 
 # CHECK: move.l %a1, %a0
 0x20 0x49
+
 # CHECK: lea (50,%a0), %a1
 0x43 0xe8 0x00 0x32
+
+# CHECK: link.w %a3, #31
+0x4e 0x53 0x00 0x1f
+
+# CHECK: link.l %a6, #65537
+0x48 0x0e 0x00 0x01 0x00 0x01
+
+# CHECK: unlk %a0
+0x4e 0x58
\ No newline at end of file
Index: llvm/lib/Target/M68k/M68kInstrData.td
===================================================================
--- llvm/lib/Target/M68k/M68kInstrData.td
+++ llvm/lib/Target/M68k/M68kInstrData.td
@@ -435,6 +435,33 @@
 def LEA32 # AM : MxLEA<!cast<MxOpBundle>("MxOp32AddrMode_"#AM),
                        !cast<MxEncMemOp>("MxMoveSrcOpEnc_"#AM)>;
 
+//===----------------------------------------------------------------------===//
+// LINK/UNLK
+//===----------------------------------------------------------------------===//
+
+let Uses = [SP], Defs = [SP] in {
+
+def LINK16 : MxInst<(outs MxARD16:$dst), (ins Mxi16imm:$disp), "link.w\t$dst, $disp", []> {
+  let Inst = (ascend
+    (descend 0b0100111001010, (operand "$dst", 3)),
+    (operand "$disp", 16)
+  );
+}
+
+def LINK32 : MxInst<(outs MxARD32:$dst), (ins Mxi32imm:$disp), "link.l\t$dst, $disp", []> {
+  let Inst = (ascend
+    (descend 0b0100100000001, (operand "$dst", 3)),
+    (slice "$disp", 31, 16),
+    (slice "$disp", 15, 0)
+  );
+}
+
+def UNLK : MxInst<(outs MxARD32:$dst), (ins), "unlk\t$dst", []> {
+  let Inst = (descend 0b0100111001011, (operand "$dst", 3));
+}
+
+} // let Uses = [SP], Defs = [SP]
+
 //===----------------------------------------------------------------------===//
 // Pseudos
 //===----------------------------------------------------------------------===//


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125444.428848.patch
Type: text/x-patch
Size: 2427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220512/df457013/attachment.bin>


More information about the llvm-commits mailing list