llvm.org GIT mirror llvm / 16996c4
Tests for the aligned bundling support added in r170718 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170719 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Bendersky 7 years ago
13 changed file(s) with 289 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # RUN: llvm-mc -filetype=obj -triple armv7-linux-gnueabi %s -o - \
1 # RUN: | llvm-objdump -no-show-raw-insn -triple armv7 -disassemble - | FileCheck %s
2
3 # On ARM each instruction is 4 bytes long so padding for individual
4 # instructions should not be inserted. However, for bundle=locked groups
5 # it can be.
6
7 .syntax unified
8 .text
9 .bundle_align_mode 4
10
11 bx lr
12 and r1, r1, r2
13 and r1, r1, r2
14 .bundle_lock
15 bx r9
16 bx r8
17 .bundle_unlock
18 # CHECK: c: nop
19 # CHECK-NEXT: 10: bx
20 # CHECK-NEXT: 14: bx
21
22 # pow2 here
23 .align 4
24 bx lr
25 .bundle_lock
26 bx r9
27 bx r9
28 bx r9
29 bx r8
30 .bundle_unlock
31 # CHECK: 20: bx
32 # CHECK-NEXT: 24: nop
33 # CHECK-NEXT: 28: nop
34 # CHECK-NEXT: 2c: nop
35 # CHECK-NEXT: 30: bx
36
0 config.suffixes = ['.s']
1
2 targets = set(config.root.targets_to_build.split())
3 if not 'X86' in targets:
4 config.unsupported = True
5
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # Missing .bundle_align_mode argument
3 # CHECK: error: unknown token
4
5 .bundle_align_mode
6 imull $17, %ebx, %ebp
7
0 # RUN: llvm-mc -filetype=asm -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # Just a simple test for the assembly emitter - making sure it emits back the
3 # bundling directives.
4
5 .text
6 foo:
7 .bundle_align_mode 4
8 # CHECK: .bundle_align_mode 4
9 pushq %rbp
10 .bundle_lock
11 # CHECK: .bundle_lock
12 cmpl %r14d, %ebp
13 jle .L_ELSE
14 .bundle_unlock
15 # CHECK: .bundle_unlock
16
17
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # CHECK: ERROR: Fragment can't be larger than a bundle size
3
4 .text
5 foo:
6 .bundle_align_mode 4
7 pushq %rbp
8
9 .bundle_lock
10 pushq %r14
11 callq bar
12 callq bar
13 callq bar
14 callq bar
15 .bundle_unlock
16
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
1 # RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
2
3 # Test two different executable sections with bundling.
4
5 .bundle_align_mode 3
6 .section text1, "x"
7 # CHECK: section text1
8 imull $17, %ebx, %ebp
9 imull $17, %ebx, %ebp
10
11 imull $17, %ebx, %ebp
12 # CHECK: 6: nop
13 # CHECK-NEXT: 8: imull
14
15 .section text2, "x"
16 # CHECK: section text2
17 imull $17, %ebx, %ebp
18 imull $17, %ebx, %ebp
19
20 imull $17, %ebx, %ebp
21 # CHECK: 6: nop
22 # CHECK-NEXT: 8: imull
23
24
0 config.suffixes = ['.s']
1
2 targets = set(config.root.targets_to_build.split())
3 if not 'X86' in targets:
4 config.unsupported = True
5
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # .bundle_lock can't come without a .bundle_align_mode before it
3
4 # CHECK: ERROR: .bundle_lock forbidden when bundling is disabled
5
6 imull $17, %ebx, %ebp
7 .bundle_lock
8
9
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
1 # RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
2
3 # Test some variations of padding for bundle-locked groups.
4
5 .text
6 foo:
7 .bundle_align_mode 4
8
9 # Each of these callq instructions is 5 bytes long
10 callq bar
11 callq bar
12
13 .bundle_lock
14 callq bar
15 callq bar
16 .bundle_unlock
17 # We'll need a 6-byte NOP before this group
18 # CHECK: a: nop
19 # CHECK-NEXT: 10: callq
20 # CHECK-NEXT: 15: callq
21
22 .bundle_lock
23 callq bar
24 callq bar
25 .bundle_unlock
26 # Same here
27 # CHECK: 1a: nop
28 # CHECK-NEXT: 20: callq
29 # CHECK-NEXT: 25: callq
30
31 .align 16, 0x90
32 callq bar
33 .bundle_lock
34 callq bar
35 callq bar
36 callq bar
37 .bundle_unlock
38 # And here we'll need a 11-byte NOP
39 # CHECK: 30: callq
40 # CHECK: 35: nop
41 # CHECK-NEXT: 40: callq
42 # CHECK-NEXT: 45: callq
43
44
45
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
1 # RUN: | llvm-objdump -disassemble - | FileCheck %s
2
3 # Test that instructions inside bundle-locked groups are relaxed even if their
4 # fixup is short enough not to warrant relaxation on its own.
5
6 .text
7 foo:
8 .bundle_align_mode 4
9 pushq %rbp
10
11 movl %edi, %ebx
12 callq bar
13 movl %eax, %r14d
14 imull $17, %ebx, %ebp
15 movl %ebx, %edi
16 callq bar
17 cmpl %r14d, %ebp
18 .bundle_lock
19
20 jle .L_ELSE
21 # This group would've started at 0x18 and is too long, so a chunky NOP padding
22 # is inserted to push it to 0x20.
23 # CHECK: 18: {{[a-f0-9 ]+}} nopl
24
25 # The long encoding for JLE should be used here even though its target is close
26 # CHECK-NEXT: 20: 0f 8e
27
28 addl %ebp, %eax
29
30 jmp .L_RET
31 # Same for the JMP
32 # CHECK: 28: e9
33
34 .bundle_unlock
35
36 .L_ELSE:
37 imull %ebx, %eax
38 .L_RET:
39
40 popq %rbx
41
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
1 # RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
2
3 # Test simple NOP insertion for single instructions.
4
5 .text
6 foo:
7 # Will be bundle-aligning to 16 byte boundaries
8 .bundle_align_mode 4
9 pushq %rbp
10 pushq %r14
11 pushq %rbx
12
13 movl %edi, %ebx
14 callq bar
15 movl %eax, %r14d
16
17 imull $17, %ebx, %ebp
18 # This imull is 3 bytes long and should have started at 0xe, so two bytes
19 # of nop padding are inserted instead and it starts at 0x10
20 # CHECK: nop
21 # CHECK-NEXT: 10: imull
22
23 movl %ebx, %edi
24 callq bar
25 cmpl %r14d, %ebp
26 jle .L_ELSE
27 # Due to the padding that's inserted before the addl, the jump target
28 # becomes farther by one byte.
29 # CHECK: jle 5
30
31 addl %ebp, %eax
32 # CHECK: nop
33 # CHECK-NEXT: 20: addl
34
35 jmp .L_RET
36 .L_ELSE:
37 imull %ebx, %eax
38 .L_RET:
39 ret
40
41 # Just sanity checking that data fills don't drive bundling crazy
42 .data
43 .byte 40
44 .byte 98
45
46
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # This test invokes .bundle_lock and then switches to a different section
3 # w/o the appropriate unlock.
4
5 # CHECK: ERROR: Unterminated .bundle_lock
6
7 .bundle_align_mode 3
8 .section text1, "x"
9 imull $17, %ebx, %ebp
10 .bundle_lock
11 imull $17, %ebx, %ebp
12
13 .section text2, "x"
14 imull $17, %ebx, %ebp
15
0 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - |& FileCheck %s
1
2 # .bundle_unlock can't come without a .bundle_lock before it
3
4 # CHECK: ERROR: .bundle_unlock without matching lock
5
6 .bundle_align_mode 3
7 imull $17, %ebx, %ebp
8 .bundle_unlock
9
10