diff --git a/llvm/lib/Target/M68k/M68kInstrData.td b/llvm/lib/Target/M68k/M68kInstrData.td --- a/llvm/lib/Target/M68k/M68kInstrData.td +++ b/llvm/lib/Target/M68k/M68kInstrData.td @@ -435,6 +435,33 @@ def LEA32 # AM : MxLEA("MxOp32AddrMode_"#AM), !cast("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 //===----------------------------------------------------------------------===// diff --git a/llvm/test/MC/Disassembler/M68k/data.txt b/llvm/test/MC/Disassembler/M68k/data.txt --- a/llvm/test/MC/Disassembler/M68k/data.txt +++ b/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 diff --git a/llvm/test/MC/M68k/Data/Classes/MxLink.s b/llvm/test/MC/M68k/Data/Classes/MxLink.s new file mode 100644 --- /dev/null +++ b/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