1 ; RUN: llc < %s -mtriple=i686-- -mcpu=core2 -no-integrated-as | FileCheck %s
3 define i32 @t1() nounwind {
5 %0 = tail call i32 asm sideeffect inteldialect "mov eax, $1\0A\09mov $0, eax", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 1) nounwind
8 ; CHECK: {{## InlineAsm Start|#APP}}
13 ; CHECK: {{## InlineAsm End|#NO_APP}}
16 define void @t2() nounwind {
18 call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
21 ; CHECK: {{## InlineAsm Start|#APP}}
22 ; CHECK: .intel_syntax
25 ; CHECK: {{## InlineAsm End|#NO_APP}}
28 define void @t3(i32 %V) nounwind {
30 %V.addr = alloca i32, align 4
31 store i32 %V, ptr %V.addr, align 4
32 call void asm sideeffect inteldialect "mov eax, DWORD PTR [$0]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %V.addr) nounwind
35 ; CHECK: {{## InlineAsm Start|#APP}}
36 ; CHECK: .intel_syntax
37 ; CHECK: mov eax, DWORD PTR {{[[esp]}}
39 ; CHECK: {{## InlineAsm End|#NO_APP}}
42 %struct.t18_type = type { i32, i32 }
44 define i32 @t18() nounwind {
46 %foo = alloca %struct.t18_type, align 4
47 store i32 1, ptr %foo, align 4
48 %b = getelementptr inbounds %struct.t18_type, ptr %foo, i32 0, i32 1
49 store i32 2, ptr %b, align 4
50 call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
51 %b1 = getelementptr inbounds %struct.t18_type, ptr %foo, i32 0, i32 1
52 %0 = load i32, ptr %b1, align 4
55 ; CHECK: {{## InlineAsm Start|#APP}}
56 ; CHECK: .intel_syntax
58 ; CHECK: mov eax, [ebx].0
59 ; CHECK: mov [ebx].4, ecx
61 ; CHECK: {{## InlineAsm End|#NO_APP}}
64 define void @t19_helper() nounwind {
69 define void @t19() nounwind {
71 call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(ptr @t19_helper) nounwind
74 ; CHECK: movl ${{_?}}t19_helper, %eax
75 ; CHECK: {{## InlineAsm Start|#APP}}
76 ; CHECK: .intel_syntax
79 ; CHECK: {{## InlineAsm End|#NO_APP}}
82 @results = global [2 x i32] [i32 3, i32 2], align 4
84 define ptr @t30() nounwind ssp {
86 %res = alloca ptr, align 4
87 call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"(ptr elementtype([2 x i32]) @results) nounwind
88 call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(ptr) %res) nounwind
89 %0 = load ptr, ptr %res, align 4
92 ; CHECK: {{## InlineAsm Start|#APP}}
93 ; CHECK: .intel_syntax
94 ; CHECK: lea edi, dword ptr [{{_?}}results]
96 ; CHECK: {{## InlineAsm End|#NO_APP}}
97 ; CHECK: {{## InlineAsm Start|#APP}}
98 ; CHECK: .intel_syntax
99 ; CHECK: mov dword ptr [esp], edi
101 ; CHECK: {{## InlineAsm End|#NO_APP}}
102 ; CHECK: movl (%esp), %eax
105 ; Stack realignment plus MS inline asm that does *not* adjust the stack is no
110 %val = alloca i32, align 64
111 store i32 -1, ptr %val, align 64
112 call void asm sideeffect inteldialect "mov dword ptr $0, esp", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %val)
113 %sp = load i32, ptr %val, align 64
117 ; CHECK: movl %esp, %ebp
118 ; CHECK: andl $-64, %esp
119 ; CHECK: {{## InlineAsm Start|#APP}}
120 ; CHECK: .intel_syntax
121 ; CHECK: mov dword ptr [esp], esp
123 ; CHECK: {{## InlineAsm End|#NO_APP}}
124 ; CHECK: movl (%esp), %eax
128 ; Make sure ${:uid} works. Clang uses it for MS inline asm labels.
145 %r = alloca i32, align 4
146 call void asm sideeffect inteldialect "xor eax, eax\0A\09.L__MSASMLABEL_.${:uid}__wloop:\0A\09inc eax\0A\09cmp eax, $$42\0A\09jne .L__MSASMLABEL_.${:uid}__wloop\0A\09mov dword ptr $0, eax", "=*m,~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) nonnull %r)
147 %0 = load i32, ptr %r, align 4
150 ; CHECK: {{## InlineAsm Start|#APP}}
151 ; CHECK: .L__MSASMLABEL_.0__wloop:
152 ; CHECK: jne .L__MSASMLABEL_.0__wloop
154 ; CHECK: {{## InlineAsm End|#NO_APP}}
158 declare hidden void @other_func()
160 define void @naked() #0 {
161 call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{esp},~{ebp},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void()) @other_func)
165 attributes #0 = { naked }