[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 03:38:30 PDT 2023


simon_tatham created this revision.
simon_tatham added reviewers: nickdesaulniers, peter.smith, kristof.beyls, t.p.northover, rengolin.
Herald added a subscriber: hiraditya.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

AArch64 has five system registers intended to be useful as thread
pointers: one for each exception level which is RW at that level and
inaccessible to lower ones, and the special TPIDRRO_EL0 which is
readable but not writable at EL0. AArch32 has three, corresponding to
the AArch64 ones that aren't specific to EL2 or EL3.

Currently clang supports only a subset of these registers, and not
even a consistent subset between AArch64 and AArch32. For AArch64,
clang permits you to choose between the four TPIDR_ELn thread
registers, but not the fifth one, TPIDRRO_EL0. 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. There
is no thread register that you can currently use in both targets!

For custom and bare-metal purposes, users might very reasonably want
to use any of these thread registers. There's no reason they shouldn't
all be supported as options, even if the default choices follow
existing practice on typical operating systems.

This commit extends the range of values acceptable to the `-mtp=`
clang option, so that you can specify any of these registers by (the
lower-case version of) their official names in the ArmARM:

- tpidr_el0, tpidrro_el0, tpidr_el1, tpidr_el2, tpidr_el3 for AArch64
- tpidrurw, tpidruro, tpidrprw for AArch32

All existing values of the option are still supported and behave the
same as before. Defaults are also unchanged. No command line that
worked already should change behaviour as a result of this.

The new values for the `-mtp=` option have been agreed with Arm's gcc
developers (although I don't know whether they plan to implement them
in the near future).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152433

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-translation.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb2.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/test/CodeGen/AArch64/arm64-builtins-linux.ll
  llvm/test/CodeGen/ARM/readtp.ll
  llvm/test/CodeGen/ARM/stack-guard-tls.ll
  llvm/test/CodeGen/ARM/thread_pointer.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152433.529547.patch
Type: text/x-patch
Size: 21868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230608/aa5421e2/attachment.bin>


More information about the llvm-commits mailing list