Skip to content

fix(inst): make fence.tso a separate inst, fix fence bug #460

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 14 commits into from
Apr 29, 2025
Merged

Conversation

dhower-qc
Copy link
Collaborator

fixes #428

@AFOliveira
Copy link
Collaborator

This likely could be merged as is without any problems, right?

@AFOliveira
Copy link
Collaborator

Fixes #360

@dhower-qc
Copy link
Collaborator Author

Yes, it just needs to go in after cpp_hart

@dhower-qc dhower-qc requested a review from ThinkOpenly March 25, 2025 17:49
@dhower-qc dhower-qc enabled auto-merge March 25, 2025 17:49
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@AFOliveira
Copy link
Collaborator

is this something that was forgotten?

Signed-off-by: Derek Hower <[email protected]>
Even though non-zero encodings of fm/xs1/xd are "reserved for future use", the spec says they shall be executed as though they were zero

Signed-off-by: Derek Hower <[email protected]>
@dhower-qc
Copy link
Collaborator Author

Yes, it was forgotten. I have it ready again, but it's failing because of a mismatch with riscv-opcodes.

@AFOliveira
Copy link
Collaborator

Yes, it was forgotten. I have it ready again, but it's failing because of a mismatch with riscv-opcodes.

It's a mismatch with LLVM. This is supposed to happen, since our view of the information is on the ISA side, which allows several arguments (in hardware) for a fence, while the pragmatic implementation of fence in a compiler is a full constant expression, since it is the only one that the ISA clearly defines. I will make a patch so the test skips fence.

This also brings me to the question that in the future, "variable" could have a separation between "hardware-only" and "assembly". Since they not always match. This is a great effort and I think should not a be a priority for now.

@ThinkOpenly
Copy link
Collaborator

It's a mismatch with LLVM. This is supposed to happen, since our view of the information is on the ISA side, which allows several arguments (in hardware) for a fence, while the pragmatic implementation of fence in a compiler is a full constant expression, since it is the only one that the ISA clearly defines. I will make a patch so the test skips fence.

This also brings me to the question that in the future, "variable" could have a separation between "hardware-only" and "assembly". Since they not always match.

I'm not following completely. Is this an artifact of having "variables" (rd, rs1) that aren't actually variables? Does that imply that the definition of fence.tso should not show these fields as variables? The spec says:

The unused fields in the FENCE instructions--rs1 and rd--are reserved for finer-grain fences in future
extensions. For forward compatibility, base implementations shall ignore these fields, and standard
software shall zero these fields.

Given "shall", shall we also restrict the valid values here to only zero?

not: 1, 2, 3, [...], 31

This is a great effort and I think should not a be a priority for now.

Shall we open an issue?

@dhower-qc
Copy link
Collaborator Author

Given "shall", shall we also restrict the valid values here to only zero?

The "shall" is that the fields should be ignored, not that they are illegal. If we use not, then any non-zero value will be considered an illegal instruction.

@AFOliveira
Copy link
Collaborator

My view on it is that the spec leaves open to later implementations to move fence around and switch any of those values. However, from the compiler view what I suppose happened is that "shall" is enough for them to assume that every bit is 0, and if someone does a different implementation, then whoever implements that is responsible for updating the compiler

@AFOliveira
Copy link
Collaborator

Shall we open an issue

Sure, I will.

@AFOliveira
Copy link
Collaborator

Smoke test fixed in #687

@dhower-qc dhower-qc changed the title Make fence.tso a separate inst, fix fence bug fix(inst): make fence.tso a separate inst, fix fence bug Apr 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 29, 2025
since compiler and ISA view of the instruction differ

Fixes #460

Signed-off-by: Afonso Oliveira <[email protected]>
auto-merge was automatically disabled April 29, 2025 22:12

Pull request was closed

@dhower-qc dhower-qc reopened this Apr 29, 2025
@dhower-qc dhower-qc enabled auto-merge April 29, 2025 22:16
@dhower-qc dhower-qc added this pull request to the merge queue Apr 29, 2025
Merged via the queue into main with commit 01c02cd Apr 29, 2025
17 checks passed
@dhower-qc dhower-qc deleted the fence branch April 29, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fence.tso is not pseudo for Fence
3 participants