Page MenuHomePhabricator

[RISCV] Support -target-abi at the MC layer and for codegen

Authored by asb on Mar 6 2019, 6:23 AM.



This patch adds proper handling of -target-abi, as accepted by llvm-mc and llc. Lowering (codegen) for the hard-float ABIs will follow in a subsequent patch. However, this patch does add MC layer support for the hard float and RVE ABIs (emission of the appropriate ELF flags

ABI parsing must be shared between codegen and the MC layer, so we add computeTargetABI to RISCVUtils. A warning will be printed if an invalid or unrecognized ABI is given.

Diff Detail


Event Timeline

asb created this revision.Mar 6 2019, 6:23 AM
asb added a comment.Mar 6 2019, 6:24 AM

RV32E is intentionally left out of this patch as well. I feel it will be cleaner to add basic recognition of -target-abi=rv32e alongside basic support for the E extension (e.g. -march=risc32 -mattr=+e).

apazos added inline comments.Mar 6 2019, 6:25 PM
41 ↗(On Diff #189497)

I find strange that instantiating a backend can cause an error.

55 ↗(On Diff #189497)

Instead of returning error, should we just use the default abi setting you apply in the beginning of this function (ILP32 or ILP64) and print a warning?

asb updated this revision to Diff 189842.Mar 8 2019, 4:22 AM
asb edited the summary of this revision. (Show Details)

Updated to print a warning if an invalid ABI name is given, or if an ABI can't be selected for the current -march. Also add minimal support for recognising ilp32e, including setting the EF_RISCV_RVE ELF flag if -target-abi ilp32e is specified.

asb marked 2 inline comments as done.Mar 8 2019, 4:23 AM
apazos added inline comments.Mar 8 2019, 9:59 AM
42 ↗(On Diff #189842)

Now it always returns a valid ABI, right? Do we need this check?

asb updated this revision to Diff 189882.Mar 8 2019, 10:34 AM
asb marked 2 inline comments as done.

Removed unnecessary use of Expected<T> that was missed in the last update.

42 ↗(On Diff #189842)

Meant to remove this, thanks for catching.

asb updated this revision to Diff 189883.Mar 8 2019, 10:38 AM

Add missed MC rv32ifd -target-abi=ilp32d test case.

apazos added a comment.Mar 8 2019, 1:49 PM

Thanks Alex, LGTM.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 9 2019, 1:27 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2019, 1:27 AM
Herald added a subscriber: jrtc27. · View Herald Transcript