2013-12-04 11:41:33 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
2013-09-04 12:12:25 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
|
2012-10-24 07:42:25 +08:00
|
|
|
|
|
|
|
void t1() {
|
|
|
|
int var = 10;
|
|
|
|
__asm mov rax, offset var ; rax = address of myvar
|
|
|
|
// CHECK: t1
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect
|
|
|
|
// CHECK-SAME: mov rax, $0
|
|
|
|
// CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
|
2012-10-24 07:42:25 +08:00
|
|
|
}
|
2012-10-25 01:23:06 +08:00
|
|
|
|
|
|
|
void t2() {
|
|
|
|
int var = 10;
|
2019-12-31 03:33:56 +08:00
|
|
|
__asm mov qword ptr [eax], offset var
|
2012-10-25 01:23:06 +08:00
|
|
|
// CHECK: t2
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect
|
2019-12-31 03:33:56 +08:00
|
|
|
// CHECK-SAME: mov qword ptr [eax], $0
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
|
2012-10-25 01:23:06 +08:00
|
|
|
}
|
2013-02-22 17:10:20 +08:00
|
|
|
|
2013-04-11 02:08:17 +08:00
|
|
|
struct t3_type { int a, b; };
|
|
|
|
|
|
|
|
int t3() {
|
|
|
|
struct t3_type foo;
|
|
|
|
foo.a = 1;
|
|
|
|
foo.b = 2;
|
|
|
|
__asm {
|
|
|
|
lea ebx, foo
|
|
|
|
mov eax, [ebx].0
|
|
|
|
mov [ebx].4, ecx
|
|
|
|
}
|
|
|
|
return foo.b;
|
|
|
|
// CHECK: t3
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect
|
|
|
|
// CHECK-SAME: lea ebx, $0
|
2017-08-24 16:47:26 +08:00
|
|
|
// CHECK-SAME: mov eax, [ebx]
|
|
|
|
// CHECK-SAME: mov [ebx + $$4], ecx
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
|
2013-04-11 02:08:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int t4() {
|
|
|
|
struct t3_type foo;
|
|
|
|
foo.a = 1;
|
|
|
|
foo.b = 2;
|
|
|
|
__asm {
|
|
|
|
lea ebx, foo
|
2014-07-06 13:26:54 +08:00
|
|
|
{
|
|
|
|
mov eax, [ebx].foo.a
|
|
|
|
}
|
2013-04-11 02:08:17 +08:00
|
|
|
mov [ebx].foo.b, ecx
|
|
|
|
}
|
|
|
|
return foo.b;
|
|
|
|
// CHECK: t4
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect
|
|
|
|
// CHECK-SAME: lea ebx, $0
|
2017-08-24 16:47:26 +08:00
|
|
|
// CHECK-SAME: mov eax, [ebx]
|
|
|
|
// CHECK-SAME: mov [ebx + $$4], ecx
|
2017-05-05 02:19:52 +08:00
|
|
|
// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
|
2013-04-11 02:08:17 +08:00
|
|
|
}
|
2020-01-10 03:01:55 +08:00
|
|
|
|
|
|
|
void bar() {}
|
|
|
|
|
|
|
|
void t5() {
|
|
|
|
__asm {
|
|
|
|
call bar
|
|
|
|
jmp bar
|
|
|
|
}
|
|
|
|
// CHECK: t5
|
|
|
|
// CHECK: call void asm sideeffect inteldialect
|
|
|
|
// CHECK-SAME: call qword ptr ${0:P}
|
|
|
|
// CHECK-SAME: jmp qword ptr ${1:P}
|
|
|
|
// CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(void (...)* bitcast (void ()* @bar to void (...)*), void (...)* bitcast (void ()* @bar to void (...)*))
|
|
|
|
}
|