166 lines · plain
1; RUN: llc < %s -mtriple=i686-- -mcpu=core2 -no-integrated-as | FileCheck %s2 3define i32 @t1() nounwind {4entry:5 %0 = tail call i32 asm sideeffect inteldialect "mov eax, $1\0A\09mov $0, eax", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 1) nounwind6 ret i32 %07; CHECK: t18; CHECK: {{## InlineAsm Start|#APP}}9; CHECK: .intel_syntax10; CHECK: mov eax, ecx11; CHECK: mov ecx, eax12; CHECK: .att_syntax13; CHECK: {{## InlineAsm End|#NO_APP}}14}15 16define void @t2() nounwind {17entry:18 call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind19 ret void20; CHECK: t221; CHECK: {{## InlineAsm Start|#APP}}22; CHECK: .intel_syntax23; CHECK: mov eax, 124; CHECK: .att_syntax25; CHECK: {{## InlineAsm End|#NO_APP}}26}27 28define void @t3(i32 %V) nounwind {29entry:30 %V.addr = alloca i32, align 431 store i32 %V, ptr %V.addr, align 432 call void asm sideeffect inteldialect "mov eax, DWORD PTR [$0]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %V.addr) nounwind33 ret void34; CHECK: t335; CHECK: {{## InlineAsm Start|#APP}}36; CHECK: .intel_syntax37; CHECK: mov eax, DWORD PTR {{[[esp]}}38; CHECK: .att_syntax39; CHECK: {{## InlineAsm End|#NO_APP}}40}41 42%struct.t18_type = type { i32, i32 }43 44define i32 @t18() nounwind {45entry:46 %foo = alloca %struct.t18_type, align 447 store i32 1, ptr %foo, align 448 %b = getelementptr inbounds %struct.t18_type, ptr %foo, i32 0, i32 149 store i32 2, ptr %b, align 450 call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind51 %b1 = getelementptr inbounds %struct.t18_type, ptr %foo, i32 0, i32 152 %0 = load i32, ptr %b1, align 453 ret i32 %054; CHECK: t1855; CHECK: {{## InlineAsm Start|#APP}}56; CHECK: .intel_syntax57; CHECK: lea ebx, foo58; CHECK: mov eax, [ebx].059; CHECK: mov [ebx].4, ecx60; CHECK: .att_syntax61; CHECK: {{## InlineAsm End|#NO_APP}}62}63 64define void @t19_helper() nounwind {65entry:66 ret void67}68 69define void @t19() nounwind {70entry:71 call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(ptr @t19_helper) nounwind72 ret void73; CHECK-LABEL: t19:74; CHECK: movl ${{_?}}t19_helper, %eax75; CHECK: {{## InlineAsm Start|#APP}}76; CHECK: .intel_syntax77; CHECK: call eax78; CHECK: .att_syntax79; CHECK: {{## InlineAsm End|#NO_APP}}80}81 82@results = global [2 x i32] [i32 3, i32 2], align 483 84define ptr @t30() nounwind ssp {85entry:86 %res = alloca ptr, align 487 call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"(ptr elementtype([2 x i32]) @results) nounwind88 call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(ptr) %res) nounwind89 %0 = load ptr, ptr %res, align 490 ret ptr %091; CHECK-LABEL: t30:92; CHECK: {{## InlineAsm Start|#APP}}93; CHECK: .intel_syntax94; CHECK: lea edi, dword ptr [{{_?}}results]95; CHECK: .att_syntax96; CHECK: {{## InlineAsm End|#NO_APP}}97; CHECK: {{## InlineAsm Start|#APP}}98; CHECK: .intel_syntax99; CHECK: mov dword ptr [esp], edi100; CHECK: .att_syntax101; CHECK: {{## InlineAsm End|#NO_APP}}102; CHECK: movl (%esp), %eax103}104 105; Stack realignment plus MS inline asm that does *not* adjust the stack is no106; longer an error.107 108define i32 @t31() {109entry:110 %val = alloca i32, align 64111 store i32 -1, ptr %val, align 64112 call void asm sideeffect inteldialect "mov dword ptr $0, esp", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %val)113 %sp = load i32, ptr %val, align 64114 ret i32 %sp115; CHECK-LABEL: t31:116; CHECK: pushl %ebp117; CHECK: movl %esp, %ebp118; CHECK: andl $-64, %esp119; CHECK: {{## InlineAsm Start|#APP}}120; CHECK: .intel_syntax121; CHECK: mov dword ptr [esp], esp122; CHECK: .att_syntax123; CHECK: {{## InlineAsm End|#NO_APP}}124; CHECK: movl (%esp), %eax125; CHECK: ret126}127 128; Make sure ${:uid} works. Clang uses it for MS inline asm labels.129;130; C source:131; int uid() {132; int r;133; __asm {134; xor eax, eax135; wloop:136; inc eax137; cmp eax, 42138; jne wloop139; mov r, eax140; }141; return r;142; }143define i32 @uid() {144entry:145 %r = alloca i32, align 4146 call void asm sideeffect inteldialect "xor eax, eax\0A\09.L__MSASMLABEL_.${:uid}__wloop:\0A\09inc eax\0A\09cmp eax, $$42\0A\09jne .L__MSASMLABEL_.${:uid}__wloop\0A\09mov dword ptr $0, eax", "=*m,~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) nonnull %r)147 %0 = load i32, ptr %r, align 4148 ret i32 %0149; CHECK-LABEL: uid:150; CHECK: {{## InlineAsm Start|#APP}}151; CHECK: .L__MSASMLABEL_.0__wloop:152; CHECK: jne .L__MSASMLABEL_.0__wloop153; CHECK: .att_syntax154; CHECK: {{## InlineAsm End|#NO_APP}}155; CHECK: ret156}157 158declare hidden void @other_func()159 160define void @naked() #0 {161 call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{esp},~{ebp},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void()) @other_func)162 unreachable163}164 165attributes #0 = { naked }166