From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 8758f77e for ; Thu, 16 Jan 2020 16:14:41 +0000 (UTC) Received: (qmail 26134 invoked by uid 550); 16 Jan 2020 16:14:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26116 invoked from network); 16 Jan 2020 16:14:39 -0000 Date: Thu, 16 Jan 2020 11:14:27 -0500 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20200116161427.GO30412@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: Rich Felker Subject: Re: [musl] Considering x86-64 fenv.s to C On Thu, Jan 16, 2020 at 03:30:03PM +1100, Damian McGuckin wrote: > > I was just looking at fenv.s in x86-64 with a view to doing this as > C-code with some __asm__. I have limited experience with playing > with this stuff in an SSE-only environment, i.e. no 80-bit floats. > Before I attempt anything, I need to expand my knowledge. > > My observations on > > musl-1.1.24/src/fenv/x86_64/fenv.s > > * feclearexcept > > considers both the X87 status word and the SSE MXCSR > > * feraiseexcept > > ignores the X87 status word and considers only the SSE MXCSR > > * fetesteexcept > > considers both the X87 status word and the SSE MXCSR > > * fesetround > > considers both the X87 control word and the SSE MXCSR > > * fegetround > > ignores the X87 control word and considers only the SSE MXCSR > > Why is the X87 component of the FPU control/status sometimes ignored > and sometimes not? > > Does the X87 control or status bits automatically flow through to the > equivalent stuff in the SSE or vica-versa? > > I assume that 'fwait' is irrelevant and unnecessary, even if one is > using the x87 FPU? As an aside, rather than implementing x86-specific C versions of these, I'd like to end up with a general framework where the arch just exposes a header (fenv_arch.h?) defining some primitives, and the actual fenv function logic is all shared C. I'm not sure what the right generalization is though. It looks like all archs have a get/set exception-flags (status word) operation, but the rest varies a bit. Would you be interested in assessing what kind of abstraction makes sense here? Rich