Skip to content
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

[spec] Add reserved version for Xtensa architecture #3894

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

thewilsonator
Copy link
Contributor

See also ldc-developers/ldc#4725

cc @TurkeyMan is Xtensa ESP always 32-bit? What to do about Xtensa-S2/Xtensa-S3? I assume they will be specified in the target triple and any information they provide can be done through other means (e.g. __traits(getTargetInfo))

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @thewilsonator! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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.

@TurkeyMan
Copy link
Contributor

ESP32 is LX6, -S2,S3 are LX7, which has some additional instructions. It's always 32bit as far as I know. LX7 has some rudimentary SIMD stuff, a MAC instruction in particular is something the backend will want to take advantage of.

It'll be nice to feed as much knowledge as possible through getTargetInfo as you say; the whole point of the Xtensa platform is to be extensible, determining if specific ISA features are present for the selected target will be more useful than comparing the target to a whole bunch of known implementations in software...

@TurkeyMan
Copy link
Contributor

See here: https://github.com/espressif/llvm-project/blob/xtensa_release_18.1.2/llvm/lib/Target/Xtensa/Xtensa.td#L194
They specify the processors from a compound list of features... how much trouble is it to expose that list via getTargetInfo somehow? It seems like the notion of feature sets is already known to LLVM... of software can query those feature flags, it can use the hardware as it's available.

@JohanEngelen
Copy link
Contributor

@TurkeyMan Doesn't LDC's __traits(targetHasFeature, ...) cover what you need? (the functionality that you want should not be covered by a bunch of version identifiers)

@TurkeyMan
Copy link
Contributor

Sure. How do we know what all those features are named to test for them?

@thewilsonator
Copy link
Contributor Author

Yeah that sounds like CPU variants, not something that should have different version.
I suspect that the different subtarget features will be handled by __traits(targetHasFeature, ...) and the different CPU variants will be handled by __traits(getTargetCPU) (which will return e.g. "esp8266" or "esp32s3")

Sure. How do we know what all those features are named to test for them?

the string is the first argument of SubtargetFeature in feature foo in SubtargetFeature<"foo", ...>

import std.stdio;
void main() {
  writeln("CPU = ", __traits(targetCPU));
  writeln("Has 'sse4.1' = ", __traits(targetHasFeature, "sse4.1"));
}
def FeatureSSE41   : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
                                      "Enable SSE 4.1 instructions",
                                      [FeatureSSSE3]>;

in
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86.td#L80

So for https://github.com/espressif/llvm-project/blob/xtensa_release_18.1.2/llvm/lib/Target/Xtensa/Xtensa.td#L18

the features will be

  writeln("CPU = ", __traits(targetCPU)); // prints e.g. `esp32s2`
 writeln("Has 'density' = ", __traits(targetHasFeature, "density"));
 writeln("Has 'fp' = ", __traits(targetHasFeature, "fp"));
// ditto for "windowed", "bool", etc.

@TurkeyMan
Copy link
Contributor

I suspect that the different subtarget features will be handled by __traits(targetHasFeature, ...) and the different CPU variants will be handled by __traits(getTargetCPU) (which will return e.g. "esp8266" or "esp32s3")

Yes, this sounds perfect to me!

@dlang-bot dlang-bot merged commit 73c91e1 into dlang:master Aug 8, 2024
2 checks passed
@thewilsonator thewilsonator deleted the thewilsonator-patch-4 branch August 24, 2024 06:19
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