1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86 -mcpu=core2 -no-integrated-as | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdefine i32 @t1() nounwind { 4*9880d681SAndroid Build Coastguard Workerentry: 5*9880d681SAndroid Build Coastguard Worker %0 = tail call i32 asm sideeffect inteldialect "mov eax, $1\0A\09mov $0, eax", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 1) nounwind 6*9880d681SAndroid Build Coastguard Worker ret i32 %0 7*9880d681SAndroid Build Coastguard Worker; CHECK: t1 8*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 9*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 10*9880d681SAndroid Build Coastguard Worker; CHECK: mov eax, ecx 11*9880d681SAndroid Build Coastguard Worker; CHECK: mov ecx, eax 12*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 13*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 14*9880d681SAndroid Build Coastguard Worker} 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workerdefine void @t2() nounwind { 17*9880d681SAndroid Build Coastguard Workerentry: 18*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind 19*9880d681SAndroid Build Coastguard Worker ret void 20*9880d681SAndroid Build Coastguard Worker; CHECK: t2 21*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 22*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 23*9880d681SAndroid Build Coastguard Worker; CHECK: mov eax, 1 24*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 25*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 26*9880d681SAndroid Build Coastguard Worker} 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Workerdefine void @t3(i32 %V) nounwind { 29*9880d681SAndroid Build Coastguard Workerentry: 30*9880d681SAndroid Build Coastguard Worker %V.addr = alloca i32, align 4 31*9880d681SAndroid Build Coastguard Worker store i32 %V, i32* %V.addr, align 4 32*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "mov eax, DWORD PTR [$0]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %V.addr) nounwind 33*9880d681SAndroid Build Coastguard Worker ret void 34*9880d681SAndroid Build Coastguard Worker; CHECK: t3 35*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 36*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 37*9880d681SAndroid Build Coastguard Worker; CHECK: mov eax, DWORD PTR {{[[esp]}} 38*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 39*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 40*9880d681SAndroid Build Coastguard Worker} 41*9880d681SAndroid Build Coastguard Worker 42*9880d681SAndroid Build Coastguard Worker%struct.t18_type = type { i32, i32 } 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Workerdefine i32 @t18() nounwind { 45*9880d681SAndroid Build Coastguard Workerentry: 46*9880d681SAndroid Build Coastguard Worker %foo = alloca %struct.t18_type, align 4 47*9880d681SAndroid Build Coastguard Worker %a = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 0 48*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %a, align 4 49*9880d681SAndroid Build Coastguard Worker %b = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 1 50*9880d681SAndroid Build Coastguard Worker store i32 2, i32* %b, align 4 51*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind 52*9880d681SAndroid Build Coastguard Worker %b1 = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 1 53*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* %b1, align 4 54*9880d681SAndroid Build Coastguard Worker ret i32 %0 55*9880d681SAndroid Build Coastguard Worker; CHECK: t18 56*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 57*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 58*9880d681SAndroid Build Coastguard Worker; CHECK: lea ebx, foo 59*9880d681SAndroid Build Coastguard Worker; CHECK: mov eax, [ebx].0 60*9880d681SAndroid Build Coastguard Worker; CHECK: mov [ebx].4, ecx 61*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 62*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 63*9880d681SAndroid Build Coastguard Worker} 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Workerdefine void @t19_helper() nounwind { 66*9880d681SAndroid Build Coastguard Workerentry: 67*9880d681SAndroid Build Coastguard Worker ret void 68*9880d681SAndroid Build Coastguard Worker} 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Workerdefine void @t19() nounwind { 71*9880d681SAndroid Build Coastguard Workerentry: 72*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t19_helper) nounwind 73*9880d681SAndroid Build Coastguard Worker ret void 74*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t19: 75*9880d681SAndroid Build Coastguard Worker; CHECK: movl ${{_?}}t19_helper, %eax 76*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 77*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 78*9880d681SAndroid Build Coastguard Worker; CHECK: call eax 79*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 80*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 81*9880d681SAndroid Build Coastguard Worker} 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Worker@results = global [2 x i32] [i32 3, i32 2], align 4 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Workerdefine i32* @t30() nounwind ssp { 86*9880d681SAndroid Build Coastguard Workerentry: 87*9880d681SAndroid Build Coastguard Worker %res = alloca i32*, align 4 88*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"([2 x i32]* @results) nounwind 89*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(i32** %res) nounwind 90*9880d681SAndroid Build Coastguard Worker %0 = load i32*, i32** %res, align 4 91*9880d681SAndroid Build Coastguard Worker ret i32* %0 92*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t30: 93*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 94*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 95*9880d681SAndroid Build Coastguard Worker; CHECK: lea edi, dword ptr [{{_?}}results] 96*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 97*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 98*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 99*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 100*9880d681SAndroid Build Coastguard Worker; CHECK: mov dword ptr [esp], edi 101*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 102*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 103*9880d681SAndroid Build Coastguard Worker; CHECK: movl (%esp), %eax 104*9880d681SAndroid Build Coastguard Worker} 105*9880d681SAndroid Build Coastguard Worker 106*9880d681SAndroid Build Coastguard Worker; Stack realignment plus MS inline asm that does *not* adjust the stack is no 107*9880d681SAndroid Build Coastguard Worker; longer an error. 108*9880d681SAndroid Build Coastguard Worker 109*9880d681SAndroid Build Coastguard Workerdefine i32 @t31() { 110*9880d681SAndroid Build Coastguard Workerentry: 111*9880d681SAndroid Build Coastguard Worker %val = alloca i32, align 64 112*9880d681SAndroid Build Coastguard Worker store i32 -1, i32* %val, align 64 113*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "mov dword ptr $0, esp", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %val) 114*9880d681SAndroid Build Coastguard Worker %sp = load i32, i32* %val, align 64 115*9880d681SAndroid Build Coastguard Worker ret i32 %sp 116*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t31: 117*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 118*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp 119*9880d681SAndroid Build Coastguard Worker; CHECK: andl $-64, %esp 120*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm Start|#APP}} 121*9880d681SAndroid Build Coastguard Worker; CHECK: .intel_syntax 122*9880d681SAndroid Build Coastguard Worker; CHECK: mov dword ptr [esp], esp 123*9880d681SAndroid Build Coastguard Worker; CHECK: .att_syntax 124*9880d681SAndroid Build Coastguard Worker; CHECK: {{## InlineAsm End|#NO_APP}} 125*9880d681SAndroid Build Coastguard Worker; CHECK: movl (%esp), %eax 126*9880d681SAndroid Build Coastguard Worker; CHECK: ret 127*9880d681SAndroid Build Coastguard Worker} 128*9880d681SAndroid Build Coastguard Worker 129*9880d681SAndroid Build Coastguard Workerdeclare hidden void @other_func() 130*9880d681SAndroid Build Coastguard Worker 131*9880d681SAndroid Build Coastguard Workerdefine void @naked() #0 { 132*9880d681SAndroid Build Coastguard Worker call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{esp},~{ebp},~{dirflag},~{fpsr},~{flags}"(void()* @other_func) 133*9880d681SAndroid Build Coastguard Worker unreachable 134*9880d681SAndroid Build Coastguard Worker} 135*9880d681SAndroid Build Coastguard Worker 136*9880d681SAndroid Build Coastguard Workerattributes #0 = { naked } 137