Mercurial > hg > CbC > CbC_gcc
comparison gcc/genpreds.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Generate from machine description: | 1 /* Generate from machine description: |
2 - prototype declarations for operand predicates (tm-preds.h) | 2 - prototype declarations for operand predicates (tm-preds.h) |
3 - function definitions of operand predicates, if defined new-style | 3 - function definitions of operand predicates, if defined new-style |
4 (insn-preds.c) | 4 (insn-preds.c) |
5 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 | 5 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
6 Free Software Foundation, Inc. | 6 Free Software Foundation, Inc. |
7 | 7 |
8 This file is part of GCC. | 8 This file is part of GCC. |
9 | 9 |
10 GCC is free software; you can redistribute it and/or modify | 10 GCC is free software; you can redistribute it and/or modify |
26 #include "coretypes.h" | 26 #include "coretypes.h" |
27 #include "tm.h" | 27 #include "tm.h" |
28 #include "rtl.h" | 28 #include "rtl.h" |
29 #include "errors.h" | 29 #include "errors.h" |
30 #include "obstack.h" | 30 #include "obstack.h" |
31 #include "read-md.h" | |
31 #include "gensupport.h" | 32 #include "gensupport.h" |
32 | 33 |
33 /* Given a predicate expression EXP, from form NAME at line LINENO, | 34 /* Given a predicate expression EXP, from form NAME at line LINENO, |
34 verify that it does not contain any RTL constructs which are not | 35 verify that it does not contain any RTL constructs which are not |
35 valid in predicate definitions. Returns true if EXP is | 36 valid in predicate definitions. Returns true if EXP is |
64 const char *p; | 65 const char *p; |
65 for (p = XSTR (exp, 1); *p; p++) | 66 for (p = XSTR (exp, 1); *p; p++) |
66 { | 67 { |
67 if (!ISDIGIT (*p) && !ISLOWER (*p)) | 68 if (!ISDIGIT (*p) && !ISLOWER (*p)) |
68 { | 69 { |
69 message_with_line (lineno, "%s: invalid character in path " | 70 error_with_line (lineno, "%s: invalid character in path " |
70 "string '%s'", name, XSTR (exp, 1)); | 71 "string '%s'", name, XSTR (exp, 1)); |
71 have_error = 1; | |
72 return true; | 72 return true; |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 /* fall through */ | 76 /* fall through */ |
79 case MATCH_OPERAND: | 79 case MATCH_OPERAND: |
80 case MATCH_TEST: | 80 case MATCH_TEST: |
81 return false; | 81 return false; |
82 | 82 |
83 default: | 83 default: |
84 message_with_line (lineno, | 84 error_with_line (lineno, |
85 "%s: cannot use '%s' in a predicate expression", | 85 "%s: cannot use '%s' in a predicate expression", |
86 name, GET_RTX_NAME (GET_CODE (exp))); | 86 name, GET_RTX_NAME (GET_CODE (exp))); |
87 have_error = 1; | |
88 return true; | 87 return true; |
89 } | 88 } |
90 } | 89 } |
91 | 90 |
92 /* Predicates are defined with (define_predicate) or | 91 /* Predicates are defined with (define_predicate) or |
116 | 115 |
117 add_predicate (pred); | 116 add_predicate (pred); |
118 return; | 117 return; |
119 | 118 |
120 bad_name: | 119 bad_name: |
121 message_with_line (lineno, | 120 error_with_line (lineno, |
122 "%s: predicate name must be a valid C function name", | 121 "%s: predicate name must be a valid C function name", |
123 XSTR (defn, 0)); | 122 XSTR (defn, 0)); |
124 have_error = 1; | |
125 return; | 123 return; |
126 } | 124 } |
127 | 125 |
128 /* Given a predicate, if it has an embedded C block, write the block | 126 /* Given a predicate, if it has an embedded C block, write the block |
129 out as a static inline subroutine, and augment the RTL test with a | 127 out as a static inline subroutine, and augment the RTL test with a |
181 p->exp = and_exp; | 179 p->exp = and_exp; |
182 | 180 |
183 printf ("static inline int\n" | 181 printf ("static inline int\n" |
184 "%s_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)\n", | 182 "%s_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)\n", |
185 p->name); | 183 p->name); |
186 print_rtx_ptr_loc (p->c_block); | 184 print_md_ptr_loc (p->c_block); |
187 if (p->c_block[0] == '{') | 185 if (p->c_block[0] == '{') |
188 fputs (p->c_block, stdout); | 186 fputs (p->c_block, stdout); |
189 else | 187 else |
190 printf ("{\n %s\n}", p->c_block); | 188 printf ("{\n %s\n}", p->c_block); |
191 fputs ("\n\n", stdout); | 189 fputs ("\n\n", stdout); |
762 return; | 760 return; |
763 | 761 |
764 if (!ISALPHA (name[0]) && name[0] != '_') | 762 if (!ISALPHA (name[0]) && name[0] != '_') |
765 { | 763 { |
766 if (name[1] == '\0') | 764 if (name[1] == '\0') |
767 message_with_line (lineno, "constraint name '%s' is not " | 765 error_with_line (lineno, "constraint name '%s' is not " |
768 "a letter or underscore", name); | 766 "a letter or underscore", name); |
769 else | 767 else |
770 message_with_line (lineno, "constraint name '%s' does not begin " | 768 error_with_line (lineno, "constraint name '%s' does not begin " |
771 "with a letter or underscore", name); | 769 "with a letter or underscore", name); |
772 have_error = 1; | |
773 return; | 770 return; |
774 } | 771 } |
775 for (p = name; *p; p++) | 772 for (p = name; *p; p++) |
776 if (!ISALNUM (*p)) | 773 if (!ISALNUM (*p)) |
777 { | 774 { |
778 if (*p == '<' || *p == '>' || *p == '_') | 775 if (*p == '<' || *p == '>' || *p == '_') |
779 need_mangled_name = true; | 776 need_mangled_name = true; |
780 else | 777 else |
781 { | 778 { |
782 message_with_line (lineno, | 779 error_with_line (lineno, |
783 "constraint name '%s' must be composed of " | 780 "constraint name '%s' must be composed of " |
784 "letters, digits, underscores, and " | 781 "letters, digits, underscores, and " |
785 "angle brackets", name); | 782 "angle brackets", name); |
786 have_error = 1; | |
787 return; | 783 return; |
788 } | 784 } |
789 } | 785 } |
790 | 786 |
791 if (strchr (generic_constraint_letters, name[0])) | 787 if (strchr (generic_constraint_letters, name[0])) |
792 { | 788 { |
793 if (name[1] == '\0') | 789 if (name[1] == '\0') |
794 message_with_line (lineno, "constraint letter '%s' cannot be " | 790 error_with_line (lineno, "constraint letter '%s' cannot be " |
795 "redefined by the machine description", name); | 791 "redefined by the machine description", name); |
796 else | 792 else |
797 message_with_line (lineno, "constraint name '%s' cannot be defined by " | 793 error_with_line (lineno, "constraint name '%s' cannot be defined by " |
798 "the machine description, as it begins with '%c'", | 794 "the machine description, as it begins with '%c'", |
799 name, name[0]); | 795 name, name[0]); |
800 have_error = 1; | |
801 return; | 796 return; |
802 } | 797 } |
803 | 798 |
804 | 799 |
805 namelen = strlen (name); | 800 namelen = strlen (name); |
814 if ((*iter)->namelen >= namelen) | 809 if ((*iter)->namelen >= namelen) |
815 slot = iter; | 810 slot = iter; |
816 | 811 |
817 if (!strcmp ((*iter)->name, name)) | 812 if (!strcmp ((*iter)->name, name)) |
818 { | 813 { |
819 message_with_line (lineno, "redefinition of constraint '%s'", name); | 814 error_with_line (lineno, "redefinition of constraint '%s'", name); |
820 message_with_line ((*iter)->lineno, "previous definition is here"); | 815 message_with_line ((*iter)->lineno, "previous definition is here"); |
821 have_error = 1; | |
822 return; | 816 return; |
823 } | 817 } |
824 else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) | 818 else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) |
825 { | 819 { |
826 message_with_line (lineno, "defining constraint '%s' here", name); | 820 error_with_line (lineno, "defining constraint '%s' here", name); |
827 message_with_line ((*iter)->lineno, "renders constraint '%s' " | 821 message_with_line ((*iter)->lineno, "renders constraint '%s' " |
828 "(defined here) a prefix", (*iter)->name); | 822 "(defined here) a prefix", (*iter)->name); |
829 have_error = 1; | |
830 return; | 823 return; |
831 } | 824 } |
832 else if (!strncmp ((*iter)->name, name, namelen)) | 825 else if (!strncmp ((*iter)->name, name, namelen)) |
833 { | 826 { |
834 message_with_line (lineno, "constraint '%s' is a prefix", name); | 827 error_with_line (lineno, "constraint '%s' is a prefix", name); |
835 message_with_line ((*iter)->lineno, "of constraint '%s' " | 828 message_with_line ((*iter)->lineno, "of constraint '%s' " |
836 "(defined here)", (*iter)->name); | 829 "(defined here)", (*iter)->name); |
837 have_error = 1; | |
838 return; | 830 return; |
839 } | 831 } |
840 } | 832 } |
841 | 833 |
842 is_const_int = strchr (const_int_constraints, name[0]) != 0; | 834 is_const_int = strchr (const_int_constraints, name[0]) != 0; |
853 || GET_CODE (XEXP (exp, 0)) != MATCH_CODE | 845 || GET_CODE (XEXP (exp, 0)) != MATCH_CODE |
854 || strcmp (XSTR (XEXP (exp, 0), 0), | 846 || strcmp (XSTR (XEXP (exp, 0), 0), |
855 GET_RTX_NAME (appropriate_code))) | 847 GET_RTX_NAME (appropriate_code))) |
856 { | 848 { |
857 if (name[1] == '\0') | 849 if (name[1] == '\0') |
858 message_with_line (lineno, "constraint letter '%c' is reserved " | 850 error_with_line (lineno, "constraint letter '%c' is reserved " |
859 "for %s constraints", | 851 "for %s constraints", |
860 name[0], GET_RTX_NAME (appropriate_code)); | 852 name[0], GET_RTX_NAME (appropriate_code)); |
861 else | 853 else |
862 message_with_line (lineno, "constraint names beginning with '%c' " | 854 error_with_line (lineno, "constraint names beginning with '%c' " |
863 "(%s) are reserved for %s constraints", | 855 "(%s) are reserved for %s constraints", |
864 name[0], name, | 856 name[0], name, GET_RTX_NAME (appropriate_code)); |
865 GET_RTX_NAME (appropriate_code)); | |
866 | |
867 have_error = 1; | |
868 return; | 857 return; |
869 } | 858 } |
870 | 859 |
871 if (is_memory) | 860 if (is_memory) |
872 { | 861 { |
873 if (name[1] == '\0') | 862 if (name[1] == '\0') |
874 message_with_line (lineno, "constraint letter '%c' cannot be a " | 863 error_with_line (lineno, "constraint letter '%c' cannot be a " |
875 "memory constraint", name[0]); | 864 "memory constraint", name[0]); |
876 else | 865 else |
877 message_with_line (lineno, "constraint name '%s' begins with '%c', " | 866 error_with_line (lineno, "constraint name '%s' begins with '%c', " |
878 "and therefore cannot be a memory constraint", | 867 "and therefore cannot be a memory constraint", |
879 name, name[0]); | 868 name, name[0]); |
880 | |
881 have_error = 1; | |
882 return; | 869 return; |
883 } | 870 } |
884 else if (is_address) | 871 else if (is_address) |
885 { | 872 { |
886 if (name[1] == '\0') | 873 if (name[1] == '\0') |
887 message_with_line (lineno, "constraint letter '%c' cannot be a " | 874 error_with_line (lineno, "constraint letter '%c' cannot be a " |
888 "memory constraint", name[0]); | 875 "memory constraint", name[0]); |
889 else | 876 else |
890 message_with_line (lineno, "constraint name '%s' begins with '%c', " | 877 error_with_line (lineno, "constraint name '%s' begins with '%c', " |
891 "and therefore cannot be a memory constraint", | 878 "and therefore cannot be a memory constraint", |
892 name, name[0]); | 879 name, name[0]); |
893 | |
894 have_error = 1; | |
895 return; | 880 return; |
896 } | 881 } |
897 } | 882 } |
898 | 883 |
899 | 884 |
1350 #include \"recog.h\"\n\ | 1335 #include \"recog.h\"\n\ |
1351 #include \"output.h\"\n\ | 1336 #include \"output.h\"\n\ |
1352 #include \"flags.h\"\n\ | 1337 #include \"flags.h\"\n\ |
1353 #include \"hard-reg-set.h\"\n\ | 1338 #include \"hard-reg-set.h\"\n\ |
1354 #include \"resource.h\"\n\ | 1339 #include \"resource.h\"\n\ |
1355 #include \"toplev.h\"\n\ | 1340 #include \"diagnostic-core.h\"\n\ |
1356 #include \"reload.h\"\n\ | 1341 #include \"reload.h\"\n\ |
1357 #include \"regs.h\"\n\ | 1342 #include \"regs.h\"\n\ |
1358 #include \"tm-constrs.h\"\n"); | 1343 #include \"tm-constrs.h\"\n"); |
1359 | 1344 |
1360 FOR_ALL_PREDICATES (p) | 1345 FOR_ALL_PREDICATES (p) |
1406 int pattern_lineno, next_insn_code = 0; | 1391 int pattern_lineno, next_insn_code = 0; |
1407 | 1392 |
1408 progname = argv[0]; | 1393 progname = argv[0]; |
1409 if (argc <= 1) | 1394 if (argc <= 1) |
1410 fatal ("no input file name"); | 1395 fatal ("no input file name"); |
1411 if (init_md_reader_args_cb (argc, argv, parse_option) != SUCCESS_EXIT_CODE) | 1396 if (!init_rtx_reader_args_cb (argc, argv, parse_option)) |
1412 return FATAL_EXIT_CODE; | 1397 return FATAL_EXIT_CODE; |
1413 | 1398 |
1414 while ((defn = read_md_rtx (&pattern_lineno, &next_insn_code)) != 0) | 1399 while ((defn = read_md_rtx (&pattern_lineno, &next_insn_code)) != 0) |
1415 switch (GET_CODE (defn)) | 1400 switch (GET_CODE (defn)) |
1416 { | 1401 { |