xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/gencodes.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* Generate from machine description:
21debfc3dSmrg    - some macros CODE_FOR_... giving the insn_code_number value
31debfc3dSmrg    for each of the defined standard insn names.
4*8feb0f0bSmrg    Copyright (C) 1987-2020 Free Software Foundation, Inc.
51debfc3dSmrg 
61debfc3dSmrg This file is part of GCC.
71debfc3dSmrg 
81debfc3dSmrg GCC is free software; you can redistribute it and/or modify it under
91debfc3dSmrg the terms of the GNU General Public License as published by the Free
101debfc3dSmrg Software Foundation; either version 3, or (at your option) any later
111debfc3dSmrg version.
121debfc3dSmrg 
131debfc3dSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
141debfc3dSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
151debfc3dSmrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
161debfc3dSmrg for more details.
171debfc3dSmrg 
181debfc3dSmrg You should have received a copy of the GNU General Public License
191debfc3dSmrg along with GCC; see the file COPYING3.  If not see
201debfc3dSmrg <http://www.gnu.org/licenses/>.  */
211debfc3dSmrg 
221debfc3dSmrg 
231debfc3dSmrg #include "bconfig.h"
241debfc3dSmrg #include "system.h"
251debfc3dSmrg #include "coretypes.h"
261debfc3dSmrg #include "tm.h"
271debfc3dSmrg #include "rtl.h"
281debfc3dSmrg #include "errors.h"
291debfc3dSmrg #include "gensupport.h"
301debfc3dSmrg 
311debfc3dSmrg static void
gen_insn(md_rtx_info * info)321debfc3dSmrg gen_insn (md_rtx_info *info)
331debfc3dSmrg {
341debfc3dSmrg   const char *name = XSTR (info->def, 0);
351debfc3dSmrg   int truth = maybe_eval_c_test (XSTR (info->def, 2));
361debfc3dSmrg 
371debfc3dSmrg   /* Don't mention instructions whose names are the null string
381debfc3dSmrg      or begin with '*'.  They are in the machine description just
391debfc3dSmrg      to be recognized.  */
401debfc3dSmrg   if (name[0] != 0 && name[0] != '*')
411debfc3dSmrg     {
421debfc3dSmrg       if (truth == 0)
431debfc3dSmrg 	printf (",\n   CODE_FOR_%s = CODE_FOR_nothing", name);
441debfc3dSmrg       else
451debfc3dSmrg 	printf (",\n  CODE_FOR_%s = %d", name, info->index);
461debfc3dSmrg     }
471debfc3dSmrg }
481debfc3dSmrg 
491debfc3dSmrg int
main(int argc,const char ** argv)501debfc3dSmrg main (int argc, const char **argv)
511debfc3dSmrg {
521debfc3dSmrg   progname = "gencodes";
531debfc3dSmrg 
541debfc3dSmrg   /* We need to see all the possibilities.  Elided insns may have
551debfc3dSmrg      direct references to CODE_FOR_xxx in C code.  */
561debfc3dSmrg   insn_elision = 0;
571debfc3dSmrg 
581debfc3dSmrg   if (!init_rtx_reader_args (argc, argv))
591debfc3dSmrg     return (FATAL_EXIT_CODE);
601debfc3dSmrg 
611debfc3dSmrg   printf ("\
621debfc3dSmrg /* Generated automatically by the program `gencodes'\n\
631debfc3dSmrg    from the machine description file `md'.  */\n\
641debfc3dSmrg \n\
651debfc3dSmrg #ifndef GCC_INSN_CODES_H\n\
661debfc3dSmrg #define GCC_INSN_CODES_H\n\
671debfc3dSmrg \n\
681debfc3dSmrg enum insn_code {\n\
691debfc3dSmrg   CODE_FOR_nothing = 0");
701debfc3dSmrg 
711debfc3dSmrg   /* Read the machine description.  */
721debfc3dSmrg 
731debfc3dSmrg   md_rtx_info info;
741debfc3dSmrg   while (read_md_rtx (&info))
751debfc3dSmrg     switch (GET_CODE (info.def))
761debfc3dSmrg       {
771debfc3dSmrg       case DEFINE_INSN:
781debfc3dSmrg       case DEFINE_EXPAND:
791debfc3dSmrg 	gen_insn (&info);
801debfc3dSmrg 	break;
811debfc3dSmrg 
821debfc3dSmrg       default:
831debfc3dSmrg 	break;
841debfc3dSmrg     }
851debfc3dSmrg 
861debfc3dSmrg   printf ("\n};\n\
871debfc3dSmrg \n\
881debfc3dSmrg const unsigned int NUM_INSN_CODES = %d;\n\
891debfc3dSmrg #endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ());
901debfc3dSmrg 
911debfc3dSmrg   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
921debfc3dSmrg     return FATAL_EXIT_CODE;
931debfc3dSmrg 
941debfc3dSmrg   return SUCCESS_EXIT_CODE;
951debfc3dSmrg }
96