xref: /llvm-project/clang/test/Headers/ms-intrin.cpp (revision 9bf68c2400e8966511332dfbf5c0f05e8a3300fa)
1 // RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu pentium4 \
2 // RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
3 // RUN:     -ffreestanding -fsyntax-only -Werror -Wsystem-headers \
4 // RUN:     -isystem %S/Inputs/include %s
5 
6 // RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu broadwell \
7 // RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
8 // RUN:     -ffreestanding -emit-obj -o /dev/null -Werror -Wsystem-headers \
9 // RUN:     -isystem %S/Inputs/include %s
10 
11 // RUN: %clang_cc1 -triple x86_64-pc-win32  \
12 // RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
13 // RUN:     -ffreestanding -emit-obj -o /dev/null -Werror -Wsystem-headers \
14 // RUN:     -isystem %S/Inputs/include %s
15 
16 // RUN: %clang_cc1 -triple thumbv7--windows \
17 // RUN:     -fms-compatibility -fms-compatibility-version=17.00 \
18 // RUN:     -ffreestanding -fsyntax-only -Werror -Wsystem-headers \
19 // RUN:     -isystem %S/Inputs/include %s
20 
21 // RUN: %clang_cc1 -triple aarch64--windows \
22 // RUN:     -fms-compatibility -fms-compatibility-version=17.00 \
23 // RUN:     -ffreestanding -fsyntax-only -Werror -Wsystem-headers \
24 // RUN:     -isystem %S/Inputs/include %s
25 
26 // RUN: %clang_cc1 -triple arm64ec--windows \
27 // RUN:     -fms-compatibility -fms-compatibility-version=17.00 \
28 // RUN:     -ffreestanding -fsyntax-only -Werror -Wsystem-headers \
29 // RUN:     -isystem %S/Inputs/include %s
30 
31 // REQUIRES: x86-registered-target
32 
33 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
34 // stddef.h.  Work around it with this typedef.
35 typedef __SIZE_TYPE__ size_t;
36 
37 #include <intrin.h>
38 
39 // Use some C++ to make sure we closed the extern "C" brackets.
40 template <typename T>
41 void foo(T V) {}
42 
43 // __asm__ blocks are only checked for inline functions that end up being
44 // emitted, so call functions with __asm__ blocks to make sure their inline
45 // assembly parses.
46 void f() {
47   __movsb(0, 0, 0);
48   __movsd(0, 0, 0);
49   __movsw(0, 0, 0);
50 
51   __stosd(0, 0, 0);
52   __stosw(0, 0, 0);
53 
54 #if defined(_M_X64) && !defined(_M_ARM64EC)
55   __movsq(0, 0, 0);
56   __stosq(0, 0, 0);
57 #endif
58 
59   int info[4];
60   __cpuid(info, 0);
61   __cpuidex(info, 0, 0);
62 #if (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(_M_IX86)
63   _xgetbv(0);
64 #endif
65   __halt();
66   __nop();
67   __readmsr(0);
68 
69   __readcr3();
70   __writecr3(0);
71 
72 #ifdef _M_ARM
73   __dmb(_ARM_BARRIER_ISHST);
74 #endif
75 
76 #ifdef _M_ARM64
77   __dmb(_ARM64_BARRIER_SY);
78 #endif
79 }
80