-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement ctfe yl2x and yl2xp1 #4012
Conversation
|
@ibuclaw Please, check my *nix inline assebler code. Is it ok? |
31f0e0a to
65d847c
Compare
You can implement x64 asm for VC in vcbuild/ldfpu.asm. |
|
Ok |
65d847c to
6fe4b48
Compare
| Expression *eval_yl2x(Loc loc, FuncDeclaration *fd, Expressions *arguments) | ||
| { | ||
| Expression *arg0 = (*arguments)[0]; | ||
| assert(arg0->op == TOKfloat64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why float64 instead of float80?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I did it similar examples like eval_sqrt
Expression *eval_sqrt(Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
Expression *arg0 = (*arguments)[0];
assert(arg0->op == TOKfloat64);
return new RealExp(loc, Port::sqrt(arg0->toReal()), arg0->type);
}
Maybe CTFE stores all floating numbers with op == TOKfloat64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you're right, the others do it too.
|
GDC can't use this, but this is not touching any shared code anyway. |
| import core.math : yl2x; | ||
| static x = yl2x(0, 0); | ||
| import std.math : rndtol; | ||
| static x = rndtol(1.2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, rndtol may be CTFE-able in GDC - I'll have to check this in detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> cat test.d
import std.math : rndtol;
static x = rndtol(1.2);
pragma(msg, rndtol(1.2));
> gdc test.d -S
1L
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should remove this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed it.
|
@ibuclaw Please comment the next code: Is it ok? It works, but I'm scared by unused assembler syntax. Do I need to add additional instructions like |
|
Added solaris support: tested with |
|
@IgorStepanov you don't need fwait with modern CPUs, and finit is only needed at program startup. |
|
Auto-merge toggled on |
implement ctfe yl2x and yl2xp1
|
Thanks!
It was needed only when x87 was implemented as separate chip?
I thinked, finit should be called after using xmm indtructions. |
|
This broke building DMD x64 with MSVC 2010. |
|
If I change
Does it work for you? |
|
Fixed it, the functions were not declared as |
| mov eax, y | ||
| mov ebx, x | ||
| mov ecx, res | ||
| finit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I create PR, which fix it? I'll do it after 3-5 hours.
|
Created #4052 Is it ok? |
This PR intriduces builtin compile-time yl2x and yl2xp1 for some platforms.
Supported platforms: DMC, VS (x86, x86_64), MinGW (x86 and x86_64), GCC (x86, x86_64), SunC(x86, x86_64).
If platform doesn't support this builtin, "cannot evaluate unimplemented builtin..." error will be raised as it was early.