Skip to content

Conversation

@WalterBright
Copy link
Member

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8322"

@rainers
Copy link
Member

rainers commented Jun 2, 2018

Building on Appveyor fails because the D part assumes real exists on the C++ side, but that uses longdouble_soft.
As this is only a temporary problem until the other C files are translated aswell, it's probably easiest to just force the correct mangling with pragma(mangle) on a couple of functions.

@WalterBright
Copy link
Member Author

Another possibility may be to just convert bcomplex.c to D as well.

@rainers
Copy link
Member

rainers commented Jun 2, 2018

Affected functions seem to be el_toldouble, _modulo and Complex_ld::abs.

@rainers
Copy link
Member

rainers commented Jun 2, 2018

Another option is to use longdouble_soft in D instead of real whenever version CRuntime_Microsoft is active. That needs a tiny change for y2lx, too.

@WalterBright
Copy link
Member Author

Since it'll all be converted to D anyway, I figured might as well go ahead and convert bcomplex.c to D in this PR.

@WalterBright WalterBright force-pushed the evalu8.d branch 12 times, most recently from 9a1673f to f9e5f9c Compare June 2, 2018 23:40
@WalterBright
Copy link
Member Author

Appveyor failures:

unittest
core.exception.AssertError@src\core\math.d(116): unittest failure
----------------
0x01114497
0x011AA5D3 in gc_clrProxy
core.exception.AssertError@src\rt\util\typeinfo.d(250): Assertion failure
----------------
0x01114441
0x011AA5D3 in gc_clrProxy
2/42 unittests FAILED
--- errorlevel 1

which have nothing to do with this PR. @rainers what's going on?

@WalterBright WalterBright force-pushed the evalu8.d branch 7 times, most recently from 680a3cd to e9c315a Compare June 3, 2018 00:56
@WalterBright
Copy link
Member Author

@rainers are you able to replicate the AppVeyor failures? I can't on my machine.

@WalterBright
Copy link
Member Author

You have to keep targ_ldouble here because when built with LDC on Windows, real is the same as double.

Making that change causes semaphoreci to fail with:

gdmd -c -of../generated/linux/release/64/divcoeff.o  -version=MARS -fPIC -w -de -O -release -inline -m64  dmd/backend/divcoeff.d
dmd/backend/bcomplex.d:217:1: error: struct dmd.backend.bcomplex.Complex_ld no size yet for forward reference
 struct Complex_ld
 ^
dmd/backend/cdef.d:798:1: error: union dmd.backend.cdef.eve no size yet for forward reference
 union eve
 ^

src/dmd/e2ir.d Outdated
e.EV.Vcldouble.re = re;
e.EV.Vcldouble.im = im;
e.EV.Vcldouble.re = cast(real)re;
e.EV.Vcldouble.im = cast(real)im;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is no longer necessary and is harmful to the LDC build, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, gone

* instead of the soft long double ones.
*/

extern (D) real el_toldoubled(elem *e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, still more uses of real instead of targ_ldouble...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

*/
version (CRuntime_Microsoft)
{
extern (D) private real _modulo(real x, real y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the casts should go into this function instead of the call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right

#include "global.h"
#include "el.h"
#include "type.h"
version (SPP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: no module name here? (I won't object to module names without package if that's that's how you want to do it ;-) )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No imports of it yet, I'll probably worry about that when imports happen. Right now, I just want to get it to work :-)

@rainers
Copy link
Member

rainers commented Jun 3, 2018

Still too many uses of real. Shall I push a fix?

@WalterBright
Copy link
Member Author

Yes, I could use your help. I'm mostly just floundering about on these platforms I have little knowledge of.

@rainers
Copy link
Member

rainers commented Jun 3, 2018

Yes, I could use your help. I'm mostly just floundering about on these platforms I have little knowledge of.

Done. Now let's see the other platforms complain...

@rainers
Copy link
Member

rainers commented Jun 3, 2018

This failed because comparison of two targ_ldoubles is forwarded to longdouble_soft.opCmp, but that cannot return "false" for all comparisons involving nan. Now added explicit checks.

@WalterBright
Copy link
Member Author

It's all green and ready to pull! Thanks @rainers for your invaluable help. ping @JinShil @wilzbach @jacob-carlborg ?

{
r = y.re / y.im;
den = y.im + r * y.re;
q.re = cast(float)((x.re * r + x.im) / den);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation looks good, but I don't understand why the casts to float and double in this file are needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they make it clearer what is happening

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the casts are necessary if targ_ldouble resolves to longdouble_soft, as there is no implicit conversion to float/double then.

@JinShil
Copy link
Contributor

JinShil commented Jun 4, 2018

Also, I see an obvious opportunity for templated code here (may even remove the need for the casts), but I understand if you want to keep the code easy to cross-reference to the C implementation.

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

* Copyright: public domain
* License: public domain
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/bcomplex.d, backend/_bcomplex.d)
* Source: $(DMDSRC backend/_bcomplex.d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI underscore escaping is no longer needed. We enabled the opt-out about two months ago.
See: dlang/dlang.org#2307

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also last year you made a point of using absolute links here as they are clickable (see #7030).
Though I was a fan of DMDSRC, so I don't mind ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it should be the full version.

case TYenum:
#if !MARS
case TYmemptr:
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this result in a version(MARS){} else { ... } ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided that having too many version statements was clutter, and so removed the ones that weren't really necessary.

assert((statusFE() & 0x3800) == 0);
assert(e && EOP(e));
op = e->Eoper;
assert(e && !OTleaf(e.Eoper));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define EOP or EBIN as a function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think those macros paid off.

@JinShil
Copy link
Contributor

JinShil commented Jun 4, 2018

It also appears bcomplex.c was not deleted in this PR. Shouldn't it be?

@dlang-bot dlang-bot merged commit de5544c into dlang:master Jun 4, 2018
@WalterBright WalterBright deleted the evalu8.d branch June 4, 2018 03:17
@WalterBright WalterBright mentioned this pull request Jun 4, 2018
@WalterBright
Copy link
Member Author

deleted ?

Yes:
#8328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants