[all-commits] [llvm/llvm-project] 1f70fc: [Clang][AArch64] Add customisable immediate range ...

SpencerAbson via All-commits all-commits at lists.llvm.org
Fri Sep 6 05:12:58 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1f70fcefa981e6e2b7e60678545766426fbefd96
      https://github.com/llvm/llvm-project/commit/1f70fcefa981e6e2b7e60678545766426fbefd96
  Author: SpencerAbson <Spencer.Abson at arm.com>
  Date:   2024-09-06 (Fri, 06 Sep 2024)

  Changed paths:
    M clang/include/clang/Basic/CMakeLists.txt
    M clang/include/clang/Basic/TargetBuiltins.h
    M clang/include/clang/Basic/arm_fp16.td
    A clang/include/clang/Basic/arm_immcheck_incl.td
    M clang/include/clang/Basic/arm_neon.td
    M clang/include/clang/Basic/arm_neon_incl.td
    M clang/include/clang/Basic/arm_sve_sme_incl.td
    M clang/include/clang/Sema/SemaARM.h
    M clang/lib/Sema/SemaARM.cpp
    M clang/test/CodeGen/aarch64-neon-luti.c
    R clang/test/CodeGen/arm-neon-range-checks.c
    R clang/test/Sema/aarch64-neon-bf16-ranges.c
    R clang/test/Sema/aarch64-neon-fp16-ranges.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/bfloat16.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/conversions.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/copy-vector-lane.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/dotprod.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/extract-elt-from-vector.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/extract-vector-from-vectors.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/fp16-scalar.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/fp16-v84.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/fp16-vector.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/fused-multiply-accumulate.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/luti.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/matrix-multiplication.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/multiply-extended.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/saturating-multiply-accumulate.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/saturating-multiply-by-scalar-and-widen.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/set-lanes-to-value.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/set-vector-lane.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/sqrdmlah-ranges.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vcmla.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-load.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-accumulate-by-scalar.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-by-scalar-and-widen.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-by-scalar.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-subtract-by-scalar.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-shift-left.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-shift-right.c
    A clang/test/Sema/aarch64-neon-immediate-ranges/vector-store.c
    R clang/test/Sema/aarch64-neon-ranges.c
    M clang/utils/TableGen/NeonEmitter.cpp
    M clang/utils/TableGen/SveEmitter.cpp
    M clang/utils/TableGen/TableGen.cpp
    M clang/utils/TableGen/TableGenBackends.h
    M llvm/docs/CommandGuide/tblgen.rst
    A llvm/include/llvm/TableGen/AArch64ImmCheck.h

  Log Message:
  -----------
  [Clang][AArch64] Add customisable immediate range checking to NEON (#100278)

This patch moves NEON immediate argument specification and checking to
the system currently shared by both SVE and SME.

In its current form, the TableGen definition of a NEON intrinsic cannot
control how its immediate arguments are range-checked, this information
must be inferred from the name of the intrinsic by NeonEmitter, which
also assumes that any NEON instruction will only ever receive a single
immediate argument. For SVE/SME instrinsics, this information is more
conveniently supplied in the TableGen definition.

As a result, for each immediate argument, NEON instructions must define
- The index of the immediate argument to be checked
- The type of immediate range check to be performed,
    (e.g., ImmCheckShiftRight)
- The index of the argument whose type defines the context
    of this immediate check (base type, vector size).
- **Difference from SVE/SME** If this definition generates a polymorphic
NEON builtin, the base type defined by this argument is overwritten by
that of the type code supplied to the overloaded builtin call. This
third argument is omitted in some cases due to this.

Here is an example for
[`vfma_laneq`](https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:@navigationhierarchiessimdisa=[Neon]&q=vfma_laneq)
- The immediate is supplied in argument 3
- The immediate is used as an index into the lanes of argument 2
- So we must perform an immediate check on argument 3, based on the type
information of argument 2.
- `ImmCheck<3, ImmCheckLaneIndex, 2>`

During this work, we discovered that the existing immediate
range-checking system was largely untested, which made it difficult to
make reliable progress. Missing tests have been added to verify this
implementation against all intrinsics which take constrained immediate
arguments. All test immediate range checking tests for NEON intrinsics
are moved to a dedicated directory
`clang/test/Sema/aarch64-neon-immediate-ranges/`.



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