| 1 |
/* |
| 2 |
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2020 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-dsp-lib |
| 6 |
* Created on: 31 мар. 2020 г. |
| 7 |
* |
| 8 |
* lsp-dsp-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-dsp-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef PRIVATE_DSP_ARCH_X86_AVX_XCR_H_ |
| 23 |
#define PRIVATE_DSP_ARCH_X86_AVX_XCR_H_ |
| 24 |
|
| 25 |
#ifndef PRIVATE_DSP_ARCH_X86_AVX_IMPL |
| 26 |
#error "This header should not be included directly" |
| 27 |
#endif /* PRIVATE_DSP_ARCH_X86_AVX_IMPL */ |
| 28 |
|
| 29 |
namespace lsp |
| 30 |
{ |
| 31 |
namespace x86 |
| 32 |
{ |
| 33 |
#ifdef ARCH_X86_AVX |
| 34 |
uint64_t read_xcr(umword_t xcr_id) |
| 35 |
{ |
| 36 |
uint64_t xcr; |
| 37 |
|
| 38 |
ARCH_X86_ASM |
| 39 |
( |
| 40 |
__ASM_EMIT64("xor %%rax, %%rax") |
| 41 |
__ASM_EMIT("xgetbv") |
| 42 |
__ASM_EMIT64("shl $32, %%rdx") |
| 43 |
__ASM_EMIT64("or %%rdx, %%rax") |
| 44 |
: __IF_32("=A" (xcr)) __IF_64("=a" (xcr)) |
| 45 |
: "c" (xcr_id) |
| 46 |
: __IF_64("%rdx") |
| 47 |
); |
| 48 |
return xcr; |
| 49 |
} |
| 50 |
#else |
| 51 |
uint64_t read_xcr(umword_t xcr_id) |
| 52 |
{ |
| 53 |
return 0; |
| 54 |
} |
| 55 |
#endif /* ARCH_X86_AVX */ |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
#endif /* PRIVATE_DSP_ARCH_X86_AVX_XCR_H_ */ |