ftp.nice.ch/peanuts/GeneralData/Usenet/news/1991/CSN-91.tar.gz#/comp-sys-next/1991/Mar/68040-Math:-Compiling-library-calls-or-inline-?

This is 68040-Math:-Compiling-library-calls-or-inline-? in view mode; [Up]


Date: Sun 19-Feb-1991 15:42:25 From: toon@news.sara.nl Subject: 68040 Math: Compiling library calls or inline ? In article <1991Feb18.181012.12483@kithrup.COM>, sef@kithrup.COM (Sean Eric Fagan) writes: > In article <1991Feb18.105109.2810@news.sara.nl> I write: >>Well, that depends on how this is implemented. I can imagine that in the >>old ('030) case, sin(), cos(), tan() and friends translated to either a >>single instruction library call, or a single instruction expanded inline >>(although I don't know enough of the (gcc) compiler to know whether it >>is _possible_ to translate library calls to inline code). Sean shows: > > /* file <math.h> */ > > #ifdef __GNUC__ > # ifdef __OPTIMIZE__ > static __inline double > sin(double x) { > double temp; > __asm ("fsin %0, %1" : "=F" (temp) : "f" (x)); > return temp; > } > /* ... */ > #endif __GNUC__ Well, according to the original poster, the instruction was something like FSINCOS, so you perhaps have to do some result twiddling after this instruction, but basically this is what I meant: expanding the library call (or what is a library call on most machines) inline. Thanks. I assume one could also do this for the more complex instruction sequence that comprises '040 equivalent of one 68882 FSINCOS instruction. There is one point to make here: It is faster than having a library routine doing it (saves jump-to-subroutine and return instruction - and the instruction cache flushing that goes with it (someone who really knows the '040 care to comment, please ?)) but it also takes a longer instruction stream (if you use more than one sin() call in your program). > [ ... useful example deleted ... ] > > THERE IS NO EASY WAY TO REPLACE THAT fsin WITHOUT RECOMPILING. IF RECOMPILE > AND USE AN OPTIMIZED SUBROUTINE, THAT DOES *NOT* USE THE fsin INSTRUCTION, > YOUR CODE WILL BE FASTER ON THE 68040. Hm, I hope I didn't formulate my original posting in such a way that this is what you read in it. Of course I didn't really believe that putting a '040 board in your CuBE would automagically convert FSINCOS instructions to library routines - that's why you need the trap code ... Anyway, this discussion is highly academic to me, as there is as yet no official NeXT dealer in the Netherlands - no CuBEs, no stations, no service ...

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.