|
| 1 | +; RUN: llc -mtriple=mips -relocation-model=static -mattr=single-float < %s \ |
| 2 | +; RUN: | FileCheck --check-prefixes=ALL,SYM32,O32 %s |
| 3 | +; RUN: llc -mtriple=mipsel -relocation-model=static -mattr=single-float < %s \ |
| 4 | +; RUN: | FileCheck --check-prefixes=ALL,SYM32,O32 %s |
| 5 | + |
| 6 | +; RUN: llc -mtriple=mips64 -relocation-model=static -target-abi n32 -mattr=single-float < %s \ |
| 7 | +; RUN: | FileCheck --check-prefixes=ALL,SYM32,N32,NEW,NEWBE %s |
| 8 | +; RUN: llc -mtriple=mips64el -relocation-model=static -target-abi n32 -mattr=single-float < %s \ |
| 9 | +; RUN: | FileCheck --check-prefixes=ALL,SYM32,N32,NEW,NEWLE %s |
| 10 | + |
| 11 | +; RUN: llc -mtriple=mips64 -relocation-model=static -target-abi n64 -mattr=single-float < %s \ |
| 12 | +; RUN: | FileCheck --check-prefixes=ALL,SYM64,N64,NEW,NEWBE %s |
| 13 | +; RUN: llc -mtriple=mips64el -relocation-model=static -target-abi n64 -mattr=single-float < %s \ |
| 14 | +; RUN: | FileCheck --check-prefixes=ALL,SYM64,N64,NEW,NEWLE %s |
| 15 | + |
| 16 | +@floats = global [11 x float] zeroinitializer |
| 17 | +@doubles = global [11 x double] zeroinitializer |
| 18 | + |
| 19 | +define void @double_args(double %a, ...) |
| 20 | + nounwind { |
| 21 | +entry: |
| 22 | + %0 = getelementptr [11 x double], ptr @doubles, i32 0, i32 1 |
| 23 | + store volatile double %a, ptr %0 |
| 24 | + |
| 25 | + %ap = alloca ptr |
| 26 | + call void @llvm.va_start(ptr %ap) |
| 27 | + %b = va_arg ptr %ap, double |
| 28 | + %1 = getelementptr [11 x double], ptr @doubles, i32 0, i32 2 |
| 29 | + store volatile double %b, ptr %1 |
| 30 | + call void @llvm.va_end(ptr %ap) |
| 31 | + ret void |
| 32 | +} |
| 33 | + |
| 34 | +; ALL-LABEL: double_args: |
| 35 | +; We won't test the way the global address is calculated in this test. This is |
| 36 | +; just to get the register number for the other checks. |
| 37 | +; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) |
| 38 | +; SYM64-DAG: daddiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) |
| 39 | + |
| 40 | +; O32 forbids using floating point registers for the non-variable portion. |
| 41 | +; N32/N64 allow it. |
| 42 | +; O32-DAG: sw $4, 8([[R2]]) |
| 43 | +; O32-DAG: sw $5, 12([[R2]]) |
| 44 | +; NEW-DAG: sd $4, 8([[R2]]) |
| 45 | + |
| 46 | +; The varargs portion is dumped to stack |
| 47 | +; O32-DAG: sw $6, 16($sp) |
| 48 | +; O32-DAG: sw $7, 20($sp) |
| 49 | +; NEW-DAG: sd $5, 8($sp) |
| 50 | +; NEW-DAG: sd $6, 16($sp) |
| 51 | +; NEW-DAG: sd $7, 24($sp) |
| 52 | +; NEW-DAG: sd $8, 32($sp) |
| 53 | +; NEW-DAG: sd $9, 40($sp) |
| 54 | +; NEW-DAG: sd $10, 48($sp) |
| 55 | +; NEW-DAG: sd $11, 56($sp) |
| 56 | + |
| 57 | +; Get the varargs pointer |
| 58 | +; O32 has 4 bytes padding, 4 bytes for the varargs pointer, and 8 bytes reserved |
| 59 | +; for arguments 1 and 2. |
| 60 | +; N32/N64 has 8 bytes for the varargs pointer, and no reserved area. |
| 61 | +; O32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 16 |
| 62 | +; O32-DAG: sw [[VAPTR]], 4($sp) |
| 63 | +; N32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 8 |
| 64 | +; N32-DAG: sw [[VAPTR]], 4($sp) |
| 65 | +; N64-DAG: daddiu [[VAPTR:\$[0-9]+]], $sp, 8 |
| 66 | +; N64-DAG: sd [[VAPTR]], 0($sp) |
| 67 | + |
| 68 | +; Increment the pointer then get the varargs arg |
| 69 | +; LLVM will rebind the load to the stack pointer instead of the varargs pointer |
| 70 | +; during lowering. This is fine and doesn't change the behaviour. |
| 71 | +; O32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 |
| 72 | +; N32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 |
| 73 | +; N64-DAG: daddiu [[VAPTR]], [[VAPTR]], 8 |
| 74 | +; O32-DAG: lw [[R3:\$[0-9]+]], 16($sp) |
| 75 | +; O32-DAG: lw [[R4:\$[0-9]+]], 20($sp) |
| 76 | +; O32-DAG: sw [[R3]], 16([[R2]]) |
| 77 | +; O32-DAG: sw [[R4]], 20([[R2]]) |
| 78 | +; NEW-DAG: ld [[R3:\$[0-9]+]], 8($sp) |
| 79 | +; NEW-DAG: sd [[R3]], 16([[R2]]) |
| 80 | + |
| 81 | +define void @float_args(float %a, ...) nounwind { |
| 82 | +entry: |
| 83 | + %0 = getelementptr [11 x float], ptr @floats, i32 0, i32 1 |
| 84 | + store volatile float %a, ptr %0 |
| 85 | + |
| 86 | + %ap = alloca ptr |
| 87 | + call void @llvm.va_start(ptr %ap) |
| 88 | + %b = va_arg ptr %ap, float |
| 89 | + %1 = getelementptr [11 x float], ptr @floats, i32 0, i32 2 |
| 90 | + store volatile float %b, ptr %1 |
| 91 | + call void @llvm.va_end(ptr %ap) |
| 92 | + ret void |
| 93 | +} |
| 94 | + |
| 95 | +; ALL-LABEL: float_args: |
| 96 | +; We won't test the way the global address is calculated in this test. This is |
| 97 | +; just to get the register number for the other checks. |
| 98 | +; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) |
| 99 | +; SYM64-DAG: daddiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) |
| 100 | + |
| 101 | +; The first four arguments are the same in O32/N32/N64. |
| 102 | +; The non-variable portion should be unaffected. |
| 103 | +; O32-DAG: mtc1 $4, $f0 |
| 104 | +; O32-DAG: swc1 $f0, 4([[R2]]) |
| 105 | +; NEW-DAG: swc1 $f12, 4([[R2]]) |
| 106 | + |
| 107 | +; The varargs portion is dumped to stack |
| 108 | +; O32-DAG: sw $5, 12($sp) |
| 109 | +; O32-DAG: sw $6, 16($sp) |
| 110 | +; O32-DAG: sw $7, 20($sp) |
| 111 | +; NEW-DAG: sd $5, 8($sp) |
| 112 | +; NEW-DAG: sd $6, 16($sp) |
| 113 | +; NEW-DAG: sd $7, 24($sp) |
| 114 | +; NEW-DAG: sd $8, 32($sp) |
| 115 | +; NEW-DAG: sd $9, 40($sp) |
| 116 | +; NEW-DAG: sd $10, 48($sp) |
| 117 | +; NEW-DAG: sd $11, 56($sp) |
| 118 | + |
| 119 | +; Get the varargs pointer |
| 120 | +; O32 has 4 bytes padding, 4 bytes for the varargs pointer, and should have 8 |
| 121 | +; bytes reserved for arguments 1 and 2 (the first float arg) but as discussed in |
| 122 | +; arguments-float.ll, GCC doesn't agree with MD00305 and treats floats as 4 |
| 123 | +; bytes so we only have 12 bytes total. |
| 124 | +; N32/N64 has 8 bytes for the varargs pointer, and no reserved area. |
| 125 | +; O32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 12 |
| 126 | +; O32-DAG: sw [[VAPTR]], 4($sp) |
| 127 | +; N32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 8 |
| 128 | +; N32-DAG: sw [[VAPTR]], 4($sp) |
| 129 | +; N64-DAG: daddiu [[VAPTR:\$[0-9]+]], $sp, 8 |
| 130 | +; N64-DAG: sd [[VAPTR]], 0($sp) |
| 131 | + |
| 132 | +; Increment the pointer then get the varargs arg |
| 133 | +; LLVM will rebind the load to the stack pointer instead of the varargs pointer |
| 134 | +; during lowering. This is fine and doesn't change the behaviour. |
| 135 | +; Also, in big-endian mode the offset must be increased by 4 to retrieve the |
| 136 | +; correct half of the argument slot. |
| 137 | +; |
| 138 | +; O32-DAG: addiu [[VAPTR]], [[VAPTR]], 4 |
| 139 | +; N32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 |
| 140 | +; N64-DAG: daddiu [[VAPTR]], [[VAPTR]], 8 |
| 141 | +; O32-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 12($sp) |
| 142 | +; NEWLE-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 8($sp) |
| 143 | +; NEWBE-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 12($sp) |
| 144 | +; ALL-DAG: swc1 [[FTMP1]], 8([[R2]]) |
| 145 | + |
| 146 | +declare void @llvm.va_start(ptr) |
| 147 | +declare void @llvm.va_copy(ptr, ptr) |
| 148 | +declare void @llvm.va_end(ptr) |
0 commit comments