|[2 earlier articles]|
|Re: register variables in C. email@example.com (1992-04-23)|
|Re: register variables in C. firstname.lastname@example.org (1992-04-23)|
|Re: register variables in C. dave.howell@ColumbiaSC.NCR.COM (Dave Howell) (1992-04-24)|
|Re: register variables in C. email@example.com (1992-04-29)|
|Re: register variables in C. firstname.lastname@example.org (1992-04-30)|
|Re: register variables in C. Brian.Scearce@Eng.Sun.COM (1992-04-30)|
|Re: register variables in C. email@example.com (1992-05-01)|
|Re: register variables in C. metaware!miker@uunet.UU.NET (1992-05-01)|
|Re: register variables in C. firstname.lastname@example.org (1992-05-01)|
|Re: register variables in C. email@example.com (1992-05-01)|
|Re: register variables in C. firstname.lastname@example.org (1992-05-02)|
|Re: register variables in C. email@example.com (1992-05-04)|
|Re: register variables in C. firstname.lastname@example.org (1992-05-04)|
|[2 later articles]|
|From:||email@example.com (David Keppel)|
|Keywords:||registers, optimize, bibliography|
|Organization:||Computer Science & Engineering, U. of Washington, Seattle|
|Date:||Fri, 1 May 1992 02:18:31 GMT|
John Levine writes:
>[Use them, let the compiler decide with `-Dregister=auto'.]
You might want to define register to nothing in case `auto' forces vars to
memory for some reason. This approach is all-or-nothing which is
undesirable since different compilers & architectures have different
needs. I recommend `register' for the most important variables and and
use other #defines for the remainder [Cannon et. al]:
register int x1;
register int y1;
REGISTER int x2;
REGISTER int y2;
This approach can tell compiler A `x1' and `y1' belong in registers and
can tell compiler B that `x2' and `y2' also belong in registers. It also
avoids telling `A' that `x2' and `y2' belong in registers, which keeps
compiler A from being swamped with register declarations. That might be
important on machines with few registers. It also helps the person
porting/maintaining the code in deciding which things the original
programmer believes are most important.
In writing code for several platforms you may need to define REGISTER,
REGISTER2, etc., to cover the various targets.
I believe that C programmers who are tuning programs should use `register'
and REGISTER and so on because it works in practice and documents
performance tuning. `register' should be used when the situation demands
it; it shouldn't be used gratuitously (nor should `REGISTER' and so on).
I don't recall: the original question could have been ``should I use
`register'?'' or ``should my compiler recognize `register'?'' As a
programmer, I am willing to use a compiler that ignores register
declarations (e.g., GNU CC) because it does a good job in general and
because register allocation is just one of many tuning problems. I would
be happier still if it recognized `register', as I could always turn it
off (-Dregister) but could use it when the situation demands.
For the asbestos at heart:
[Cannon et. al]
L. W. Cannon, R. A. Elliot, L. W. Kirchhoff J. H. Miller,
J. M. Milner, R. W. Mitze, E. P. Schan, N. O. Whittington,
Henry Spencer, David Keppel, Mark S. Brader _Recommended C
Style and Coding Standards_. (Originally published as
_Indian Hill C Style and Coding Standards_, rewritten by the
last three authors.) ISBN 0-91615-46-8, 1990.
It's available via anonymous ftp from `cs.washington.edu' (126.96.36.199) in
`pub/cstyle.tar.Z', be sure to do the transfer in binary (image) mode.
;-D on ( The style pedant ) Pardo
Return to the
Search the comp.compilers archives again.