Skip to content

Commit 1ff630d

Browse files
[LLVM][NVPTX] Add support for brkpt instruction (#104470)
This commit adds NVPTX codegen support for brkpt instruction (https://docs.nvidia.com/cuda/parallel-thread-execution/#miscellaneous-instructions-brkpt) with test under CodeGen/NVPTX/brkpt.ll
1 parent f44f026 commit 1ff630d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,8 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
648648

649649
// TRAP can be lowered to PTX trap
650650
setOperationAction(ISD::TRAP, MVT::Other, Legal);
651+
// DEBUGTRAP can be lowered to PTX brkpt
652+
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
651653

652654
// Register custom handling for vector loads/stores
653655
for (MVT VT : MVT::fixedlen_vector_valuetypes()) {

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,8 @@ def Callseq_End :
38453845
// Emit an `exit` as well to convey to ptxas that `trap` exits the CFG.
38463846
// This won't be necessary in a future version of ptxas.
38473847
def trapinst : NVPTXInst<(outs), (ins), "trap; exit;", [(trap)]>;
3848+
// brkpt instruction
3849+
def debugtrapinst : NVPTXInst<(outs), (ins), "brkpt;", [(debugtrap)]>;
38483850

38493851
// Call prototype wrapper
38503852
def SDTCallPrototype : SDTypeProfile<0, 1, [SDTCisInt<0>]>;

llvm/test/CodeGen/NVPTX/brkpt.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc -o - -march=nvptx64 %s | FileCheck %s
2+
3+
; CHECK-LABEL: .func breakpoint
4+
define void @breakpoint() {
5+
; CHECK: brkpt;
6+
call void @llvm.debugtrap()
7+
ret void
8+
}

0 commit comments

Comments
 (0)