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, 1991, 1995, 1998, 5 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. 6 7This file is part of GCC. 8 9GCC is free software; you can redistribute it and/or modify it under 10the terms of the GNU General Public License as published by the Free 11Software Foundation; either version 2, or (at your option) any later 12version. 13 14GCC is distributed in the hope that it will be useful, but WITHOUT ANY 15WARRANTY; without even the implied warranty of MERCHANTABILITY or 16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17for more details. 18 19You should have received a copy of the GNU General Public License 20along with GCC; see the file COPYING. If not, write to the Free 21Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2202110-1301, USA. */ 23 24 25#include "bconfig.h" 26#include "system.h" 27#include "coretypes.h" 28#include "tm.h" 29#include "rtl.h" 30#include "errors.h" 31#include "gensupport.h" 32 33static void 34gen_insn (rtx insn, int code) 35{ 36 const char *name = XSTR (insn, 0); 37 int truth = maybe_eval_c_test (XSTR (insn, 2)); 38 39 /* Don't mention instructions whose names are the null string 40 or begin with '*'. They are in the machine description just 41 to be recognized. */ 42 if (name[0] != 0 && name[0] != '*') 43 { 44 if (truth == 0) 45 printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); 46 else 47 printf (" CODE_FOR_%s = %d,\n", name, code); 48 } 49} 50 51int 52main (int argc, char **argv) 53{ 54 rtx desc; 55 56 progname = "gencodes"; 57 58 /* We need to see all the possibilities. Elided insns may have 59 direct references to CODE_FOR_xxx in C code. */ 60 insn_elision = 0; 61 62 if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) 63 return (FATAL_EXIT_CODE); 64 65 puts ("\ 66/* Generated automatically by the program `gencodes'\n\ 67 from the machine description file `md'. */\n\ 68\n\ 69#ifndef GCC_INSN_CODES_H\n\ 70#define GCC_INSN_CODES_H\n\ 71\n\ 72enum insn_code {"); 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 gen_insn (desc, insn_code_number); 87 } 88 89 puts (" CODE_FOR_nothing\n\ 90};\n\ 91\n\ 92#endif /* GCC_INSN_CODES_H */"); 93 94 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) 95 return FATAL_EXIT_CODE; 96 97 return SUCCESS_EXIT_CODE; 98} 99 100/* Define this so we can link with print-rtl.o to get debug_rtx function. */ 101 102const char * 103get_insn_name (int code ATTRIBUTE_UNUSED) 104{ 105 return NULL; 106} 107