This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add new ELF attribute to track reserved registers
Changes PlannedPublic

Authored by edward-jones on Nov 15 2021, 6:52 AM.

Details

Summary

This attribute is described in this pull request to the RISCV psABI: New attribute: Tag_RISCV_reserved_register

This adds a new attribute used to record reserved register information. This is used to check compatibility between ABI subvariants like overlay which reserve registers for use in the overlay engine.

Currently this is limited to only the x0-x31 range of registers. At the very least support for the floating point registers needs to be added, and in future this may also need to handle registers outside the available 64 bit mask (eg CSR or vector extension registers)

Diff Detail

Event Timeline

edward-jones created this revision.Nov 15 2021, 6:52 AM
edward-jones requested review of this revision.Nov 15 2021, 6:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2021, 6:52 AM
kito-cheng added inline comments.Mar 7 2022, 4:06 AM
llvm/include/llvm/MC/MCELFStreamer.h
95

I would suggest change this into APInt, since we might also use more than 64 bits, e.g. vector register.

llvm/test/MC/RISCV/attribute-reserved-regs.s
21

Do you mind add few more testcase for floating point register or even vector register?

Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 4:06 AM
kito-cheng added inline comments.Mar 7 2022, 5:10 AM
llvm/test/MC/RISCV/attribute-reserved-regs.s
13

I saw you've setup a mask attribute printer but seems like here still print in decimal?

RISCVAttrs::RESERVED_REGS,
&ELFAttributeParser::maskAttribute,
edward-jones added inline comments.Mar 7 2022, 5:22 AM
llvm/include/llvm/MC/MCELFStreamer.h
95

Okay, I suspect this will make things a bit more complicated since the setAttributeItem interface only accepts a fixed width value. I'll have to change it so that this attribute is emitted as a ULEB128.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
106

Something I needed to fix here. I believe the pull request mandates using the DWARF numbers for the registers and I need to do this in a more generic way here since right now the register numbers are just hardcoded in.

edward-jones planned changes to this revision.Mar 7 2022, 5:22 AM