Skip to content

[SPARC] Disassembler doesn't sign extend and aligns PC relative disponents. #139284

@Rot127

Description

@Rot127

According to the SparcV9 ISA the branch instructions with the format 2-4 have displacement immediate values which get sign extended:

Image

But the operand types for these displacement immediates never define a decoding method:

def bprtarget : Operand<OtherVT> {
let EncoderMethod = "getBranchPredTargetOpValue";
}
def bprtarget16 : Operand<OtherVT> {
let EncoderMethod = "getBranchOnRegTargetOpValue";
}

This leads to the bits being simply extracted and added as unsigned immediate operand to the MCInst.

The resulting branch instructions are not aligned, PC-relative or correctly sign extended values in the disassembler.

echo "0x10, 0xbf, 0xff, 0xff" | llvm-mc --triple=sparcv9 --disassemble
	.text
	ba 4194303 // = 0x3FFFFF but should be 0xffffffff_fffffffc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions