-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Expose CPU model (and features?) as compile time flags #14524
Comments
A measure to somewhat curb uncontrolled grow would be to expose flags with a prefix to clearly designate that it's a cpu flag, for example. For example, the flag for I'm not sure if this is really necessary but it might be required if there's any chance of collision beteween flag names derived from different sources. For reference: currently supported flags based on the target platform. |
The feature flags are effectively the compile-time analog of #2824. I suggest naming them like So far I haven't been aware of any LLVM C APIs that expose this information yet, e.g. the fact SSE2 is available in x86 baseline unless you pass a conflicting |
There's |
This is a proof of concept to extract the feature flags from LLVM's TableGen files: (someone on the LLVM Discord server suggested that this is indeed the way to go) HertzDevil@52dac16 The default model is Note that LLVM also adds some default flags on its own, for example this is where SSE2 is enabled, even though the It looks like |
Also apparently those flags aren't always forward-compatible: llvm/llvm-project#96246 |
I'm not sure if we want to use the CPU and feature names as flags directly. Apart from We should also preserve all casing and symbols, i.e. Also I guess plain flags are the most backward-compatible option, meaning a 1.0.0 compiler will not error if it sees a flag, but are there any other options in the macro language? |
In #14393 that adds support for AVR microcontrollers, the target CPU model must be specified (it impacts a lot of thing, from codegen to the linker) and I expose it as a compile time flag, so we can decide to implement something differently depending on the CPU model, for example abstract which pins are available, among other things.
Now, it might be interesting to always expose the CPU model when it has been specified with
--mcpu
. It might be useful when targeting ARM?As a complement, or alternative, it might be more useful to expose CPU features for X86 or ARM. For example
avx2
,cx16
,neon
orlse
.Of course that would increase the surface of flags even more, but this is already happening in a way that is hardly controllable anyways.
Reference: #14393 (comment)
The text was updated successfully, but these errors were encountered: