[llvm] [M68k][MC] Add support for DBcc instructions (PR #193930)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 24 02:51:03 PDT 2026
https://github.com/techmetx11 created https://github.com/llvm/llvm-project/pull/193930
None
>From 2be64664f2c679f09ab76ae0ce4833cf69e7102a Mon Sep 17 00:00:00 2001
From: techmetx11 <techmetx11 at disroot.org>
Date: Fri, 24 Apr 2026 10:42:16 +0100
Subject: [PATCH] [M68k][MC] Add support for DBcc instructions
---
llvm/lib/Target/M68k/M68kInstrControl.td | 24 ++++++++++++++++++++++
llvm/test/MC/M68k/Control/Classes/MxDBcc.s | 9 ++++++++
2 files changed, 33 insertions(+)
create mode 100644 llvm/test/MC/M68k/Control/Classes/MxDBcc.s
diff --git a/llvm/lib/Target/M68k/M68kInstrControl.td b/llvm/lib/Target/M68k/M68kInstrControl.td
index f6dcdb50e3455..3a49160283b99 100644
--- a/llvm/lib/Target/M68k/M68kInstrControl.td
+++ b/llvm/lib/Target/M68k/M68kInstrControl.td
@@ -267,6 +267,30 @@ def BSR32 : MxBsr<MxBrTarget32, MxType32, (descend 0b1111, 0b1111),
(operand "$dst", 32, (encoder "encodePCRelImm<32>"),
(decoder "DecodeImm32"))>;
+/// ---------------------------------------------------
+/// F E D C | B A 9 8 | 7 6 5 4 3 | 2 1 0
+/// ---------------------------------------------------
+/// 0 1 0 1 | CONDITION | 1 1 0 0 1 | REGISTER
+/// ---------------------------------------------------
+/// 16-BIT DISPLACEMENT
+/// ---------------------------------------------------
+let isBranch = 1, isTerminator = 1, Uses = [CCR] in
+class MxDBcc<string cc>
+ : MxInst<(outs MxDRD32:$reg), (ins TARGET:$dst), "db"#cc#"\t$reg, $dst", []> {
+ let Inst =
+ (ascend
+ (descend 0b0101, !cast<MxEncCondOp>("MxCC"#cc).Value, 0b11001, (operand $reg, 3)),
+ (operand "$dst", 16, (encoder "encodePCRelImm<16>")
+ );
+}
+
+foreach cc = [ "t", "f", "cc", "ls", "lt", "eq", "mi", "ne", "ge",
+ "cs", "pl", "gt", "hi", "vc", "le", "vs"] in {
+ def DB#cc : MxDBcc<cc>;
+}
+
+def DBRA: MxDBcc<"t">;
+
//===----------------------------------------------------------------------===//
// Call
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/MC/M68k/Control/Classes/MxDBcc.s b/llvm/test/MC/M68k/Control/Classes/MxDBcc.s
new file mode 100644
index 0000000000000..fdf8b5e7f4626
--- /dev/null
+++ b/llvm/test/MC/M68k/Control/Classes/MxDBcc.s
@@ -0,0 +1,9 @@
+; RUN: llvm-mc -triple=m68k -motorola-integers -show-encoding %s | FileCheck %s
+
+; CHECK: dbt %d0, $1
+; CHECK-SAME: encoding: [0x50,0xc8,0x00,0x01]
+dbt %d0, $1
+
+; CHECK: dbcc %d4, $28
+; CHECK-SAME: encoding: [0x54,0xcc,0x00,0x28]
+dbcc %d4, $28
More information about the llvm-commits
mailing list