152845Sphk/* Generate from machine description: 252845Sphk - some macros CODE_FOR_... giving the insn_code_number value 352845Sphk for each of the defined standard insn names. 452845Sphk Copyright (C) 1987, 1991, 1995, 1998, 552845Sphk 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. 652845Sphk 752845SphkThis file is part of GCC. 852845Sphk 952845SphkGCC is free software; you can redistribute it and/or modify it under 1052845Sphkthe terms of the GNU General Public License as published by the Free 1152845SphkSoftware Foundation; either version 2, or (at your option) any later 1252845Sphkversion. 1352845Sphk 1452845SphkGCC is distributed in the hope that it will be useful, but WITHOUT ANY 1552845SphkWARRANTY; without even the implied warranty of MERCHANTABILITY or 1652845SphkFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1752845Sphkfor more details. 1852845Sphk 1952845SphkYou should have received a copy of the GNU General Public License 2052845Sphkalong with GCC; see the file COPYING. If not, write to the Free 2152845SphkSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2252845Sphk02110-1301, USA. */ 2352845Sphk 2452845Sphk 2552845Sphk#include "bconfig.h" 2652845Sphk#include "system.h" 2752845Sphk#include "coretypes.h" 2852845Sphk#include "tm.h" 2952845Sphk#include "rtl.h" 3052845Sphk#include "errors.h" 3152845Sphk#include "gensupport.h" 3252845Sphk 33116189Sobrienstatic void 34116189Sobriengen_insn (rtx insn, int code) 35116189Sobrien{ 3652845Sphk const char *name = XSTR (insn, 0); 3752845Sphk int truth = maybe_eval_c_test (XSTR (insn, 2)); 3852845Sphk 39114216Skan /* Don't mention instructions whose names are the null string 4052845Sphk or begin with '*'. They are in the machine description just 4152845Sphk to be recognized. */ 4252845Sphk if (name[0] != 0 && name[0] != '*') 4352845Sphk { 4452845Sphk if (truth == 0) 4552845Sphk printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); 4652845Sphk else 4752845Sphk printf (" CODE_FOR_%s = %d,\n", name, code); 4853648Sarchie } 4952845Sphk} 5052845Sphk 5152845Sphkint 5252845Sphkmain (int argc, char **argv) 5352845Sphk{ 5452845Sphk rtx desc; 5552845Sphk 5652845Sphk progname = "gencodes"; 5752845Sphk 5852845Sphk /* We need to see all the possibilities. Elided insns may have 5952845Sphk direct references to CODE_FOR_xxx in C code. */ 6052845Sphk insn_elision = 0; 6152845Sphk 6252845Sphk if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) 6352845Sphk return (FATAL_EXIT_CODE); 6452845Sphk 6552845Sphk puts ("\ 6652845Sphk/* Generated automatically by the program `gencodes'\n\ 6752845Sphk from the machine description file `md'. */\n\ 6852845Sphk\n\ 6952845Sphk#ifndef GCC_INSN_CODES_H\n\ 7052845Sphk#define GCC_INSN_CODES_H\n\ 7152845Sphk\n\ 7252845Sphkenum insn_code {"); 7352845Sphk 7452845Sphk /* Read the machine description. */ 7552845Sphk 7652845Sphk while (1) 7752845Sphk { 7852845Sphk int line_no; 7952845Sphk int insn_code_number; 8052845Sphk 8152845Sphk desc = read_md_rtx (&line_no, &insn_code_number); 8252845Sphk if (desc == NULL) 8352845Sphk break; 8452845Sphk 8552845Sphk if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND) 8652845Sphk gen_insn (desc, insn_code_number); 8752845Sphk } 8852845Sphk 8952845Sphk puts (" CODE_FOR_nothing\n\ 9052845Sphk};\n\ 9152845Sphk\n\ 9252845Sphk#endif /* GCC_INSN_CODES_H */"); 9352845Sphk 9452845Sphk if (ferror (stdout) || fflush (stdout) || fclose (stdout)) 9552845Sphk return FATAL_EXIT_CODE; 9652845Sphk 9752845Sphk return SUCCESS_EXIT_CODE; 9852845Sphk} 9952845Sphk