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

Side by Side Diff: tests_lit/assembler/x86/immediate_encodings.ll

Issue 1387963002: Make sure that all globals are internal, except for "start" functions. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix new tests. Created 5 years, 2 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/PNaClTranslator.cpp ('k') | tests_lit/assembler/x86/jump_encodings.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; Tests various aspects of x86 immediate encoding. Some encodings are shorter. 1 ; Tests various aspects of x86 immediate encoding. Some encodings are shorter.
2 ; For example, the encoding is shorter for 8-bit immediates or when using EAX. 2 ; For example, the encoding is shorter for 8-bit immediates or when using EAX.
3 ; This assumes that EAX is chosen as the first free register in O2 mode. 3 ; This assumes that EAX is chosen as the first free register in O2 mode.
4 4
5 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s 5 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s
6 6
7 define internal i32 @testXor8Imm8(i32 %arg) { 7 define internal i32 @testXor8Imm8(i32 %arg) {
8 entry: 8 entry:
9 %arg_i8 = trunc i32 %arg to i8 9 %arg_i8 = trunc i32 %arg to i8
10 %result_i8 = xor i8 %arg_i8, 127 10 %result_i8 = xor i8 %arg_i8, 127
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ; CHECK: 69 c0 01 04 00 00 imul eax,eax 243 ; CHECK: 69 c0 01 04 00 00 imul eax,eax
244 244
245 define internal i32 @testMul32Imm16Neg(i32 %arg) { 245 define internal i32 @testMul32Imm16Neg(i32 %arg) {
246 entry: 246 entry:
247 %result = mul i32 %arg, -255 247 %result = mul i32 %arg, -255
248 ret i32 %result 248 ret i32 %result
249 } 249 }
250 ; CHECK-LABEL: testMul32Imm16Neg 250 ; CHECK-LABEL: testMul32Imm16Neg
251 ; CHECK: 69 c0 01 ff ff ff imul eax,eax,0xffffff01 251 ; CHECK: 69 c0 01 ff ff ff imul eax,eax,0xffffff01
252 252
253 define i32 @testMul32Imm32ThreeAddress(i32 %a) { 253 define internal i32 @testMul32Imm32ThreeAddress(i32 %a) {
254 entry: 254 entry:
255 %mul = mul i32 232, %a 255 %mul = mul i32 232, %a
256 %add = add i32 %mul, %a 256 %add = add i32 %mul, %a
257 ret i32 %add 257 ret i32 %add
258 } 258 }
259 ; CHECK-LABEL: testMul32Imm32ThreeAddress 259 ; CHECK-LABEL: testMul32Imm32ThreeAddress
260 ; CHECK: 69 c8 e8 00 00 00 imul ecx,eax,0xe8 260 ; CHECK: 69 c8 e8 00 00 00 imul ecx,eax,0xe8
261 261
262 define i32 @testMul32Mem32Imm32ThreeAddress(i32 %addr_arg) { 262 define internal i32 @testMul32Mem32Imm32ThreeAddress(i32 %addr_arg) {
263 entry: 263 entry:
264 %__1 = inttoptr i32 %addr_arg to i32* 264 %__1 = inttoptr i32 %addr_arg to i32*
265 %a = load i32, i32* %__1, align 1 265 %a = load i32, i32* %__1, align 1
266 %mul = mul i32 232, %a 266 %mul = mul i32 232, %a
267 ret i32 %mul 267 ret i32 %mul
268 } 268 }
269 ; CHECK-LABEL: testMul32Mem32Imm32ThreeAddress 269 ; CHECK-LABEL: testMul32Mem32Imm32ThreeAddress
270 ; CHECK: 69 00 e8 00 00 00 imul eax,DWORD PTR [eax],0xe8 270 ; CHECK: 69 00 e8 00 00 00 imul eax,DWORD PTR [eax],0xe8
271 271
272 define i32 @testMul32Imm8ThreeAddress(i32 %a) { 272 define internal i32 @testMul32Imm8ThreeAddress(i32 %a) {
273 entry: 273 entry:
274 %mul = mul i32 127, %a 274 %mul = mul i32 127, %a
275 %add = add i32 %mul, %a 275 %add = add i32 %mul, %a
276 ret i32 %add 276 ret i32 %add
277 } 277 }
278 ; CHECK-LABEL: testMul32Imm8ThreeAddress 278 ; CHECK-LABEL: testMul32Imm8ThreeAddress
279 ; CHECK: 6b c8 7f imul ecx,eax,0x7f 279 ; CHECK: 6b c8 7f imul ecx,eax,0x7f
280 280
281 define i32 @testMul32Mem32Imm8ThreeAddress(i32 %addr_arg) { 281 define internal i32 @testMul32Mem32Imm8ThreeAddress(i32 %addr_arg) {
282 entry: 282 entry:
283 %__1 = inttoptr i32 %addr_arg to i32* 283 %__1 = inttoptr i32 %addr_arg to i32*
284 %a = load i32, i32* %__1, align 1 284 %a = load i32, i32* %__1, align 1
285 %mul = mul i32 127, %a 285 %mul = mul i32 127, %a
286 ret i32 %mul 286 ret i32 %mul
287 } 287 }
288 ; CHECK-LABEL: testMul32Mem32Imm8ThreeAddress 288 ; CHECK-LABEL: testMul32Mem32Imm8ThreeAddress
289 ; CHECK: 6b 00 7f imul eax,DWORD PTR [eax],0x7f 289 ; CHECK: 6b 00 7f imul eax,DWORD PTR [eax],0x7f
290 290
291 define i32 @testMul16Imm16ThreeAddress(i32 %a) { 291 define internal i32 @testMul16Imm16ThreeAddress(i32 %a) {
292 entry: 292 entry:
293 %arg_i16 = trunc i32 %a to i16 293 %arg_i16 = trunc i32 %a to i16
294 %mul = mul i16 232, %arg_i16 294 %mul = mul i16 232, %arg_i16
295 %add = add i16 %mul, %arg_i16 295 %add = add i16 %mul, %arg_i16
296 %result = zext i16 %add to i32 296 %result = zext i16 %add to i32
297 ret i32 %result 297 ret i32 %result
298 } 298 }
299 ; CHECK-LABEL: testMul16Imm16ThreeAddress 299 ; CHECK-LABEL: testMul16Imm16ThreeAddress
300 ; CHECK: 66 69 c8 e8 00 imul cx,ax,0xe8 300 ; CHECK: 66 69 c8 e8 00 imul cx,ax,0xe8
301 301
302 define i32 @testMul16Mem16Imm16ThreeAddress(i32 %addr_arg) { 302 define internal i32 @testMul16Mem16Imm16ThreeAddress(i32 %addr_arg) {
303 entry: 303 entry:
304 %__1 = inttoptr i32 %addr_arg to i16* 304 %__1 = inttoptr i32 %addr_arg to i16*
305 %a = load i16, i16* %__1, align 1 305 %a = load i16, i16* %__1, align 1
306 %mul = mul i16 232, %a 306 %mul = mul i16 232, %a
307 %result = zext i16 %mul to i32 307 %result = zext i16 %mul to i32
308 ret i32 %result 308 ret i32 %result
309 } 309 }
310 ; CHECK-LABEL: testMul16Mem16Imm16ThreeAddress 310 ; CHECK-LABEL: testMul16Mem16Imm16ThreeAddress
311 ; CHECK: 66 69 00 e8 00 imul ax,WORD PTR [eax],0xe8 311 ; CHECK: 66 69 00 e8 00 imul ax,WORD PTR [eax],0xe8
312 312
313 define i32 @testMul16Imm8ThreeAddress(i32 %a) { 313 define internal i32 @testMul16Imm8ThreeAddress(i32 %a) {
314 entry: 314 entry:
315 %arg_i16 = trunc i32 %a to i16 315 %arg_i16 = trunc i32 %a to i16
316 %mul = mul i16 127, %arg_i16 316 %mul = mul i16 127, %arg_i16
317 %add = add i16 %mul, %arg_i16 317 %add = add i16 %mul, %arg_i16
318 %result = zext i16 %add to i32 318 %result = zext i16 %add to i32
319 ret i32 %result 319 ret i32 %result
320 } 320 }
321 ; CHECK-LABEL: testMul16Imm8ThreeAddress 321 ; CHECK-LABEL: testMul16Imm8ThreeAddress
322 ; CHECK: 66 6b c8 7f imul cx,ax,0x7f 322 ; CHECK: 66 6b c8 7f imul cx,ax,0x7f
323 323
324 define i32 @testMul16Mem16Imm8ThreeAddress(i32 %addr_arg) { 324 define internal i32 @testMul16Mem16Imm8ThreeAddress(i32 %addr_arg) {
325 entry: 325 entry:
326 %__1 = inttoptr i32 %addr_arg to i16* 326 %__1 = inttoptr i32 %addr_arg to i16*
327 %a = load i16, i16* %__1, align 1 327 %a = load i16, i16* %__1, align 1
328 %mul = mul i16 127, %a 328 %mul = mul i16 127, %a
329 %result = zext i16 %mul to i32 329 %result = zext i16 %mul to i32
330 ret i32 %result 330 ret i32 %result
331 } 331 }
332 ; CHECK-LABEL: testMul16Mem16Imm8ThreeAddress 332 ; CHECK-LABEL: testMul16Mem16Imm8ThreeAddress
333 ; CHECK: 66 6b 00 7f imul ax,WORD PTR [eax],0x7f 333 ; CHECK: 66 6b 00 7f imul ax,WORD PTR [eax],0x7f
334 334
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ret i64 %shl 366 ret i64 %shl
367 } 367 }
368 ; CHECK-LABEL: test_via_shl64Bit 368 ; CHECK-LABEL: test_via_shl64Bit
369 ; CHECK: 0f a5 c2 shld edx,eax,cl 369 ; CHECK: 0f a5 c2 shld edx,eax,cl
370 ; CHECK: d3 e0 shl eax,cl 370 ; CHECK: d3 e0 shl eax,cl
371 ; CHECK: f6 c1 20 test cl,0x20 371 ; CHECK: f6 c1 20 test cl,0x20
372 372
373 ; Test a few register encodings of "test". 373 ; Test a few register encodings of "test".
374 declare i64 @llvm.ctlz.i64(i64, i1) 374 declare i64 @llvm.ctlz.i64(i64, i1)
375 375
376 define i64 @test_via_ctlz_64(i64 %x, i64 %y, i64 %z, i64 %w) { 376 define internal i64 @test_via_ctlz_64(i64 %x, i64 %y, i64 %z, i64 %w) {
377 entry: 377 entry:
378 %r = call i64 @llvm.ctlz.i64(i64 %x, i1 false) 378 %r = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
379 %r2 = call i64 @llvm.ctlz.i64(i64 %y, i1 false) 379 %r2 = call i64 @llvm.ctlz.i64(i64 %y, i1 false)
380 %r3 = call i64 @llvm.ctlz.i64(i64 %z, i1 false) 380 %r3 = call i64 @llvm.ctlz.i64(i64 %z, i1 false)
381 %r4 = call i64 @llvm.ctlz.i64(i64 %w, i1 false) 381 %r4 = call i64 @llvm.ctlz.i64(i64 %w, i1 false)
382 %res1 = add i64 %r, %r2 382 %res1 = add i64 %r, %r2
383 %res2 = add i64 %r3, %r4 383 %res2 = add i64 %r3, %r4
384 %res = add i64 %res1, %res2 384 %res = add i64 %res1, %res2
385 ret i64 %res 385 ret i64 %res
386 } 386 }
387 ; CHECK-LABEL: test_via_ctlz_64 387 ; CHECK-LABEL: test_via_ctlz_64
388 ; CHECK-DAG: 85 c0 test eax,eax 388 ; CHECK-DAG: 85 c0 test eax,eax
389 ; CHECK-DAG: 85 db test ebx,ebx 389 ; CHECK-DAG: 85 db test ebx,ebx
390 ; CHECK-DAG: 85 f6 test esi,esi 390 ; CHECK-DAG: 85 f6 test esi,esi
OLDNEW
« no previous file with comments | « src/PNaClTranslator.cpp ('k') | tests_lit/assembler/x86/jump_encodings.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698