-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
Description
According to the SparcV9 ISA the branch instructions with the format 2-4 have displacement immediate values which get sign extended:
But the operand types for these displacement immediates never define a decoding method:
llvm-project/llvm/lib/Target/Sparc/SparcInstrInfo.td
Lines 224 to 230 in 865fb9c
| 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