https://d.puremagic.com/issues/show_bug.cgi?id=3749
--- Comment #13 from Iain Buclaw <[email protected]> 2014-01-08 04:31:41 PST --- (In reply to comment #12) > (In reply to comment #11) > > (In reply to comment #10) > > > What's the state of this? > > > Having log/exp functions at compile time would be very useful, e.g. to > > > pregenerate scientific tables. > > > > std.math now has pure generic implementations. > > > > One of the main problems holding CTFE support back is that there is no > > straightforward way to do math operations such as isNaN, isInfinity, > > signbit, > > frexp which require access (and for some, manipulation) of the bits in float > > types. > > We had the same issue with hashOf in druntime and now there is a huge > machinery > to compute exponent and mantissa. > Could we allow to read specific floating point values through intrinsics at > compile time? > Something like exponent(float), signbit(float), mantissa(float)? > > > Saying that, DMD has a problem that GDC doesn't - it uses the IASM > > implementations of std.math functions that can't be evaluated at compile > > time. > > How do you treat std.math.log at runtime as intrinsic or does it run the same > code? Is there a performance penalty? We don't implement y2lx in GDC, so it uses the !INLINE_Y2LX implemenatation. :) If you instead meant eg: std.math.sin, this is the process (approximately). User code (import std.math) -> Compiler registers real sin() as BUILT_IN_FRONTEND User code calls std.math.sin -> CTFE sees function is BUILTINsin and calls eval_builtin() -> eval_builtin generates call to BUILT_IN_SINL and then calls fold_builtin() -> fold_builtin validates input parameters and calls mpfr_sin() -> Returns MPFR evaluated value to fold_builtin as GCC tree. -> Returns GCC tree to eval_builtin which converts it to RealExp value. Compiler unable to fold builtin -> Returns CallExp to C math lib function sin() It's a long winded way, and I'd like to ideally skip passing through the middle-end and call MPFR directly. :) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
