annotate clang/test/CodeGen/mozilla-ms-inline-asm.c @ 207:2e18cbf3894f

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