2013-12-04 11:41:33 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
2022-02-25 04:30:30 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -Wno-strict-prototypes -fasm-blocks -emit-llvm -o - | FileCheck %s
|
2012-10-24 07:42:25 +08:00
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
void t1(void) {
|
2012-10-24 07:42:25 +08:00
|
|
|
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
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
void t2(void) {
|
2012-10-25 01:23:06 +08:00
|
|
|
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; };
|
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
int t3(void) {
|
2013-04-11 02:08:17 +08:00
|
|
|
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
|
2022-01-05 22:16:24 +08:00
|
|
|
// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* elementtype(%struct.t3_type) %{{.*}})
|
2013-04-11 02:08:17 +08:00
|
|
|
}
|
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
int t4(void) {
|
2013-04-11 02:08:17 +08:00
|
|
|
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
|
2022-01-05 22:16:24 +08:00
|
|
|
// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* elementtype(%struct.t3_type) %{{.*}})
|
2013-04-11 02:08:17 +08:00
|
|
|
}
|
2020-01-10 03:01:55 +08:00
|
|
|
|
|
|
|
void bar() {}
|
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
void t5(void) {
|
2020-01-10 03:01:55 +08:00
|
|
|
__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}
|
2022-01-05 22:16:24 +08:00
|
|
|
// CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(void (...)* elementtype(void (...)) bitcast (void ()* @bar to void (...)*), void (...)* elementtype(void (...)) bitcast (void ()* @bar to void (...)*))
|
2020-01-10 03:01:55 +08:00
|
|
|
}
|