Mercurial > hg > CbC > CbC_gcc
comparison gcc/gencodes.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Generate from machine description: | 1 /* Generate from machine description: |
2 - some macros CODE_FOR_... giving the insn_code_number value | 2 - some macros CODE_FOR_... giving the insn_code_number value |
3 for each of the defined standard insn names. | 3 for each of the defined standard insn names. |
4 Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003, | 4 Copyright (C) 1987-2017 Free Software Foundation, Inc. |
5 2004, 2007, 2010 Free Software Foundation, Inc. | |
6 | 5 |
7 This file is part of GCC. | 6 This file is part of GCC. |
8 | 7 |
9 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
10 the terms of the GNU General Public License as published by the Free | 9 the terms of the GNU General Public License as published by the Free |
28 #include "rtl.h" | 27 #include "rtl.h" |
29 #include "errors.h" | 28 #include "errors.h" |
30 #include "gensupport.h" | 29 #include "gensupport.h" |
31 | 30 |
32 static void | 31 static void |
33 gen_insn (rtx insn, int code) | 32 gen_insn (md_rtx_info *info) |
34 { | 33 { |
35 const char *name = XSTR (insn, 0); | 34 const char *name = XSTR (info->def, 0); |
36 int truth = maybe_eval_c_test (XSTR (insn, 2)); | 35 int truth = maybe_eval_c_test (XSTR (info->def, 2)); |
37 | 36 |
38 /* Don't mention instructions whose names are the null string | 37 /* Don't mention instructions whose names are the null string |
39 or begin with '*'. They are in the machine description just | 38 or begin with '*'. They are in the machine description just |
40 to be recognized. */ | 39 to be recognized. */ |
41 if (name[0] != 0 && name[0] != '*') | 40 if (name[0] != 0 && name[0] != '*') |
42 { | 41 { |
43 if (truth == 0) | 42 if (truth == 0) |
44 printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); | 43 printf (",\n CODE_FOR_%s = CODE_FOR_nothing", name); |
45 else | 44 else |
46 printf (" CODE_FOR_%s = %d,\n", name, code); | 45 printf (",\n CODE_FOR_%s = %d", name, info->index); |
47 } | 46 } |
48 } | 47 } |
49 | 48 |
50 int | 49 int |
51 main (int argc, char **argv) | 50 main (int argc, const char **argv) |
52 { | 51 { |
53 rtx desc; | |
54 | |
55 progname = "gencodes"; | 52 progname = "gencodes"; |
56 | 53 |
57 /* We need to see all the possibilities. Elided insns may have | 54 /* We need to see all the possibilities. Elided insns may have |
58 direct references to CODE_FOR_xxx in C code. */ | 55 direct references to CODE_FOR_xxx in C code. */ |
59 insn_elision = 0; | 56 insn_elision = 0; |
60 | 57 |
61 if (!init_rtx_reader_args (argc, argv)) | 58 if (!init_rtx_reader_args (argc, argv)) |
62 return (FATAL_EXIT_CODE); | 59 return (FATAL_EXIT_CODE); |
63 | 60 |
64 puts ("\ | 61 printf ("\ |
65 /* Generated automatically by the program `gencodes'\n\ | 62 /* Generated automatically by the program `gencodes'\n\ |
66 from the machine description file `md'. */\n\ | 63 from the machine description file `md'. */\n\ |
67 \n\ | 64 \n\ |
68 #ifndef GCC_INSN_CODES_H\n\ | 65 #ifndef GCC_INSN_CODES_H\n\ |
69 #define GCC_INSN_CODES_H\n\ | 66 #define GCC_INSN_CODES_H\n\ |
70 \n\ | 67 \n\ |
71 enum insn_code {"); | 68 enum insn_code {\n\ |
69 CODE_FOR_nothing = 0"); | |
72 | 70 |
73 /* Read the machine description. */ | 71 /* Read the machine description. */ |
74 | 72 |
75 while (1) | 73 md_rtx_info info; |
76 { | 74 while (read_md_rtx (&info)) |
77 int line_no; | 75 switch (GET_CODE (info.def)) |
78 int insn_code_number; | 76 { |
79 | 77 case DEFINE_INSN: |
80 desc = read_md_rtx (&line_no, &insn_code_number); | 78 case DEFINE_EXPAND: |
81 if (desc == NULL) | 79 gen_insn (&info); |
82 break; | 80 break; |
83 | 81 |
84 if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND) | 82 default: |
85 gen_insn (desc, insn_code_number); | 83 break; |
86 } | 84 } |
87 | 85 |
88 puts (" CODE_FOR_nothing\n\ | 86 printf ("\n};\n\ |
89 };\n\ | |
90 \n\ | 87 \n\ |
91 #endif /* GCC_INSN_CODES_H */"); | 88 const unsigned int NUM_INSN_CODES = %d;\n\ |
89 #endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ()); | |
92 | 90 |
93 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | 91 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) |
94 return FATAL_EXIT_CODE; | 92 return FATAL_EXIT_CODE; |
95 | 93 |
96 return SUCCESS_EXIT_CODE; | 94 return SUCCESS_EXIT_CODE; |