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