Skip to content

arm64: Improve clang to use zero register for inline asm #2127

@mrutland-arm

Description

@mrutland-arm

With gcc inline assembly, using the "Z" constraint with the "w" or "x" operand modifiers results in the "wzr" or "xzr" zero register being used. This is described in the GCC documentation for AArch64 operand modifiers:

https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#AArch64-Operand-Modifiers

The "Z" constraint is described in:
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html

The arm64 kernel port uses these constraints for several pieces of of inline assembly (e.g. MMIO accessors, and system register accessors), but LLVM doesn't (currently) use the zero register for these cases, and instead movess the integer constant zero into another general purpose register, as noted on the list:

It would be helpful if LLVM could generate the zero register for these cases, as this will result in better code generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [ARCH] arm64This bug impacts ARCH=arm64[BUG] llvmA bug that should be fixed in upstream LLVMenhancementNew feature or requestfeature-requestNot a bug per-se

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions