1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 3 сент. 2018 г. 7 * 8 * lsp-plugins 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-plugins 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-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef DSP_ARCH_ARM_FPSCR_H_ 23 #define DSP_ARCH_ARM_FPSCR_H_ 24 25 #include <common/types.h> 26 27 #define FPSCR_IOC (1 << 0) /* Invlid operation cumulative exception */ 28 #define FPSCR_DZC (1 << 1) /* Division by zero cumulative exception */ 29 #define FPSCR_OFC (1 << 2) /* Overflow cumulative exception */ 30 #define FPSCR_UFC (1 << 3) /* Underflow cumulative exception */ 31 #define FPSCR_IXC (1 << 4) /* Inexact cumulative exception */ 32 #define FPSCR_IDC (1 << 7) /* Input decimal cumulative exception */ 33 #define FPSCR_IOE (1 << 8) /* Invalid operation exception enable */ 34 #define FPSCR_DZE (1 << 9) /* Division by zero exception enable */ 35 #define FPSCR_OFE (1 << 10) /* Overflow exception enable */ 36 #define FPSCR_UFE (1 << 11) /* Underflow exception enable */ 37 #define FPSCR_IXE (1 << 12) /* Inexact exception enable */ 38 #define FPSCR_IDE (1 << 15) /* Input Denormal exception enable */ 39 #define FPSCR_LEN_MASK (7 << 16) /* Length, deprecated by ARM */ 40 #define FPSCR_STRIDE_MASK (3 << 20) /* Stride, deprecated by ARM */ 41 #define FPSCR_RMODE_MASK (3 << 22) /* Rounding mode mask */ 42 #define FPSCR_RMODE_RN (0 << 22) /* Rounding to nearest */ 43 #define FPSCR_RMODE_RP (1 << 22) /* Rounding towards plus infinity */ 44 #define FPSCR_RMODE_RM (2 << 22) /* Rounding towards minus infinity */ 45 #define FPSCR_RMODE_RZ (3 << 22) /* Rounding towards zero */ 46 #define FPSCR_FZ (1 << 24) /* Flush-to-zero mode */ 47 #define FPSCR_DN (1 << 25) /* Default NaN mode control */ 48 #define FPSCR_AHP (1 << 26) /* Alternative half-precision control */ 49 #define FPSCR_QC (1 << 27) /* Cumulative saturation */ 50 #define FPSCR_V (1 << 28) /* Overflow condition flag */ 51 #define FPSCR_C (1 << 29) /* Carry condition flag */ 52 #define FPSCR_Z (1 << 30) /* Zero condition flag */ 53 #define FPSCR_N (1 << 31) /* Negative condition flag */ 54 55 namespace arm 56 { 57 #ifdef ARCH_ARM read_fpscr()58 inline uint32_t read_fpscr() 59 { 60 uint32_t fpscr; 61 62 ARCH_ARM_ASM 63 ( 64 __ASM_EMIT("vmrs %[fpscr], FPSCR") 65 : [fpscr] "=&r" (fpscr) 66 : : 67 ); 68 69 return fpscr; 70 } 71 write_fpscr(uint32_t fpscr)72 inline void write_fpscr(uint32_t fpscr) 73 { 74 ARCH_ARM_ASM 75 ( 76 __ASM_EMIT("vmsr FPSCR, %[fpscr]") 77 : 78 : [fpscr] "r" (fpscr) 79 : 80 ); 81 } 82 #else 83 inline uint32_t read_fpscr() 84 { 85 return 0; 86 } 87 88 inline void write_fpscr(uint32_t fpscr) 89 { 90 } 91 #endif /* ARCH_ARM */ 92 } 93 94 #endif /* DSP_ARCH_ARM_FPSCR_H_ */ 95