llvm.org GIT mirror llvm / d1f487b
Fix for Bug 34475 - LOCK/REP/REPNE prefixes emitted as instruction on their own. Differential Revision: https://reviews.llvm.org/D39546 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317330 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew V. Tischenko 1 year, 11 months ago
8 changed file(s) with 68 addition(s) and 130 deletion(s). Raw diff Collapse all Expand all
5353 if (TSFlags & X86II::LOCK)
5454 OS << "\tlock\t";
5555 if (!(TSFlags & X86II::LOCK) && Flags & X86::IP_HAS_LOCK)
56 OS << "\tlock\n";
56 OS << "\tlock\t";
5757
5858 if (Flags & X86::IP_HAS_REPEAT_NE)
59 OS << "\trepne\n";
59 OS << "\trepne\t";
6060 else if (Flags & X86::IP_HAS_REPEAT)
61 OS << "\trep\n";
61 OS << "\trep\t";
6262
6363 // Output CALLpcrel32 as "callq" in 64-bit mode.
6464 // In Intel annotation it's always emitted as "call".
4040 uint64_t TSFlags = Desc.TSFlags;
4141
4242 if (TSFlags & X86II::LOCK)
43 OS << "\tlock\n";
43 OS << "\tlock\t";
4444
4545 unsigned Flags = MI->getFlags();
4646 if (Flags & X86::IP_HAS_REPEAT_NE)
47 OS << "\trepne\n";
47 OS << "\trepne\t";
4848 else if (Flags & X86::IP_HAS_REPEAT)
49 OS << "\trep\n";
49 OS << "\trep\t";
5050
5151 printInstruction(MI, OS);
5252
1818 %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %retval.sroa.2.0.extract.trunc, 1
1919 ret { i64, i64 } %.fca.1.insert
2020 }
21 ; CHECK: lock
22 ; CHECK-NEXT: cmpxchg16b
21 ; CHECK: lock cmpxchg16b
2322
2423 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
2524 attributes #1 = { nounwind }
3838 ; CHECK: [[B]]:
3939 ; CHECK-NEXT: popfq
4040
41 ; CHECK: rep
42 ; CHECK-NEXT: movsb (%rsi), %es:(%rdi)
41 ; CHECK: rep movsb (%rsi), %es:(%rdi)
4342
4443 ; Function Attrs: nounwind sanitize_address uwtable
4544 define void @rep_movs_1b(i8* %dst, i8* %src, i64 %n) #0 {
7271 ; CHECK: [[Q]]:
7372 ; CHECK-NEXT: popfq
7473
75 ; CHECK: rep
76 ; CHECK-NEXT: movsq (%rsi), %es:(%rdi)
74 ; CHECK: rep movsq (%rsi), %es:(%rdi)
7775
7876 ; Function Attrs: nounwind sanitize_address uwtable
7977 define void @rep_movs_8b(i64* %dst, i64* %src, i64 %n) #0 {
22 # CHECK: movl %fs:24, %eax
33 0x64 0xa1 0x18 0x00 0x00 0x00 # mov eax, dword ptr fs:[18h]
44
5 # CHECK: rep
6 # CHECK-NEXT: insb %dx, %es:(%edi)
5 # CHECK: rep insb %dx, %es:(%edi)
76 0xf3 0x6c #rep ins
8 # CHECK: rep
9 # CHECK-NEXT: insl %dx, %es:(%edi)
7 # CHECK: rep insl %dx, %es:(%edi)
108 0xf3 0x6d #rep ins
11 # CHECK: rep
12 # CHECK-NEXT: movsb (%esi), %es:(%edi)
9 # CHECK: rep movsb (%esi), %es:(%edi)
1310 0xf3 0xa4 #rep movs
14 # CHECK: rep
15 # CHECK-NEXT: movsl (%esi), %es:(%edi)
11 # CHECK: rep movsl (%esi), %es:(%edi)
1612 0xf3 0xa5 #rep movs
17 # CHECK: rep
18 # CHECK-NEXT: outsb (%esi), %dx
13 # CHECK: rep outsb (%esi), %dx
1914 0xf3 0x6e #rep outs
20 # CHECK: rep
21 # CHECK-NEXT: outsl (%esi), %dx
15 # CHECK: rep outsl (%esi), %dx
2216 0xf3 0x6f #rep outs
23 # CHECK: rep
24 # CHECK-NEXT: lodsb (%esi), %al
17 # CHECK: rep lodsb (%esi), %al
2518 0xf3 0xac #rep lods
26 # CHECK: rep
27 # CHECK-NEXT: lodsl (%esi), %eax
19 # CHECK: rep lodsl (%esi), %eax
2820 0xf3 0xad #rep lods
29 # CHECK: rep
30 # CHECK-NEXT: stosb %al, %es:(%edi)
21 # CHECK: rep stosb %al, %es:(%edi)
3122 0xf3 0xaa #rep stos
32 # CHECK: rep
33 # CHECK-NEXT: stosl %eax, %es:(%edi)
23 # CHECK: rep stosl %eax, %es:(%edi)
3424 0xf3 0xab #rep stos
35 # CHECK: rep
36 # CHECK-NEXT: cmpsb %es:(%edi), (%esi)
25 # CHECK: rep cmpsb %es:(%edi), (%esi)
3726 0xf3 0xa6 #rep cmps
38 # CHECK: rep
39 # CHECK-NEXT: cmpsl %es:(%edi), (%esi)
27 # CHECK: rep cmpsl %es:(%edi), (%esi)
4028 0xf3 0xa7 #repe cmps
41 # CHECK: rep
42 # CHECK-NEXT: scasb %es:(%edi), %al
29 # CHECK: rep scasb %es:(%edi), %al
4330 0xf3 0xae #repe scas
44 # CHECK: rep
45 # CHECK-NEXT: scasl %es:(%edi), %eax
31 # CHECK: rep scasl %es:(%edi), %eax
4632 0xf3 0xaf #repe scas
47 # CHECK: repne
48 # CHECK-NEXT: cmpsb %es:(%edi), (%esi)
33 # CHECK: repne cmpsb %es:(%edi), (%esi)
4934 0xf2 0xa6 #repne cmps
50 # CHECK: repne
51 # CHECK-NEXT: cmpsl %es:(%edi), (%esi)
35 # CHECK: repne cmpsl %es:(%edi), (%esi)
5236 0xf2 0xa7 #repne cmps
53 # CHECK: repne
54 # CHECK-NEXT: scasb %es:(%edi), %al
37 # CHECK: repne scasb %es:(%edi), %al
5538 0xf2 0xae #repne scas
56 # CHECK: repne
57 # CHECK-NEXT: scasl %es:(%edi), %eax
39 # CHECK: repne scasl %es:(%edi), %eax
5840 0xf2 0xaf #repne scas
5941
60 # CHECK: repne
61 # CHECK-NEXT: scasw %es:(%edi), %ax
42 # CHECK: repne scasw %es:(%edi), %ax
6243 0xf2 0x66 0xaf
63 # CHECK: repne
64 # CHECK-NEXT: scasw %es:(%edi), %ax
44 # CHECK: repne scasw %es:(%edi), %ax
6545 0x66 0xf2 0xaf
6646
67 # CHECK: rep
68 # CHECK-NEXT: scasw %es:(%edi), %ax
47 # CHECK: rep scasw %es:(%edi), %ax
6948 0xf3 0x66 0xaf
70 # CHECK: rep
71 # CHECK-NEXT: scasw %es:(%edi), %ax
49 # CHECK: rep scasw %es:(%edi), %ax
7250 0x66 0xf3 0xaf
7351
74 # CHECK: repne
75 # CHECK: insw %dx, %es:(%edi)
52 # CHECK: repne insw %dx, %es:(%edi)
7653 0xf2 0x66 0x6d
77 # CHECK: repne
78 # CHECK: insw %dx, %es:(%edi)
54 # CHECK: repne insw %dx, %es:(%edi)
7955 0x66 0xf2 0x6d
8056
81 # CHECK: rep
82 # CHECK: insw %dx, %es:(%edi)
57 # CHECK: rep insw %dx, %es:(%edi)
8358 0xf3 0x66 0x6d
84 # CHECK: rep
85 # CHECK: insw %dx, %es:(%edi)
59 # CHECK: rep insw %dx, %es:(%edi)
8660 0x66 0xf3 0x6d
88 # CHECK: mulsd %xmm7, %xmm7
99 0xf2 0x66 0x0f 0x59 0xff
1010
11 # CHECK: repne
12 # CHECK-NEXT: scasw %es:(%rdi), %ax
11 # CHECK: repne scasw %es:(%rdi), %ax
1312 0xf2 0x66 0xaf
14 # CHECK: rep
15 # CHECK-NEXT: scasw %es:(%rdi), %ax
13 # CHECK: repne scasw %es:(%rdi), %ax
1614 0x66 0xf2 0xaf
1715
18 # CHECK: rep
19 # CHECK-NEXT: scasw %es:(%rdi), %ax
16 # CHECK: rep scasw %es:(%rdi), %ax
2017 0xf3 0x66 0xaf
21 # CHECK: rep
22 # CHECK-NEXT: scasw %es:(%rdi), %ax
18 # CHECK: rep scasw %es:(%rdi), %ax
2319 0x66 0xf3 0xaf
2420
25 # CHECK: repne
26 # CHECK: insw %dx, %es:(%rdi)
21 # CHECK: repne insw %dx, %es:(%rdi)
2722 0xf2 0x66 0x6d
28 # CHECK: repne
29 # CHECK: insw %dx, %es:(%rdi)
23 # CHECK: repne insw %dx, %es:(%rdi)
3024 0x66 0xf2 0x6d
3125
32 # CHECK: rep
33 # CHECK: insw %dx, %es:(%rdi)
26 # CHECK: rep insw %dx, %es:(%rdi)
3427 0xf3 0x66 0x6d
35 # CHECK: rep
36 # CHECK: insw %dx, %es:(%rdi)
28 # CHECK: rep insw %dx, %es:(%rdi)
3729 0x66 0xf3 0x6d
0 # RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s
11
2 # CHECK: rep
3 # CHECK-NEXT: insb %dx, %es:(%rdi)
2 # CHECK: rep insb %dx, %es:(%rdi)
43 0xf3 0x6c #rep ins
5 # CHECK: rep
6 # CHECK-NEXT: insl %dx, %es:(%rdi)
4 # CHECK: rep insl %dx, %es:(%rdi)
75 0xf3 0x6d #rep ins
8 # CHECK: rep
9 # CHECK-NEXT: movsb (%rsi), %es:(%rdi)
6 # CHECK: rep movsb (%rsi), %es:(%rdi)
107 0xf3 0xa4 #rep movs
11 # CHECK: rep
12 # CHECK-NEXT: movsl (%rsi), %es:(%rdi)
8 # CHECK: rep movsl (%rsi), %es:(%rdi)
139 0xf3 0xa5 #rep movs
14 # CHECK: rep
15 # CHECK-NEXT: outsb (%rsi), %dx
10 # CHECK: rep outsb (%rsi), %dx
1611 0xf3 0x6e #rep outs
17 # CHECK: rep
18 # CHECK-NEXT: outsl (%rsi), %dx
12 # CHECK: rep outsl (%rsi), %dx
1913 0xf3 0x6f #rep outs
20 # CHECK: rep
21 # CHECK-NEXT: lodsb (%rsi), %al
14 # CHECK: rep lodsb (%rsi), %al
2215 0xf3 0xac #rep lods
23 # CHECK: rep
24 # CHECK-NEXT: lodsl (%rsi), %eax
16 # CHECK: rep lodsl (%rsi), %eax
2517 0xf3 0xad #rep lods
26 # CHECK: rep
27 # CHECK-NEXT: stosb %al, %es:(%rdi)
18 # CHECK: rep stosb %al, %es:(%rdi)
2819 0xf3 0xaa #rep stos
29 # CHECK: rep
30 # CHECK-NEXT: stosl %eax, %es:(%rdi)
20 # CHECK: rep stosl %eax, %es:(%rdi)
3121 0xf3 0xab #rep stos
32 # CHECK: rep
33 # CHECK-NEXT: cmpsb %es:(%rdi), (%rsi)
22 # CHECK: rep cmpsb %es:(%rdi), (%rsi)
3423 0xf3 0xa6 #rep cmps
35 # CHECK: rep
36 # CHECK-NEXT: cmpsl %es:(%rdi), (%rsi)
24 # CHECK: rep cmpsl %es:(%rdi), (%rsi)
3725 0xf3 0xa7 #repe cmps
38 # CHECK: rep
39 # CHECK-NEXT: scasb %es:(%rdi), %al
26 # CHECK: rep scasb %es:(%rdi), %al
4027 0xf3 0xae #repe scas
41 # CHECK: rep
42 # CHECK-NEXT: scasl %es:(%rdi), %eax
28 # CHECK: rep scasl %es:(%rdi), %eax
4329 0xf3 0xaf #repe scas
44 # CHECK: repne
45 # CHECK-NEXT: cmpsb %es:(%rdi), (%rsi)
30 # CHECK: repne cmpsb %es:(%rdi), (%rsi)
4631 0xf2 0xa6 #repne cmps
47 # CHECK: repne
48 # CHECK-NEXT: cmpsl %es:(%rdi), (%rsi)
32 # CHECK: repne cmpsl %es:(%rdi), (%rsi)
4933 0xf2 0xa7 #repne cmps
50 # CHECK: repne
51 # CHECK-NEXT: scasb %es:(%rdi), %al
34 # CHECK: repne scasb %es:(%rdi), %al
5235 0xf2 0xae #repne scas
53 # CHECK: repne
54 # CHECK-NEXT: scasl %es:(%rdi), %eax
36 # CHECK: repne scasl %es:(%rdi), %eax
5537 0xf2 0xaf #repne scas
5638
5739 # CHECK: lock
58 # CHECK-NEXT: orl $16, %fs:776
40 # CHECK-NEXT: orl $16, %fs:776
5941 0xf0 0x64 0x83 0x0c 0x25 0x08 0x03 0x00 0x00 0x10
6042
6143 # CHECK: movq %fs:768, %rdi
6244 0x64 0x48 0x8b 0x3c 0x25 0x00 0x03 0x00 0x00
6345
64 # CHECK: rep
65 # CHECK-NEXT: stosq %rax, %es:(%rdi)
46 # CHECK: rep stosq %rax, %es:(%rdi)
6647 0xf3 0x48 0xab
6748
68 # CHECK: rep
69 # CHECK-NEXT: stosq %rax, %es:(%edi)
49 # CHECK: rep stosq %rax, %es:(%edi)
7050 0xf3 0x67 0x48 0xab
7151
7252 # CHECK: movl 32(%rbp), %eax
10383 0x66,0x83,0xc0,0xf4
10484
10585 # Test that multiple redundant prefixes work (redundant, but valid x86).
106 # CHECK: rep
107 # CHECK-NEXT: stosq
86 # CHECK: rep stosq
10887 0xf3 0xf3 0x48 0xab
109
11088
11189 # Test that we can disassembler control registers above CR8
11290 # CHECK: movq %cr15, %rax
850850 0xf0 0x48 0x0f 0xc1 0xcb
851851
852852 # rdar://13493622 lldb doesn't print the x86 rep/repne prefix when disassembling
853 # CHECK: repne
854 # CHECK-NEXT: movsl
853 # CHECK: repne movsl
855854 0xf2 0xa5
856 # CHECK: repne
857 # CHECK-NEXT: movsq
855 # CHECK: repne movsq
858856 0xf2 0x48 0xa5
859 # CHECK: repne
860 # CHECK-NEXT: movb $0, (%rax)
857 # CHECK: repne movb $0, (%rax)
861858 0xf2 0xc6 0x0 0x0
862859
863860 # rdar://11019859 Support 2013 Haswell RTM instructions and HLE prefixes