Files
clang-p2996/llvm/test/CodeGen/AArch64/fpmode.ll
Serge Pavlov 9e30c96aee [AArch64] Lowering of fpmode intrinsics in DAG (#80611)
LLVM intrinsics `get_fpmode`, `set_fpmode` and `reset_fpmode` operate
control modes, the bits of FP environment that affect FP operations. On
AArch64 these bits are in FPCR. The lowering implemented to produce code
close to that of GLIBC.
2024-04-27 19:01:24 +07:00

69 lines
2.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | FileCheck --check-prefix=DAG %s
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel %s -o - | FileCheck --check-prefix=GIS %s
declare i32 @llvm.get.fpmode.i32()
declare void @llvm.set.fpmode.i32(i32 %fpmode)
declare void @llvm.reset.fpmode()
define i32 @func_get_fpmode() #0 {
; DAG-LABEL: func_get_fpmode:
; DAG: // %bb.0: // %entry
; DAG-NEXT: mrs x0, FPCR
; DAG-NEXT: // kill: def $w0 killed $w0 killed $x0
; DAG-NEXT: ret
;
; GIS-LABEL: func_get_fpmode:
; GIS: // %bb.0: // %entry
; GIS-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; GIS-NEXT: add x0, sp, #12
; GIS-NEXT: bl fegetmode
; GIS-NEXT: ldr w0, [sp, #12]
; GIS-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; GIS-NEXT: ret
entry:
%fpmode = call i32 @llvm.get.fpmode.i32()
ret i32 %fpmode
}
define void @func_set_fpmode(i32 %fpmode) #0 {
; DAG-LABEL: func_set_fpmode:
; DAG: // %bb.0: // %entry
; DAG-NEXT: mov w8, w0
; DAG-NEXT: msr FPCR, x8
; DAG-NEXT: ret
;
; GIS-LABEL: func_set_fpmode:
; GIS: // %bb.0: // %entry
; GIS-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; GIS-NEXT: str w0, [sp, #12]
; GIS-NEXT: add x0, sp, #12
; GIS-NEXT: bl fesetmode
; GIS-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; GIS-NEXT: ret
entry:
call void @llvm.set.fpmode.i32(i32 %fpmode)
ret void
}
define void @func_reset_fpmode() #0 {
; DAG-LABEL: func_reset_fpmode:
; DAG: // %bb.0: // %entry
; DAG-NEXT: mov x9, #-48904 // =0xffffffffffff40f8
; DAG-NEXT: mrs x8, FPCR
; DAG-NEXT: movk x9, #63488, lsl #16
; DAG-NEXT: and x8, x8, x9
; DAG-NEXT: msr FPCR, x8
; DAG-NEXT: ret
;
; GIS-LABEL: func_reset_fpmode:
; GIS: // %bb.0: // %entry
; GIS-NEXT: mov x0, #-1 // =0xffffffffffffffff
; GIS-NEXT: b fesetmode
entry:
call void @llvm.reset.fpmode()
ret void
}
attributes #0 = { nounwind }