|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3 |
| 2 | +; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi ilp32d \ |
| 3 | +; RUN: -global-isel -stop-after=irtranslator -verify-machineinstrs < %s \ |
| 4 | +; RUN: | FileCheck -check-prefix=RV32-ILP32D %s |
| 5 | + |
| 6 | +; This file contains tests that will have differing output for the ilp32/ilp32f |
| 7 | +; and ilp32d ABIs. |
| 8 | + |
| 9 | +define i32 @callee_double_in_fpr(i32 %a, double %b) nounwind { |
| 10 | + ; RV32-ILP32D-LABEL: name: callee_double_in_fpr |
| 11 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 12 | + ; RV32-ILP32D-NEXT: liveins: $x10, $f10_d |
| 13 | + ; RV32-ILP32D-NEXT: {{ $}} |
| 14 | + ; RV32-ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 |
| 15 | + ; RV32-ILP32D-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $f10_d |
| 16 | + ; RV32-ILP32D-NEXT: [[FPTOSI:%[0-9]+]]:_(s32) = G_FPTOSI [[COPY1]](s64) |
| 17 | + ; RV32-ILP32D-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[FPTOSI]] |
| 18 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[ADD]](s32) |
| 19 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $x10 |
| 20 | + %b_fptosi = fptosi double %b to i32 |
| 21 | + %1 = add i32 %a, %b_fptosi |
| 22 | + ret i32 %1 |
| 23 | +} |
| 24 | + |
| 25 | +define i32 @caller_double_in_fpr() nounwind { |
| 26 | + ; RV32-ILP32D-LABEL: name: caller_double_in_fpr |
| 27 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 28 | + ; RV32-ILP32D-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 |
| 29 | + ; RV32-ILP32D-NEXT: [[C1:%[0-9]+]]:_(s64) = G_FCONSTANT double 2.000000e+00 |
| 30 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[C]](s32) |
| 31 | + ; RV32-ILP32D-NEXT: $f10_d = COPY [[C1]](s64) |
| 32 | + ; RV32-ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_double_in_fpr, implicit-def $x1, implicit $x10, implicit $f10_d, implicit-def $x10 |
| 33 | + ; RV32-ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 |
| 34 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[COPY]](s32) |
| 35 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $x10 |
| 36 | + %1 = call i32 @callee_double_in_fpr(i32 1, double 2.0) |
| 37 | + ret i32 %1 |
| 38 | +} |
| 39 | + |
| 40 | +; Must keep define on a single line due to an update_llc_test_checks.py limitation |
| 41 | +define i32 @callee_double_in_gpr_exhausted_fprs(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i) nounwind { |
| 42 | + ; RV32-ILP32D-LABEL: name: callee_double_in_gpr_exhausted_fprs |
| 43 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 44 | + ; RV32-ILP32D-NEXT: liveins: $x10, $x11, $f10_d, $f11_d, $f12_d, $f13_d, $f14_d, $f15_d, $f16_d, $f17_d |
| 45 | + ; RV32-ILP32D-NEXT: {{ $}} |
| 46 | + ; RV32-ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $f10_d |
| 47 | + ; RV32-ILP32D-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $f11_d |
| 48 | + ; RV32-ILP32D-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $f12_d |
| 49 | + ; RV32-ILP32D-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $f13_d |
| 50 | + ; RV32-ILP32D-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY $f14_d |
| 51 | + ; RV32-ILP32D-NEXT: [[COPY5:%[0-9]+]]:_(s64) = COPY $f15_d |
| 52 | + ; RV32-ILP32D-NEXT: [[COPY6:%[0-9]+]]:_(s64) = COPY $f16_d |
| 53 | + ; RV32-ILP32D-NEXT: [[COPY7:%[0-9]+]]:_(s64) = COPY $f17_d |
| 54 | + ; RV32-ILP32D-NEXT: [[COPY8:%[0-9]+]]:_(s32) = COPY $x10 |
| 55 | + ; RV32-ILP32D-NEXT: [[COPY9:%[0-9]+]]:_(s32) = COPY $x11 |
| 56 | + ; RV32-ILP32D-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY8]](s32), [[COPY9]](s32) |
| 57 | + ; RV32-ILP32D-NEXT: [[FPTOSI:%[0-9]+]]:_(s32) = G_FPTOSI [[COPY7]](s64) |
| 58 | + ; RV32-ILP32D-NEXT: [[FPTOSI1:%[0-9]+]]:_(s32) = G_FPTOSI [[MV]](s64) |
| 59 | + ; RV32-ILP32D-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[FPTOSI]], [[FPTOSI1]] |
| 60 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[ADD]](s32) |
| 61 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $x10 |
| 62 | + %h_fptosi = fptosi double %h to i32 |
| 63 | + %i_fptosi = fptosi double %i to i32 |
| 64 | + %1 = add i32 %h_fptosi, %i_fptosi |
| 65 | + ret i32 %1 |
| 66 | +} |
| 67 | + |
| 68 | +define i32 @caller_double_in_gpr_exhausted_fprs() nounwind { |
| 69 | + ; RV32-ILP32D-LABEL: name: caller_double_in_gpr_exhausted_fprs |
| 70 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 71 | + ; RV32-ILP32D-NEXT: [[C:%[0-9]+]]:_(s64) = G_FCONSTANT double 1.000000e+00 |
| 72 | + ; RV32-ILP32D-NEXT: [[C1:%[0-9]+]]:_(s64) = G_FCONSTANT double 2.000000e+00 |
| 73 | + ; RV32-ILP32D-NEXT: [[C2:%[0-9]+]]:_(s64) = G_FCONSTANT double 3.000000e+00 |
| 74 | + ; RV32-ILP32D-NEXT: [[C3:%[0-9]+]]:_(s64) = G_FCONSTANT double 4.000000e+00 |
| 75 | + ; RV32-ILP32D-NEXT: [[C4:%[0-9]+]]:_(s64) = G_FCONSTANT double 5.000000e+00 |
| 76 | + ; RV32-ILP32D-NEXT: [[C5:%[0-9]+]]:_(s64) = G_FCONSTANT double 6.000000e+00 |
| 77 | + ; RV32-ILP32D-NEXT: [[C6:%[0-9]+]]:_(s64) = G_FCONSTANT double 7.000000e+00 |
| 78 | + ; RV32-ILP32D-NEXT: [[C7:%[0-9]+]]:_(s64) = G_FCONSTANT double 8.000000e+00 |
| 79 | + ; RV32-ILP32D-NEXT: [[C8:%[0-9]+]]:_(s64) = G_FCONSTANT double 9.000000e+00 |
| 80 | + ; RV32-ILP32D-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C8]](s64) |
| 81 | + ; RV32-ILP32D-NEXT: $f10_d = COPY [[C]](s64) |
| 82 | + ; RV32-ILP32D-NEXT: $f11_d = COPY [[C1]](s64) |
| 83 | + ; RV32-ILP32D-NEXT: $f12_d = COPY [[C2]](s64) |
| 84 | + ; RV32-ILP32D-NEXT: $f13_d = COPY [[C3]](s64) |
| 85 | + ; RV32-ILP32D-NEXT: $f14_d = COPY [[C4]](s64) |
| 86 | + ; RV32-ILP32D-NEXT: $f15_d = COPY [[C5]](s64) |
| 87 | + ; RV32-ILP32D-NEXT: $f16_d = COPY [[C6]](s64) |
| 88 | + ; RV32-ILP32D-NEXT: $f17_d = COPY [[C7]](s64) |
| 89 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[UV]](s32) |
| 90 | + ; RV32-ILP32D-NEXT: $x11 = COPY [[UV1]](s32) |
| 91 | + ; RV32-ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_double_in_gpr_exhausted_fprs, implicit-def $x1, implicit $f10_d, implicit $f11_d, implicit $f12_d, implicit $f13_d, implicit $f14_d, implicit $f15_d, implicit $f16_d, implicit $f17_d, implicit $x10, implicit $x11, implicit-def $x10 |
| 92 | + ; RV32-ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 |
| 93 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[COPY]](s32) |
| 94 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $x10 |
| 95 | + %1 = call i32 @callee_double_in_gpr_exhausted_fprs( |
| 96 | + double 1.0, double 2.0, double 3.0, double 4.0, double 5.0, double 6.0, |
| 97 | + double 7.0, double 8.0, double 9.0) |
| 98 | + ret i32 %1 |
| 99 | +} |
| 100 | + |
| 101 | +define double @callee_double_ret() nounwind { |
| 102 | + ; RV32-ILP32D-LABEL: name: callee_double_ret |
| 103 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 104 | + ; RV32-ILP32D-NEXT: [[C:%[0-9]+]]:_(s64) = G_FCONSTANT double 1.000000e+00 |
| 105 | + ; RV32-ILP32D-NEXT: $f10_d = COPY [[C]](s64) |
| 106 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $f10_d |
| 107 | + ret double 1.0 |
| 108 | +} |
| 109 | + |
| 110 | +define i32 @caller_double_ret() nounwind { |
| 111 | + ; RV32-ILP32D-LABEL: name: caller_double_ret |
| 112 | + ; RV32-ILP32D: bb.1 (%ir-block.0): |
| 113 | + ; RV32-ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_double_ret, implicit-def $x1, implicit-def $f10_d |
| 114 | + ; RV32-ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $f10_d |
| 115 | + ; RV32-ILP32D-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) |
| 116 | + ; RV32-ILP32D-NEXT: $x10 = COPY [[TRUNC]](s32) |
| 117 | + ; RV32-ILP32D-NEXT: PseudoRET implicit $x10 |
| 118 | + %1 = call double @callee_double_ret() |
| 119 | + %2 = bitcast double %1 to i64 |
| 120 | + %3 = trunc i64 %2 to i32 |
| 121 | + ret i32 %3 |
| 122 | +} |
0 commit comments