[Ada] Ease interface with builtins that returns void *
Tristan Gingold
gingold@adacore.com
Mon Jul 16 14:31:00 GMT 2012
On Jul 16, 2012, at 3:58 PM, Duncan Sands wrote:
> Hi Tristan,
>
>>> indeed, for two years already. Is there any reason not to do this for all
>>> functions, rather than just limiting it to builtins?
>>
>> I don't understand what do you mean. We need to do this implicit conversion for builtins because they are known by the compiler. Which other functions (that aren't builtins) are you referring to ?
>
> all of them! First off, the LLVM optimizers do a better job if an argument of a
> user defined function that is really a pointer is declared as such, rather than
> declared as an integer then cast to a pointer before being used. I don't know
> if the GCC optimizers are sensitive to this too. Also, the LLVM optimizers
> recognize some standard library functions that the gcc optimizers do not, but
> fail to recognize them when called from Ada because they have the wrong
> prototype: an integer rather than a pointer argument. Finally I would argue
> that as System.Address is really a pointer, playing pretty much exactly the
> same role as void* in C, it is more philosophically correct to express it as a
> void*. That said, it should probably just be declared as a pointer in the
> System package rather than doing all this mucking around in the gcc interface.
Ah, what you want is the use of 'void *' for System.Address.
We didn't choose that because the semantic of System.Address (which includes arithmetic on the whole address space) doesn't match the void * one.
But, you can try to implement this scheme by modifying the runtime. I don't know if this is a small work or not.
Tristan.
More information about the Gcc-patches
mailing list