New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aarch64: support rN register names #36210
Comments
assigned to @m-gupta |
I am testing a patch to handle this. |
Can you be a bit more specific about where in GCC "rn" is acceptable? It is certainly not true in the general case, for example: int function(void) Error: operand 1 should be an integer register -- 'mov r0,r0' From the kernel patch it looks like that this is only being used in restricted cases, for example register constraints. Do you have a list of what can and can't be given as "r"? I think that if we can get to a point where we know where "r" is accepted and where it isn't, and if all the cases of where "r" is used, it doesn't matter whether the register is "x" or "w", and if we can add tests to make sure that allowing use of "r" doesn't leak into places where it shouldn't then I think this should be ok. I'm just one person though, to sample the community I suggest including the wider community including people that may use inline asm on non linux platforms, for example should this leak out into Darwin or not? |
I am not aware of the requirements on "r" in GCC. Although on lkml https://lkml.org/lkml/2018/3/1/286 , this was posted as an example: void foo(void)
} Disassembly of section .text: 0000000000000000 : |
Peter, $ aarch64-linux-gnu-gcc -S aarch64_regs.c -o - // 0 "" 2 |
I've got an older gcc, 5.4, to hand (at a conference right now). It does give the same output when -S is used, however try assembling that with aarch64-linux-gnu-as (binutils 2.26.1), I think you'll see the same error that I do? It is rare that GNU inline assembler is written down in any one place. I think the chances of getting a change accepted to clang will be larger if there is a good idea of when "r" is accepted and when it isn't. We may have to look into GCC to find this out. At a first approximation it looks like "r" is acceptable when the compiler will choose the size of the register so that the assembler only sees "w" or "x". |
I believe, assembler will only see w or x (from the example on lkml). |
Submitted as https://reviews.llvm.org/rL328829 |
Marked this as a blocker for llvm 6.0.1 release. |
Extended Description
Verbatim copied from https://bugs.chromium.org/p/chromium/issues/detail?id=824526
The upstream kernel commit f2d3b2e8759a ("arm/arm64: smccc: Implement SMCCC v1.1 inline primitive")
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f2d3b2e8759a5833df6f022e42df2d581e6d843c) uses the names "r0", "r1", ... for the general purpose registers that are usually known as "x0", "x1", ...
Use of the rN register names for arm64 is supported by gcc, but not by clang, in consequence upstream kernels and v4.14 (LTS/CrOS) currently don't build with clang for arm64.
Kernel maintainers don't seem to be inclined to use the xN names, probably also because the code in question is shared between arm64 and arm32, and arm32 registers are named rN.
"I'd say this is really a bug in Clang. Architecturally, the register in AArch64 state is still named "r0"; "x0"/"w0" are assembler operands which additionally encode the size of the corresponding access to r0."
https://lkml.org/lkml/2018/3/1/186
Maintainers might accept a fix, but expect LLVM to work on supporting rN register names for arm64 in future releases:
"It would be preferable to see evidence of the llvm community committing to fix this before we consider merging a bodge into Linux for it."
The text was updated successfully, but these errors were encountered: