278278 : "0"(__leaf), "2"(__count))
279279#endif
280280
281+ /// Queries the processor to determine the highest supported \c CPUID leaf.
282+ /// This intrinsic is only available on x86 and x64.
283+ ///
284+ /// \headerfile <cpuid.h>
285+ ///
286+ /// This intrinsic corresponds to the <c> CPUID </c> instruction.
287+ ///
288+ /// \param __leaf
289+ /// \a __leaf can be either 0x0 or 0x8000000. If \a __leaf == 0x0, the
290+ /// highest supported value for basic \c CPUID information is returned.
291+ /// If \a __leaf == 0x8000000, the highest supported value for extended
292+ /// \c CPUID information is returned.
293+ /// \param __sig
294+ /// If the \a __sig pointer is non-null, the first four bytes of the
295+ /// signature (as found in the \c EBX register) are returned in the
296+ /// location pointed to by \a __sig.
297+ /// \returns Returns 0 if \c CPUID is supported; otherwise returns the value
298+ /// that \c CPUID returns in the \c EAX register.
281299static __inline unsigned int __get_cpuid_max (unsigned int __leaf ,
282300 unsigned int * __sig )
283301{
@@ -311,6 +329,32 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf,
311329 return __eax ;
312330}
313331
332+ /// For the requested \c CPUID leaf, queries the processor for information
333+ /// about the CPU type and CPU features (such as processor vendor, supported
334+ /// instruction sets, CPU capabilities, cache sizes, CPU model and family, and
335+ /// other hardware details). This intrinsic is only available on x86 and x64.
336+ ///
337+ /// \headerfile <cpuid.h>
338+ ///
339+ /// This intrinsic corresponds to the <c> CPUID </c> instruction.
340+ ///
341+ /// \param __leaf
342+ /// An unsigned integer that identifies the level (also called "leaf") at
343+ /// which the \c CPUID instruction will be executed.
344+ /// \param __eax
345+ /// A pointer to an integer that corresponds to the \c EAX register where
346+ /// \c CPUID stores output results.
347+ /// \param __ebx
348+ /// A pointer to an integer that corresponds to the \c EBX register where
349+ /// \c CPUID stores output results.
350+ /// \param __ecx
351+ /// A pointer to an integer that corresponds to the \c ECX register where
352+ /// \c CPUID stores output results.
353+ /// \param __edx
354+ /// A pointer to an integer that corresponds to the \c EDX register where
355+ /// \c CPUID stores output results.
356+ /// \returns Returns 1 if the requested \c CPUID leaf is supported; otherwise
357+ /// returns 0.
314358static __inline int __get_cpuid (unsigned int __leaf , unsigned int * __eax ,
315359 unsigned int * __ebx , unsigned int * __ecx ,
316360 unsigned int * __edx )
@@ -324,6 +368,36 @@ static __inline int __get_cpuid (unsigned int __leaf, unsigned int *__eax,
324368 return 1 ;
325369}
326370
371+ /// For the requested \c CPUID leaf and subleaf, queries the processor for
372+ /// information about the CPU type and CPU features (such as processor vendor,
373+ /// supported instruction sets, CPU capabilities, cache sizes, CPU model and
374+ /// family, and other hardware details). This intrinsic is only available on
375+ /// x86 and x64.
376+ ///
377+ /// \headerfile <cpuid.h>
378+ ///
379+ /// This intrinsic corresponds to the <c> CPUID </c> instruction.
380+ ///
381+ /// \param __leaf
382+ /// An unsigned integer that identifies the level (also called "leaf") at
383+ /// which the \c CPUID instruction will be executed.
384+ /// \param __subleaf
385+ /// An unsigned integer that identifies the sublevel (also called
386+ /// "subleaf") at which the \c CPUID instruction will be executed.
387+ /// \param __eax
388+ /// A pointer to an integer that corresponds to the \c EAX register where
389+ /// \c CPUID stores output results.
390+ /// \param __ebx
391+ /// A pointer to an integer that corresponds to the \c EBX register where
392+ /// \c CPUID stores output results.
393+ /// \param __ecx
394+ /// A pointer to an integer that corresponds to the \c ECX register where
395+ /// \c CPUID stores output results.
396+ /// \param __edx
397+ /// A pointer to an integer that corresponds to the \c EDX register where
398+ /// \c CPUID stores output results.
399+ /// \returns Returns 1 if the requested \c CPUID leaf is supported; otherwise
400+ /// returns 0.
327401static __inline int __get_cpuid_count (unsigned int __leaf ,
328402 unsigned int __subleaf ,
329403 unsigned int * __eax , unsigned int * __ebx ,
@@ -345,6 +419,28 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
345419// builtin. Given __has_builtin does not detect builtins on aux triples, we need
346420// to explicitly check for some offloading cases.
347421#if !defined(__NVPTX__ ) && !defined(__AMDGPU__ ) && !defined(__SPIRV__ )
422+ /// Executes the \c CPUID instruction with the specified leaf and subleaf
423+ /// values, and returns the results from the CPU's registers. This intrinsic
424+ /// is only available on x86 and x64.
425+ ///
426+ /// \headerfile <cpuid.h>
427+ ///
428+ /// This intrinsic corresponds to the <c> CPUID </c> instruction.
429+ ///
430+ /// \param __cpu_info
431+ /// An output array of four integers:
432+ /// <ul>
433+ /// <li>\a __cpuInfo[0] receives the value of the \c EAX register.</li>
434+ /// <li>\a __cpuInfo[1] receives the value of the \c EBX register.</li>
435+ /// <li>\a __cpuInfo[2] receives the value of the \c ECX register.</li>
436+ /// <li>\a __cpuInfo[3] receives the value of the \c EDX register.</li>
437+ /// </ul>
438+ /// \param __leaf
439+ /// An unsigned integer that identifies the level (also called the "leaf")
440+ /// at which the \c CPUID instruction will be executed.
441+ /// \param __subleaf
442+ /// An unsigned integer that identifies the sublevel (also called the
443+ /// "subleaf") at which the \c CPUID instruction will be executed.
348444static __inline void __cpuidex (int __cpu_info [4 ], int __leaf , int __subleaf ) {
349445 __cpuid_count (__leaf , __subleaf , __cpu_info [0 ], __cpu_info [1 ], __cpu_info [2 ],
350446 __cpu_info [3 ]);
0 commit comments