xref: /llvm-project/llvm/test/CodeGen/X86/preserve_mostcc64.ll (revision 10629bb96aebfefaadfb0069bc7e276b868fcef9)
1; RUN: sed -e "s/RETTYPE/void/;s/RETVAL//" %s | llc -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck --check-prefixes=ALL,VOID %s
2; RUN: sed -e "s/RETTYPE/i32/;s/RETVAL/undef/" %s | llc -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck --check-prefixes=ALL,INT %s
3; RUN: sed -e "s/RETTYPE/\{i64\,i64\}/;s/RETVAL/undef/" %s | llc -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck --check-prefixes=ALL,INT128 %s
4
5; Every GPR should be saved - except r11 and return registers
6define preserve_mostcc RETTYPE @preserve_mostcc1(i64, i64, double, double) nounwind {
7entry:
8;ALL-LABEL:   preserve_mostcc1
9;ALL:         pushq %r10
10;ALL-NEXT:    pushq %r9
11;ALL-NEXT:    pushq %r8
12;ALL-NEXT:    pushq %rdi
13;ALL-NEXT:    pushq %rsi
14;VOID-NEXT:   pushq %rdx
15;INT-NEXT:    pushq %rdx
16;INT128-NOT:  pushq %rdx
17;ALL-NEXT:    pushq %rcx
18;VOID-NEXT:   pushq %rax
19;INT-NOT:     pushq %rax
20;INT128-NOT:  pushq %rax
21;ALL-NEXT:    pushq %rbp
22;ALL-NEXT:    pushq %r15
23;ALL-NEXT:    pushq %r14
24;ALL-NEXT:    pushq %r13
25;ALL-NEXT:    pushq %r12
26;ALL-NEXT:    pushq %rbx
27;ALL:         popq    %rbx
28;ALL-NEXT:    popq    %r12
29;ALL-NEXT:    popq    %r13
30;ALL-NEXT:    popq    %r14
31;ALL-NEXT:    popq    %r15
32;ALL-NEXT:    popq    %rbp
33;VOID-NEXT:   popq    %rax
34;INT-NOT:     popq    %rax
35;INT128-NOT:  popq    %rax
36;ALL-NEXT:    popq    %rcx
37;VOID-NEXT:   popq    %rdx
38;INT-NEXT:    popq    %rdx
39;INT128-NOT:  popq    %rdx
40;ALL-NEXT:    popq    %rsi
41;ALL-NEXT:    popq    %rdi
42;ALL-NEXT:    popq    %r8
43;ALL-NEXT:    popq    %r9
44;ALL-NEXT:    popq    %r10
45  call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{rbp},~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15}"()
46  ret RETTYPE RETVAL
47}
48
49; Make sure R11, return registers and XMMs are saved before the call
50declare preserve_mostcc RETTYPE @foo(i64, i64, double, double)
51define void @preserve_mostcc2() nounwind {
52entry:
53;ALL-LABEL: preserve_mostcc2
54;VOID-NOT:  movq %rax, [[REG1:%[a-z0-9]+]]
55;INT:       movq %rax, [[REG1:%[a-z0-9]+]]
56;INT128:    movq %rax, [[REG1:%[a-z0-9]+]]
57;VOID-NOT:  movq %rdx, [[REG2:%[a-z0-9]+]]
58;INT-NOT:   movq %rdx, [[REG2:%[a-z0-9]+]]
59;INT128:    movq %rdx, [[REG2:%[a-z0-9]+]]
60;ALL:       movq %r11, [[REG3:%[a-z0-9]+]]
61;ALL:       movaps %xmm2
62;ALL:       movaps %xmm3
63;ALL:       movaps %xmm4
64;ALL:       movaps %xmm5
65;ALL:       movaps %xmm6
66;ALL:       movaps %xmm7
67;ALL:       movaps %xmm8
68;ALL:       movaps %xmm9
69;ALL:       movaps %xmm10
70;ALL:       movaps %xmm11
71;ALL:       movaps %xmm12
72;ALL:       movaps %xmm13
73;ALL:       movaps %xmm14
74;ALL:       movaps %xmm15
75;ALL:       call
76;VOID-NOT:  movq {{.*}}, %rax
77;INT:       movq [[REG1]], %rax
78;INT128:    movq [[REG1]], %rax
79;VOID-NOT:  movq {{.*}}, %rdx
80;INT-NOT:   movq {{.*}}, %rdx
81;INT128:    movq [[REG2]], %rdx
82;ALL:       movq [[REG3]], %r11
83;ALL:       movaps {{.*}} %xmm2
84;ALL:       movaps {{.*}} %xmm3
85;ALL:       movaps {{.*}} %xmm4
86;ALL:       movaps {{.*}} %xmm5
87;ALL:       movaps {{.*}} %xmm6
88;ALL:       movaps {{.*}} %xmm7
89;ALL:       movaps {{.*}} %xmm8
90;ALL:       movaps {{.*}} %xmm9
91;ALL:       movaps {{.*}} %xmm10
92;ALL:       movaps {{.*}} %xmm11
93;ALL:       movaps {{.*}} %xmm12
94;ALL:       movaps {{.*}} %xmm13
95;ALL:       movaps {{.*}} %xmm14
96;ALL:       movaps {{.*}} %xmm15
97  %a0 = call i64 asm sideeffect "", "={rax}"() nounwind
98  %a1 = call i64 asm sideeffect "", "={rcx}"() nounwind
99  %a2 = call i64 asm sideeffect "", "={rdx}"() nounwind
100  %a3 = call i64 asm sideeffect "", "={r8}"() nounwind
101  %a4 = call i64 asm sideeffect "", "={r9}"() nounwind
102  %a5 = call i64 asm sideeffect "", "={r10}"() nounwind
103  %a6 = call i64 asm sideeffect "", "={r11}"() nounwind
104  %a10 = call <2 x double> asm sideeffect "", "={xmm2}"() nounwind
105  %a11 = call <2 x double> asm sideeffect "", "={xmm3}"() nounwind
106  %a12 = call <2 x double> asm sideeffect "", "={xmm4}"() nounwind
107  %a13 = call <2 x double> asm sideeffect "", "={xmm5}"() nounwind
108  %a14 = call <2 x double> asm sideeffect "", "={xmm6}"() nounwind
109  %a15 = call <2 x double> asm sideeffect "", "={xmm7}"() nounwind
110  %a16 = call <2 x double> asm sideeffect "", "={xmm8}"() nounwind
111  %a17 = call <2 x double> asm sideeffect "", "={xmm9}"() nounwind
112  %a18 = call <2 x double> asm sideeffect "", "={xmm10}"() nounwind
113  %a19 = call <2 x double> asm sideeffect "", "={xmm11}"() nounwind
114  %a20 = call <2 x double> asm sideeffect "", "={xmm12}"() nounwind
115  %a21 = call <2 x double> asm sideeffect "", "={xmm13}"() nounwind
116  %a22 = call <2 x double> asm sideeffect "", "={xmm14}"() nounwind
117  %a23 = call <2 x double> asm sideeffect "", "={xmm15}"() nounwind
118  call preserve_mostcc RETTYPE @foo(i64 1, i64 2, double 3.0, double 4.0)
119  call void asm sideeffect "", "{rax},{rcx},{rdx},{r8},{r9},{r10},{r11},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},{xmm8},{xmm9},{xmm10},{xmm11},{xmm12},{xmm13},{xmm14},{xmm15}"(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 %a6, <2 x double> %a10, <2 x double> %a11, <2 x double> %a12, <2 x double> %a13, <2 x double> %a14, <2 x double> %a15, <2 x double> %a16, <2 x double> %a17, <2 x double> %a18, <2 x double> %a19, <2 x double> %a20, <2 x double> %a21, <2 x double> %a22, <2 x double> %a23)
120  ret void
121}
122