2012-08-09 05:15:52 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s
|
2012-08-09 04:37:31 +08:00
|
|
|
|
|
|
|
void t1() {
|
|
|
|
// CHECK: @t1
|
2012-09-06 03:01:07 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-09 04:37:31 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
__asm {}
|
|
|
|
}
|
2012-08-14 04:32:07 +08:00
|
|
|
|
|
|
|
void t2() {
|
|
|
|
// CHECK: @t2
|
2012-09-06 03:01:07 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-14 04:32:07 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
__asm nop
|
|
|
|
__asm nop
|
|
|
|
__asm nop
|
|
|
|
}
|
|
|
|
|
|
|
|
void t3() {
|
|
|
|
// CHECK: @t3
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "nop\0A\09nop\0A\09nop", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-14 04:32:07 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
__asm nop __asm nop __asm nop
|
|
|
|
}
|
|
|
|
|
|
|
|
void t4(void) {
|
|
|
|
// CHECK: @t4
|
2012-09-06 03:01:07 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "mov ebx, eax", "~{ebx},~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "mov ecx, ebx", "~{ecx},~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-14 04:32:07 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
__asm mov ebx, eax
|
|
|
|
__asm mov ecx, ebx
|
|
|
|
}
|
|
|
|
|
|
|
|
void t5(void) {
|
|
|
|
// CHECK: @t5
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "mov ebx, eax\0A\09mov ecx, ebx", "~{ebx},~{ecx},~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-14 04:32:07 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
__asm mov ebx, eax __asm mov ecx, ebx
|
|
|
|
}
|
2012-08-15 07:48:41 +08:00
|
|
|
|
|
|
|
void t6(void) {
|
|
|
|
__asm int 0x2c
|
|
|
|
// CHECK: t6
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-15 07:48:41 +08:00
|
|
|
}
|
|
|
|
|
2012-08-22 01:01:26 +08:00
|
|
|
void t7() {
|
2012-08-15 07:48:41 +08:00
|
|
|
__asm {
|
|
|
|
int 0x2c ; } asm comments are fun! }{
|
|
|
|
}
|
|
|
|
__asm {}
|
2012-08-22 01:01:26 +08:00
|
|
|
// CHECK: t7
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-09-06 03:01:07 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-15 07:48:41 +08:00
|
|
|
}
|
2012-08-22 01:01:26 +08:00
|
|
|
int t8() {
|
2012-08-15 07:48:41 +08:00
|
|
|
__asm int 3 ; } comments for single-line asm
|
|
|
|
__asm {}
|
|
|
|
__asm int 4
|
|
|
|
return 10;
|
2012-08-22 01:01:26 +08:00
|
|
|
// CHECK: t8
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "int $$3", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-09-06 03:01:07 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-15 07:48:41 +08:00
|
|
|
// CHECK: ret i32 10
|
|
|
|
}
|
2012-08-22 01:01:26 +08:00
|
|
|
void t9() {
|
2012-08-15 07:48:41 +08:00
|
|
|
__asm {
|
|
|
|
push ebx
|
|
|
|
mov ebx, 0x07
|
|
|
|
pop ebx
|
|
|
|
}
|
2012-08-22 01:01:26 +08:00
|
|
|
// CHECK: t9
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-15 07:48:41 +08:00
|
|
|
}
|
2012-08-17 01:10:59 +08:00
|
|
|
|
2012-08-22 01:01:26 +08:00
|
|
|
unsigned t10(void) {
|
2012-08-17 01:10:59 +08:00
|
|
|
unsigned i = 1, j;
|
|
|
|
__asm {
|
|
|
|
mov eax, i
|
|
|
|
mov j, eax
|
|
|
|
}
|
|
|
|
return j;
|
2012-08-22 01:01:26 +08:00
|
|
|
// CHECK: t10
|
2012-08-17 01:10:59 +08:00
|
|
|
// CHECK: [[I:%[a-zA-Z0-9]+]] = alloca i32, align 4
|
|
|
|
// CHECK: [[J:%[a-zA-Z0-9]+]] = alloca i32, align 4
|
|
|
|
// CHECK: store i32 1, i32* [[I]], align 4
|
2012-09-11 08:51:28 +08:00
|
|
|
// CHECK: call i32 asm sideeffect inteldialect "mov eax, $1\0A\09mov $0, eax", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}) nounwind
|
2012-08-17 01:10:59 +08:00
|
|
|
// CHECK: [[RET:%[a-zA-Z0-9]+]] = load i32* [[J]], align 4
|
|
|
|
// CHECK: ret i32 [[RET]]
|
|
|
|
}
|
2012-08-17 06:25:38 +08:00
|
|
|
|
2012-08-22 01:01:26 +08:00
|
|
|
void t11(void) {
|
2012-08-17 06:25:38 +08:00
|
|
|
__asm EVEN
|
|
|
|
__asm ALIGN
|
2012-09-07 03:56:25 +08:00
|
|
|
// CHECK: t11
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-17 06:25:38 +08:00
|
|
|
}
|
|
|
|
|
2012-08-22 01:01:26 +08:00
|
|
|
void t12(void) {
|
2012-08-17 06:25:38 +08:00
|
|
|
__asm {
|
|
|
|
_emit 0x4A
|
|
|
|
_emit 0x43
|
|
|
|
_emit 0x4B
|
|
|
|
}
|
2012-09-07 03:56:25 +08:00
|
|
|
// CHECK: t12
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-17 06:25:38 +08:00
|
|
|
}
|
|
|
|
|
2012-08-22 01:01:26 +08:00
|
|
|
void t13(void) {
|
2012-08-17 06:25:38 +08:00
|
|
|
unsigned arr[10];
|
|
|
|
__asm LENGTH arr ; sizeof(arr)/sizeof(arr[0])
|
|
|
|
__asm SIZE arr ; sizeof(arr)
|
|
|
|
__asm TYPE arr ; sizeof(arr[0])
|
2012-09-07 03:56:25 +08:00
|
|
|
// CHECK: t13
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind
|
2012-08-17 06:25:38 +08:00
|
|
|
}
|
2012-09-11 08:51:28 +08:00
|
|
|
|
|
|
|
void t14(void) {
|
|
|
|
__asm mov eax, 1
|
|
|
|
// CHECK: t14
|
|
|
|
// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
}
|