[PATCH] D147102: [M68k] Add `TRAP`, `TRAPV`, `BKPT`, `ILLEGAL` instructions

Ian D. Scott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 20:17:28 PDT 2023


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

This makes it possible to use `TRAP` to make Linux system calls using inline assembly for instance.

This does not validate that the 4 and 3 bit immediates taken by `TRAP` and `BKPT` are in range. But it seems the backend isn't validating the range of immediates in general.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147102

Files:
  llvm/lib/Target/M68k/M68kInstrControl.td


Index: llvm/lib/Target/M68k/M68kInstrControl.td
===================================================================
--- llvm/lib/Target/M68k/M68kInstrControl.td
+++ llvm/lib/Target/M68k/M68kInstrControl.td
@@ -353,3 +353,19 @@
           (ADDX8dd MxDRD8:$op, (MOV8di 0))>;
 def : Pat<(sub MxXRD32:$op, (i32 (MxSetCC_C MxCONDcs, CCR))),
           (ADDX32dd MxDRD32:$op, (MOV32ri 0))>;
+
+def TRAP : MxInst<(outs), (ins Mxi8imm:$vect), "trap\t$vect", []> {
+  let Inst = (descend 0b0100, 0b1110, 0b0100, (operand "$vect", 4));
+}
+
+def TRAPV : MxInst<(outs), (ins), "trapv", []> {
+  let Inst = (descend 0b0100, 0b1110, 0b0111, 0b0110);
+}
+
+def BKPT : MxInst<(outs), (ins Mxi8imm:$vect), "bkpt\t$vect", []> {
+  let Inst = (descend 0b0100, 0b1000, 0b0100, 0b1 , (operand "$vect", 3));
+}
+
+def ILLEGAL : MxInst<(outs), (ins), "illegal", []> {
+  let Inst = (descend 0b0100, 0b1010, 0b1111, 0b1100);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147102.509194.patch
Type: text/x-patch
Size: 905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230329/51c0daac/attachment.bin>


More information about the llvm-commits mailing list