[comp.lang.c] How is type **********p implemented?

shaunc@gold.gvg.tek.com (Shaun Case) (06/26/91)

How do C compiler writers implement items like int ***************p, for
which the target processor has insufficient levels of hardware indirection?
I can think of a couple of different ways, but they seem to be pretty 
inefficient.  I'd really like an answer, this is literally keeping me
awake staring at the ceiling.  

Please email responses; I will summarize if there is sufficient interest.

Shaun

(boy, is that "i before e except after c" rule unreliable... or is it? :)

henry@zoo.toronto.edu (Henry Spencer) (06/27/91)

In article <2623@gold.gvg.tek.com> shaunc@gold.gvg.tek.com (Shaun Case) writes:
>How do C compiler writers implement items like int ***************p, for
>which the target processor has insufficient levels of hardware indirection?

The obvious way, actually.  Most modern processors (anything that ends in
"86" is not modern :-)) have only one level of indirection in their
addressing system.  So if the user declares something like your `p' and
then does `x = ***************p;', the code is the equivalent of:

	tmp1 = *p;
	tmp2 = *tmp1;
	tmp3 = *tmp2;
	...
	x = *tmpn;

In practice, usually all the tmp* will share a single register unless the
hardware has strange ideas about data types.
-- 
"We're thinking about upgrading from    | Henry Spencer @ U of Toronto Zoology
SunOS 4.1.1 to SunOS 3.5."              |  henry@zoo.toronto.edu  utzoo!henry