Hi gcc-patches mailing list,
Antoni Boucher via Sourceware Forge 
<[email protected]> has requested that the following 
forgejo pull request
be published on the mailing list.

Created on: 2025-10-16 19:43:44+00:00
Latest update: 2026-05-22 14:52:50+00:00
Changes: 9 changed files, 211 additions, 19 deletions
Head revision: antoyo/gcc ref gccjit/aarch64-cpu-features commit 
dd9be5cebf171bd806de17998b02596d120426d4
Base revision: gcc/gcc-TEST ref trunk commit 
6c01778628d93c5135536e051dc39f8d85198d06 r16-4563-g6c01778628d93c
Merge base: 6c01778628d93c5135536e051dc39f8d85198d06
Full diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/108.diff
Discussion:  https://forge.sourceware.org/gcc/gcc-TEST/pulls/108
Requested Reviewers: pinskia, dmalcolm

```
gcc/ChangeLog:

        * config.gcc: Mention new aarch64-jit.o file.
        * config/aarch64/aarch64-jit.cc: Detect CPU features.
        * config/aarch64/aarch64-jit.h: New target hook.
        * config/aarch64/t-aarch64: Mention new aarch64-jit.cc file.
        * config/i386/i386-jit.cc: Remove target-dependent type
        detection.

gcc/jit/ChangeLog:

        * jit-target.cc: Move target-dependent type detection to common
        file.

gcc/testsuite/ChangeLog:

        * jit.dg/all-non-failing-tests.h: Mention new test.
        * jit.dg/test-target-info-aarch64.c: New test.

Co-authored-by: winstonallo <[email protected]>
```


Changed files:
- A: gcc/config/aarch64/aarch64-jit.cc
- A: gcc/config/aarch64/aarch64-jit.h
- A: gcc/testsuite/jit.dg/test-target-info-aarch64.c
- M: gcc/config.gcc
- M: gcc/config/aarch64/t-aarch64
- M: gcc/config/i386/i386-jit.cc
- M: gcc/jit/jit-target.cc
- M: gcc/jit/jit-target.h
- M: gcc/testsuite/jit.dg/all-non-failing-tests.h


Antoni Boucher (1):
  libgccjit: Add support for Aarch64 CPU features

 gcc/config.gcc                                |  1 +
 gcc/config/aarch64/aarch64-jit.cc             | 70 +++++++++++++++++++
 gcc/config/aarch64/aarch64-jit.h              | 22 ++++++
 gcc/config/aarch64/t-aarch64                  |  4 ++
 gcc/config/i386/i386-jit.cc                   | 18 -----
 gcc/jit/jit-target.cc                         | 47 +++++++++++++
 gcc/jit/jit-target.h                          |  4 +-
 gcc/testsuite/jit.dg/all-non-failing-tests.h  |  3 +
 .../jit.dg/test-target-info-aarch64.c         | 61 ++++++++++++++++
 9 files changed, 211 insertions(+), 19 deletions(-)
 create mode 100644 gcc/config/aarch64/aarch64-jit.cc
 create mode 100644 gcc/config/aarch64/aarch64-jit.h
 create mode 100644 gcc/testsuite/jit.dg/test-target-info-aarch64.c

Range-diff against v1:
1:  dcd2f8e20cf4 ! 1:  dd9be5cebf17 libgccjit: Add support for Aarch64 CPU 
features
    @@ Commit message
     
                 * jit-target.cc: Move target-dependent type detection to common
                 file.
    +            (jit_add_target_info_space): New function.
    +            * jit-target.h (jit_add_target_info_space): New function.
     
         gcc/testsuite/ChangeLog:
     
    @@ gcc/config.gcc: aarch64*-*-*)
      ## gcc/config/aarch64/aarch64-jit.cc (new) ##
     @@
     +/* Subroutines for the jit front end on the AArch64 architecture.
    -+   Copyright (C) 2024 Free Software Foundation, Inc.
    ++   Copyright (C) 2025 Free Software Foundation, Inc.
     +
     +GCC is free software; you can redistribute it and/or modify
     +it under the terms of the GNU General Public License as published by
    @@ gcc/config/aarch64/aarch64-jit.cc (new)
     +  }
     +#endif
     +
    -+  if (TARGET_AES)
    -+    jit_add_target_info ("target_feature", "aes");
    -+  if (TARGET_BF16_FP)
    -+    jit_add_target_info ("target_feature", "bf16");
    ++#define AARCH64_OPT_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, \
    ++  EXPLICIT_OFF, FEATURE_STRING) \
    ++if (AARCH64_HAVE_ISA (IDENT)) jit_add_target_info_space 
("target_feature", NAME, \
    ++  FEATURE_STRING);
    ++#include "aarch64-option-extensions.def"
    ++
     +  if (TARGET_BTI)
     +    jit_add_target_info ("target_feature", "bti");
    -+  if (TARGET_COMPLEX)
    -+    jit_add_target_info ("target_feature", "fcma");
    -+  if (TARGET_CRC32)
    -+    jit_add_target_info ("target_feature", "crc");
    -+  if (TARGET_DOTPROD)
    -+    jit_add_target_info ("target_feature", "dotprod");
    -+  if (TARGET_SVE_F32MM)
    -+    jit_add_target_info ("target_feature", "f32mm");
    -+  if (TARGET_SVE_F64MM)
    -+    jit_add_target_info ("target_feature", "f64mm");
    -+  if (TARGET_F16FML)
    -+    jit_add_target_info ("target_feature", "fhm");
    -+  if (TARGET_FP_F16INST)
    -+    jit_add_target_info ("target_feature", "fp16");
    -+  if (TARGET_FRINT)
    -+    jit_add_target_info ("target_feature", "frintts");
    -+  if (TARGET_I8MM)
    -+    jit_add_target_info ("target_feature", "i8mm");
    -+  if (TARGET_JSCVT)
    -+    jit_add_target_info ("target_feature", "jsconv");
    -+  if (TARGET_LSE)
    -+    jit_add_target_info ("target_feature", "lse");
    -+  if (TARGET_MEMTAG)
    -+    jit_add_target_info ("target_feature", "mte");
    -+  if (TARGET_PAUTH)
    -+  {
    -+    jit_add_target_info ("target_feature", "paca");
    -+    jit_add_target_info ("target_feature", "pacg");
    -+  }
    -+  if (TARGET_RNG)
    -+    jit_add_target_info ("target_feature", "rand");
    -+  if (TARGET_RCPC)
    -+    jit_add_target_info ("target_feature", "rcpc");
    -+  if (TARGET_RCPC2)
    -+    jit_add_target_info ("target_feature", "rcpc2");
    -+  if (TARGET_SIMD_RDMA)
    -+    jit_add_target_info ("target_feature", "rdm");
    -+  if (TARGET_SB)
    -+    jit_add_target_info ("target_feature", "sb");
    -+  if (TARGET_SHA2)
    -+    jit_add_target_info ("target_feature", "sha2");
    -+  if (TARGET_SHA3)
    -+    jit_add_target_info ("target_feature", "sha3");
    -+  if (TARGET_SIMD)
    -+    jit_add_target_info ("target_feature", "neon");
    -+  if (TARGET_SM4)
    -+    jit_add_target_info ("target_feature", "sm4");
    -+  if (TARGET_SVE)
    -+    jit_add_target_info ("target_feature", "sve");
    -+  if (TARGET_SVE2)
    -+    jit_add_target_info ("target_feature", "sve2");
    -+  if (TARGET_SVE2_AES)
    -+    jit_add_target_info ("target_feature", "sve2-aes");
    -+  if (TARGET_SVE2_BITPERM)
    -+    jit_add_target_info ("target_feature", "sve2-bitperm");
    -+  if (TARGET_SVE2_SHA3)
    -+    jit_add_target_info ("target_feature", "sve2-sha3");
    -+  if (TARGET_SVE2_SM4)
    -+    jit_add_target_info ("target_feature", "sve2-sm4");
    -+  if (TARGET_TME)
    -+    jit_add_target_info ("target_feature", "tme");
    -+  // TODO: features dit, dpb, dpb2, flagm, lor, pan, pmuv3, ras, spe, 
ssbs, vh
    -+
    -+  if (AARCH64_HAVE_ISA (V8_1A))
    -+    jit_add_target_info ("target_feature", "v8.1a");
    -+  if (AARCH64_HAVE_ISA (V8_2A))
    -+    jit_add_target_info ("target_feature", "v8.2a");
    -+  if (AARCH64_HAVE_ISA (V8_3A))
    -+    jit_add_target_info ("target_feature", "v8.3a");
    -+  if (AARCH64_HAVE_ISA (V8_4A))
    -+    jit_add_target_info ("target_feature", "v8.4a");
    -+  if (AARCH64_HAVE_ISA (V8_5A))
    -+    jit_add_target_info ("target_feature", "v8.5a");
    -+  if (AARCH64_HAVE_ISA (V8_6A))
    -+    jit_add_target_info ("target_feature", "v8.6a");
    -+  if (AARCH64_HAVE_ISA (V8_7A))
    -+    jit_add_target_info ("target_feature", "v8.7a");
    ++  // TODO: features dit, dpb, dpb2, lor, pan, pmuv3, ras, spe, vh
    ++
    ++#define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \
    ++if (AARCH64_HAVE_ISA (ARCH_IDENT)) jit_add_target_info ("target_feature", 
NAME);
    ++#include "aarch64-arches.def"
     +}
     
      ## gcc/config/aarch64/aarch64-jit.h (new) ##
     @@
     +/* Definitions for the jit front end on the AArch64 architecture.
    -+   Copyright (C) 2024 Free Software Foundation, Inc.
    ++   Copyright (C) 2025 Free Software Foundation, Inc.
     +
     +GCC is free software; you can redistribute it and/or modify
     +it under the terms of the GNU General Public License as published by
    @@ gcc/config/i386/i386-jit.cc: ix86_jit_register_target_info (void)
     -    jit_target_add_supported_target_dependent_type 
(GCC_JIT_TYPE_UINT128_T);
     -    jit_target_add_supported_target_dependent_type 
(GCC_JIT_TYPE_INT128_T);
     -  }
    +-
    +-  if (float16_type_node != NULL && TYPE_PRECISION (float16_type_node) == 
16)
    +-    jit_target_add_supported_target_dependent_type (GCC_JIT_TYPE_FLOAT16);
    +-
    +-  if (float32_type_node != NULL && TYPE_PRECISION (float32_type_node) == 
32)
    +-    jit_target_add_supported_target_dependent_type (GCC_JIT_TYPE_FLOAT32);
    +-
    +-  if (float64_type_node != NULL && TYPE_PRECISION (float64_type_node) == 
64)
    +-    jit_target_add_supported_target_dependent_type (GCC_JIT_TYPE_FLOAT64);
    +-
    +-  if (float128_type_node != NULL && TYPE_PRECISION (float128_type_node) 
== 128)
    +-    jit_target_add_supported_target_dependent_type 
(GCC_JIT_TYPE_FLOAT128);
     -
      #define ADD_TARGET_INFO jit_add_target_info
      #include "i386-rust-and-jit.inc"
      #undef ADD_TARGET_INFO
     
      ## gcc/jit/jit-target.cc ##
    +@@ gcc/jit/jit-target.cc: You should have received a copy of the GNU 
General Public License
    + along with GCC; see the file COPYING3.  If not see
    + <http://www.gnu.org/licenses/>.  */
    + 
    ++#define INCLUDE_SSTREAM
    + #define INCLUDE_STRING
    + #define INCLUDE_ALGORITHM
    + #include "config.h"
     @@ gcc/jit/jit-target.cc: along with GCC; see the file COPYING3.  If not 
see
    + #include "tm_p.h"
    + #include "target.h"
    + #include "calls.h"
    ++#include <iterator>
    + 
    + #include "jit-playback.h"
    + #include "jit-target.h"
      
      /* Initialize all variables of the Target structure.  */
      
     +void
     +jit_target_dependent_types_init ()
     +{
    -+  if (targetm.scalar_mode_supported_p (TImode))
    ++  if (targetm.scalar_mode_supported_p (TImode))
     +  {
     +    jit_target_add_supported_target_dependent_type 
(GCC_JIT_TYPE_UINT128_T);
     +    jit_target_add_supported_target_dependent_type 
(GCC_JIT_TYPE_INT128_T);
    @@ gcc/jit/jit-target.cc: along with GCC; see the file COPYING3.  If not see
      }
      
      /* Add a target info key:value to JIT_TARGET_INFO for use by
    +@@ gcc/jit/jit-target.cc: jit_add_target_info (const char *key, const char 
*value)
    +     jit_target_info->m_info[key].insert (value);
    + }
    + 
    ++/*
    ++ This splits the values by whitespace and calls jit_add_target_info for 
each
    ++ value.
    ++ */
    ++void jit_add_target_info_space (const char *key, const char *name,
    ++  const char *values)
    ++{
    ++  std::istringstream iss (values);
    ++  std::vector<std::string> split_values;
    ++  std::copy (std::istream_iterator<std::string> (iss),
    ++    std::istream_iterator<std::string> (),
    ++    std::back_inserter (split_values));
    ++
    ++  if (split_values.empty ())
    ++    jit_add_target_info (key, name);
    ++  else
    ++  {
    ++    for (auto value : split_values)
    ++      jit_add_target_info (key, value.c_str ());
    ++  }
    ++}
    ++
    + void
    + jit_target_set_arch (std::string const& arch)
    + {
    +
    + ## gcc/jit/jit-target.h ##
    +@@ gcc/jit/jit-target.h: struct target_info {
    +     bool has_target_value (const char *key, const char *value);
    + 
    +     std::unordered_map<const char *,
    +-  std::unordered_set<const char *, CStringHash, CStringEqual>,
    ++  std::unordered_set<std::string>,
    +   CStringHash, CStringEqual>
    +   m_info;
    +     std::string m_arch;
    +@@ gcc/jit/jit-target.h: extern void jit_target_set_arch (std::string 
const& arch);
    + extern void
    + jit_target_add_supported_target_dependent_type (enum gcc_jit_types type_);
    + extern void jit_add_target_info (const char *key, const char *value);
    ++extern void jit_add_target_info_space (const char *key, const char *name,
    ++  const char *values);
    + extern target_info * jit_get_target_info ();
    + 
    + #endif /* GCC_JIT_TARGET_H  */
     
      ## gcc/testsuite/jit.dg/all-non-failing-tests.h ##
     @@
-- 
2.54.0

Reply via email to