1/* Generate from machine description: 2 - some macros CODE_FOR_... giving the insn_code_number value 3 for each of the defined standard insn names. 4 Copyright (C) 1987-2015 Free Software Foundation, Inc. 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under 9the terms of the GNU General Public License as published by the Free 10Software Foundation; either version 3, or (at your option) any later 11version. 12 13GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14WARRANTY; without even the implied warranty of MERCHANTABILITY or 15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16for more details. 17 18You should have received a copy of the GNU General Public License 19along with GCC; see the file COPYING3. If not see 20<http://www.gnu.org/licenses/>. */ 21 22 23#include "bconfig.h" 24#include "system.h" 25#include "coretypes.h" 26#include "tm.h" 27#include "rtl.h" 28#include "errors.h" 29#include "gensupport.h" 30 31static void 32gen_insn (rtx insn, int code) 33{ 34 const char *name = XSTR (insn, 0); 35 int truth = maybe_eval_c_test (XSTR (insn, 2)); 36 37 /* Don't mention instructions whose names are the null string 38 or begin with '*'. They are in the machine description just 39 to be recognized. */ 40 if (name[0] != 0 && name[0] != '*') 41 { 42 if (truth == 0) 43 printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); 44 else 45 printf (" CODE_FOR_%s = %d,\n", name, code); 46 } 47} 48 49int 50main (int argc, char **argv) 51{ 52 rtx desc; 53 int last = 1; 54 55 progname = "gencodes"; 56 57 /* We need to see all the possibilities. Elided insns may have 58 direct references to CODE_FOR_xxx in C code. */ 59 insn_elision = 0; 60 61 if (!init_rtx_reader_args (argc, argv)) 62 return (FATAL_EXIT_CODE); 63 64 puts ("\ 65/* Generated automatically by the program `gencodes'\n\ 66 from the machine description file `md'. */\n\ 67\n\ 68#ifndef GCC_INSN_CODES_H\n\ 69#define GCC_INSN_CODES_H\n\ 70\n\ 71enum insn_code {\n\ 72 CODE_FOR_nothing = 0,\n"); 73 74 /* Read the machine description. */ 75 76 while (1) 77 { 78 int line_no; 79 int insn_code_number; 80 81 desc = read_md_rtx (&line_no, &insn_code_number); 82 if (desc == NULL) 83 break; 84 85 if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND) 86 { 87 gen_insn (desc, insn_code_number); 88 last = insn_code_number + 1; 89 } 90 } 91 92 printf (" LAST_INSN_CODE = %d\n\ 93};\n\ 94\n\ 95#endif /* GCC_INSN_CODES_H */\n", last); 96 97 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) 98 return FATAL_EXIT_CODE; 99 100 return SUCCESS_EXIT_CODE; 101} 102