• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
3 
t1()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
9 // CHECK-SAME: mov rax, $0
10 // CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
11 }
12 
t2()13 void t2() {
14   int var = 10;
15   __asm mov qword ptr [eax], offset var
16 // CHECK: t2
17 // CHECK: call void asm sideeffect inteldialect
18 // CHECK-SAME: mov qword ptr [eax], $0
19 // CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
20 }
21 
22 struct t3_type { int a, b; };
23 
t3()24 int t3() {
25   struct t3_type foo;
26   foo.a = 1;
27   foo.b = 2;
28   __asm {
29      lea ebx, foo
30      mov eax, [ebx].0
31      mov [ebx].4, ecx
32   }
33   return foo.b;
34 // CHECK: t3
35 // CHECK: call void asm sideeffect inteldialect
36 // CHECK-SAME: lea ebx, $0
37 // CHECK-SAME: mov eax, [ebx]
38 // CHECK-SAME: mov [ebx + $$4], ecx
39 // CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
40 }
41 
t4()42 int t4() {
43   struct t3_type foo;
44   foo.a = 1;
45   foo.b = 2;
46   __asm {
47      lea ebx, foo
48      {
49        mov eax, [ebx].foo.a
50      }
51      mov [ebx].foo.b, ecx
52   }
53   return foo.b;
54 // CHECK: t4
55 // CHECK: call void asm sideeffect inteldialect
56 // CHECK-SAME: lea ebx, $0
57 // CHECK-SAME: mov eax, [ebx]
58 // CHECK-SAME: mov [ebx + $$4], ecx
59 // CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
60 }
61 
bar()62 void bar() {}
63 
t5()64 void t5() {
65   __asm {
66     call bar
67     jmp bar
68   }
69   // CHECK: t5
70   // CHECK: call void asm sideeffect inteldialect
71   // CHECK-SAME: call qword ptr ${0:P}
72   // CHECK-SAME: jmp qword ptr ${1:P}
73   // CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(void (...)* bitcast (void ()* @bar to void (...)*), void (...)* bitcast (void ()* @bar to void (...)*))
74 }
75