[all-commits] [llvm/llvm-project] 53f7f8: [Clang][AArch64] Fix Pure Scalables Types argument...

Momchil Velikov via All-commits all-commits at lists.llvm.org
Mon Oct 28 08:43:36 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 53f7f8eccabd6e3383edfeec312bf8671a89bc66
      https://github.com/llvm/llvm-project/commit/53f7f8eccabd6e3383edfeec312bf8671a89bc66
  Author: Momchil Velikov <momchil.velikov at arm.com>
  Date:   2024-10-28 (Mon, 28 Oct 2024)

  Changed paths:
    M clang/include/clang/CodeGen/CGFunctionInfo.h
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/Targets/AArch64.cpp
    A clang/test/CodeGen/aarch64-pure-scalable-args-empty-union.c
    A clang/test/CodeGen/aarch64-pure-scalable-args.c

  Log Message:
  -----------
  [Clang][AArch64] Fix Pure Scalables Types argument passing and return (#112747)

Pure Scalable Types are defined in AAPCS64 here:

https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#pure-scalable-types-psts

And should be passed according to Rule C.7 here:

https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#682parameter-passing-rules

This part of the ABI is completely unimplemented in Clang, instead it
treats PSTs sometimes as HFAs/HVAs, sometime as general composite types.

This patch implements the rules for passing PSTs by employing the
`CoerceAndExpand` method and extending it to:
* allow array types in the `coerceToType`; Now only `[N x i8]` are
considered padding.
* allow mismatch between the elements of the `coerceToType` and the
elements of the `unpaddedCoerceToType`; AArch64 uses this to map
fixed-length vector types to SVE vector types.

Corectly passing a PST argument needs a decision in Clang about whether
to pass it in memory or registers or, equivalently, whether to use the
`Indirect` or `Expand/CoerceAndExpand` method. It was considered
relatively harder (or not practically possible) to make that decision in
the AArch64 backend.
Hence this patch implements the register counting from AAPCS64 (cf.
`NSRN`, `NPRN`) to guide the Clang's decision.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list