1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32 3; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA64 4 5;; TODO: Add more test cases after ABI implementation for ilp32f and lp64f. 6 7declare float @llvm.sin.f32(float) 8declare float @llvm.cos.f32(float) 9declare float @llvm.pow.f32(float, float) 10declare double @llvm.sin.f64(double) 11declare double @llvm.cos.f64(double) 12declare double @llvm.pow.f64(double, double) 13 14define float @sin_f32(float %a) nounwind { 15; LA32-LABEL: sin_f32: 16; LA32: # %bb.0: 17; LA32-NEXT: b %plt(sinf) 18; 19; LA64-LABEL: sin_f32: 20; LA64: # %bb.0: 21; LA64-NEXT: b %plt(sinf) 22 %1 = call float @llvm.sin.f32(float %a) 23 ret float %1 24} 25 26define float @cos_f32(float %a) nounwind { 27; LA32-LABEL: cos_f32: 28; LA32: # %bb.0: 29; LA32-NEXT: b %plt(cosf) 30; 31; LA64-LABEL: cos_f32: 32; LA64: # %bb.0: 33; LA64-NEXT: b %plt(cosf) 34 %1 = call float @llvm.cos.f32(float %a) 35 ret float %1 36} 37 38define float @sincos_f32(float %a) nounwind { 39; LA32-LABEL: sincos_f32: 40; LA32: # %bb.0: 41; LA32-NEXT: addi.w $sp, $sp, -32 42; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill 43; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill 44; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill 45; LA32-NEXT: fmov.s $fs0, $fa0 46; LA32-NEXT: bl %plt(sinf) 47; LA32-NEXT: fmov.s $fs1, $fa0 48; LA32-NEXT: fmov.s $fa0, $fs0 49; LA32-NEXT: bl %plt(cosf) 50; LA32-NEXT: fadd.s $fa0, $fs1, $fa0 51; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload 52; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload 53; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload 54; LA32-NEXT: addi.w $sp, $sp, 32 55; LA32-NEXT: ret 56; 57; LA64-LABEL: sincos_f32: 58; LA64: # %bb.0: 59; LA64-NEXT: addi.d $sp, $sp, -32 60; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill 61; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill 62; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill 63; LA64-NEXT: fmov.s $fs0, $fa0 64; LA64-NEXT: bl %plt(sinf) 65; LA64-NEXT: fmov.s $fs1, $fa0 66; LA64-NEXT: fmov.s $fa0, $fs0 67; LA64-NEXT: bl %plt(cosf) 68; LA64-NEXT: fadd.s $fa0, $fs1, $fa0 69; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload 70; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload 71; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload 72; LA64-NEXT: addi.d $sp, $sp, 32 73; LA64-NEXT: ret 74 %1 = call float @llvm.sin.f32(float %a) 75 %2 = call float @llvm.cos.f32(float %a) 76 %3 = fadd float %1, %2 77 ret float %3 78} 79 80define float @pow_f32(float %a, float %b) nounwind { 81; LA32-LABEL: pow_f32: 82; LA32: # %bb.0: 83; LA32-NEXT: b %plt(powf) 84; 85; LA64-LABEL: pow_f32: 86; LA64: # %bb.0: 87; LA64-NEXT: b %plt(powf) 88 %1 = call float @llvm.pow.f32(float %a, float %b) 89 ret float %1 90} 91 92define float @frem_f32(float %a, float %b) nounwind { 93; LA32-LABEL: frem_f32: 94; LA32: # %bb.0: 95; LA32-NEXT: b %plt(fmodf) 96; 97; LA64-LABEL: frem_f32: 98; LA64: # %bb.0: 99; LA64-NEXT: b %plt(fmodf) 100 %1 = frem float %a, %b 101 ret float %1 102} 103 104define double @sin_f64(double %a) nounwind { 105; LA32-LABEL: sin_f64: 106; LA32: # %bb.0: 107; LA32-NEXT: b %plt(sin) 108; 109; LA64-LABEL: sin_f64: 110; LA64: # %bb.0: 111; LA64-NEXT: b %plt(sin) 112 %1 = call double @llvm.sin.f64(double %a) 113 ret double %1 114} 115 116define double @cos_f64(double %a) nounwind { 117; LA32-LABEL: cos_f64: 118; LA32: # %bb.0: 119; LA32-NEXT: b %plt(cos) 120; 121; LA64-LABEL: cos_f64: 122; LA64: # %bb.0: 123; LA64-NEXT: b %plt(cos) 124 %1 = call double @llvm.cos.f64(double %a) 125 ret double %1 126} 127 128define double @sincos_f64(double %a) nounwind { 129; LA32-LABEL: sincos_f64: 130; LA32: # %bb.0: 131; LA32-NEXT: addi.w $sp, $sp, -32 132; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill 133; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill 134; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill 135; LA32-NEXT: fmov.d $fs0, $fa0 136; LA32-NEXT: bl %plt(sin) 137; LA32-NEXT: fmov.d $fs1, $fa0 138; LA32-NEXT: fmov.d $fa0, $fs0 139; LA32-NEXT: bl %plt(cos) 140; LA32-NEXT: fadd.d $fa0, $fs1, $fa0 141; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload 142; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload 143; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload 144; LA32-NEXT: addi.w $sp, $sp, 32 145; LA32-NEXT: ret 146; 147; LA64-LABEL: sincos_f64: 148; LA64: # %bb.0: 149; LA64-NEXT: addi.d $sp, $sp, -32 150; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill 151; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill 152; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill 153; LA64-NEXT: fmov.d $fs0, $fa0 154; LA64-NEXT: bl %plt(sin) 155; LA64-NEXT: fmov.d $fs1, $fa0 156; LA64-NEXT: fmov.d $fa0, $fs0 157; LA64-NEXT: bl %plt(cos) 158; LA64-NEXT: fadd.d $fa0, $fs1, $fa0 159; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload 160; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload 161; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload 162; LA64-NEXT: addi.d $sp, $sp, 32 163; LA64-NEXT: ret 164 %1 = call double @llvm.sin.f64(double %a) 165 %2 = call double @llvm.cos.f64(double %a) 166 %3 = fadd double %1, %2 167 ret double %3 168} 169 170define double @pow_f64(double %a, double %b) nounwind { 171; LA32-LABEL: pow_f64: 172; LA32: # %bb.0: 173; LA32-NEXT: b %plt(pow) 174; 175; LA64-LABEL: pow_f64: 176; LA64: # %bb.0: 177; LA64-NEXT: b %plt(pow) 178 %1 = call double @llvm.pow.f64(double %a, double %b) 179 ret double %1 180} 181 182define double @frem_f64(double %a, double %b) nounwind { 183; LA32-LABEL: frem_f64: 184; LA32: # %bb.0: 185; LA32-NEXT: b %plt(fmod) 186; 187; LA64-LABEL: frem_f64: 188; LA64: # %bb.0: 189; LA64-NEXT: b %plt(fmod) 190 %1 = frem double %a, %b 191 ret double %1 192} 193