[PATCH, gfortran] Re: Cray Pointers

Asher Langton langton2@llnl.gov
Fri Aug 12 21:14:00 GMT 2005


At 4:32 PM -0400 8/12/05, Andrew Pinski wrote:
>On Aug 12, 2005, at 4:29 PM, Paul Brook wrote:
>
>>>>% cat ex3.f90.t02.original
>>>>MAIN__ ()
>>>>{
>>>>    real4 t;
>>>>    int8 ipt;
>>>>
>>>>    {
>>>>      <unnamed type> D.805;
>>>>
>>>>      D.805 = (<unnamed type>) (int8) &t;
>>>>      ipt = (int8) D.805;
>>>>    }
>>>>    *(real4 *) ipt = 1.0e+0;
>>>>}
>>>
>>>can you use "void*" instead when you have a pointer?
>>
>>That wouldn't help. Aliasing works based on the type that the value is
>>accesses though, not the type of any intermediate variables used to store the
>>pointer. The type-based-aliasing rules are exactly the same regardless of the
>>type of ipt.
>
>That is not the issue I was trying to help here, I was trying to help with
>the extra casts, which should help with the compiler time and memory usage
>in the compiler.


It would be possible to treat Cray pointers as actual C-like pointers 
in the front end, but the patch would be much larger and more 
complicated.  As it stands now, nothing extra needs to be done to 
translate Cray pointers; they're simply ordinary integers.  If we 
were to change the type, then there would be all sorts of other 
changes necessary to handle arithmetic on pointers (and arithmetic 
involving both pointers and integers), parameter passing, IO, etc. 
It would complicate the compiler, and I suspect the resulting code 
would have even more casting.  As it is, going the GENERIC format 
already introduces a lot of extra variables and extra casts, so the 
compile-time cost of the extra Cray pointer-related casts probably 
isn't  too big a deal.

-Asher



More information about the Gcc-patches mailing list