[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 04:09:14 PDT 2023

simon_tatham added a comment.

In D152433#4405428 <https://reviews.llvm.org/D152433#4405428>, @rengolin wrote:

> The only minor visible difference is the removal of `read-tp-hard` option from the LLVM side, which could be used by other downstream implementations.

Yes. I wasn't sure how much that mattered, and like you, I came down weakly on the side of not worrying about the change and keeping the names logical. I'll change it back without complaining if anyone else has a strong opinion, though!

Comment at: clang/include/clang/Driver/Options.td:3525
+           "For AArch32: 'soft' uses a function call, or 'tpidrurw', 'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 'tpidruro'. "
+           "For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 'tpidrro_el0' use the five system registers. 'elN' is an alias for 'tpidr_elN'.">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias<mexecute_only>; // Alias for GCC compatibility
rengolin wrote:
> From your comment:
> > "In AArch32, on the other hand, the _only_ thread register you can choose (apart from 'none, use a function call') is the one that's read-only at EL0."
> I inferred the current alias `el0` would map to the read-only version `tpidrro_el0`.
> Looking at the implementation below (`AArch64ExpandPseudoInsts.cpp`), `EL0` seems to be the default when choosing the thread pointer?
If you inferred that, then I was unclear, and should reword :-)

`el0` is a name only accepted on AArch64, and maps to the AArch64 register `tpidr_el0`.

The only hardware option in AArch32 (before this commit) is called `cp15` (unhelpfully, since all three regs are in CP15), and is an alias for `tpidruro`, which is the AArch32 register that's readonly at EL0 and writable at EL1 (and in fact aliases the bottom 32 bits of tpidrro_el0).

Yes, the current defaults are different between AArch32 and 64 (unsurprisingly, since no register is currently supported on both), but that makes sense, since Linux also seems to do things differently. On AArch32 the code generation uses TPIDRURO, which unprivileged code can read but not write, and on AArch64 it uses TPIDR_EL0 which unprivileged code can overwrite if it wants to. I don't know why the defaults are different, but I have no plan to change them here!

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list