I am working on a custom riscv target which supports bundle instruction(an instruction contains multiple sub instructions).
Since the change in ⚙ D123264 [RISCV] Pre-RA expand pseudos pass, it uses PreInstrSymbol for AUIPC instruction instead of splitting a new block and using block label. There comes the problems for fixup.
For a bundle instruction like
{ aupic pcrel_hi(ptr1); aupic pcrel_hi(ptr2) }
addi a10, pcrel_low(pcrel_hi_ptr1)
.
I need to set PreInstrSymbol for this bundle instruction(call it pcrel_bundle
) and replace all uses of pcrel_hi_ptr1
and pcrel_hi_ptr2
with pcrel_bundle
. That results in:
.Lpcrel_bundle
{ aupic pcrel_hi(ptr1); aupic pcrel_hi(ptr2) }
addi a10, pcrel_low(pcrel_bundle)
.
When doing fixup for pcrel_low in assembler or linker, I could only achieve this pcrel_bundle symbol but losing the information which exact pcrel_hi fixup I am looking for.
I could figure out a way to extend the structure of MCSymbol and the code in getRISCPCRelHi20() to support this, but it’s kind of tedious and ugly.
Can someone provide me with suggestions for a better solution?