[libc-commits] [PATCH] D106604: [libc] Raise denormal exception if the libc defines __FE_DENORM.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jul 22 15:08:09 PDT 2021
sivachandra created this revision.
sivachandra added a reviewer: michaelrj.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
sivachandra requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106604
Files:
libc/utils/FPUtil/x86_64/FEnvImpl.h
Index: libc/utils/FPUtil/x86_64/FEnvImpl.h
===================================================================
--- libc/utils/FPUtil/x86_64/FEnvImpl.h
+++ libc/utils/FPUtil/x86_64/FEnvImpl.h
@@ -251,41 +251,29 @@
// ensure that the writes by the exception handler are maintained
// when raising the next exception.
- if (statusValue & internal::ExceptionFlags::Invalid) {
+ auto raiseHelper = [](uint16_t singleExceptFlag) {
internal::X87StateDescriptor state;
internal::getX87StateDescriptor(state);
- state.StatusWord |= internal::ExceptionFlags::Invalid;
- internal::writeX87StateDescriptor(state);
- internal::fwait();
- }
- if (statusValue & internal::ExceptionFlags::DivByZero) {
- internal::X87StateDescriptor state;
- internal::getX87StateDescriptor(state);
- state.StatusWord |= internal::ExceptionFlags::DivByZero;
- internal::writeX87StateDescriptor(state);
- internal::fwait();
- }
- if (statusValue & internal::ExceptionFlags::Overflow) {
- internal::X87StateDescriptor state;
- internal::getX87StateDescriptor(state);
- state.StatusWord |= internal::ExceptionFlags::Overflow;
- internal::writeX87StateDescriptor(state);
- internal::fwait();
- }
- if (statusValue & internal::ExceptionFlags::Underflow) {
- internal::X87StateDescriptor state;
- internal::getX87StateDescriptor(state);
- state.StatusWord |= internal::ExceptionFlags::Underflow;
- internal::writeX87StateDescriptor(state);
- internal::fwait();
- }
- if (statusValue & internal::ExceptionFlags::Inexact) {
- internal::X87StateDescriptor state;
- internal::getX87StateDescriptor(state);
- state.StatusWord |= internal::ExceptionFlags::Inexact;
+ state.StatusWord |= singleExceptFlag;
internal::writeX87StateDescriptor(state);
internal::fwait();
+ };
+
+ if (statusValue & internal::ExceptionFlags::Invalid)
+ raiseHelper(internal::ExceptionFlags::Invalid);
+ if (statusValue & internal::ExceptionFlags::DivByZero)
+ raiseHelper(internal::ExceptionFlags::DivByZero);
+ if (statusValue & internal::ExceptionFlags::Overflow)
+ raiseHelper(internal::ExceptionFlags::Overflow);
+ if (statusValue & internal::ExceptionFlags::Underflow)
+ raiseHelper(internal::ExceptionFlags::Underflow);
+ if (statusValue & internal::ExceptionFlags::Inexact)
+ raiseHelper(internal::ExceptionFlags::Inexact);
+#ifdef __FE_DENORM
+ if (statusValue & internal::ExceptionFlags::Denormal) {
+ raiseHelper(internal::ExceptionFlags::Denormal);
}
+#endif // __FE_DENORM
// There is no special synchronization scheme available to
// raise SEE exceptions. So, we will ignore that for now.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106604.360991.patch
Type: text/x-patch
Size: 2675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210722/af3d30a1/attachment.bin>
More information about the libc-commits
mailing list