-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Adds new cpu architectures propeller1 and propeller2. #21563
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const std = @import("../std.zig"); | ||
| const CpuFeature = std.Target.Cpu.Feature; | ||
| const CpuModel = std.Target.Cpu.Model; | ||
|
|
||
| pub const Feature = enum {}; | ||
|
|
||
| pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet; | ||
| pub const featureSetHas = CpuFeature.FeatureSetFns(Feature).featureSetHas; | ||
| pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; | ||
| pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; | ||
|
|
||
| pub const all_features: [0]CpuFeature = .{}; | ||
|
|
||
| pub const cpu = struct { | ||
| pub const generic = CpuModel{ | ||
| .name = "generic", | ||
| .llvm_name = null, | ||
| .features = featureSet(&[_]Feature{}), | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1856,6 +1856,9 @@ const NavGen = struct { | |
| .flash3, | ||
| .flash4, | ||
| .flash5, | ||
| .cog, | ||
| .lut, | ||
| .hub, | ||
| => unreachable, | ||
| }; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thought about this a bit more and I think I'd prefer representing P2 as a CPU feature. My reasoning is that we actually have precedent for this already; for example, MIPS r6 made many backwards-incompatible changes (e.g. reallocated encodings, removed instructions), yet we don't represent that as a distinct
Archtag. I believe PowerPC has also historically removed features, but I can't remember the exact details there.But let's just get this merged with this approach for now and I'll do a follow-up PR showing what I have in mind.
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 would mean we have no
genericcpu then, but onlypropeller1andpropeller2? They are neither binary compatible nor instruction compatible, it's more like arm vs. aarch64 than arm vs. thumbThis would also mean you can't check on arch but always have to check on the actual CPU in your code as well, so if you ever need to do something for p1 and p2, it would look like this:
I wonder why they made them a CPU/Feature in the gcc port. Probably due to convenience as otherwise you have to use
prop1-none-eabi-gccandprop2-none-eabi-gccinstead ofprop-none-eabi-gccThere 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.
Yes; this is no different from the MIPS situation. The "generic" CPU would be arbitrarily defined to be
propeller1, just asmips32/mips64(r1) are arbitrarily defined to be the generic CPUs for MIPS.You would check the feature flag that the CPU would imply; specifically,
propeller2would implyp2. That currently looks likestd.Target.propeller.featureSetHas(target.cpu.features, .p2)which is indeed too verbose, but I have some ideas for making this API more ergonomic that I plan to get to soon. I think something liketarget.cpu.features.has(.propeller, .p2)should be possible with some light comptime magic.From what I saw in GCC and binutils, there's still a decent amount of overlap in instruction encodings, and they don't use wholly separate en/decoding tables or anything. In this way, I don't think the arm vs aarch64 comparison quite works because A64 really is an entirely new instruction set from A32.
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.
Let's wait until we have all toolchains tested if they agree on the C type sizes
Uh oh!
There was an error while loading. Please reload this page.
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 think one heuristic to determine whether it should be a CPU feature vs a different arch is whether you would want two different self-hosted backend implementations, or whether you would rather have one that checks the CPU feature. If they would share a lot of implementation code, that is a hint that the same CPU arch would make sense.
Another heurisic would be
@sizeOf(usize). This is the only reason x86 and x86_64 are not the same CPU arch for example even though 64bit is a CPU feature that can be enabled for x86 (which doesn't make any sense given this way of doing things), and you would definitely use the same backend logic for both.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.
That's a pretty good heuristic and i think i have to take a deep-dive into codegen for that 😁
They both have basically the same idea behind the instruction encoding and style, but the semantics of basically all except the most basic instructions are different.
It starts with
RDLONGwhich can only read Hub memory on P1 and reads continuous memory on P2.@sizeOf(usize)would be 32 bit with 23 bit padding for 2 of the 3 address spaces so it's kinda hard to say.But now i'm super tempted to create a self-hosted backend for the two processors... 🤔
Next steps for me is still getting all the compilers up and running, which sadly takes a lot of time :(