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

Add pseudo-instructions for Zimop/Zcmop #194

Merged
merged 8 commits into from
Oct 17, 2023
Merged

Conversation

ved-rivos
Copy link
Contributor

Add mop.r.N, mop.rr.N, and c.mop.N pseudo-instructions that match all instructions in that group.

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2023

Codecov Report

Merging #194 (b9d63ad) into master (e6b3022) will decrease coverage by 0.75%.
Report is 8 commits behind head on master.
The diff coverage is n/a.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
- Coverage   93.58%   92.83%   -0.75%     
==========================================
  Files           3        3              
  Lines         717      642      -75     
==========================================
- Hits          671      596      -75     
  Misses         46       46              
Files Coverage Δ
constants.py 100.00% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


mop.r.N rd rs1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this works, given that the parser is supposed to issue an error when multiple instructions use the same opcode. Don't you need to use the $pseudo_op directive? If not, did you accidentally detect a bug in the parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser did not complain. Likely it only looks for identical code points but not an overlapping code point. I could not use the pseudo_op directive as unlikely a true pseudo-op which requires a 1:1 map with an op, this a 1:N map.

Copy link
Contributor Author

@ved-rivos ved-rivos Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can remove this change in opcodes. For spike for example, we can achieve the same by using MOP_R_0_MATCH as both match and mask. Or we just add 48 instructions into spike..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we’ve found one bug and one deficiency in the parser. It should detect any form of overlap, not just exact matches, and we should be able to declare pseudos that overlap multiple instructions. That’s what the @ directive used to do in the old version of this script.

IMO we should use this version of the patch, and fix the bug later, but it would probably be good to get @neelgala’s input before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit worried about that people using this may get multi-hits but I now think thats unfounded as they would either use the _N version or the individual decode and not both. So agree that we should use this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right syntax to use:

c.mop.N c_mop_t 1..0=1 6..2=0 11=0 7=1 12=0 15..13=3
$pseudo_op rv_zcmop::c.mop.N c.mop.0 1..0=1 6..2=0 11..7=1  12=0 15..13=3

I added this to the arg_lut
arg_lut['c_mop_t'] = (10,8)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emitted_pseudo_ops = [
- include the list of pseudo instructions here so that they are emitted for spike.

And your syntax looks correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have updated this PR. It looks correct to me but I will test it with spike later today and let you know.

  • include the list of pseudo instructions here so that they are emitted for spike.

May be a good addition to the readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with new mnemonics for c.mop

Copy link
Member

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks @ved-rivos and @neelgala.

@aswaterman aswaterman merged commit 19e3ddc into riscv:master Oct 17, 2023
2 checks passed
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.

4 participants