This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Allow -mattr=tpidr-el[1|2|3]
ClosedPublic

Authored by philip.derrin on Nov 18 2018, 10:31 PM.

Details

Summary

Added subtarget features for AArch64 to use TPIDR_EL[1|2|3] as the TLS base register, rather than the default TPIDR_EL0.

Diff Detail

Event Timeline

ryank created this revision.Nov 18 2018, 10:31 PM

What is the use-case for wanting to use SP_ELx for the thread pointer, instead of TPIDR_ELx?

lib/Target/AArch64/AArch64.td
244

Is this likely to be used for anything other than the TPIDR registers? I think it would be better to make the name more specific, unless we are also going to gate all system registers in the assembler on these features.

lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
938

Why can SP_EL3 not be used?

I will take over this patch; it was submitted by an intern at my employer who has since finished his internship.

What is the use-case for wanting to use SP_ELx for the thread pointer, instead of TPIDR_ELx?

This is not useful, and I will remove it. It was based on the observation that in some kernels, SP_ELx is left pointing at a thread-local exception context while the kernel switches to SP_EL0, so SP_ELx could double as a TLS pointer, leaving TPIDR_ELx free for other uses. However, SP_ELx is not accessible via the MRS instruction at ELx; it can only be accessed at higher levels. This is also presumably the reason SP_EL3 was left out — it is never accessible to MRS so AArch64SysReg::SP_EL3 does not exist.

As for the naming of use-el*, would tpidr-el* be acceptable?

Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2019, 9:59 PM
philip.derrin commandeered this revision.Mar 19 2019, 10:26 PM
philip.derrin added a reviewer: ryank.
philip.derrin retitled this revision from [AArch64] Allow -mattr=use_el[1|2|3] and -mattr=use_sp_for_tp to [AArch64] Allow -mattr=tpidr-el[1|2|3].
philip.derrin edited the summary of this revision. (Show Details)
olista01 accepted this revision.Mar 20 2019, 3:12 AM

LGTM. Do you have commit access? If not, I can commit this for you.

This revision is now accepted and ready to land.Mar 20 2019, 3:12 AM

I don't have commit access; please go ahead and commit it.

This revision was automatically updated to reflect the committed changes.