hev 426cedccd3
[LoongArch] Add support for the ud macro instruction (#171583)
This patch adds support for the `ud ui5` macro instruction. The `ui5`
operand must be inthe range `0-31`. The macro expands to:

`amswap.w $rd, $r1, $rj`

where `ui5` specifies the register number used for `$rd` in the expanded
instruction, and `$rd` is the same as `$rj`.

Relevant binutils patch:

https://sourceware.org/pipermail/binutils/2025-December/146042.html
2025-12-11 13:31:03 +08:00

27 lines
743 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc --mtriple=loongarch32 -mattr=+d --verify-machineinstrs < %s | FileCheck %s
; RUN: llc --mtriple=loongarch64 -mattr=+d --verify-machineinstrs < %s | FileCheck %s
;; Verify that we lower @llvm.trap() and @llvm.debugtrap() correctly.
declare void @llvm.trap()
declare void @llvm.debugtrap()
define void @test_trap() nounwind {
; CHECK-LABEL: test_trap:
; CHECK: # %bb.0:
; CHECK-NEXT: ud 0
; CHECK-NEXT: ret
tail call void @llvm.trap()
ret void
}
define void @test_debugtrap() nounwind {
; CHECK-LABEL: test_debugtrap:
; CHECK: # %bb.0:
; CHECK-NEXT: break 0
; CHECK-NEXT: ret
tail call void @llvm.debugtrap()
ret void
}