1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - -std=c++11 | FileCheck %s
15 // CHECK-LABEL: define{{.*}} void @_Z2t1v()
16 Foo::ptr
= (int *)0xDEADBEEF;
17 Foo::Bar::ptr
= (int *)0xDEADBEEF;
18 // CHECK: call void asm sideeffect inteldialect
19 // CHECK-SAME: mov eax, $0
20 // CHECK-SAME: mov eax, $1
21 // CHECK-SAME: mov eax, $2
22 // CHECK-SAME: mov eax, dword ptr $3
23 // CHECK-SAME: mov eax, dword ptr $4
24 // CHECK-SAME: "*m,*m,*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(ptr) @_ZN3Foo3ptrE, ptr elementtype(ptr) @_ZN3Foo3Bar3ptrE, ptr elementtype(ptr) @_ZN3Foo3ptrE, ptr elementtype(ptr) @_ZN3Foo3ptrE, ptr elementtype(ptr) @_ZN3Foo3ptrE)
25 __asm mov eax
, Foo ::ptr
26 __asm mov eax
, Foo :: Bar :: ptr
27 __asm mov eax
, [Foo:: ptr
]
28 __asm mov eax
, dword ptr
[Foo :: ptr
]
29 __asm mov eax
, dword ptr
[Foo :: ptr
]
35 __asm mov eax
, offset
Foo::ptr
36 __asm mov eax
, offset
Foo::Bar::ptr
37 // CHECK-LABEL: define{{.*}} void @_Z2t2v()
38 // CHECK: call void asm sideeffect inteldialect
39 // CHECK-SAME: mov eax, $0
40 // CHECK-SAME: mov eax, $1
41 // CHECK-SAME: "i,i,~{eax},~{dirflag},~{fpsr},~{flags}"(ptr @_ZN3Foo3ptrE, ptr @_ZN3Foo3Bar3ptrE)
44 // CHECK-LABEL: define{{.*}} void @_Z2t3v()
46 __asm mov eax
, LENGTH
Foo::ptr
47 __asm mov eax
, LENGTH
Foo::Bar::ptr
48 __asm mov eax
, LENGTH
Foo::arr
49 __asm mov eax
, LENGTH
Foo::Bar::arr
51 __asm mov eax
, TYPE
Foo::ptr
52 __asm mov eax
, TYPE
Foo::Bar::ptr
53 __asm mov eax
, TYPE
Foo::arr
54 __asm mov eax
, TYPE
Foo::Bar::arr
56 __asm mov eax
, SIZE
Foo::ptr
57 __asm mov eax
, SIZE
Foo::Bar::ptr
58 __asm mov eax
, SIZE
Foo::arr
59 __asm mov eax
, SIZE
Foo::Bar::arr
60 // CHECK: call void asm sideeffect inteldialect
61 // CHECK-SAME: mov eax, $$1
62 // CHECK-SAME: mov eax, $$1
63 // CHECK-SAME: mov eax, $$4
64 // CHECK-SAME: mov eax, $$2
65 // CHECK-SAME: mov eax, $$4
66 // CHECK-SAME: mov eax, $$4
67 // CHECK-SAME: mov eax, $$4
68 // CHECK-SAME: mov eax, $$1
69 // CHECK-SAME: mov eax, $$4
70 // CHECK-SAME: mov eax, $$4
71 // CHECK-SAME: mov eax, $$16
72 // CHECK-SAME: mov eax, $$2
73 // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
83 // CHECK-LABEL: define{{.*}} void @_ZN2T44testEv(
85 // CHECK: [[T0:%.*]] = alloca ptr,
86 // CHECK: [[THIS:%.*]] = load ptr, ptr [[T0]]
87 // CHECK: [[X:%.*]] = getelementptr inbounds nuw [[T4:%.*]], ptr [[THIS]], i32 0, i32 0
90 // CHECK: call void asm sideeffect inteldialect
91 // CHECK-SAME: mov eax, $1
92 // CHECK-SAME: mov $0, eax
93 // CHECK-SAME: "=*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) @_ZN2T41yE, ptr elementtype(i32) {{.*}})
96 template <class T
> struct T5
{
97 template <class U
> static T
create(U
);
100 // CHECK-LABEL: define{{.*}} void @_Z5test5v()
102 // CHECK: [[X:%.*]] = alloca i32
103 // CHECK: [[Y:%.*]] = alloca i32
106 __asm call T5
<int>::create
<float>
108 // CHECK: call void asm sideeffect inteldialect
109 // CHECK-SAME: push $0
110 // CHECK-SAME: call ${2:P}
111 // CHECK-SAME: mov $1, eax
112 // CHECK-SAME: "=*m,=*m,*m,~{esp},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %y, ptr elementtype(i32) %x, ptr elementtype(i32 (float)) @_ZN2T5IiE6createIfEEiT_)
115 // Just verify this doesn't emit an error.
128 __asm mov eax
, [eax
].A
.b
129 // CHECK-LABEL: define{{.*}} void @_Z9t7_structv
130 // CHECK: call void asm sideeffect inteldialect
131 // CHECK-SAME: mov eax, [eax + $$4]
132 // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
140 __asm mov eax
, [eax
].A
.b
141 // CHECK-LABEL: define{{.*}} void @_Z10t7_typedefv
142 // CHECK: call void asm sideeffect inteldialect
143 // CHECK-SAME: mov eax, [eax + $$4]
144 // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
152 __asm mov eax
, [eax
].A
.b
153 // CHECK-LABEL: define{{.*}} void @_Z8t7_usingv
154 // CHECK: call void asm sideeffect inteldialect
155 // CHECK-SAME: mov eax, [eax + $$4]
156 // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
161 // CHECK-LABEL: define{{.*}} void @_Z2t8v()
162 // CHECK: call void asm sideeffect inteldialect
163 // CHECK-SAME: L__MSASMLABEL_.${:uid}__some_label:
164 // CHECK-SAME: "~{dirflag},~{fpsr},~{flags}"()
167 __asm jmp some_label
; This should jump forwards
170 // CHECK-LABEL: define internal void @_ZZ2t8vEN1A1gEv()
171 // CHECK: call void asm sideeffect inteldialect
172 // CHECK-SAME: jmp L__MSASMLABEL_.${:uid}__some_label
173 // CHECK-SAME: L__MSASMLABEL_.${:uid}__some_label:
175 // CHECK-SAME: "~{dirflag},~{fpsr},~{flags}"()
182 // CHECK-LABEL: define{{.*}} void @_Z2t9v()
187 __asm mov eax
, dword ptr
[eax
]this.b
188 // CHECK: call void asm sideeffect inteldialect
189 // CHECK-SAME: mov eax, dword ptr [eax + $$4]
190 // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()