Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site sfmag.UUCP Path: utzoo!watmath!clyde!burl!ulysses!sfmag!mjs From: mjs@sfmag.UUCP (M.J.Shannon) Newsgroups: net.lang.c Subject: Re: Can C default to float? Are there float regs? Message-ID: <698@sfmag.UUCP> Date: Sun, 15-Sep-85 10:41:46 EDT Article-I.D.: sfmag.698 Posted: Sun Sep 15 10:41:46 1985 Date-Received: Sun, 15-Sep-85 23:53:55 EDT References: <418@phri.UUCP> <700002@fthood> <187@graffiti.UUCP> <175@mit-bug.UUCP> <897@turtlevax.UUCP> Organization: AT&T Information Systems, Summit, NJ Lines: 57 > In article <175@mit-bug.UUCP> dove@mit-bugs-bunny.UUCP (Web dove) writes: > >Many people in our group find it frustrating that C converts floating > >arithmetic to double. Converting float variables to double, doing the > >calculation and converting back to float is usually so costly that it > >is faster to do it in double. Unfortunately, this wastes space. > >Also, our machines (vax 750/4.2bsd) would be faster if the > >computations were done in straight float. Many people resort to > >fortran/assembler to accomplish this, but it is unfortunate to need to use > >two languages. > > > >I realize that this violates the standard for C, but has anyone ever > >changed the compiler to accomplish this? > > I've heard of some implementations that do this. They have implemented > two separate compilers, which one can switch between with a flag: one > for the "standard interpretation" of the C specification, and one that > accommodates "float" as a bonafide type with a complete set of > operations on them. > > The 16-bit machines allowed for two types of fixed point arithmetic: > short (int) and long. There is no reason why this could not also be > implemented for floating-point numbers. > > >On a related note, it appears that register declarations for float variables > >have no effect on our compiler (they don't cause the variables to be stored > >in registers). It has been hypothesized that those who write the compiler > >don't feel that making "register float" do something is worth the effort. > > > >Is there anyone who has made "register float" work? Is it impossible? > > Similarly this is not impossible. I don't believe that the C spec > precludes this. It's just that many machines do not have > flaoting-point registers. > > On machines such as the 68000 that have separate address and data > register sets, the C compiler doesn't normally distinguish between the > two when allocating them; special enhancements need to be made to the > compiler in order for the allocation to be done appropriately. A > similar enhancement need to be done for floating-point registers. > > -- > Ken Turkowski @ CADLINC, Menlo Park, CA > UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken > ARPA: turtlevax!ken@DECWRL.ARPA Also, for machines which do have floating point registers, getting the code generator to produce the correct code to use them is less trivial than most would believe. It is for this reason that most VAX compilers no longer implement "register double" in registers (though many did at one time or another, there were a significant number of cases that the compiler got wrong, and fixing these cases would have taken orders of magnitude more work than was feasable). -- Marty Shannon UUCP: ihnp4!attunix!mjs Phone: +1 (201) 522 6063 Disclaimer: I speak for no one.