aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/GlobalISel/callingconv.ll
blob: c7e4d91ac3c7b980ecbac73fdb26069d84aca103 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=i386-linux-gnu -mattr=+sse2  -global-isel < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X32 --check-prefix=X32_GISEL
; RUN: llc -mtriple=i386-linux-gnu -mattr=+sse2               < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X32 --check-prefix=X32_ISEL
; RUN: llc -mtriple=x86_64-linux-gnu             -global-isel < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64 --check-prefix=X64_GISEL
; RUN: llc -mtriple=x86_64-linux-gnu                          < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64 --check-prefix=X64_ISEL

define i32 @test_ret_i32() {
; X32-LABEL: test_ret_i32:
; X32:       # BB#0:
; X32-NEXT:    movl $20, %eax
; X32-NEXT:    retl
;
; X64-LABEL: test_ret_i32:
; X64:       # BB#0:
; X64-NEXT:    movl $20, %eax
; X64-NEXT:    retq
  ret i32 20
}

define i64 @test_ret_i64() {
; X32_GISEL-LABEL: test_ret_i64:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    movl $4294967295, %eax # imm = 0xFFFFFFFF
; X32_GISEL-NEXT:    movl $15, %edx
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_ret_i64:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movl $-1, %eax
; X32_ISEL-NEXT:    movl $15, %edx
; X32_ISEL-NEXT:    retl
;
; X64-LABEL: test_ret_i64:
; X64:       # BB#0:
; X64-NEXT:    movabsq $68719476735, %rax # imm = 0xFFFFFFFFF
; X64-NEXT:    retq
  ret i64 68719476735
}

define i8 @test_arg_i8(i8 %a) {
; X32_GISEL-LABEL: test_arg_i8:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    leal 4(%esp), %eax
; X32_GISEL-NEXT:    movb (%eax), %al
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_arg_i8:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movb 4(%esp), %al
; X32_ISEL-NEXT:    retl
;
; X64-LABEL: test_arg_i8:
; X64:       # BB#0:
; X64-NEXT:    movl %edi, %eax
; X64-NEXT:    retq
  ret i8 %a
}

define i16 @test_arg_i16(i16 %a) {
; X32_GISEL-LABEL: test_arg_i16:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    leal 4(%esp), %eax
; X32_GISEL-NEXT:    movzwl (%eax), %eax
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_arg_i16:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movzwl 4(%esp), %eax
; X32_ISEL-NEXT:    retl
;
; X64-LABEL: test_arg_i16:
; X64:       # BB#0:
; X64-NEXT:    movl %edi, %eax
; X64-NEXT:    retq
  ret i16 %a
}

define i32 @test_arg_i32(i32 %a) {
; X32_GISEL-LABEL: test_arg_i32:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    leal 4(%esp), %eax
; X32_GISEL-NEXT:    movl (%eax), %eax
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_arg_i32:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movl 4(%esp), %eax
; X32_ISEL-NEXT:    retl
;
; X64-LABEL: test_arg_i32:
; X64:       # BB#0:
; X64-NEXT:    movl %edi, %eax
; X64-NEXT:    retq
  ret i32 %a
}

define i64 @test_arg_i64(i64 %a) {
; X32_GISEL-LABEL: test_arg_i64:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    leal 4(%esp), %eax
; X32_GISEL-NEXT:    movl (%eax), %eax
; X32_GISEL-NEXT:    leal 8(%esp), %ecx
; X32_GISEL-NEXT:    movl (%ecx), %edx
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_arg_i64:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movl 4(%esp), %eax
; X32_ISEL-NEXT:    movl 8(%esp), %edx
; X32_ISEL-NEXT:    retl
;
; X64-LABEL: test_arg_i64:
; X64:       # BB#0:
; X64-NEXT:    movq %rdi, %rax
; X64-NEXT:    retq
  ret i64 %a
}

define i64 @test_i64_args_8(i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %arg5, i64 %arg6, i64 %arg7, i64 %arg8) {
; X32_GISEL-LABEL: test_i64_args_8:
; X32_GISEL:       # BB#0:
; X32_GISEL-NEXT:    leal 60(%esp), %eax
; X32_GISEL-NEXT:    movl (%eax), %eax
; X32_GISEL-NEXT:    leal 64(%esp), %ecx
; X32_GISEL-NEXT:    movl (%ecx), %edx
; X32_GISEL-NEXT:    retl
;
; X32_ISEL-LABEL: test_i64_args_8:
; X32_ISEL:       # BB#0:
; X32_ISEL-NEXT:    movl 60(%esp), %eax
; X32_ISEL-NEXT:    movl 64(%esp), %edx
; X32_ISEL-NEXT:    retl
;
; X64_GISEL-LABEL: test_i64_args_8:
; X64_GISEL:       # BB#0:
; X64_GISEL-NEXT:    leaq 16(%rsp), %rax
; X64_GISEL-NEXT:    movq (%rax), %rax
; X64_GISEL-NEXT:    retq
;
; X64_ISEL-LABEL: test_i64_args_8:
; X64_ISEL:       # BB#0:
; X64_ISEL-NEXT:    movq 16(%rsp), %rax
; X64_ISEL-NEXT:    retq

  ret i64 %arg8
}

define <4 x i32> @test_v4i32_args(<4 x i32> %arg1, <4 x i32> %arg2) {
; X32-LABEL: test_v4i32_args:
; X32:       # BB#0:
; X32-NEXT:    movaps %xmm1, %xmm0
; X32-NEXT:    retl
;
; X64-LABEL: test_v4i32_args:
; X64:       # BB#0:
; X64-NEXT:    movaps %xmm1, %xmm0
; X64-NEXT:    retq
  ret <4 x i32> %arg2
}

define <8 x i32> @test_v8i32_args(<8 x i32> %arg1) {
; X32-LABEL: test_v8i32_args:
; X32:       # BB#0:
; X32-NEXT:    retl
;
; X64-LABEL: test_v8i32_args:
; X64:       # BB#0:
; X64-NEXT:    retq

  ret <8 x i32> %arg1
}