-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Add LDC-specific traits for CTFE information about the target machine. #1434
Add LDC-specific traits for CTFE information about the target machine. #1434
Conversation
@9il what do you think? |
Awesome! Thank you a lot! |
Ping @WalterBright @ibuclaw – what do you think about the API? |
The latter is redundant. We should try to avoid redundant core language features. |
so is hasMember |
I left targetHasFeature for convenience. |
I can't say that gcc readily provides this information, but it seems reasonable. |
True, but we learn from our mistakes rather than repeat them.
|
Neither does LLVM :( |
Well at least you have |
OK, I've been able to squeeze the feature info out of LLVM with a small LLVM patch :) |
I guess you could cache this information in |
Nice! I hope this makes it into all compilers. There is always the option to define a safe fall-back like "i386" for dmd on x86. @ibuclaw Maybe checking the implementation of this helps:
|
@mleise - I'm aware of how gcc generates macros, gdc uses the same mechanism for generating pre-defined version conditions. ;-) All I said was that there is no "ready to use" way of getting the information. |
e81cefd
to
9a644a6
Compare
I removed |
9737024
to
34e2896
Compare
For LLVM version < 3.7, |
We might as well just raise the minimum requirement to 3.7 at some point… |
Ping! :) |
LGTM This would be very helpful for Mir's BLAS Micro Kernel parameter estimation. LDC generates (see gist) efficient micro kernel code, and #1472 will allow to optimize it even more :-) |
One theme at DConf was the unification of the frontends. ("One frontend to rule them all") One source of differences in the frontend are compiler-specific extensions. An easy way to support this is the addition of hooks. An application may (or may not) use these hooks for additional processing. This hook was inspired by a current PR (ldc-developers/ldc#1434). LDC-specific pragmas could be realized with the same approach.
One theme at DConf was the unification of the frontends. ("One frontend to rule them all") One source of differences in the frontend are compiler-specific extensions. An easy way to support this is the addition of hooks. An application may (or may not) use these hooks for additional processing. This hook was inspired by a current PR (ldc-developers/ldc#1434). LDC-specific pragmas could be realized with the same approach.
One theme at DConf was the unification of the frontends. ("One frontend to rule them all") One source of differences in the frontend are compiler-specific extensions. An easy way to support this is the addition of hooks. An application may (or may not) use these hooks for additional processing. This hook was inspired by a current PR (ldc-developers/ldc#1434). LDC-specific pragmas could be realized with the same approach.
One theme at DConf was the unification of the frontends. ("One frontend to rule them all") One source of differences in the frontend are compiler-specific extensions. An easy way to support this is the addition of hooks. An application may (or may not) use these hooks for additional processing. This hook was inspired by a current PR (ldc-developers/ldc#1434). LDC-specific pragmas could be realized with the same approach.
One theme at DConf was the unification of the frontends. ("One frontend to rule them all") One source of differences in the frontend are compiler-specific extensions. An easy way to support this is the addition of hooks. An application may (or may not) use these hooks for additional processing. This hook was inspired by a current PR (ldc-developers/ldc#1434). LDC-specific pragmas could be realized with the same approach.
@redstar Can I merge this? The "hook" is the same as #5771 so it is easily modified once that is merged. |
59e9b21
to
a6bfe12
Compare
__traits(targetCPU) == "broadwell" __traits(targetHasFeature, "sse2") == bool
a6bfe12
to
5ffd34f
Compare
Will merge when green. |
@9il Can you update us on how you are using this in your code? :) |
Will do with BLAS release :) |
Edit: updated to current state of the PR. (removed
__traits(targetFeatures)
)This adds the following LDC-specific traits:
Example usage:
Outputs on my machine: