/* Generated automatically by "genstr" from "isa-evolution.in".
   Please do not edit this file directly.

   Copyright (C) 2023-2024 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 LOONGARCH_EVOLUTION_H
#define LOONGARCH_EVOLUTION_H

#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS)

#include "options.h"

static constexpr struct {
  int cpucfg_word;
  unsigned int cpucfg_bit;
  HOST_WIDE_INT isa_evolution_bit;
} cpucfg_map[] = {
  { 2, 1u << 25, OPTION_MASK_ISA_FRECIPE },
  { 2, 1u << 26, OPTION_MASK_ISA_DIV32 },
  { 2, 1u << 27, OPTION_MASK_ISA_LAM_BH },
  { 2, 1u << 28, OPTION_MASK_ISA_LAMCAS },
  { 3, 1u << 23, OPTION_MASK_ISA_LD_SEQ_SA },
};

static constexpr int cpucfg_useful_idx[] = {
  0,
  1,
  2,
  3,
  16,
  17,
  18,
  19,
};

static constexpr int N_CPUCFG_WORDS = 20;

/* ISA evolution features */
enum {
  EVO_FRECIPE = 0,
  EVO_DIV32 = 1,
  EVO_LAM_BH = 2,
  EVO_LAMCAS = 3,
  EVO_LD_SEQ_SA = 4,
  N_EVO_FEATURES = 5
};

/* Condition macros */
#define ISA_HAS_FRECIPE \
  (la_target.isa.evolution & OPTION_MASK_ISA_FRECIPE)
#define ISA_HAS_DIV32 \
  (la_target.isa.evolution & OPTION_MASK_ISA_DIV32)
#define ISA_HAS_LAM_BH \
  (la_target.isa.evolution & OPTION_MASK_ISA_LAM_BH)
#define ISA_HAS_LAMCAS \
  (la_target.isa.evolution & OPTION_MASK_ISA_LAMCAS)
#define ISA_HAS_LD_SEQ_SA \
  (la_target.isa.evolution & OPTION_MASK_ISA_LD_SEQ_SA)

/* Bitmasks on la_target.isa.evolution.  */
extern int la_evo_feature_masks[N_EVO_FEATURES];

/* Builtin macro names for the evolution features.  */
extern const char* la_evo_macro_name[N_EVO_FEATURES];

/* The ISA version where a specific feature is introduced.  */
extern int la_evo_version_major[N_EVO_FEATURES];
extern int la_evo_version_minor[N_EVO_FEATURES];

#endif

#endif /* LOONGARCH_EVOLUTION_H */
