Hi Jerno,
On Wed, Oct 10, 2012 at 7:41 PM, j j <
jerro....@gmail.com> wrote:
> Hi, I'd like to talk to you about declarations for gcc builtin x86
> intrinsics in LDC. I think it would be useful if LDC provided a module
> containing the declarations for those intrinsics, like for example
> this one:
>
> pragma(intrinsic, "
llvm.x86.sse.min.ps")
> float4 __builtin_ia32_minps (float4, float4);
It certainly would be an useful addition, at the very least for
porting C/C++ SIMD code, and we should be able to get all the
necessary information out of LLVM/Clang tablegen files, as they are
installed into include/ anyway.
> What I don't know is where these declarations should go - should they
> be publicly imported into llvm.intrinsics, or should there be in a
> separate module, for example llvm.gccbuiltins?
I think I'd prefer creating a new ldc.gccbuiltins module just for the
sake of keeping everything nice and tidy, but I don't really have a
strong opinion on it.
> I'm currently using the script at
https://gist.github.com/3851893 to
> generate the gcc builtin declarations from IntrinsicsX86.td. It is
> written in D, so I guess I would have to rewrite it in something else
> (probably C++) if we wanted to use it at build time.
One option would be to just build your tool after druntime and Phobos
have been built. However, in theory someone could want to build LDC
for a target which is not the host target, so yes, it might be a wise
idea not to introduce a dependency on D in our build process.
However, there might be a more elegant way to do it anyway: According
to the folks in #llvm, it should not be hard to write a custom
TableGen-based tool to directly gather the information we need, using
llvm/TableGen/*.h and libLLVMTableGen.a. For reference, see
utils/TableGen/IntrinsicsEmitter.cpp (a piece of code emitting a list
of all GCC builtins was removed in r153432).
Anyway, thanks a lot for looking into this – I'd very much like to see
an addition like this.
David