Home | History | Annotate | Download | only in CodeGen
      1 // REQUIRES: x86-registered-target
      2 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
      3 
      4 void t1() {
      5   int var = 10;
      6   __asm mov rax, offset var ; rax = address of myvar
      7 // CHECK: t1
      8 // CHECK: call void asm sideeffect inteldialect "mov rax, $0", "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
      9 }
     10 
     11 void t2() {
     12   int var = 10;
     13   __asm mov [eax], offset var
     14 // CHECK: t2
     15 // CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
     16 }
     17 
     18 struct t3_type { int a, b; };
     19 
     20 int t3() {
     21   struct t3_type foo;
     22   foo.a = 1;
     23   foo.b = 2;
     24   __asm {
     25      lea ebx, foo
     26      mov eax, [ebx].0
     27      mov [ebx].4, ecx
     28   }
     29   return foo.b;
     30 // CHECK: t3
     31 // CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr $0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
     32 }
     33 
     34 int t4() {
     35   struct t3_type foo;
     36   foo.a = 1;
     37   foo.b = 2;
     38   __asm {
     39      lea ebx, foo
     40      {
     41        mov eax, [ebx].foo.a
     42      }
     43      mov [ebx].foo.b, ecx
     44   }
     45   return foo.b;
     46 // CHECK: t4
     47 // CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr $0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
     48 }
     49