[PATCH] D70945: Handle BUNDLE instructions in MipsAsmPrinter

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 01:01:27 PST 2019


arichardson created this revision.
arichardson added a reviewer: atanasyan.
Herald added subscribers: llvm-commits, jrtc27, hiraditya, sdardis.
Herald added a project: LLVM.
arichardson added a parent revision: D70944: MipsDelaySlotFiller: Don't move BUNDLE instructions into the delay slot.

In our CHERI fork we use BUNDLE instructions to ensure that a
three-instruction sequence to generate a program-counter-relative value is
emitted without reordering or insertions (since that would break the 32-bit
offset computation).

Currently MipsAsmPrinter asserts when it encounters a pseudo instruction.
To handle BUNDLE we can simply skip the instruction which will then make
EmitInstruction() process the contents of the bundle in order.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70945

Files:
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/delay-slot-filler-bundled-insts.mir


Index: llvm/test/CodeGen/Mips/delay-slot-filler-bundled-insts.mir
===================================================================
--- llvm/test/CodeGen/Mips/delay-slot-filler-bundled-insts.mir
+++ llvm/test/CodeGen/Mips/delay-slot-filler-bundled-insts.mir
@@ -2,6 +2,17 @@
 ## Check that the delay-slot filler does not attempt to split BUNDLE instructions
 # RUN: llc %s -start-before=mips-delay-slot-filler -stop-after=mips-delay-slot-filler \
 # RUN:   -verify-machineinstrs -o - | FileCheck %s
+## Check that we can emit assembly for input with BUNDLE instructions:
+# RUN: llc %s -start-before=mips-delay-slot-filler -verify-machineinstrs -o - | FileCheck %s -check-prefix ASM
+
+# ASM:  # %bb.0:
+# ASM-NEXT: daddiu	$sp, $sp, -16
+# ASM-NEXT: sd	$ra, 8($sp)
+## BUNDLE should be emitted in order:
+# ASM-NEXT: daddiu	$sp, $sp, -16
+# ASM-NEXT: daddiu	$sp, $sp, 16
+# ASM-NEXT: beqz	$4, .LBB0_2
+# ASM-NEXT: nop
 --- |
   target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
   target triple = "mips64-unknown-freebsd"
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -257,6 +257,10 @@
     if (emitPseudoExpansionLowering(*OutStreamer, &*I))
       continue;
 
+    // Skip the BUNDLE pseudo instruction and lower the contents
+    if (I->isBundle())
+      continue;
+
     if (I->getOpcode() == Mips::PseudoReturn ||
         I->getOpcode() == Mips::PseudoReturn64 ||
         I->getOpcode() == Mips::PseudoIndirectBranch ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70945.231841.patch
Type: text/x-patch
Size: 1605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191203/bb417ac5/attachment.bin>


More information about the llvm-commits mailing list