[PATCH] D67180: [MIPS GlobalISel] Select llvm.trap intrinsic
Petar Avramovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 04:15:15 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371055: [MIPS GlobalISel] Select llvm.trap intrinsic (authored by Petar.Avramovic, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D67180?vs=218715&id=218886#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67180/new/
https://reviews.llvm.org/D67180
Files:
llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/trap.mir
llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/trap.ll
Index: llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/trap.mir
===================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/trap.mir
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/trap.mir
@@ -0,0 +1,22 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
+--- |
+
+ declare void @llvm.trap()
+ define void @f() { ret void }
+
+...
+---
+name: f
+alignment: 2
+body: |
+ bb.1 (%ir-block.0):
+ ; MIPS32-LABEL: name: f
+ ; MIPS32: TRAP
+ ; MIPS32: RetRA
+ G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
+ RetRA
+
+...
+
+
Index: llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/trap.ll
===================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/trap.ll
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/trap.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
+
+ declare void @llvm.trap()
+
+ define void @f() {
+; MIPS32-LABEL: f:
+; MIPS32: # %bb.0:
+; MIPS32-NEXT: break
+; MIPS32-NEXT: jr $ra
+; MIPS32-NEXT: nop
+ call void @llvm.trap()
+ ret void
+ }
Index: llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
+++ llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
@@ -219,8 +219,16 @@
return true;
}
-bool MipsLegalizerInfo::legalizeIntrinsic(MachineInstr &MI, MachineRegisterInfo &MRI,
+bool MipsLegalizerInfo::legalizeIntrinsic(MachineInstr &MI,
+ MachineRegisterInfo &MRI,
MachineIRBuilder &MIRBuilder) const {
+ const MipsSubtarget &ST =
+ static_cast<const MipsSubtarget &>(MI.getMF()->getSubtarget());
+ const MipsInstrInfo &TII = *ST.getInstrInfo();
+ const MipsRegisterInfo &TRI = *ST.getRegisterInfo();
+ const RegisterBankInfo &RBI = *ST.getRegBankInfo();
+ MIRBuilder.setInstr(MI);
+
switch (MI.getIntrinsicID()) {
case Intrinsic::memcpy:
case Intrinsic::memset:
@@ -230,6 +238,11 @@
return false;
MI.eraseFromParent();
return true;
+ case Intrinsic::trap: {
+ MachineInstr *Trap = MIRBuilder.buildInstr(Mips::TRAP);
+ MI.eraseFromParent();
+ return constrainSelectedInstRegOperands(*Trap, TII, TRI, RBI);
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67180.218886.patch
Type: text/x-patch
Size: 2745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190905/ffdacc86/attachment.bin>
More information about the llvm-commits
mailing list