1  /* Arm Custom Datapath Extension (CDE) intrinsics include file.
       2  
       3     Copyright (C) 2020-2023 Free Software Foundation, Inc.
       4     Contributed by Arm Ltd.
       5  
       6     This file is part of GCC.
       7  
       8     GCC is free software; you can redistribute it and/or modify it
       9     under the terms of the GNU General Public License as published
      10     by the Free Software Foundation; either version 3, or (at your
      11     option) any later version.
      12  
      13     GCC is distributed in the hope that it will be useful, but WITHOUT
      14     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      15     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
      16     License for more details.
      17  
      18     Under Section 7 of GPL version 3, you are granted additional
      19     permissions described in the GCC Runtime Library Exception, version
      20     3.1, as published by the Free Software Foundation.
      21  
      22     You should have received a copy of the GNU General Public License and
      23     a copy of the GCC Runtime Library Exception along with this program;
      24     see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      25     <http://www.gnu.org/licenses/>.  */
      26  
      27  #ifndef _GCC_ARM_CDE_H
      28  #define _GCC_ARM_CDE_H 1
      29  
      30  #include <stdint.h>
      31  
      32  #if defined (__ARM_FEATURE_CDE)
      33  
      34  #define __arm_cx1(coproc, imm) \
      35  	__builtin_arm_cx1si(coproc, imm)
      36  
      37  #define __arm_cx1a(coproc, acc, imm) \
      38  	__builtin_arm_cx1asi(coproc, acc, imm)
      39  
      40  #define __arm_cx2(coproc, n, imm) \
      41  	__builtin_arm_cx2si(coproc, n, imm)
      42  
      43  #define __arm_cx2a(coproc, acc, n, imm) \
      44  	__builtin_arm_cx2asi(coproc, acc, n, imm)
      45  
      46  #define __arm_cx3(coproc, n, m, imm) \
      47  	__builtin_arm_cx3si(coproc, n, m, imm)
      48  
      49  #define __arm_cx3a(coproc, acc, n, m, imm) \
      50  	__builtin_arm_cx3asi(coproc, acc, n, m, imm)
      51  
      52  #define __arm_cx1d(coproc, imm) \
      53  	__builtin_arm_cx1di(coproc, imm)
      54  
      55  #define __arm_cx1da(coproc, acc, imm) \
      56  	__builtin_arm_cx1adi(coproc, acc, imm)
      57  
      58  #define __arm_cx2d(coproc, n, imm) \
      59  	__builtin_arm_cx2di(coproc, n, imm)
      60  
      61  #define __arm_cx2da(coproc, acc, n, imm) \
      62  	__builtin_arm_cx2adi(coproc, acc, n, imm)
      63  
      64  #define __arm_cx3d(coproc, n, m, imm) \
      65  	__builtin_arm_cx3di(coproc, n, m, imm)
      66  
      67  #define __arm_cx3da(coproc, acc, n, m, imm) \
      68  	__builtin_arm_cx3adi(coproc, acc, n, m, imm)
      69  
      70  #if defined (__ARM_FP) || defined (__ARM_FEATURE_MVE)
      71  
      72  /* CDE builtins using FPU/MVE registers.  */
      73  
      74  /* uint32_t
      75     __arm_vcx1_u32(int coproc, uint32_t imm);  */
      76  #define __arm_vcx1_u32(coproc, imm) \
      77  	__builtin_arm_vcx1si(coproc, imm)
      78  
      79  /* uint32_t
      80     __arm_vcx1a_u32(int coproc, uint32_t acc, uint32_t imm);  */
      81  #define __arm_vcx1a_u32(coproc, acc, imm) \
      82  	__builtin_arm_vcx1asi(coproc, acc, imm)
      83  
      84  /* uint32_t
      85     __arm_vcx2_u32(int coproc, uint32_t n, uint32_t imm);  */
      86  #define __arm_vcx2_u32(coproc, n, imm) \
      87  	__builtin_arm_vcx2si(coproc, n, imm)
      88  
      89  /* uint32_t
      90     __arm_vcx2a_u32(int coproc, uint32_t acc, uint32_t n, uint32_t imm);  */
      91  #define __arm_vcx2a_u32(coproc, acc, n, imm) \
      92  	__builtin_arm_vcx2asi(coproc, acc, n, imm)
      93  
      94  /* uint32_t
      95     __arm_vcx3_u32(int coproc, uint32_t n, uint32_t m, uint32_t imm);  */
      96  #define __arm_vcx3_u32(coproc, n, m, imm) \
      97  	__builtin_arm_vcx3si(coproc, n, m, imm)
      98  
      99  /* uint32_t
     100     __arm_vcx3a_u32(int coproc, uint32_t acc, uint32_t n, uint32_t m,
     101  		   uint32_t imm);  */
     102  #define __arm_vcx3a_u32(coproc, acc, n, m, imm) \
     103  	__builtin_arm_vcx3asi(coproc, acc, n, m, imm)
     104  
     105  /* uint64_t
     106     __arm_vcx1d_u64(int coproc, uint32_t imm);  */
     107  #define __arm_vcx1d_u64(coproc, imm) \
     108  	__builtin_arm_vcx1di(coproc, imm)
     109  
     110  /* uint64_t
     111     __arm_vcx1da_u64(int coproc, uint64_t acc, uint32_t imm);  */
     112  #define __arm_vcx1da_u64(coproc, acc, imm) \
     113  	__builtin_arm_vcx1adi(coproc, acc, imm)
     114  
     115  /* uint64_t
     116     __arm_vcx2d_u64(int coproc, uint64_t m, uint32_t imm);  */
     117  #define __arm_vcx2d_u64(coproc, m, imm) \
     118  	__builtin_arm_vcx2di(coproc, m, imm)
     119  
     120  /* uint64_t
     121     __arm_vcx2da_u64(int coproc, uint64_t acc, uint64_t m, uint32_t imm);  */
     122  #define __arm_vcx2da_u64(coproc, acc, m, imm) \
     123  	__builtin_arm_vcx2adi(coproc, acc, m, imm)
     124  
     125  /* uint64_t
     126     __arm_vcx3d_u64(int coproc, uint64_t n, uint64_t m, uint32_t imm);  */
     127  #define __arm_vcx3d_u64(coproc, n, m, imm) \
     128  	__builtin_arm_vcx3di(coproc, n, m, imm)
     129  
     130  /* uint64_t
     131     __arm_vcx3da_u64(int coproc, uint64_t acc, uint64_t n, uint64_t m,
     132  		    uint32_t imm);  */
     133  #define __arm_vcx3da_u64(coproc, acc, n, m, imm) \
     134  	__builtin_arm_vcx3adi(coproc, acc, n, m, imm)
     135  
     136  #endif /* __ARM_FP || __ARM_FEATURE_MVE.  */
     137  #endif /* __ARM_FEATURE_CDE.  */
     138  
     139  #if __ARM_FEATURE_MVE
     140  #include "arm_mve_types.h"
     141  
     142  #define __arm_vcx1q_u8(coproc, imm) \
     143  	(uint8x16_t)__builtin_arm_vcx1qv16qi(coproc, imm)
     144  #define __arm_vcx1qa(coproc, acc, imm) \
     145  	__builtin_arm_vcx1qav16qi(coproc, acc, imm)
     146  #define __arm_vcx2q(coproc, n, imm) \
     147  	__builtin_arm_vcx2qv16qi(coproc, n, imm)
     148  #define __arm_vcx2q_u8(coproc, n, imm) \
     149  	(uint8x16_t)__builtin_arm_vcx2qv16qi(coproc, n, imm)
     150  #define __arm_vcx2qa(coproc, acc, n, imm) \
     151  	__builtin_arm_vcx2qav16qi(coproc, acc, n, imm)
     152  #define __arm_vcx3q(coproc, n, m, imm) \
     153  	__builtin_arm_vcx3qv16qi(coproc, n, m, imm)
     154  #define __arm_vcx3q_u8(coproc, n, m, imm) \
     155  	(uint8x16_t)__builtin_arm_vcx3qv16qi(coproc, n, m, imm)
     156  #define __arm_vcx3qa(coproc, acc, n, m, imm) \
     157  	__builtin_arm_vcx3qav16qi(coproc, acc, n, m, imm)
     158  
     159  #define __arm_vcx1q_m(coproc, inactive, imm, pred) \
     160  	__builtin_arm_vcx1q_p_v16qi(coproc, inactive, imm, pred)
     161  #define __arm_vcx1qa_m(coproc, acc, imm, pred) \
     162  	__builtin_arm_vcx1qa_p_v16qi(coproc, acc, imm, pred)
     163  
     164  #define __arm_vcx2q_m(coproc, inactive, n, imm, pred) \
     165  	__builtin_arm_vcx2q_p_v16qi(coproc, inactive, n, imm, pred)
     166  #define __arm_vcx2qa_m(coproc, acc, n, imm, pred) \
     167  	__builtin_arm_vcx2qa_p_v16qi(coproc, acc, n, imm, pred)
     168  
     169  #define __arm_vcx3q_m(coproc, inactive, n, m, imm, pred) \
     170  	__builtin_arm_vcx3q_p_v16qi(coproc, inactive, n, m, imm, pred)
     171  #define __arm_vcx3qa_m(coproc, acc, n, m, imm, pred) \
     172  	__builtin_arm_vcx3qa_p_v16qi(coproc, acc, n, m, imm, pred)
     173  
     174  #endif
     175  
     176  #endif