[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: killing registers
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Re: killing registers
- From: Jesper Louis Andersen <jlouis_(_at_)_jlouis_(_dot_)_dk>
- Date: Wed, 5 Jun 2002 17:29:05 +0200
- Mail-followup-to: Jesper Louis Andersen <jlouis_(_at_)_jlouis_(_dot_)_dk>, tech_(_at_)_openbsd_(_dot_)_org
On Fri, May 31, 2002 at 03:55:27AM -0600, Theo de Raadt wrote:
> > while browsing the cvs logs I see, that ocassionally registers get wiped (e.g.
> > "register int c" -> "int c", example: src/bin/mt/mt.c revision 1.18 to 1.19).
> > What is the reason for that?
> Compilers no longer need it.
To elaborate on it:
Most compilers in fact ignores the ``register'' keyword, as they are
better of placing variables into registers than humans. Furthermore
different architectures have a different number of registers leading to
a very different policy for placing variables into registers.
The task of allocating variables to registers are known as
register-allocation. The problem is NP-hard and is thus not something
simple to do. Normally one deploys a heuristical approach in allocating,
which often leads to better allocation than a human can do. An
alternative is the linear-scan algorithm, which normally is used when
you have to do register allocation fast (eg Just-in-time compilation).
The allocator gives a less optimal solution but is a lot faster.
C isn't that low-level anymore. It completely lacks branching hints and
caching hints for instance. And register allocation can be done very
efficiently by a compiler nowadays
Visit your host, monkey.org