2014-09-06 04:06:06 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
2014-09-05 04:16:12 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks | FileCheck %s
|
2014-09-05 04:04:38 +08:00
|
|
|
|
|
|
|
// Check that we take EAX or EAX:EDX and return it from these functions for MSVC
|
|
|
|
// compatibility.
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
long long f_i64() {
|
|
|
|
__asm {
|
|
|
|
mov eax, 1
|
|
|
|
mov edx, 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i64 @f_i64()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
|
|
|
|
// CHECK: ret i64 %[[r]]
|
|
|
|
|
|
|
|
int f_i32() {
|
|
|
|
__asm {
|
|
|
|
mov eax, 1
|
|
|
|
mov edx, 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @f_i32()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
|
|
|
|
// CHECK: ret i32 %[[r]]
|
|
|
|
|
|
|
|
short f_i16() {
|
|
|
|
__asm {
|
|
|
|
mov eax, 1
|
|
|
|
mov edx, 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local signext i16 @f_i16()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
|
|
|
|
// CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
|
|
|
|
// CHECK: ret i16 %[[r_i16]]
|
|
|
|
|
|
|
|
char f_i8() {
|
|
|
|
__asm {
|
|
|
|
mov eax, 1
|
|
|
|
mov edx, 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local signext i8 @f_i8()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
|
|
|
|
// CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
|
|
|
|
// CHECK: ret i8 %[[r_i8]]
|
|
|
|
|
|
|
|
bool f_i1() {
|
|
|
|
__asm {
|
2016-09-03 07:16:06 +08:00
|
|
|
mov eax, 1L
|
|
|
|
mov edx, 1U
|
2014-09-05 04:04:38 +08:00
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local zeroext i1 @f_i1()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
|
|
|
|
// CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
|
|
|
|
// CHECK: store i8 %[[r_i8]], i8* %{{.*}}
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}}
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: ret i1 %[[r_i1]]
|
|
|
|
|
|
|
|
struct FourChars {
|
|
|
|
char a, b, c, d;
|
|
|
|
};
|
|
|
|
FourChars f_s4() {
|
|
|
|
__asm {
|
|
|
|
mov eax, 0x01010101
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @f_s4()
|
2017-08-24 16:47:26 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "={eax},~{eax},{{.*}}"
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: store i32 %[[r]], i32* %{{.*}}
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}}
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: ret i32 %[[r_i32]]
|
|
|
|
|
|
|
|
struct EightChars {
|
|
|
|
char a, b, c, d, e, f, g, h;
|
|
|
|
};
|
|
|
|
EightChars f_s8() {
|
|
|
|
__asm {
|
2016-09-03 07:16:06 +08:00
|
|
|
mov eax, 01010101h
|
|
|
|
mov edx, 01010101b
|
2014-09-05 04:04:38 +08:00
|
|
|
}
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i64 @f_s8()
|
2017-08-24 16:47:26 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=A,~{eax},{{.*}}"
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: store i64 %[[r]], i64* %{{.*}}
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}}
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: ret i64 %[[r_i64]]
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
__asm xor eax, eax
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @main()
|
2014-09-05 04:04:38 +08:00
|
|
|
// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
|
|
|
|
// CHECK: ret i32 %[[r]]
|