[all-commits] [llvm/llvm-project] 10e422: [ARM, AArch64] Add a full set of -mtp= options.

Simon Tatham via All-commits all-commits at lists.llvm.org
Thu Jun 15 01:28:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 10e42281144ecca019764b554f3f0f709bba0f71
      https://github.com/llvm/llvm-project/commit/10e42281144ecca019764b554f3f0f709bba0f71
  Author: Simon Tatham <simon.tatham at arm.com>
  Date:   2023-06-15 (Thu, 15 Jun 2023)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    M clang/lib/Driver/ToolChains/Arch/ARM.cpp
    M clang/lib/Driver/ToolChains/Arch/ARM.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    A clang/test/Driver/aarch64-thread-pointer.c
    A clang/test/Driver/arm-thread-pointer.c
    M clang/test/Driver/clang-translation.c
    M llvm/lib/Target/AArch64/AArch64.td
    M llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
    M llvm/lib/Target/ARM/ARM.td
    M llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
    M llvm/lib/Target/ARM/ARMInstrInfo.td
    M llvm/lib/Target/ARM/ARMInstrThumb2.td
    M llvm/lib/Target/ARM/ARMPredicates.td
    M llvm/lib/Target/ARM/ARMSubtarget.h
    M llvm/test/CodeGen/AArch64/arm64-builtins-linux.ll
    M llvm/test/CodeGen/ARM/readtp.ll
    M llvm/test/CodeGen/ARM/stack-guard-tls.ll
    M llvm/test/CodeGen/ARM/thread_pointer.ll

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

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 TPIDRURO, which
   corresponds to (the bottom 32 bits of) AArch64's TPIDRRO_EL0.

So 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:

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

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).

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D152433




More information about the All-commits mailing list