[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGen / ms-intrinsics-cpuid.c
blobdbce707e9d0cf3819b4e800700152fd13633c0fc
1 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
2 // RUN: -Werror -triple i686-windows-msvc -emit-llvm %s -o - | FileCheck %s --check-prefix=X86
3 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
4 // RUN: -Werror -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck %s --check-prefix=X64
6 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
7 // stddef.h. Work around it with this typedef.
8 typedef __SIZE_TYPE__ size_t;
10 #include <intrin.h>
12 #pragma intrinsic(__cpuid)
14 void test__cpuid(int cpuInfo[4], int function_id) {
15 __cpuid(cpuInfo, function_id);
17 // X86-LABEL: define {{.*}} @test__cpuid(ptr noundef %{{.*}}, i32 noundef %{{.*}})
18 // X86-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},{ax},{cx}"
19 // X86-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
20 // X86-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
21 // X86-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
22 // X86-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
23 // X86-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
24 // X86-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
25 // X86-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
26 // X86-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
27 // X86-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
28 // X86-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
29 // X86-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
30 // X86-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
32 // X64-LABEL: define {{.*}} @test__cpuid(ptr noundef %{{.*}}, i32 noundef %{{.*}})
33 // X64-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "xchgq %rbx, ${1:q}\0Acpuid\0Axchgq %rbx, ${1:q}", "={ax},=r,={cx},={dx},0,2"
34 // X64-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
35 // X64-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
36 // X64-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
37 // X64-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
38 // X64-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
39 // X64-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
40 // X64-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
41 // X64-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
42 // X64-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
43 // X64-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
44 // X64-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
45 // X64-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
47 #pragma intrinsic(__cpuidex)
49 void test__cpuidex(int cpuInfo[4], int function_id, int subfunction_id) {
50 __cpuidex(cpuInfo, function_id, subfunction_id);
52 // X86-LABEL: define {{.*}} @test__cpuidex(ptr noundef %{{.*}}, i32 noundef %{{.*}}, i32 noundef %{{.*}})
53 // X86-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},{ax},{cx}"
54 // X86-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
55 // X86-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
56 // X86-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
57 // X86-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
58 // X86-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
59 // X86-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
60 // X86-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
61 // X86-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
62 // X86-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
63 // X86-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
64 // X86-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
65 // X86-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
67 // X64-LABEL: define {{.*}} @test__cpuidex(ptr noundef %{{.*}}, i32 noundef %{{.*}}, i32 noundef %{{.*}})
68 // X64-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "xchgq %rbx, ${1:q}\0Acpuid\0Axchgq %rbx, ${1:q}", "={ax},=r,={cx},={dx},0,2"
69 // X64-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
70 // X64-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
71 // X64-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
72 // X64-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
73 // X64-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
74 // X64-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
75 // X64-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
76 // X64-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
77 // X64-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
78 // X64-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
79 // X64-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
80 // X64-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4