Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site turtlevax.UUCP
Path: utzoo!linus!decvax!decwrl!turtlevax!ken
From: ken@turtlevax.UUCP (Ken Turkowski)
Newsgroups: net.lang.c
Subject: Re: Can C default to float? Are there float regs?
Message-ID: <897@turtlevax.UUCP>
Date: Fri, 13-Sep-85 13:11:52 EDT
Article-I.D.: turtleva.897
Posted: Fri Sep 13 13:11:52 1985
Date-Received: Sun, 15-Sep-85 04:54:45 EDT
References: <418@phri.UUCP> <700002@fthood> <187@graffiti.UUCP> <175@mit-bug.UUCP>
Reply-To: ken@turtlevax.UUCP (Ken Turkowski)
Organization: CADLINC, Inc. @ Menlo Park, CA
Lines: 44
Summary: 

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