150
|
1 // REQUIRES: x86-registered-target
|
|
2 // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | opt -strip -S | FileCheck %s
|
|
3
|
|
4 // Some test cases for MS inline asm support from Mozilla code base.
|
|
5
|
|
6 void invoke_copy_to_stack() {}
|
|
7
|
|
8 void invoke(void* that, unsigned methodIndex,
|
|
9 unsigned paramCount, void* params)
|
|
10 {
|
|
11 // CHECK: @invoke
|
|
12 // CHECK: %5 = alloca i8*, align 4
|
|
13 // CHECK: %6 = alloca i32, align 4
|
|
14 // CHECK: %7 = alloca i32, align 4
|
|
15 // CHECK: %8 = alloca i8*, align 4
|
|
16 // CHECK: store i8* %0, i8** %5, align 4
|
|
17 // CHECK: store i32 %1, i32* %6, align 4
|
|
18 // CHECK: store i32 %2, i32* %7, align 4
|
|
19 // CHECK: store i8* %3, i8** %8, align 4
|
|
20 // CHECK: call void asm sideeffect inteldialect
|
|
21 // CHECK-SAME: mov edx,$1
|
|
22 // CHECK-SAME: test edx,edx
|
|
23 // CHECK-SAME: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
|
|
24 // ^ Can't use {{.*}} here because the matching is greedy.
|
|
25 // CHECK-SAME: mov eax,edx
|
|
26 // CHECK-SAME: shl eax,$$3
|
|
27 // CHECK-SAME: sub esp,eax
|
|
28 // CHECK-SAME: mov ecx,esp
|
|
29 // CHECK-SAME: push $0
|
|
30 // CHECK-SAME: call dword ptr ${2:P}
|
|
31 // CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams:
|
|
32 // CHECK-SAME: mov ecx,$3
|
|
33 // CHECK-SAME: push ecx
|
|
34 // CHECK-SAME: mov edx,[ecx]
|
|
35 // CHECK-SAME: mov eax,$4
|
|
36 // CHECK-SAME: call dword ptr[edx + eax * $$4]
|
|
37 // CHECK-SAME: mov esp,ebp
|
|
38 // CHECK-SAME: pop ebp
|
|
39 // CHECK-SAME: ret
|
|
40 // CHECK: "=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}"
|
|
41 // CHECK: (i8** %8, i32* %7, void (...)* bitcast (void ()* @invoke_copy_to_stack to void (...)*), i8** %5, i32* %6)
|
|
42 // CHECK: ret void
|
|
43 __asm {
|
|
44 mov edx,paramCount
|
|
45 test edx,edx
|
|
46 jz noparams
|
|
47 mov eax,edx
|
|
48 shl eax,3
|
|
49 sub esp,eax
|
|
50 mov ecx,esp
|
|
51 push params
|
|
52 call invoke_copy_to_stack
|
|
53 noparams:
|
|
54 mov ecx,that
|
|
55 push ecx
|
|
56 mov edx,[ecx]
|
|
57 mov eax,methodIndex
|
|
58 call dword ptr[edx+eax*4]
|
|
59 mov esp,ebp
|
|
60 pop ebp
|
|
61 ret
|
|
62 }
|
|
63 }
|
|
64
|