190075Sobrien/* Generate from machine description: 290075Sobrien a series of #define statements, one for each constant named in 390075Sobrien a (define_constants ...) pattern. 490075Sobrien 5169689Skan Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003, 2004 6132718Skan Free Software Foundation, Inc. 790075Sobrien 890075SobrienThis file is part of GCC. 990075Sobrien 1090075SobrienGCC is free software; you can redistribute it and/or modify 1190075Sobrienit under the terms of the GNU General Public License as published by 1290075Sobrienthe Free Software Foundation; either version 2, or (at your option) 1390075Sobrienany later version. 1490075Sobrien 1590075SobrienGCC is distributed in the hope that it will be useful, 1690075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1790075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1890075SobrienGNU General Public License for more details. 1990075Sobrien 2090075SobrienYou should have received a copy of the GNU General Public License 2190075Sobrienalong with GCC; see the file COPYING. If not, write to 22169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 23169689SkanBoston, MA 02110-1301, USA. */ 2490075Sobrien 2590075Sobrien/* This program does not use gensupport.c because it does not need to 2690075Sobrien look at insn patterns, only (define_constants), and we want to 2790075Sobrien minimize dependencies. */ 2890075Sobrien 29132718Skan#include "bconfig.h" 3090075Sobrien#include "system.h" 31132718Skan#include "coretypes.h" 32132718Skan#include "tm.h" 3390075Sobrien#include "rtl.h" 3490075Sobrien#include "errors.h" 3590075Sobrien#include "gensupport.h" 3690075Sobrien 3790075Sobrien/* Called via traverse_md_constants; emit a #define for 3890075Sobrien the current constant definition. */ 3990075Sobrien 4090075Sobrienstatic int 41132718Skanprint_md_constant (void **slot, void *info) 4290075Sobrien{ 43169689Skan struct md_constant *def = (struct md_constant *) *slot; 44169689Skan FILE *file = (FILE *) info; 4590075Sobrien 4690075Sobrien fprintf (file, "#define %s %s\n", def->name, def->value); 4790075Sobrien return 1; 4890075Sobrien} 4990075Sobrien 5090075Sobrienint 51132718Skanmain (int argc, char **argv) 5290075Sobrien{ 5390075Sobrien progname = "genconstants"; 5490075Sobrien 55169689Skan if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) 5690075Sobrien return (FATAL_EXIT_CODE); 5790075Sobrien 58169689Skan /* Initializing the MD reader has the side effect of loading up 59169689Skan the constants table that we wish to scan. */ 6090075Sobrien 6190075Sobrien puts ("/* Generated automatically by the program `genconstants'"); 6290075Sobrien puts (" from the machine description file `md'. */\n"); 6390075Sobrien puts ("#ifndef GCC_INSN_CONSTANTS_H"); 6490075Sobrien puts ("#define GCC_INSN_CONSTANTS_H\n"); 6590075Sobrien 6690075Sobrien traverse_md_constants (print_md_constant, stdout); 6790075Sobrien 6890075Sobrien puts ("\n#endif /* GCC_INSN_CONSTANTS_H */"); 6990075Sobrien 7090075Sobrien if (ferror (stdout) || fflush (stdout) || fclose (stdout)) 7190075Sobrien return FATAL_EXIT_CODE; 7290075Sobrien 7390075Sobrien return SUCCESS_EXIT_CODE; 7490075Sobrien} 75