/* Builtin lists for AArch64 SVE
   Copyright (C) 2018-2025 Free Software Foundation, Inc.

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   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/>.  */

#ifndef DEF_SVE_MODE
#define DEF_SVE_MODE(A, B, C, D)
#endif

#ifndef DEF_SVE_TYPE
#define DEF_SVE_TYPE(A, B, C, D)
#endif

#ifndef DEF_SVE_TYPE_SUFFIX
#define DEF_SVE_TYPE_SUFFIX(A, B, C, D, E)
#endif

#ifndef DEF_SME_ZA_SUFFIX
#define DEF_SME_ZA_SUFFIX(A, B, C)
#endif

#ifndef DEF_SVE_GROUP_SUFFIX
#define DEF_SVE_GROUP_SUFFIX(A, B, C)
#endif

#ifndef DEF_SVE_FUNCTION_GS_FPM
#define DEF_SVE_FUNCTION_GS_FPM(A, B, C, D, E, F)
#endif

#ifndef DEF_SVE_FUNCTION_GS
#define DEF_SVE_FUNCTION_GS(A, B, C, D, E) \
  DEF_SVE_FUNCTION_GS_FPM(A, B, C, D, E, unused)
#endif

#ifndef DEF_SVE_NEON_TYPE_SUFFIX
#define DEF_SVE_NEON_TYPE_SUFFIX(A, B, C, D, E, F, G) \
  DEF_SVE_TYPE_SUFFIX(A, B, C, D, E)
#endif

#ifndef DEF_SVE_FUNCTION
#define DEF_SVE_FUNCTION(NAME, SHAPE, TYPES, PREDS) \
  DEF_SVE_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS)
#endif

DEF_SVE_MODE (n, none, none, none)
DEF_SVE_MODE (single, none, none, none)
DEF_SVE_MODE (index, none, none, elements)
DEF_SVE_MODE (offset, none, none, bytes)
DEF_SVE_MODE (s32index, none, svint32_t, elements)
DEF_SVE_MODE (s32offset, none, svint32_t, bytes)
DEF_SVE_MODE (s64index,  none, svint64_t, elements)
DEF_SVE_MODE (s64offset, none, svint64_t, bytes)
DEF_SVE_MODE (u32base, svuint32_t, none, none)
DEF_SVE_MODE (u32base_index, svuint32_t, none, elements)
DEF_SVE_MODE (u32base_offset, svuint32_t, none, bytes)
DEF_SVE_MODE (u32base_s32index, svuint32_t, svint32_t, elements)
DEF_SVE_MODE (u32base_s32offset, svuint32_t, svint32_t, bytes)
DEF_SVE_MODE (u32base_u32index, svuint32_t, svuint32_t, elements)
DEF_SVE_MODE (u32base_u32offset, svuint32_t, svuint32_t, bytes)
DEF_SVE_MODE (u32index, none, svuint32_t, elements)
DEF_SVE_MODE (u32offset, none, svuint32_t, bytes)
DEF_SVE_MODE (u64base, svuint64_t, none, none)
DEF_SVE_MODE (u64base_index, svuint64_t, none, elements)
DEF_SVE_MODE (u64base_offset, svuint64_t, none, bytes)
DEF_SVE_MODE (u64base_s64index, svuint64_t, svint64_t, elements)
DEF_SVE_MODE (u64base_s64offset, svuint64_t, svint64_t, bytes)
DEF_SVE_MODE (u64base_u64index, svuint64_t, svuint64_t, elements)
DEF_SVE_MODE (u64base_u64offset, svuint64_t, svuint64_t, bytes)
DEF_SVE_MODE (u64index, none, svuint64_t, elements)
DEF_SVE_MODE (u64offset, none, svuint64_t, bytes)
DEF_SVE_MODE (vnum, none, none, vectors)

DEF_SVE_TYPE (svbool_t, 10, __SVBool_t, boolean_type_node)
DEF_SVE_TYPE (svcount_t, 11, __SVCount_t, boolean_type_node)
DEF_SVE_TYPE (svmfloat8_t, 13, __SVMfloat8_t, aarch64_mfp8_type_node)
DEF_SVE_TYPE (svbfloat16_t, 14, __SVBfloat16_t, bfloat16_type_node)
DEF_SVE_TYPE (svfloat16_t, 13, __SVFloat16_t, aarch64_fp16_type_node)
DEF_SVE_TYPE (svfloat32_t, 13, __SVFloat32_t, float_type_node)
DEF_SVE_TYPE (svfloat64_t, 13, __SVFloat64_t, double_type_node)
DEF_SVE_TYPE (svint8_t, 10, __SVInt8_t, get_typenode_from_name (INT8_TYPE))
DEF_SVE_TYPE (svint16_t, 11, __SVInt16_t, get_typenode_from_name (INT16_TYPE))
DEF_SVE_TYPE (svint32_t, 11, __SVInt32_t, get_typenode_from_name (INT32_TYPE))
DEF_SVE_TYPE (svint64_t, 11, __SVInt64_t, get_typenode_from_name (INT64_TYPE))
DEF_SVE_TYPE (svuint8_t, 11, __SVUint8_t, get_typenode_from_name (UINT8_TYPE))
DEF_SVE_TYPE (svuint16_t, 12, __SVUint16_t,
	      get_typenode_from_name (UINT16_TYPE))
DEF_SVE_TYPE (svuint32_t, 12, __SVUint32_t,
	      get_typenode_from_name (UINT32_TYPE))
DEF_SVE_TYPE (svuint64_t, 12, __SVUint64_t,
	      get_typenode_from_name (UINT64_TYPE))

DEF_SVE_TYPE_SUFFIX (b, svbool_t, bool, 8, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (b8, svbool_t, bool, 8, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (b16, svbool_t, bool, 16, VNx8BImode)
DEF_SVE_TYPE_SUFFIX (b32, svbool_t, bool, 32, VNx4BImode)
DEF_SVE_TYPE_SUFFIX (b64, svbool_t, bool, 64, VNx2BImode)
DEF_SVE_TYPE_SUFFIX (c, svcount_t, count, 8, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (c8, svcount_t, count, 8, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (c16, svcount_t, count, 16, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (c32, svcount_t, count, 32, VNx16BImode)
DEF_SVE_TYPE_SUFFIX (c64, svcount_t, count, 64, VNx16BImode)
DEF_SVE_NEON_TYPE_SUFFIX (mf8, svmfloat8_t, mfloat, 8, VNx16QImode,
			  Mfloat8x8_t, Mfloat8x16_t)
DEF_SVE_NEON_TYPE_SUFFIX (bf16, svbfloat16_t, bfloat, 16, VNx8BFmode,
			  Bfloat16x4_t, Bfloat16x8_t)
DEF_SVE_NEON_TYPE_SUFFIX (f16, svfloat16_t, float, 16, VNx8HFmode,
			  Float16x4_t, Float16x8_t)
DEF_SVE_NEON_TYPE_SUFFIX (f32, svfloat32_t, float, 32, VNx4SFmode,
			  Float32x2_t, Float32x4_t)
DEF_SVE_NEON_TYPE_SUFFIX (f64, svfloat64_t, float, 64, VNx2DFmode,
			  Float64x1_t, Float64x2_t)
DEF_SVE_NEON_TYPE_SUFFIX (s8, svint8_t, signed, 8, VNx16QImode,
			  Int8x8_t, Int8x16_t)
DEF_SVE_NEON_TYPE_SUFFIX (s16, svint16_t, signed, 16, VNx8HImode,
			  Int16x4_t, Int16x8_t)
DEF_SVE_NEON_TYPE_SUFFIX (s32, svint32_t, signed, 32, VNx4SImode,
			  Int32x2_t, Int32x4_t)
DEF_SVE_NEON_TYPE_SUFFIX (s64, svint64_t, signed, 64, VNx2DImode,
			  Int64x1_t, Int64x2_t)
DEF_SVE_NEON_TYPE_SUFFIX (u8, svuint8_t, unsigned, 8, VNx16QImode,
			  Uint8x8_t, Uint8x16_t)
DEF_SVE_NEON_TYPE_SUFFIX (u16, svuint16_t, unsigned, 16, VNx8HImode,
			  Uint16x4_t, Uint16x8_t)
DEF_SVE_NEON_TYPE_SUFFIX (u32, svuint32_t, unsigned, 32, VNx4SImode,
			  Uint32x2_t, Uint32x4_t)
DEF_SVE_NEON_TYPE_SUFFIX (u64, svuint64_t, unsigned, 64, VNx2DImode,
			  Uint64x1_t, Uint64x2_t)

/* Associate _za with bytes.  This is needed for svldr_vnum_za and
   svstr_vnum_za, whose ZA offset can be in the range [0, 15], as for za8.  */
DEF_SME_ZA_SUFFIX (za, 8, VNx16QImode)

DEF_SME_ZA_SUFFIX (za8, 8, VNx16QImode)
DEF_SME_ZA_SUFFIX (za16, 16, VNx8HImode)
DEF_SME_ZA_SUFFIX (za32, 32, VNx4SImode)
DEF_SME_ZA_SUFFIX (za64, 64, VNx2DImode)
DEF_SME_ZA_SUFFIX (za128, 128, VNx1TImode)

DEF_SVE_GROUP_SUFFIX (x2, 0, 2)
DEF_SVE_GROUP_SUFFIX (x3, 0, 3)
DEF_SVE_GROUP_SUFFIX (x4, 0, 4)
DEF_SVE_GROUP_SUFFIX (vg1x2, 1, 2)
DEF_SVE_GROUP_SUFFIX (vg1x4, 1, 4)
DEF_SVE_GROUP_SUFFIX (vg2, 2, 2)
DEF_SVE_GROUP_SUFFIX (vg2x1, 2, 1)
DEF_SVE_GROUP_SUFFIX (vg2x2, 2, 2)
DEF_SVE_GROUP_SUFFIX (vg2x4, 2, 4)
DEF_SVE_GROUP_SUFFIX (vg4, 4, 4)
DEF_SVE_GROUP_SUFFIX (vg4x1, 4, 1)
DEF_SVE_GROUP_SUFFIX (vg4x2, 4, 2)
DEF_SVE_GROUP_SUFFIX (vg4x4, 4, 4)

#include "aarch64-sve-builtins-base.def"
#include "aarch64-sve-builtins-sve2.def"

#undef DEF_SVE_FUNCTION
#undef DEF_SVE_FUNCTION_GS
#undef DEF_SVE_FUNCTION_GS_FPM
#undef DEF_SVE_GROUP_SUFFIX
#undef DEF_SME_ZA_SUFFIX
#undef DEF_SVE_NEON_TYPE_SUFFIX
#undef DEF_SVE_TYPE_SUFFIX
#undef DEF_SVE_TYPE
#undef DEF_SVE_MODE
