[PATCH][AArch64] Implement Armv8.5-A memory tagging (MTE) intrinsics

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Mon Nov 4 16:40:00 GMT 2019


Hi Dennis,

On 10/17/19 11:03 AM, Dennis Zhang wrote:
> Hi,
>
> Arm Memory Tagging Extension (MTE) is published with Armv8.5-A.
> It can be used for spatial and temporal memory safety detection and
> lightweight lock and key system.
>
> This patch enables new intrinsics leveraging MTE instructions to
> implement functionalities of creating tags, setting tags, reading tags,
> and manipulating tags.
> The intrinsics are part of Arm ACLE extension:
> https://developer.arm.com/docs/101028/latest/memory-tagging-intrinsics
> The MTE ISA specification can be found at
> https://developer.arm.com/docs/ddi0487/latest chapter D6.
>
> Bootstraped and regtested for aarch64-none-linux-gnu.
>
> Please help to check if it's OK for trunk.
>

This looks mostly ok to me but for further review this needs to be 
rebased on top of current trunk as there are some conflicts with the SVE 
ACLE changes that recently went in. Most conflicts looks trivial to 
resolve but one that needs more attention is the definition of the 
TARGET_RESOLVE_OVERLOADED_BUILTIN hook.

Thanks,

Kyrill

> Many Thanks
> Dennis
>
> gcc/ChangeLog:
>
> 2019-10-16  Dennis Zhang  <dennis.zhang@arm.com>
>
>         * config/aarch64/aarch64-builtins.c (enum aarch64_builtins): Add
>         AARCH64_MEMTAG_BUILTIN_START, AARCH64_MEMTAG_BUILTIN_IRG,
>         AARCH64_MEMTAG_BUILTIN_GMI, AARCH64_MEMTAG_BUILTIN_SUBP,
>         AARCH64_MEMTAG_BUILTIN_INC_TAG, AARCH64_MEMTAG_BUILTIN_SET_TAG,
>         AARCH64_MEMTAG_BUILTIN_GET_TAG, and AARCH64_MEMTAG_BUILTIN_END.
>         (aarch64_init_memtag_builtins): New.
>         (AARCH64_INIT_MEMTAG_BUILTINS_DECL): New macro.
>         (aarch64_general_init_builtins): Call 
> aarch64_init_memtag_builtins.
>         (aarch64_expand_builtin_memtag): New.
>         (aarch64_general_expand_builtin): Call 
> aarch64_expand_builtin_memtag.
>         (AARCH64_BUILTIN_SUBCODE): New macro.
>         (aarch64_resolve_overloaded_memtag): New.
>         (aarch64_resolve_overloaded_builtin): New hook. Call
>         aarch64_resolve_overloaded_memtag to handle overloaded MTE 
> builtins.
>         * config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Define
>         __ARM_FEATURE_MEMORY_TAGGING when enabled.
>         * config/aarch64/aarch64-protos.h 
> (aarch64_resolve_overloaded_builtin):
>         Add declaration.
>         * config/aarch64/aarch64.c (TARGET_RESOLVE_OVERLOADED_BUILTIN):
>         New hook.
>         * config/aarch64/aarch64.h (AARCH64_ISA_MEMTAG): New macro.
>         (TARGET_MEMTAG): Likewise.
>         * config/aarch64/aarch64.md (define_c_enum "unspec"): Add
>         UNSPEC_GEN_TAG, UNSPEC_GEN_TAG_RND, and UNSPEC_TAG_SPACE.
>         (irg, gmi, subp, addg, ldg, stg): New instructions.
>         * config/aarch64/arm_acle.h (__arm_mte_create_random_tag): New 
> macro.
>         (__arm_mte_exclude_tag, __arm_mte_increment_tag): Likewise.
>         (__arm_mte_ptrdiff, __arm_mte_set_tag, __arm_mte_get_tag): 
> Likewise.
>         * config/aarch64/predicates.md (aarch64_memtag_tag_offset): New.
>         (aarch64_granule16_uimm6, aarch64_granule16_simm9): New.
>         * config/arm/types.md (memtag): New.
>         * doc/invoke.texi (-memtag): Update description.
>
> gcc/testsuite/ChangeLog:
>
> 2019-10-16  Dennis Zhang  <dennis.zhang@arm.com>
>
>         * gcc.target/aarch64/acle/memtag_1.c: New test.
>         * gcc.target/aarch64/acle/memtag_2.c: New test.
>         * gcc.target/aarch64/acle/memtag_3.c: New test.



More information about the Gcc-patches mailing list