[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)
Chen Zheng via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 2 00:19:18 PST 2024
================
@@ -77,4 +77,196 @@ return: ; preds = %entry
ret i32 %retval3
}
-declare i32 @llvm.get.rounding() nounwind
+define void @setrnd_tozero() {
+; PPC32-LABEL: setrnd_tozero:
+; PPC32: # %bb.0: # %entry
+; PPC32-NEXT: mtfsb0 30
+; PPC32-NEXT: mtfsb1 31
+; PPC32-NEXT: blr
+;
+; PPC64-LABEL: setrnd_tozero:
+; PPC64: # %bb.0: # %entry
+; PPC64-NEXT: mtfsb0 30
+; PPC64-NEXT: mtfsb1 31
+; PPC64-NEXT: blr
+;
+; PPC64LE-LABEL: setrnd_tozero:
+; PPC64LE: # %bb.0: # %entry
+; PPC64LE-NEXT: mtfsb0 30
+; PPC64LE-NEXT: mtfsb1 31
+; PPC64LE-NEXT: blr
+;
+; DM-LABEL: setrnd_tozero:
+; DM: # %bb.0: # %entry
+; DM-NEXT: mtfsb0 30
+; DM-NEXT: mtfsb1 31
+; DM-NEXT: blr
+entry:
+ call void @llvm.set.rounding(i32 0)
+ ret void
+}
+
+define void @setrnd_tonearest_tieeven() {
+; PPC32-LABEL: setrnd_tonearest_tieeven:
+; PPC32: # %bb.0: # %entry
+; PPC32-NEXT: mtfsb0 30
+; PPC32-NEXT: mtfsb0 31
+; PPC32-NEXT: blr
+;
+; PPC64-LABEL: setrnd_tonearest_tieeven:
+; PPC64: # %bb.0: # %entry
+; PPC64-NEXT: mtfsb0 30
+; PPC64-NEXT: mtfsb0 31
+; PPC64-NEXT: blr
+;
+; PPC64LE-LABEL: setrnd_tonearest_tieeven:
+; PPC64LE: # %bb.0: # %entry
+; PPC64LE-NEXT: mtfsb0 30
+; PPC64LE-NEXT: mtfsb0 31
+; PPC64LE-NEXT: blr
+;
+; DM-LABEL: setrnd_tonearest_tieeven:
+; DM: # %bb.0: # %entry
+; DM-NEXT: mtfsb0 30
+; DM-NEXT: mtfsb0 31
+; DM-NEXT: blr
+entry:
+ call void @llvm.set.rounding(i32 1)
+ ret void
+}
+
+define void @setrnd_toposinf() {
+; PPC32-LABEL: setrnd_toposinf:
+; PPC32: # %bb.0: # %entry
+; PPC32-NEXT: mtfsb1 30
+; PPC32-NEXT: mtfsb0 31
+; PPC32-NEXT: blr
+;
+; PPC64-LABEL: setrnd_toposinf:
+; PPC64: # %bb.0: # %entry
+; PPC64-NEXT: mtfsb1 30
+; PPC64-NEXT: mtfsb0 31
+; PPC64-NEXT: blr
+;
+; PPC64LE-LABEL: setrnd_toposinf:
+; PPC64LE: # %bb.0: # %entry
+; PPC64LE-NEXT: mtfsb1 30
+; PPC64LE-NEXT: mtfsb0 31
+; PPC64LE-NEXT: blr
+;
+; DM-LABEL: setrnd_toposinf:
+; DM: # %bb.0: # %entry
+; DM-NEXT: mtfsb1 30
+; DM-NEXT: mtfsb0 31
+; DM-NEXT: blr
+entry:
+ call void @llvm.set.rounding(i32 2)
+ ret void
+}
+
+define void @setrnd_toneginf() {
+; PPC32-LABEL: setrnd_toneginf:
+; PPC32: # %bb.0: # %entry
+; PPC32-NEXT: mtfsb1 30
+; PPC32-NEXT: mtfsb1 31
+; PPC32-NEXT: blr
+;
+; PPC64-LABEL: setrnd_toneginf:
+; PPC64: # %bb.0: # %entry
+; PPC64-NEXT: mtfsb1 30
+; PPC64-NEXT: mtfsb1 31
+; PPC64-NEXT: blr
+;
+; PPC64LE-LABEL: setrnd_toneginf:
+; PPC64LE: # %bb.0: # %entry
+; PPC64LE-NEXT: mtfsb1 30
+; PPC64LE-NEXT: mtfsb1 31
+; PPC64LE-NEXT: blr
+;
+; DM-LABEL: setrnd_toneginf:
+; DM: # %bb.0: # %entry
+; DM-NEXT: mtfsb1 30
+; DM-NEXT: mtfsb1 31
+; DM-NEXT: blr
+entry:
+ call void @llvm.set.rounding(i32 3)
+ ret void
+}
+
+define void @setrnd_var(i32 %x) {
+; PPC32-LABEL: setrnd_var:
+; PPC32: # %bb.0: # %entry
+; PPC32-NEXT: stwu 1, -16(1)
+; PPC32-NEXT: .cfi_def_cfa_offset 16
----------------
chenzheng1030 wrote:
nit: no need for the cfi pseudos.
https://github.com/llvm/llvm-project/pull/67302
More information about the cfe-commits
mailing list