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

asm: Add Jump32 support #514

Merged
merged 2 commits into from
Dec 16, 2021
Merged

asm: Add Jump32 support #514

merged 2 commits into from
Dec 16, 2021

Conversation

arthurfabre
Copy link
Contributor

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().

@arthurfabre
Copy link
Contributor Author

Fixed a typo in a test.

@arthurfabre
Copy link
Contributor Author

I force pushed to re-run the tests, but CI failed again with:

E: Failed to fetch https://storage.googleapis.com/bazel-apt/dists/stable/jdk1.8/binary-amd64/Packages.gz  File has unexpected size (6503 != 6709). Mirror sync in progress? [IP: 142.250.186.112 443]

I'll try again in a bit.

asm/opcode_test.go Show resolved Hide resolved
asm/opcode.go Show resolved Hide resolved
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:
Copy link
Collaborator

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:

Suggested change
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.

Copy link
Contributor Author

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.

@lmb
Copy link
Collaborator

lmb commented Dec 15, 2021

Ping @arthurfabre do you want to pick this up again?

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().
@lmb lmb merged commit 0581fbe into master Dec 16, 2021
@lmb lmb deleted the afabre/jump32 branch December 16, 2021 12:49
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.

None yet

2 participants