1 | /* Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
---|
2 |
|
---|
3 | This file is part of GCC.
|
---|
4 |
|
---|
5 | GCC is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 3, or (at your option)
|
---|
8 | any later version.
|
---|
9 |
|
---|
10 | GCC is distributed in the hope that it will be useful,
|
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | GNU General Public License for more details.
|
---|
14 |
|
---|
15 | Under Section 7 of GPL version 3, you are granted additional
|
---|
16 | permissions described in the GCC Runtime Library Exception, version
|
---|
17 | 3.1, as published by the Free Software Foundation.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU General Public License and
|
---|
20 | a copy of the GCC Runtime Library Exception along with this program;
|
---|
21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
---|
22 | <http://www.gnu.org/licenses/>. */
|
---|
23 |
|
---|
24 | #ifndef _X86GPRINTRIN_H_INCLUDED
|
---|
25 | # error "Never use <pconfigintrin.h> directly; include <x86gprintrin.h> instead."
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #ifndef _PCONFIGINTRIN_H_INCLUDED
|
---|
29 | #define _PCONFIGINTRIN_H_INCLUDED
|
---|
30 |
|
---|
31 | #ifndef __PCONFIG__
|
---|
32 | #pragma GCC push_options
|
---|
33 | #pragma GCC target("pconfig")
|
---|
34 | #define __DISABLE_PCONFIG__
|
---|
35 | #endif /* __PCONFIG__ */
|
---|
36 |
|
---|
37 | #define __pconfig_b(leaf, b, retval) \
|
---|
38 | __asm__ __volatile__ ("pconfig\n\t" \
|
---|
39 | : "=a" (retval) \
|
---|
40 | : "a" (leaf), "b" (b) \
|
---|
41 | : "cc")
|
---|
42 |
|
---|
43 | #define __pconfig_generic(leaf, b, c, d, retval) \
|
---|
44 | __asm__ __volatile__ ("pconfig\n\t" \
|
---|
45 | : "=a" (retval), "=b" (b), "=c" (c), "=d" (d) \
|
---|
46 | : "a" (leaf), "b" (b), "c" (c), "d" (d) \
|
---|
47 | : "cc")
|
---|
48 |
|
---|
49 | extern __inline unsigned int
|
---|
50 | __attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
---|
51 | _pconfig_u32 (const unsigned int __L, size_t __D[])
|
---|
52 | {
|
---|
53 | enum __pconfig_type
|
---|
54 | {
|
---|
55 | __PCONFIG_KEY_PROGRAM = 0x01,
|
---|
56 | };
|
---|
57 |
|
---|
58 | unsigned int __R = 0;
|
---|
59 |
|
---|
60 | if (!__builtin_constant_p (__L))
|
---|
61 | __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
|
---|
62 | else switch (__L)
|
---|
63 | {
|
---|
64 | case __PCONFIG_KEY_PROGRAM:
|
---|
65 | __pconfig_b (__L, __D[0], __R);
|
---|
66 | break;
|
---|
67 | default:
|
---|
68 | __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
|
---|
69 | }
|
---|
70 | return __R;
|
---|
71 | }
|
---|
72 |
|
---|
73 | #ifdef __DISABLE_PCONFIG__
|
---|
74 | #undef __DISABLE_PCONFIG__
|
---|
75 | #pragma GCC pop_options
|
---|
76 | #endif /* __DISABLE_PCONFIG__ */
|
---|
77 |
|
---|
78 | #endif /* _PCONFIGINTRIN_H_INCLUDED */
|
---|