10765f645SNemanja Ivanovic; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3 20765f645SNemanja Ivanovic; RUN: llc -mtriple=riscv32 -mattr=+zdinx -verify-machineinstrs < %s \ 30765f645SNemanja Ivanovic; RUN: -target-abi=ilp32 -mattr=+zhinx | FileCheck %s 4228f88fdSSam Elliott 54615cc38SSam Elliott;; These tests cover the use of `r`, `R`, and `cr` constraints for floating point values on rv32. 6228f88fdSSam Elliott;; 7228f88fdSSam Elliott;; In particular, there is significant complexity around using paired GPRs for double values on rv32. 8228f88fdSSam Elliott 90765f645SNemanja Ivanovicdefine dso_local void @zdinx_asm(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind { 100765f645SNemanja Ivanovic; CHECK-LABEL: zdinx_asm: 110765f645SNemanja Ivanovic; CHECK: # %bb.0: # %entry 12576d81baSCraig Topper; CHECK-NEXT: mv a5, a4 13576d81baSCraig Topper; CHECK-NEXT: mv a7, a2 14576d81baSCraig Topper; CHECK-NEXT: mv a4, a3 15576d81baSCraig Topper; CHECK-NEXT: mv a6, a1 160765f645SNemanja Ivanovic; CHECK-NEXT: #APP 17576d81baSCraig Topper; CHECK-NEXT: fsgnjx.d a2, a6, a4 180765f645SNemanja Ivanovic; CHECK-NEXT: #NO_APP 190765f645SNemanja Ivanovic; CHECK-NEXT: sw a2, 8(a0) 200765f645SNemanja Ivanovic; CHECK-NEXT: sw a3, 12(a0) 210765f645SNemanja Ivanovic; CHECK-NEXT: ret 220765f645SNemanja Ivanovicentry: 230765f645SNemanja Ivanovic %arrayidx = getelementptr inbounds double, ptr %a, i32 1 240765f645SNemanja Ivanovic %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=r,r,r"(double %b, double %c) 250765f645SNemanja Ivanovic store double %0, ptr %arrayidx, align 8 260765f645SNemanja Ivanovic ret void 270765f645SNemanja Ivanovic} 280765f645SNemanja Ivanovic 294615cc38SSam Elliottdefine dso_local void @zdinx_asm_R(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind { 304615cc38SSam Elliott; CHECK-LABEL: zdinx_asm_R: 314615cc38SSam Elliott; CHECK: # %bb.0: # %entry 324615cc38SSam Elliott; CHECK-NEXT: mv a5, a4 33c4030c89SSam Elliott; CHECK-NEXT: mv a7, a2 344615cc38SSam Elliott; CHECK-NEXT: mv a4, a3 35c4030c89SSam Elliott; CHECK-NEXT: mv a6, a1 364615cc38SSam Elliott; CHECK-NEXT: #APP 37c4030c89SSam Elliott; CHECK-NEXT: fsgnjx.d a2, a6, a4 384615cc38SSam Elliott; CHECK-NEXT: #NO_APP 394615cc38SSam Elliott; CHECK-NEXT: sw a2, 8(a0) 404615cc38SSam Elliott; CHECK-NEXT: sw a3, 12(a0) 414615cc38SSam Elliott; CHECK-NEXT: ret 424615cc38SSam Elliottentry: 434615cc38SSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 444615cc38SSam Elliott %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=R,R,R"(double %b, double %c) 454615cc38SSam Elliott store double %0, ptr %arrayidx, align 8 464615cc38SSam Elliott ret void 474615cc38SSam Elliott} 484615cc38SSam Elliott 49408659c5SSam Elliottdefine dso_local void @zdinx_asm_inout(ptr nocapture noundef writeonly %a, double noundef %b) nounwind { 50408659c5SSam Elliott; CHECK-LABEL: zdinx_asm_inout: 51408659c5SSam Elliott; CHECK: # %bb.0: # %entry 52408659c5SSam Elliott; CHECK-NEXT: mv a3, a2 53408659c5SSam Elliott; CHECK-NEXT: mv a2, a1 54408659c5SSam Elliott; CHECK-NEXT: #APP 55408659c5SSam Elliott; CHECK-NEXT: fmv.d a2, a2 56408659c5SSam Elliott; CHECK-NEXT: #NO_APP 57408659c5SSam Elliott; CHECK-NEXT: sw a2, 8(a0) 58408659c5SSam Elliott; CHECK-NEXT: sw a3, 12(a0) 59408659c5SSam Elliott; CHECK-NEXT: ret 60408659c5SSam Elliottentry: 61408659c5SSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 62408659c5SSam Elliott %0 = tail call double asm "fsgnj.d $0, $1, $1", "=r,0"(double %b) 63408659c5SSam Elliott store double %0, ptr %arrayidx, align 8 64408659c5SSam Elliott ret void 65408659c5SSam Elliott} 66408659c5SSam Elliott 67408659c5SSam Elliottdefine dso_local void @zdinx_asm_Pr_inout(ptr nocapture noundef writeonly %a, double noundef %b) nounwind { 68408659c5SSam Elliott; CHECK-LABEL: zdinx_asm_Pr_inout: 69408659c5SSam Elliott; CHECK: # %bb.0: # %entry 70408659c5SSam Elliott; CHECK-NEXT: mv a3, a2 71408659c5SSam Elliott; CHECK-NEXT: mv a2, a1 72408659c5SSam Elliott; CHECK-NEXT: #APP 73408659c5SSam Elliott; CHECK-NEXT: fabs.d a2, a2 74408659c5SSam Elliott; CHECK-NEXT: #NO_APP 75408659c5SSam Elliott; CHECK-NEXT: sw a2, 8(a0) 76408659c5SSam Elliott; CHECK-NEXT: sw a3, 12(a0) 77408659c5SSam Elliott; CHECK-NEXT: ret 78408659c5SSam Elliottentry: 79408659c5SSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 80408659c5SSam Elliott %0 = tail call double asm "fsgnjx.d $0, $1, $1", "=R,0"(double %b) 81408659c5SSam Elliott store double %0, ptr %arrayidx, align 8 82408659c5SSam Elliott ret void 83408659c5SSam Elliott} 84408659c5SSam Elliott 85*33c44074SSam Elliottdefine dso_local void @zdinx_asm_cR_inout(ptr nocapture noundef writeonly %a, double noundef %b) nounwind { 86*33c44074SSam Elliott; CHECK-LABEL: zdinx_asm_cR_inout: 87*33c44074SSam Elliott; CHECK: # %bb.0: # %entry 88*33c44074SSam Elliott; CHECK-NEXT: mv a3, a2 89*33c44074SSam Elliott; CHECK-NEXT: mv a2, a1 90*33c44074SSam Elliott; CHECK-NEXT: #APP 91*33c44074SSam Elliott; CHECK-NEXT: fabs.d a2, a2 92*33c44074SSam Elliott; CHECK-NEXT: #NO_APP 93*33c44074SSam Elliott; CHECK-NEXT: sw a2, 8(a0) 94*33c44074SSam Elliott; CHECK-NEXT: sw a3, 12(a0) 95*33c44074SSam Elliott; CHECK-NEXT: ret 96*33c44074SSam Elliottentry: 97*33c44074SSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 98*33c44074SSam Elliott %0 = tail call double asm "fsgnjx.d $0, $1, $1", "=^cR,0"(double %b) 99*33c44074SSam Elliott store double %0, ptr %arrayidx, align 8 100*33c44074SSam Elliott ret void 101*33c44074SSam Elliott} 102*33c44074SSam Elliott 1030765f645SNemanja Ivanovicdefine dso_local void @zfinx_asm(ptr nocapture noundef writeonly %a, float noundef %b, float noundef %c) nounwind { 1040765f645SNemanja Ivanovic; CHECK-LABEL: zfinx_asm: 1050765f645SNemanja Ivanovic; CHECK: # %bb.0: # %entry 1060765f645SNemanja Ivanovic; CHECK-NEXT: #APP 1070765f645SNemanja Ivanovic; CHECK-NEXT: fsgnjx.s a1, a1, a2 1080765f645SNemanja Ivanovic; CHECK-NEXT: #NO_APP 1090765f645SNemanja Ivanovic; CHECK-NEXT: sw a1, 4(a0) 1100765f645SNemanja Ivanovic; CHECK-NEXT: ret 1110765f645SNemanja Ivanovicentry: 1120765f645SNemanja Ivanovic %arrayidx = getelementptr inbounds float, ptr %a, i32 1 1130765f645SNemanja Ivanovic %0 = tail call float asm "fsgnjx.s $0, $1, $2", "=r,r,r"(float %b, float %c) 1140765f645SNemanja Ivanovic store float %0, ptr %arrayidx, align 8 1150765f645SNemanja Ivanovic ret void 1160765f645SNemanja Ivanovic} 1170765f645SNemanja Ivanovic 1180765f645SNemanja Ivanovicdefine dso_local void @zhinx_asm(ptr nocapture noundef writeonly %a, half noundef %b, half noundef %c) nounwind { 1190765f645SNemanja Ivanovic; CHECK-LABEL: zhinx_asm: 1200765f645SNemanja Ivanovic; CHECK: # %bb.0: # %entry 1210765f645SNemanja Ivanovic; CHECK-NEXT: #APP 1220765f645SNemanja Ivanovic; CHECK-NEXT: fsgnjx.h a1, a1, a2 1230765f645SNemanja Ivanovic; CHECK-NEXT: #NO_APP 1240765f645SNemanja Ivanovic; CHECK-NEXT: sh a1, 2(a0) 1250765f645SNemanja Ivanovic; CHECK-NEXT: ret 1260765f645SNemanja Ivanovicentry: 1270765f645SNemanja Ivanovic %arrayidx = getelementptr inbounds half, ptr %a, i32 1 1280765f645SNemanja Ivanovic %0 = tail call half asm "fsgnjx.h $0, $1, $2", "=r,r,r"(half %b, half %c) 1290765f645SNemanja Ivanovic store half %0, ptr %arrayidx, align 8 1300765f645SNemanja Ivanovic ret void 1310765f645SNemanja Ivanovic} 132228f88fdSSam Elliott 133228f88fdSSam Elliottdefine dso_local void @zdinx_asm_cr(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind { 134228f88fdSSam Elliott; CHECK-LABEL: zdinx_asm_cr: 135228f88fdSSam Elliott; CHECK: # %bb.0: # %entry 136228f88fdSSam Elliott; CHECK-NEXT: addi sp, sp, -16 137228f88fdSSam Elliott; CHECK-NEXT: sw s0, 12(sp) # 4-byte Folded Spill 138228f88fdSSam Elliott; CHECK-NEXT: sw s1, 8(sp) # 4-byte Folded Spill 139228f88fdSSam Elliott; CHECK-NEXT: mv a5, a4 140228f88fdSSam Elliott; CHECK-NEXT: mv s1, a2 141228f88fdSSam Elliott; CHECK-NEXT: mv a4, a3 142228f88fdSSam Elliott; CHECK-NEXT: mv s0, a1 143228f88fdSSam Elliott; CHECK-NEXT: #APP 144228f88fdSSam Elliott; CHECK-NEXT: fsgnjx.d a2, s0, a4 145228f88fdSSam Elliott; CHECK-NEXT: #NO_APP 146228f88fdSSam Elliott; CHECK-NEXT: sw a2, 8(a0) 147228f88fdSSam Elliott; CHECK-NEXT: sw a3, 12(a0) 148228f88fdSSam Elliott; CHECK-NEXT: lw s0, 12(sp) # 4-byte Folded Reload 149228f88fdSSam Elliott; CHECK-NEXT: lw s1, 8(sp) # 4-byte Folded Reload 150228f88fdSSam Elliott; CHECK-NEXT: addi sp, sp, 16 151228f88fdSSam Elliott; CHECK-NEXT: ret 152228f88fdSSam Elliottentry: 153228f88fdSSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 154228f88fdSSam Elliott %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=^cr,^cr,^cr"(double %b, double %c) 155228f88fdSSam Elliott store double %0, ptr %arrayidx, align 8 156228f88fdSSam Elliott ret void 157228f88fdSSam Elliott} 158228f88fdSSam Elliott 159228f88fdSSam Elliottdefine dso_local void @zfinx_asm_cr(ptr nocapture noundef writeonly %a, float noundef %b, float noundef %c) nounwind { 160228f88fdSSam Elliott; CHECK-LABEL: zfinx_asm_cr: 161228f88fdSSam Elliott; CHECK: # %bb.0: # %entry 162228f88fdSSam Elliott; CHECK-NEXT: #APP 163228f88fdSSam Elliott; CHECK-NEXT: fsgnjx.s a1, a1, a2 164228f88fdSSam Elliott; CHECK-NEXT: #NO_APP 165228f88fdSSam Elliott; CHECK-NEXT: sw a1, 4(a0) 166228f88fdSSam Elliott; CHECK-NEXT: ret 167228f88fdSSam Elliottentry: 168228f88fdSSam Elliott %arrayidx = getelementptr inbounds float, ptr %a, i32 1 169228f88fdSSam Elliott %0 = tail call float asm "fsgnjx.s $0, $1, $2", "=^cr,^cr,^cr"(float %b, float %c) 170228f88fdSSam Elliott store float %0, ptr %arrayidx, align 8 171228f88fdSSam Elliott ret void 172228f88fdSSam Elliott} 173228f88fdSSam Elliott 174228f88fdSSam Elliottdefine dso_local void @zhinx_asm_cr(ptr nocapture noundef writeonly %a, half noundef %b, half noundef %c) nounwind { 175228f88fdSSam Elliott; CHECK-LABEL: zhinx_asm_cr: 176228f88fdSSam Elliott; CHECK: # %bb.0: # %entry 177228f88fdSSam Elliott; CHECK-NEXT: #APP 178228f88fdSSam Elliott; CHECK-NEXT: fsgnjx.h a1, a1, a2 179228f88fdSSam Elliott; CHECK-NEXT: #NO_APP 180228f88fdSSam Elliott; CHECK-NEXT: sh a1, 2(a0) 181228f88fdSSam Elliott; CHECK-NEXT: ret 182228f88fdSSam Elliottentry: 183228f88fdSSam Elliott %arrayidx = getelementptr inbounds half, ptr %a, i32 1 184228f88fdSSam Elliott %0 = tail call half asm "fsgnjx.h $0, $1, $2", "=^cr,^cr,^cr"(half %b, half %c) 185228f88fdSSam Elliott store half %0, ptr %arrayidx, align 8 186228f88fdSSam Elliott ret void 187228f88fdSSam Elliott} 188*33c44074SSam Elliott 189*33c44074SSam Elliottdefine dso_local void @zdinx_asm_cR(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind { 190*33c44074SSam Elliott; CHECK-LABEL: zdinx_asm_cR: 191*33c44074SSam Elliott; CHECK: # %bb.0: # %entry 192*33c44074SSam Elliott; CHECK-NEXT: addi sp, sp, -16 193*33c44074SSam Elliott; CHECK-NEXT: sw s0, 12(sp) # 4-byte Folded Spill 194*33c44074SSam Elliott; CHECK-NEXT: sw s1, 8(sp) # 4-byte Folded Spill 195*33c44074SSam Elliott; CHECK-NEXT: mv a5, a4 196*33c44074SSam Elliott; CHECK-NEXT: mv s1, a2 197*33c44074SSam Elliott; CHECK-NEXT: mv a4, a3 198*33c44074SSam Elliott; CHECK-NEXT: mv s0, a1 199*33c44074SSam Elliott; CHECK-NEXT: #APP 200*33c44074SSam Elliott; CHECK-NEXT: fsgnjx.d a2, s0, a4 201*33c44074SSam Elliott; CHECK-NEXT: #NO_APP 202*33c44074SSam Elliott; CHECK-NEXT: sw a2, 8(a0) 203*33c44074SSam Elliott; CHECK-NEXT: sw a3, 12(a0) 204*33c44074SSam Elliott; CHECK-NEXT: lw s0, 12(sp) # 4-byte Folded Reload 205*33c44074SSam Elliott; CHECK-NEXT: lw s1, 8(sp) # 4-byte Folded Reload 206*33c44074SSam Elliott; CHECK-NEXT: addi sp, sp, 16 207*33c44074SSam Elliott; CHECK-NEXT: ret 208*33c44074SSam Elliottentry: 209*33c44074SSam Elliott %arrayidx = getelementptr inbounds double, ptr %a, i32 1 210*33c44074SSam Elliott %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=^cR,^cR,^cR"(double %b, double %c) 211*33c44074SSam Elliott store double %0, ptr %arrayidx, align 8 212*33c44074SSam Elliott ret void 213*33c44074SSam Elliott} 214