alpha: sign-extend memory-format displacement - #3036
Open
Samin061 wants to merge 1 commit into
Open
Conversation
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.
Your checklist for this pull request
Detailed description
The Alpha memory-format instructions (
lda, the integer loads/stores, the store-conditional forms, and thelds/ldt/sts/sttfloat loads and stores) carry a 16-bit displacement that the ISA treats as signed, but the decoder read it out of the instruction word as a plain unsigned field and never sign-extended it, so any displacement with bit 15 set decoded to a large positive value.cstool -d alpha 0xb0,0xb0,0x42,0x20shows it: the offset prints as0xb0b0andoperands[1].immis0xb0b0, where it should be-20304. The displacement is read in the shared decode macro at the four memory-format cases (indices 1, 22, 23, 24), each storingfieldFromInstruction_4(insn, 0, 16)straight into the operand. Casting that field throughint16_tat those four sites stores the signed offset, so the same word now decodes tolda $2,-0x4f50($2). Positive displacements are unaffected.Test plan
cstool -d alpha 0xb0,0xb0,0x42,0x20now printslda $2,-0x4f50($2)withoperands[1].imm = 0xffffffffffffb0b0. I added negative-displacement cases totests/MC/Alpha/insn-alpha.s.yamlcovering the integer, store-conditional and float-memory forms, and updated the two detail cases intests/details/alpha.yamlandtests/details/cs_common_details.yamlthat had captured the old unsigned value.Closing issues
closes #3021