-
Notifications
You must be signed in to change notification settings - Fork 652
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
asm: Add Jump32 support #514
Conversation
3406732
to
fbe566e
Compare
Fixed a typo in a test. |
fbe566e
to
7103a0e
Compare
I force pushed to re-run the tests, but CI failed again with:
I'll try again in a bit. |
linker.go
Outdated
@@ -121,7 +121,7 @@ func fixupJumpsAndCalls(insns asm.Instructions) error { | |||
|
|||
ins.Constant = int64(callOffset - offset - 1) | |||
|
|||
case ins.OpCode.Class() == asm.JumpClass && ins.Offset == -1: | |||
case ins.OpCode.JumpOp() != asm.InvalidJumpOp && ins.Offset == -1: |
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 find this harder to read. How about assing Class.IsJump()
and then doing the following:
case ins.OpCode.JumpOp() != asm.InvalidJumpOp && ins.Offset == -1: | |
case ins.OpCode.Class().IsJump() && ins.Offset == -1: |
We could apply IsJump
, IsALU
in other places as well.
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.
Good idea! Added a commit to introduce these, and IsStore()
, IsLoad()
as well.
Ping @arthurfabre do you want to pick this up again? |
7103a0e
to
d3bff48
Compare
Stores, loads, jumps, and ALU operations can all be represented by two different classes. Add helpers so callers don't have to remember to check both classes. Use the new helpers in all the OpCode setters and getters. This validates classes a bit stricter than previously: ALUClass.JumpOp() would have returned a ALUOp decoded as a JumpOp. It now returns InvalidALUOp.
The unused 0x6 class now represents jumps with 32bit comparisons: https://lore.kernel.org/all/1548523574-18316-16-git-send-email-jiong.wang@netronome.com/T/ http://patchwork.ozlabs.org/project/netdev/list/?series=88386&state=* This complements 32bit ALU operations by allowing comparisons without having to sign extend registers beforehand. Add a Jump32Class to represent this. As some JumpOps are not supported by Jump32 (Call, Exit, Ja), centralize the logic for validating jump OpCodes in OpCode.JumpOp().
d3bff48
to
71df43f
Compare
The unused 0x6 class now represents jumps with 32bit comparisons:
https://lore.kernel.org/all/1548523574-18316-16-git-send-email-jiong.wang@netronome.com/T/
http://patchwork.ozlabs.org/project/netdev/list/?series=88386&state=*
This complements 32bit ALU operations by allowing comparisons without
having to sign extend registers beforehand.
Add a Jump32Class to represent this. As some JumpOps are not supported
by Jump32 (Call, Exit, Ja), centralize the logic for validating jump
OpCodes in OpCode.JumpOp().