s390x: Improved TrapIf implementation#6079
Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom Mar 23, 2023
Merged
s390x: Improved TrapIf implementation#6079alexcrichton merged 1 commit intobytecodealliance:mainfrom
alexcrichton merged 1 commit intobytecodealliance:mainfrom
Conversation
alexcrichton
approved these changes
Mar 21, 2023
| // of the branch (BRCL) instruction itself - those middle two bytes | ||
| // are zero, which matches the trap instruction itself. | ||
| let opcode = 0xc04; // BCRL | ||
| let enc = &enc_ril_c(opcode, cond.bits(), 2); |
Member
There was a problem hiding this comment.
Could this add some assertions that enc has length 6 and the middle 2 bytes are zeros?
| let cond = cond.invert().pretty_print_default(); | ||
| format!("j{} 6 ; trap", cond) | ||
| let cond = cond.pretty_print_default(); | ||
| format!("jg{} .+2", cond) |
Member
There was a problem hiding this comment.
Like the other backends (which Jamey suggested and I think is a good idea), could this include the trap code in the printing? The other backends do something like # trap={code} at the end IIRC
Member
Author
There was a problem hiding this comment.
Indeed, good idea. I've also added this for the unconditional traps now.
Following up on the discussion in bytecodealliance#6011 this adds an improved implementation of TrapIf for s390x using a single conditional branch instruction. If the trap conditions is true, we branch into the middle of the branch instruction - those middle two bytes are zero, which matches the encoding of the trap instruction. In addition, show the trap code for Trap and TrapIf instructions in assembler output.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Following up on the discussion in
#6011 this adds an improved implementation of TrapIf for s390x using a single conditional branch instruction.
If the trap conditions is true, we branch into the middle of the branch instruction - those middle two bytes are zero, which matches the encoding of the trap instruction.