| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <Jolt/Core/FPControlWord.h> |
| 8 |
|
| 9 |
JPH_NAMESPACE_BEGIN |
| 10 |
|
| 11 |
#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED |
| 12 |
|
| 13 |
#if defined(JPH_CPU_WASM) |
| 14 |
|
| 15 |
|
| 16 |
class FPExceptionsEnable { }; |
| 17 |
class FPExceptionDisableInvalid { }; |
| 18 |
class FPExceptionDisableDivByZero { }; |
| 19 |
class FPExceptionDisableOverflow { }; |
| 20 |
|
| 21 |
#elif defined(JPH_USE_SSE) |
| 22 |
|
| 23 |
|
| 24 |
class FPExceptionsEnable : public FPControlWord<0, _MM_MASK_DIV_ZERO | _MM_MASK_INVALID | _MM_MASK_OVERFLOW> { }; |
| 25 |
|
| 26 |
|
| 27 |
class FPExceptionDisableInvalid : public FPControlWord<_MM_MASK_INVALID, _MM_MASK_INVALID> { }; |
| 28 |
|
| 29 |
|
| 30 |
class FPExceptionDisableDivByZero : public FPControlWord<_MM_MASK_DIV_ZERO, _MM_MASK_DIV_ZERO> { }; |
| 31 |
|
| 32 |
|
| 33 |
class FPExceptionDisableOverflow : public FPControlWord<_MM_MASK_OVERFLOW, _MM_MASK_OVERFLOW> { }; |
| 34 |
|
| 35 |
#elif defined(JPH_CPU_ARM) && defined(JPH_COMPILER_MSVC) |
| 36 |
|
| 37 |
|
| 38 |
class FPExceptionsEnable : public FPControlWord<0, _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW> { }; |
| 39 |
|
| 40 |
|
| 41 |
class FPExceptionDisableInvalid : public FPControlWord<_EM_INVALID, _EM_INVALID> { }; |
| 42 |
|
| 43 |
|
| 44 |
class FPExceptionDisableDivByZero : public FPControlWord<_EM_ZERODIVIDE, _EM_ZERODIVIDE> { }; |
| 45 |
|
| 46 |
|
| 47 |
class FPExceptionDisableOverflow : public FPControlWord<_EM_OVERFLOW, _EM_OVERFLOW> { }; |
| 48 |
|
| 49 |
#elif defined(JPH_CPU_ARM) |
| 50 |
|
| 51 |
|
| 52 |
static constexpr uint64 FP_IOE = 1 << 8; |
| 53 |
|
| 54 |
|
| 55 |
static constexpr uint64 FP_DZE = 1 << 9; |
| 56 |
|
| 57 |
|
| 58 |
static constexpr uint64 FP_OFE = 1 << 10; |
| 59 |
|
| 60 |
|
| 61 |
class FPExceptionsEnable : public FPControlWord<FP_IOE | FP_DZE | FP_OFE, FP_IOE | FP_DZE | FP_OFE> { }; |
| 62 |
|
| 63 |
|
| 64 |
class FPExceptionDisableInvalid : public FPControlWord<0, FP_IOE> { }; |
| 65 |
|
| 66 |
|
| 67 |
class FPExceptionDisableDivByZero : public FPControlWord<0, FP_DZE> { }; |
| 68 |
|
| 69 |
|
| 70 |
class FPExceptionDisableOverflow : public FPControlWord<0, FP_OFE> { }; |
| 71 |
|
| 72 |
#elif defined(JPH_CPU_RISCV) |
| 73 |
|
| 74 |
#error "RISC-V only implements manually checking if exceptions occurred by reading the fcsr register. It doesn't generate exceptions. JPH_FLOATING_POINT_EXCEPTIONS_ENABLED must be disabled." |
| 75 |
|
| 76 |
#elif defined(JPH_CPU_PPC) |
| 77 |
|
| 78 |
#error PowerPC floating point exception handling to be implemented. JPH_FLOATING_POINT_EXCEPTIONS_ENABLED must be disabled. |
| 79 |
|
| 80 |
#else |
| 81 |
|
| 82 |
#error Unsupported CPU architecture |
| 83 |
|
| 84 |
#endif |
| 85 |
|
| 86 |
#else |
| 87 |
|
| 88 |
|
| 89 |
class FPExceptionsEnable { }; |
| 90 |
class FPExceptionDisableInvalid { }; |
| 91 |
class FPExceptionDisableDivByZero { }; |
| 92 |
class FPExceptionDisableOverflow { }; |
| 93 |
|
| 94 |
#endif |
| 95 |
|
| 96 |
JPH_NAMESPACE_END |