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: mov edx,dword ptr $1 22 // CHECK: test edx,edx 23 // CHECK: jz {{[^_]*}}__MSASMLABEL_.0__noparams 24 // ^ Can't use {{.*}} here because the matching is greedy. 25 // CHECK: mov eax,edx 26 // CHECK: shl eax,$$3 27 // CHECK: sub esp,eax 28 // CHECK: mov ecx,esp 29 // CHECK: push dword ptr $0 30 // CHECK: call dword ptr $2 31 // CHECK: {{.*}}__MSASMLABEL_.0__noparams: 32 // CHECK: mov ecx,dword ptr $3 33 // CHECK: push ecx 34 // CHECK: mov edx,[ecx] 35 // CHECK: mov eax,dword ptr $4 36 // CHECK: call dword ptr[edx+eax*$$4] 37 // CHECK: mov esp,ebp 38 // CHECK: pop ebp 39 // CHECK: 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 65