diff options
| author | Martin Storsjo <martin@martin.st> | 2018-03-20 06:19:38 +0000 |
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2018-03-20 06:19:38 +0000 |
| commit | 802b434156501ef98d70f981a8359c945adca044 (patch) | |
| tree | 7ff67a21409d85b326a7f0b8b0d958014c002748 /llvm/test | |
| parent | 2c83285716e8d32332f62dc9eea84461af46efcc (diff) | |
| download | bcm5719-llvm-802b434156501ef98d70f981a8359c945adca044.tar.gz bcm5719-llvm-802b434156501ef98d70f981a8359c945adca044.zip | |
[X86] Properly implement the calling convention for f80 for mingw/x86_64
In these cases, both parameters and return values are passed
as a pointer to a stack allocation.
MSVC doesn't use the f80 data type at all, while it is used
for long doubles on mingw.
Normally, this part of the calling convention is handled
within clang, but for intrinsics that are lowered to libcalls,
it may need to be handled within llvm as well.
Differential Revision: https://reviews.llvm.org/D44592
llvm-svn: 327957
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/finite-libcalls.ll | 85 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/scalar-fp-to-i64.ll | 26 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/win64-long-double.ll | 22 |
3 files changed, 102 insertions, 31 deletions
diff --git a/llvm/test/CodeGen/X86/finite-libcalls.ll b/llvm/test/CodeGen/X86/finite-libcalls.ll index d4b79acbd7e..d54ee48ea74 100644 --- a/llvm/test/CodeGen/X86/finite-libcalls.ll +++ b/llvm/test/CodeGen/X86/finite-libcalls.ll @@ -50,11 +50,19 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: exp_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $56, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $64, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx ; WIN-NEXT: callq expl -; WIN-NEXT: addq $56, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $64, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: exp_f80: @@ -113,11 +121,19 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: exp2_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $56, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $64, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx ; WIN-NEXT: callq exp2l -; WIN-NEXT: addq $56, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $64, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: exp2_f80: @@ -176,11 +192,19 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: log_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $56, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $64, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx ; WIN-NEXT: callq logl -; WIN-NEXT: addq $56, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $64, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: log_f80: @@ -239,11 +263,19 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: log2_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $56, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $64, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx ; WIN-NEXT: callq log2l -; WIN-NEXT: addq $56, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $64, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: log2_f80: @@ -302,11 +334,19 @@ define x86_fp80 @log10_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: log10_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $56, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $64, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx ; WIN-NEXT: callq log10l -; WIN-NEXT: addq $56, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $64, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: log10_f80: @@ -373,13 +413,22 @@ define x86_fp80 @pow_f80(x86_fp80 %x) #0 { ; ; WIN-LABEL: pow_f80: ; WIN: # %bb.0: -; WIN-NEXT: subq $72, %rsp -; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: pushq %rsi +; WIN-NEXT: subq $80, %rsp +; WIN-NEXT: movq %rcx, %rsi +; WIN-NEXT: fldt (%rdx) ; WIN-NEXT: fld %st(0) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) ; WIN-NEXT: fstpt {{[0-9]+}}(%rsp) +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rcx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %rdx +; WIN-NEXT: leaq {{[0-9]+}}(%rsp), %r8 ; WIN-NEXT: callq powl -; WIN-NEXT: addq $72, %rsp +; WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; WIN-NEXT: fstpt (%rsi) +; WIN-NEXT: movq %rsi, %rax +; WIN-NEXT: addq $80, %rsp +; WIN-NEXT: popq %rsi ; WIN-NEXT: retq ; ; MAC-LABEL: pow_f80: diff --git a/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll b/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll index 85a6cecdd66..18a79d276c1 100644 --- a/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll +++ b/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll @@ -918,7 +918,7 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind { ; AVX512_64_WIN-LABEL: x_to_u64: ; AVX512_64_WIN: # %bb.0: ; AVX512_64_WIN-NEXT: pushq %rax -; AVX512_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; AVX512_64_WIN-NEXT: fldt (%rcx) ; AVX512_64_WIN-NEXT: flds __real@{{.*}}(%rip) ; AVX512_64_WIN-NEXT: fld %st(1) ; AVX512_64_WIN-NEXT: fsub %st(1) @@ -1003,25 +1003,25 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind { ; ; SSE3_64_WIN-LABEL: x_to_u64: ; SSE3_64_WIN: # %bb.0: -; SSE3_64_WIN-NEXT: subq $24, %rsp -; SSE3_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; SSE3_64_WIN-NEXT: subq $16, %rsp +; SSE3_64_WIN-NEXT: fldt (%rcx) ; SSE3_64_WIN-NEXT: flds __real@{{.*}}(%rip) ; SSE3_64_WIN-NEXT: fld %st(1) ; SSE3_64_WIN-NEXT: fsub %st(1) ; SSE3_64_WIN-NEXT: fisttpll {{[0-9]+}}(%rsp) ; SSE3_64_WIN-NEXT: fld %st(1) -; SSE3_64_WIN-NEXT: fisttpll {{[0-9]+}}(%rsp) +; SSE3_64_WIN-NEXT: fisttpll (%rsp) ; SSE3_64_WIN-NEXT: fucompi %st(1) ; SSE3_64_WIN-NEXT: fstp %st(0) ; SSE3_64_WIN-NEXT: jbe .LBB4_1 ; SSE3_64_WIN-NEXT: # %bb.2: -; SSE3_64_WIN-NEXT: movq {{[0-9]+}}(%rsp), %rax -; SSE3_64_WIN-NEXT: addq $24, %rsp +; SSE3_64_WIN-NEXT: movq (%rsp), %rax +; SSE3_64_WIN-NEXT: addq $16, %rsp ; SSE3_64_WIN-NEXT: retq ; SSE3_64_WIN-NEXT: .LBB4_1: ; SSE3_64_WIN-NEXT: movabsq $-9223372036854775808, %rax # imm = 0x8000000000000000 ; SSE3_64_WIN-NEXT: xorq {{[0-9]+}}(%rsp), %rax -; SSE3_64_WIN-NEXT: addq $24, %rsp +; SSE3_64_WIN-NEXT: addq $16, %rsp ; SSE3_64_WIN-NEXT: retq ; ; SSE3_64_LIN-LABEL: x_to_u64: @@ -1103,7 +1103,7 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind { ; SSE2_64_WIN-LABEL: x_to_u64: ; SSE2_64_WIN: # %bb.0: ; SSE2_64_WIN-NEXT: subq $24, %rsp -; SSE2_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; SSE2_64_WIN-NEXT: fldt (%rcx) ; SSE2_64_WIN-NEXT: flds __real@{{.*}}(%rip) ; SSE2_64_WIN-NEXT: fld %st(1) ; SSE2_64_WIN-NEXT: fsub %st(1) @@ -1268,7 +1268,7 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind { ; AVX512_64_WIN-LABEL: x_to_s64: ; AVX512_64_WIN: # %bb.0: ; AVX512_64_WIN-NEXT: pushq %rax -; AVX512_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; AVX512_64_WIN-NEXT: fldt (%rcx) ; AVX512_64_WIN-NEXT: fisttpll (%rsp) ; AVX512_64_WIN-NEXT: movq (%rsp), %rax ; AVX512_64_WIN-NEXT: popq %rcx @@ -1308,7 +1308,7 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind { ; SSE3_64_WIN-LABEL: x_to_s64: ; SSE3_64_WIN: # %bb.0: ; SSE3_64_WIN-NEXT: pushq %rax -; SSE3_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; SSE3_64_WIN-NEXT: fldt (%rcx) ; SSE3_64_WIN-NEXT: fisttpll (%rsp) ; SSE3_64_WIN-NEXT: movq (%rsp), %rax ; SSE3_64_WIN-NEXT: popq %rcx @@ -1359,8 +1359,8 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind { ; ; SSE2_64_WIN-LABEL: x_to_s64: ; SSE2_64_WIN: # %bb.0: -; SSE2_64_WIN-NEXT: subq $24, %rsp -; SSE2_64_WIN-NEXT: fldt {{[0-9]+}}(%rsp) +; SSE2_64_WIN-NEXT: subq $16, %rsp +; SSE2_64_WIN-NEXT: fldt (%rcx) ; SSE2_64_WIN-NEXT: fnstcw {{[0-9]+}}(%rsp) ; SSE2_64_WIN-NEXT: movzwl {{[0-9]+}}(%rsp), %eax ; SSE2_64_WIN-NEXT: movw $3199, {{[0-9]+}}(%rsp) # imm = 0xC7F @@ -1369,7 +1369,7 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind { ; SSE2_64_WIN-NEXT: fistpll {{[0-9]+}}(%rsp) ; SSE2_64_WIN-NEXT: fldcw {{[0-9]+}}(%rsp) ; SSE2_64_WIN-NEXT: movq {{[0-9]+}}(%rsp), %rax -; SSE2_64_WIN-NEXT: addq $24, %rsp +; SSE2_64_WIN-NEXT: addq $16, %rsp ; SSE2_64_WIN-NEXT: retq ; ; SSE2_64_LIN-LABEL: x_to_s64: diff --git a/llvm/test/CodeGen/X86/win64-long-double.ll b/llvm/test/CodeGen/X86/win64-long-double.ll new file mode 100644 index 00000000000..df7ba0480bb --- /dev/null +++ b/llvm/test/CodeGen/X86/win64-long-double.ll @@ -0,0 +1,22 @@ +; RUN: llc -mtriple x86_64-w64-mingw32 %s -o - | FileCheck %s + +@glob = common dso_local local_unnamed_addr global x86_fp80 0xK00000000000000000000, align 16 + +define dso_local void @call() { +entry: + %0 = load x86_fp80, x86_fp80* @glob, align 16 + %1 = tail call x86_fp80 @floorl(x86_fp80 %0) + store x86_fp80 %1, x86_fp80* @glob, align 16 + ret void +} + +declare x86_fp80 @floorl(x86_fp80) + +; CHECK-LABEL: call +; CHECK: fldt glob(%rip) +; CHECK: fstpt [[ARGOFF:[0-9]+]](%rsp) +; CHECK: leaq [[RETOFF:[0-9]+]](%rsp), %rcx +; CHECK: leaq [[ARGOFF]](%rsp), %rdx +; CHECK: callq floorl +; CHECK: fldt [[RETOFF]](%rsp) +; CHECK: fstpt glob(%rip) |

