Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1418)

Side by Side Diff: tests_lit/llvm2ice_tests/alloc.ll

Issue 1156713003: Subzero ARM: lower alloca instruction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: trailing space Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; This is a basic test of the alloca instruction. 1 ; This is a basic test of the alloca instruction.
2 2
3 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
4 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 | FileCheck %s 4 ; RUN: --target x8632 -i %s --args -O2 \
5 ; RUN: | %if --need=target_X8632 --command FileCheck %s
6
7 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
8 ; RUN: --target x8632 -i %s --args -Om1 \
9 ; RUN: | %if --need=target_X8632 --command FileCheck %s
10
11 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented)
12 ; once enough infrastructure is in. Also, switch to --filetype=obj
13 ; when possible.
14 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \
15 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \
16 ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32 %s
5 17
6 define void @fixed_416_align_16(i32 %n) { 18 define void @fixed_416_align_16(i32 %n) {
7 entry: 19 entry:
8 %array = alloca i8, i32 416, align 16 20 %array = alloca i8, i32 416, align 16
9 %__2 = ptrtoint i8* %array to i32 21 %__2 = ptrtoint i8* %array to i32
10 call void @f1(i32 %__2) 22 call void @f1(i32 %__2)
11 ret void 23 ret void
12 } 24 }
13 ; CHECK-LABEL: fixed_416_align_16 25 ; CHECK-LABEL: fixed_416_align_16
14 ; CHECK: sub esp,0x1a0 26 ; CHECK: sub esp,0x1a0
15 ; CHECK: sub esp,0x10 27 ; CHECK: sub esp,0x10
16 ; CHECK: mov DWORD PTR [esp],eax 28 ; CHECK: mov DWORD PTR [esp],eax
17 ; CHECK: call {{.*}} R_{{.*}} f1 29 ; CHECK: call {{.*}} R_{{.*}} f1
18 30
31 ; ARM32-LABEL: fixed_416_align_16
32 ; ARM32: sub sp, sp, #416
33 ; ARM32: bl {{.*}} R_{{.*}} f1
34
19 define void @fixed_416_align_32(i32 %n) { 35 define void @fixed_416_align_32(i32 %n) {
20 entry: 36 entry:
21 %array = alloca i8, i32 400, align 32 37 %array = alloca i8, i32 400, align 32
22 %__2 = ptrtoint i8* %array to i32 38 %__2 = ptrtoint i8* %array to i32
23 call void @f1(i32 %__2) 39 call void @f1(i32 %__2)
24 ret void 40 ret void
25 } 41 }
26 ; CHECK-LABEL: fixed_416_align_32 42 ; CHECK-LABEL: fixed_416_align_32
27 ; CHECK: and esp,0xffffffe0 43 ; CHECK: and esp,0xffffffe0
28 ; CHECK: sub esp,0x1a0 44 ; CHECK: sub esp,0x1a0
29 ; CHECK: sub esp,0x10 45 ; CHECK: sub esp,0x10
30 ; CHECK: mov DWORD PTR [esp],eax 46 ; CHECK: mov DWORD PTR [esp],eax
31 ; CHECK: call {{.*}} R_{{.*}} f1 47 ; CHECK: call {{.*}} R_{{.*}} f1
32 48
49 ; ARM32-LABEL: fixed_416_align_32
50 ; ARM32: bic sp, sp, #31
51 ; ARM32: sub sp, sp, #416
52 ; ARM32: bl {{.*}} R_{{.*}} f1
53
54 ; Show that the amount to allocate will be rounded up.
33 define void @fixed_351_align_16(i32 %n) { 55 define void @fixed_351_align_16(i32 %n) {
34 entry: 56 entry:
35 %array = alloca i8, i32 351, align 16 57 %array = alloca i8, i32 351, align 16
36 %__2 = ptrtoint i8* %array to i32 58 %__2 = ptrtoint i8* %array to i32
37 call void @f1(i32 %__2) 59 call void @f1(i32 %__2)
38 ret void 60 ret void
39 } 61 }
40 ; CHECK-LABEL: fixed_351_align_16 62 ; CHECK-LABEL: fixed_351_align_16
41 ; CHECK: sub esp,0x160 63 ; CHECK: sub esp,0x160
42 ; CHECK: sub esp,0x10 64 ; CHECK: sub esp,0x10
43 ; CHECK: mov DWORD PTR [esp],eax 65 ; CHECK: mov DWORD PTR [esp],eax
44 ; CHECK: call {{.*}} R_{{.*}} f1 66 ; CHECK: call {{.*}} R_{{.*}} f1
45 67
68 ; ARM32-LABEL: fixed_351_align_16
69 ; ARM32: sub sp, sp, #352
70 ; ARM32: bl {{.*}} R_{{.*}} f1
71
46 define void @fixed_351_align_32(i32 %n) { 72 define void @fixed_351_align_32(i32 %n) {
47 entry: 73 entry:
48 %array = alloca i8, i32 351, align 32 74 %array = alloca i8, i32 351, align 32
49 %__2 = ptrtoint i8* %array to i32 75 %__2 = ptrtoint i8* %array to i32
50 call void @f1(i32 %__2) 76 call void @f1(i32 %__2)
51 ret void 77 ret void
52 } 78 }
53 ; CHECK-LABEL: fixed_351_align_32 79 ; CHECK-LABEL: fixed_351_align_32
54 ; CHECK: and esp,0xffffffe0 80 ; CHECK: and esp,0xffffffe0
55 ; CHECK: sub esp,0x160 81 ; CHECK: sub esp,0x160
56 ; CHECK: sub esp,0x10 82 ; CHECK: sub esp,0x10
57 ; CHECK: mov DWORD PTR [esp],eax 83 ; CHECK: mov DWORD PTR [esp],eax
58 ; CHECK: call {{.*}} R_{{.*}} f1 84 ; CHECK: call {{.*}} R_{{.*}} f1
59 85
86 ; ARM32-LABEL: fixed_351_align_32
87 ; ARM32: bic sp, sp, #31
88 ; ARM32: sub sp, sp, #352
89 ; ARM32: bl {{.*}} R_{{.*}} f1
90
60 declare void @f1(i32 %ignored) 91 declare void @f1(i32 %ignored)
61 92
93 declare void @f2(i32 %ignored)
94
62 define void @variable_n_align_16(i32 %n) { 95 define void @variable_n_align_16(i32 %n) {
63 entry: 96 entry:
64 %array = alloca i8, i32 %n, align 16 97 %array = alloca i8, i32 %n, align 16
65 %__2 = ptrtoint i8* %array to i32 98 %__2 = ptrtoint i8* %array to i32
66 call void @f2(i32 %__2) 99 call void @f2(i32 %__2)
67 ret void 100 ret void
68 } 101 }
69 ; CHECK-LABEL: variable_n_align_16 102 ; CHECK-LABEL: variable_n_align_16
70 ; CHECK: mov eax,DWORD PTR [ebp+0x8] 103 ; CHECK: mov eax,DWORD PTR [ebp+0x8]
71 ; CHECK: add eax,0xf 104 ; CHECK: add eax,0xf
72 ; CHECK: and eax,0xfffffff0 105 ; CHECK: and eax,0xfffffff0
73 ; CHECK: sub esp,eax 106 ; CHECK: sub esp,eax
74 ; CHECK: sub esp,0x10 107 ; CHECK: sub esp,0x10
75 ; CHECK: mov DWORD PTR [esp],eax 108 ; CHECK: mov DWORD PTR [esp],eax
76 ; CHECK: call {{.*}} R_{{.*}} f2 109 ; CHECK: call {{.*}} R_{{.*}} f2
77 110
111 ; ARM32-LABEL: variable_n_align_16
112 ; ARM32: add r0, r0, #15
113 ; ARM32: bic r0, r0, #15
114 ; ARM32: sub sp, sp, r0
115 ; ARM32: bl {{.*}} R_{{.*}} f2
116
78 define void @variable_n_align_32(i32 %n) { 117 define void @variable_n_align_32(i32 %n) {
79 entry: 118 entry:
80 %array = alloca i8, i32 %n, align 32 119 %array = alloca i8, i32 %n, align 32
81 %__2 = ptrtoint i8* %array to i32 120 %__2 = ptrtoint i8* %array to i32
82 call void @f2(i32 %__2) 121 call void @f2(i32 %__2)
83 ret void 122 ret void
84 } 123 }
85 ; In -O2, the order of the CHECK-DAG lines in the output is switched. 124 ; In -O2, the order of the CHECK-DAG lines in the output is switched.
86 ; CHECK-LABEL: variable_n_align_32 125 ; CHECK-LABEL: variable_n_align_32
87 ; CHECK-DAG: and esp,0xffffffe0 126 ; CHECK-DAG: and esp,0xffffffe0
88 ; CHECK-DAG: mov eax,DWORD PTR [ebp+0x8] 127 ; CHECK-DAG: mov eax,DWORD PTR [ebp+0x8]
89 ; CHECK: add eax,0x1f 128 ; CHECK: add eax,0x1f
90 ; CHECK: and eax,0xffffffe0 129 ; CHECK: and eax,0xffffffe0
91 ; CHECK: sub esp,eax 130 ; CHECK: sub esp,eax
92 ; CHECK: sub esp,0x10 131 ; CHECK: sub esp,0x10
93 ; CHECK: mov DWORD PTR [esp],eax 132 ; CHECK: mov DWORD PTR [esp],eax
94 ; CHECK: call {{.*}} R_{{.*}} f2 133 ; CHECK: call {{.*}} R_{{.*}} f2
95 134
135 ; ARM32-LABEL: variable_n_align_32
136 ; ARM32: bic sp, sp, #31
137 ; ARM32: add r0, r0, #31
138 ; ARM32: bic r0, r0, #31
139 ; ARM32: sub sp, sp, r0
140 ; ARM32: bl {{.*}} R_{{.*}} f2
141
96 ; Test alloca with default (0) alignment. 142 ; Test alloca with default (0) alignment.
97 define void @align0(i32 %n) { 143 define void @align0(i32 %n) {
98 entry: 144 entry:
99 %array = alloca i8, i32 %n 145 %array = alloca i8, i32 %n
100 %__2 = ptrtoint i8* %array to i32 146 %__2 = ptrtoint i8* %array to i32
101 call void @f2(i32 %__2) 147 call void @f2(i32 %__2)
102 ret void 148 ret void
103 } 149 }
104 ; CHECK-LABEL: align0 150 ; CHECK-LABEL: align0
105 ; CHECK: add [[REG:.*]],0xf 151 ; CHECK: add [[REG:.*]],0xf
106 ; CHECK: and [[REG]],0xfffffff0 152 ; CHECK: and [[REG]],0xfffffff0
107 ; CHECK: sub esp,[[REG]] 153 ; CHECK: sub esp,[[REG]]
108 154
109 declare void @f2(i32 %ignored) 155 ; ARM32-LABEL: align0
156 ; ARM32: add r0, r0, #15
157 ; ARM32: bic r0, r0, #15
158 ; ARM32: sub sp, sp, r0
159
160 ; Test a large alignment where a mask might not fit in an immediate
161 ; field of an instruction for some architectures.
162 define void @align1MB(i32 %n) {
163 entry:
164 %array = alloca i8, i32 %n, align 1048576
165 %__2 = ptrtoint i8* %array to i32
166 call void @f2(i32 %__2)
167 ret void
168 }
169 ; CHECK-LABEL: align1MB
170 ; CHECK: and esp,0xfff00000
171 ; CHECK: add [[REG:.*]],0xfffff
172 ; CHECK: and [[REG]],0xfff00000
173 ; CHECK: sub esp,[[REG]]
174
175 ; ARM32-LABEL: align1MB
176 ; ARM32: movw [[REG:.*]], #0
177 ; ARM32: movt [[REG]], #65520 ; 0xfff0
178 ; ARM32: and sp, sp, [[REG]]
179 ; ARM32: movw [[REG2:.*]], #65535 ; 0xffff
180 ; ARM32: movt [[REG2]], #15
181 ; ARM32: add r0, r0, [[REG2]]
182 ; ARM32: movw [[REG3:.*]], #0
183 ; ARM32: movt [[REG3]], #65520 ; 0xfff0
184 ; ARM32: and r0, r0, [[REG3]]
185 ; ARM32: sub sp, sp, r0
186
187 ; Test a large alignment where a mask might still fit in an immediate
188 ; field of an instruction for some architectures.
189 define void @align512MB(i32 %n) {
190 entry:
191 %array = alloca i8, i32 %n, align 536870912
192 %__2 = ptrtoint i8* %array to i32
193 call void @f2(i32 %__2)
194 ret void
195 }
196 ; CHECK-LABEL: align512MB
197 ; CHECK: and esp,0xe0000000
198 ; CHECK: add [[REG:.*]],0x1fffffff
199 ; CHECK: and [[REG]],0xe0000000
200 ; CHECK: sub esp,[[REG]]
201
202 ; ARM32-LABEL: align512MB
203 ; ARM32: and sp, sp, #-536870912 ; 0xe0000000
204 ; ARM32: mvn [[REG:.*]], #-536870912 ; 0xe0000000
205 ; ARM32: add r0, r0, [[REG]]
206 ; ARM32: and r0, r0, #-536870912 ; 0xe0000000
207 ; ARM32: sub sp, sp, r0
OLDNEW
« no previous file with comments | « src/IceUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698