[dmd-internals] math intrinsics

Sean Kelly sean at invisibleduck.org
Tue Apr 5 08:49:23 PDT 2011


On Apr 4, 2011, at 6:22 PM, Brad Roberts wrote:

> My litmus test is essentially:
> 
> 1) Is it something the compiler emits code to call.  That covers pretty 
> much all of _d_*.
> 
> 2) Is it something that the compiler expects to be named something 
> specific.  The intrinsics fall into this camp.  I don't think it that the 
> compiler should look in std.intrinsic, std.math, tango.intrinsic, etc.

I agree.  But I think a distinction could be made between stuff the compiler is expected to look for and stuff it could look for (QOI).  I think the math routines may fall into the latter category.

The really tricky one here is Range.  I feel it's really a Phobos feature rather than a druntime feature, yet I believe the language spec even talks about Range (the compiler does something fancy with it when used with foreach).

> 3) Is it something that is common across standard libraries, for example 
> both Phobos and Tango, and should be shared.  I think intrinsics fall into 
> this camp also.

Yeah.  I tend to think of this as stuff that's so fundamental it may as well be a part of the language.  The synchronization primitives in core.sync, for example.

In essence, I think of druntime as a lot like java.lang--mostly language support, but with a bunch of fundamental stuff mixed in.  There are a few tough calls though.

> For what it's worth, I still think some of the lowest level utf primitive 
> functions belong in and should be exposed by the runtime.  Right now 
> they're duplicated between rt.mumble and std.mumble.

I agree.  It's just something I haven't gotten around to sorting out yet.


More information about the dmd-internals mailing list