Re: Compiler Libraries and/or built-in routines (John D. Mitchell)
Wed, 7 Oct 1992 08:56:17 GMT

          From comp.compilers

Related articles
Re: Compiler Libraries and/or built-in routines (1992-10-06)
Re: Compiler Libraries and/or built-in routines (1992-10-07)
Re: Compiler Libraries and/or built-in routines (1992-10-07)
Re: run-time libraries (1992-10-08)
Re: Compiler Libraries and/or built-in routines (1992-10-09)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (John D. Mitchell)
Organization: University of California, at Berkeley
Date: Wed, 7 Oct 1992 08:56:17 GMT
References: 92-10-022
Keywords: library, design, comment (Larry Maturo) writes:
>I probably have a 6 or 8 compiler books and none of them address the
>issues of libraries to any great degree. ...

JPI's Topspeed compiler family all share the same back end and most of
their libraries. From what I've read/heard they produce a separate front
end for each language that they support (C/C++, Pascal, Modula-2, they
were supposedly working on Ada and something else :-) that generate some
common intermediate representation (I don't know what). The libraries, I
believe, can be written with any of their languages and the routines can
be called from any language as well (though there are probably exceptions

>Is there a particular reference book compiler writers
>use for this? Are there any standards?

I don't know of any books that talk specifically about interfacing the
compiler and the library (perhaps the Oberon books by Wirth?).

You might want to look at Plauger's _The Standard C Library_ which
(suprise) talks about a Standard conforming implementation of the ISO/ANSI
C language library.

>When I call the Sin routine in one compiler how close will the answer be
>to that of calling the Sin routine with the same argument in another

Your guess is as good as mine. Implementations of math libraries
especially are wildly different. Different hardware. Different needs
(i.e. an embedded OS might want speed over accuracy). Different standards
of mathematical precision and the like.

>How does one fake floating point when the target processor has
>no floating point unit? ...

Many people (especially in the embedded systems world) have gotten a few
texts of numerical algorithms and implement them themselves. I believe
that a book by Cody & Waite is one of the standard references for this
sort of thing (there's a full reference in [Plauger]).

I would suspect that anybody who doesn't implement a reasonable math
library was just lazy. :-?

Depending on the hardware/software/OS/etc. it can be trivial to reasonably
difficult to efficiently support both hardware based floating point and
software emulation. Microsoft and Borland both do an interesting trick
with software interrupts on the PC to handle this.

Hope this helps,
John D. Mitchell
[Cody&Waite is William J. Cody, Jr. and William Waite, "Software Manual for
the Elementary Functions," Prentice-Hall, 1980, ISBN 0-13-822064-6. It
presents robust algorithms for sqrt, log, exp, sin, and so forth in a
cookbook way, with options depending on whether you have hardware floating
point, binary vs. hex float, and other stuff. I expect that there are
faster algorithms than the ones they discuss (CORDIC, for example) but if
you do what they say, you'll get code that works. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.