[PATCH] D54143: [WIP, RISCV] Generate address sequences suitable for mcmodel=medium

Lewis Revill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 03:40:59 PST 2018


lewis-revill added a comment.

In https://reviews.llvm.org/D54143#1288531, @jrtc27 wrote:

> It's also worth noting that GCC distinguishes between these two models by calling them `medlow` and `medany`, whereas `small` (what should be `medlow`) vs `medium` (ie `medany`) is somewhat misleading, but the SPARC backend seems to already set a precedent for this divergence (`medlow` -> `small`, `medmid` -> `medium` ie 44-bit absolute, `medany` -> `large` ie 64-bit absolute).
>
> Now, there's an argument to be made whether our `medium` should continue to use absolute addressing on RV32I. The `%hi`/`%lo` pair already gives a 32-bit absolute address (signed, but that only poses a potential issue on RV64I), so we don't gain anything from this sequence. However, on RV64I, if our `medium` does mean `medany`, it will need to use PC-relative addressing, so it makes sense to have RV32I match this behaviour (and indeed, GCC also does this).


I was looking at the old GCC specifications for the code model, when they did use small/medium/large which I presume clang copied (quite hard to find actual documentation on this). Your comment about RV32I makes sense, we literally gain nothing if the PC is 32 bits. The idea of this patch was to enable programs with a 64-bit address space to be compiled correctly on RV64 (assuming they use 'medium').


Repository:
  rL LLVM

https://reviews.llvm.org/D54143





More information about the llvm-commits mailing list