2 Copyright (C) 1987-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
22 #include "coretypes.h"
24 #include "statistics.h"
28 /* Associates PTR (which can be a string, etc.) with the file location
29 specified by FILENAME and LINENO. */
36 /* This callback will be invoked whenever an md include directive is
37 processed. To be used for creation of the dependency file. */
38 void (*include_callback
) (const char *);
40 /* Global singleton. */
42 rtx_reader
*rtx_reader_ptr
;
44 /* Given an object that starts with a char * name field, return a hash
48 leading_string_hash (const void *def
)
50 return htab_hash_string (*(const char *const *) def
);
53 /* Given two objects that start with char * name fields, return true if
54 they have the same name. */
57 leading_string_eq_p (const void *def1
, const void *def2
)
59 return strcmp (*(const char *const *) def1
,
60 *(const char *const *) def2
) == 0;
63 /* Return a hash value for the pointer pointed to by DEF. */
66 leading_ptr_hash (const void *def
)
68 return htab_hash_pointer (*(const void *const *) def
);
71 /* Return true if DEF1 and DEF2 are pointers to the same pointer. */
74 leading_ptr_eq_p (const void *def1
, const void *def2
)
76 return *(const void *const *) def1
== *(const void *const *) def2
;
79 /* Associate PTR with the file position given by FILENAME and LINENO. */
82 rtx_reader::set_md_ptr_loc (const void *ptr
, const char *filename
, int lineno
)
86 loc
= (struct ptr_loc
*) obstack_alloc (&m_ptr_loc_obstack
,
87 sizeof (struct ptr_loc
));
89 loc
->filename
= filename
;
91 *htab_find_slot (m_ptr_locs
, loc
, INSERT
) = loc
;
94 /* Return the position associated with pointer PTR. Return null if no
97 const struct ptr_loc
*
98 rtx_reader::get_md_ptr_loc (const void *ptr
)
100 return (const struct ptr_loc
*) htab_find (m_ptr_locs
, &ptr
);
103 /* Associate NEW_PTR with the same file position as OLD_PTR. */
106 rtx_reader::copy_md_ptr_loc (const void *new_ptr
, const void *old_ptr
)
108 const struct ptr_loc
*loc
= get_md_ptr_loc (old_ptr
);
110 set_md_ptr_loc (new_ptr
, loc
->filename
, loc
->lineno
);
113 /* If PTR is associated with a known file position, print a #line
114 directive for it to OUTF. */
117 rtx_reader::fprint_md_ptr_loc (FILE *outf
, const void *ptr
)
119 const struct ptr_loc
*loc
= get_md_ptr_loc (ptr
);
121 fprintf (outf
, "#line %d \"%s\"\n", loc
->lineno
, loc
->filename
);
124 /* Special fprint_md_ptr_loc for writing to STDOUT. */
126 rtx_reader::print_md_ptr_loc (const void *ptr
)
128 fprint_md_ptr_loc (stdout
, ptr
);
131 /* Return a condition that satisfies both COND1 and COND2. Either string
132 may be null or empty. */
135 rtx_reader::join_c_conditions (const char *cond1
, const char *cond2
)
140 if (cond1
== 0 || cond1
[0] == 0)
143 if (cond2
== 0 || cond2
[0] == 0)
146 if (strcmp (cond1
, cond2
) == 0)
149 result
= concat ("(", cond1
, ") && (", cond2
, ")", NULL
);
150 obstack_ptr_grow (&m_joined_conditions_obstack
, result
);
151 obstack_ptr_grow (&m_joined_conditions_obstack
, cond1
);
152 obstack_ptr_grow (&m_joined_conditions_obstack
, cond2
);
153 entry
= XOBFINISH (&m_joined_conditions_obstack
, const void **);
154 *htab_find_slot (m_joined_conditions
, entry
, INSERT
) = entry
;
158 /* Print condition COND to OUTF, wrapped in brackets. If COND was created
159 by join_c_conditions, recursively invoke this function for the original
160 conditions and join the result with "&&". Otherwise print a #line
161 directive for COND if its original file position is known. */
164 rtx_reader::fprint_c_condition (FILE *outf
, const char *cond
)
166 const char **halves
= (const char **) htab_find (m_joined_conditions
, &cond
);
170 fprint_c_condition (outf
, halves
[1]);
171 fprintf (outf
, " && ");
172 fprint_c_condition (outf
, halves
[2]);
178 fprint_md_ptr_loc (outf
, cond
);
179 fprintf (outf
, "(%s)", cond
);
183 /* Special fprint_c_condition for writing to STDOUT. */
186 rtx_reader::print_c_condition (const char *cond
)
188 fprint_c_condition (stdout
, cond
);
191 /* A vfprintf-like function for reporting an error against line LINENO
192 of the current MD file. */
194 static void ATTRIBUTE_PRINTF(2,0)
195 message_at_1 (file_location loc
, const char *msg
, va_list ap
)
197 fprintf (stderr
, "%s:%d:%d: ", loc
.filename
, loc
.lineno
, loc
.colno
);
198 vfprintf (stderr
, msg
, ap
);
199 fputc ('\n', stderr
);
202 /* A printf-like function for reporting a message against location LOC. */
205 message_at (file_location loc
, const char *msg
, ...)
210 message_at_1 (loc
, msg
, ap
);
214 /* Like message_at, but treat the condition as an error. */
217 error_at (file_location loc
, const char *msg
, ...)
222 message_at_1 (loc
, msg
, ap
);
227 /* Like message_at, but treat the condition as a fatal error. */
230 fatal_at (file_location loc
, const char *msg
, ...)
235 message_at_1 (loc
, msg
, ap
);
240 /* A printf-like function for reporting an error against the current
241 position in the MD file. */
244 fatal_with_file_and_line (const char *msg
, ...)
253 fprintf (stderr
, "%s:%d:%d: error: ", rtx_reader_ptr
->get_filename (),
254 rtx_reader_ptr
->get_lineno (), rtx_reader_ptr
->get_colno ());
255 vfprintf (stderr
, msg
, ap
);
258 /* Gather some following context. */
259 for (i
= 0; i
< sizeof (context
)-1; ++i
)
264 if (c
== '\r' || c
== '\n')
273 fprintf (stderr
, "%s:%d:%d: note: following context is `%s'\n",
274 rtx_reader_ptr
->get_filename (), rtx_reader_ptr
->get_lineno (),
275 rtx_reader_ptr
->get_colno (), context
);
281 /* Report that we found character ACTUAL when we expected to find
282 character EXPECTED. */
285 fatal_expected_char (int expected
, int actual
)
288 fatal_with_file_and_line ("expected character `%c', found EOF",
291 fatal_with_file_and_line ("expected character `%c', found `%c'",
295 /* Read chars from the MD file until a non-whitespace char and return that.
296 Comments, both Lisp style and C style, are treated as whitespace. */
299 read_skip_spaces (void)
308 case ' ': case '\t': case '\f': case '\r': case '\n':
314 while (c
!= '\n' && c
!= EOF
);
324 fatal_with_file_and_line ("stray '/' in file");
328 while ((c
= read_char ()) && c
!= EOF
)
330 if (prevc
== '*' && c
== '/')
343 /* Consume any whitespace, then consume the next non-whitespace
344 character, issuing a fatal error if it is not EXPECTED. */
347 require_char_ws (char expected
)
349 int ch
= read_skip_spaces ();
351 fatal_expected_char (expected
, ch
);
354 /* Read the next character from the file. */
357 rtx_reader::read_char (void)
361 ch
= getc (m_read_md_file
);
365 m_last_line_colno
= m_read_md_colno
;
374 /* Put back CH, which was the last character read from the file. */
377 rtx_reader::unread_char (int ch
)
382 m_read_md_colno
= m_last_line_colno
;
386 ungetc (ch
, m_read_md_file
);
389 /* Read an rtx code name into NAME. It is terminated by any of the
390 punctuation chars of rtx printed syntax. */
393 rtx_reader::read_name (struct md_name
*name
)
397 int angle_bracket_depth
;
399 c
= read_skip_spaces ();
402 angle_bracket_depth
= 0;
406 angle_bracket_depth
++;
408 if ((c
== '>') && (angle_bracket_depth
> 0))
409 angle_bracket_depth
--;
411 if (c
== ' ' || c
== '\n' || c
== '\t' || c
== '\f' || c
== '\r'
414 if (angle_bracket_depth
== 0)
416 if (c
== ':' || c
== ')' || c
== ']'
417 || c
== '"' || c
== '/' || c
== '(' || c
== '[')
424 if (i
== sizeof (name
->buffer
) - 1)
425 fatal_with_file_and_line ("name too long");
426 name
->buffer
[i
++] = c
;
432 fatal_with_file_and_line ("missing name or number");
435 name
->string
= name
->buffer
;
439 /* Do constant expansion. */
440 struct md_constant
*def
;
444 struct md_constant tmp_def
;
446 tmp_def
.name
= name
->string
;
447 def
= (struct md_constant
*) htab_find (m_md_constants
, &tmp_def
);
449 name
->string
= def
->value
;
455 /* Subroutine of the string readers. Handles backslash escapes.
456 Caller has read the backslash, but not placed it into the obstack. */
459 rtx_reader::read_escape ()
461 int c
= read_char ();
465 /* Backslash-newline is replaced by nothing, as in C. */
469 /* \" \' \\ are replaced by the second character. */
475 /* Standard C string escapes:
478 all are passed through to the output string unmolested.
479 In normal use these wind up in a string constant processed
480 by the C compiler, which will translate them appropriately.
481 We do not bother checking that \[0-7] are followed by up to
482 two octal digits, or that \x is followed by N hex digits.
483 \? \u \U are left out because they are not in traditional C. */
484 case 'a': case 'b': case 'f': case 'n': case 'r': case 't': case 'v':
485 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
487 obstack_1grow (&m_string_obstack
, '\\');
490 /* \; makes stuff for a C string constant containing
493 obstack_grow (&m_string_obstack
, "\\n\\t", 4);
496 /* pass anything else through, but issue a warning. */
498 fprintf (stderr
, "%s:%d: warning: unrecognized escape \\%c\n",
499 get_filename (), get_lineno (),
501 obstack_1grow (&m_string_obstack
, '\\');
505 obstack_1grow (&m_string_obstack
, c
);
508 /* Read a double-quoted string onto the obstack. Caller has scanned
509 the leading quote. */
512 rtx_reader::read_quoted_string ()
518 c
= read_char (); /* Read the string */
524 else if (c
== '"' || c
== EOF
)
527 obstack_1grow (&m_string_obstack
, c
);
530 obstack_1grow (&m_string_obstack
, 0);
531 return XOBFINISH (&m_string_obstack
, char *);
534 /* Read a braced string (a la Tcl) onto the string obstack. Caller
535 has scanned the leading brace. Note that unlike quoted strings,
536 the outermost braces _are_ included in the string constant. */
539 rtx_reader::read_braced_string ()
542 int brace_depth
= 1; /* caller-processed */
543 unsigned long starting_read_md_lineno
= get_lineno ();
545 obstack_1grow (&m_string_obstack
, '{');
548 c
= read_char (); /* Read the string */
560 fatal_with_file_and_line
561 ("missing closing } for opening brace on line %lu",
562 starting_read_md_lineno
);
564 obstack_1grow (&m_string_obstack
, c
);
567 obstack_1grow (&m_string_obstack
, 0);
568 return XOBFINISH (&m_string_obstack
, char *);
571 /* Read some kind of string constant. This is the high-level routine
572 used by read_rtx. It handles surrounding parentheses, leading star,
573 and dispatch to the appropriate string constant reader. */
576 rtx_reader::read_string (int star_if_braced
)
582 c
= read_skip_spaces ();
586 c
= read_skip_spaces ();
589 old_lineno
= get_lineno ();
591 stringbuf
= read_quoted_string ();
595 obstack_1grow (&m_string_obstack
, '*');
596 stringbuf
= read_braced_string ();
599 fatal_with_file_and_line ("expected `\"' or `{', found `%c'", c
);
602 require_char_ws (')');
604 set_md_ptr_loc (stringbuf
, get_filename (), old_lineno
);
608 /* Skip the rest of a construct that started at line LINENO and that
609 is currently nested by DEPTH levels of parentheses. */
612 rtx_reader::read_skip_construct (int depth
, file_location loc
)
619 c
= read_skip_spaces ();
622 error_at (loc
, "unterminated construct");
657 /* Given a string, return the number of comma-separated elements in it.
658 Return 0 for the null string. */
661 n_comma_elts (const char *s
)
675 /* Given a pointer to a (char *), return a pointer to the beginning of the
676 next comma-separated element in the string. Advance the pointer given
677 to the end of that element. Return NULL if at end of string. Caller
678 is responsible for copying the string if necessary. White space between
679 a comma and an element is ignored. */
682 scan_comma_elt (const char **pstr
)
685 const char *p
= *pstr
;
697 while (*p
!= ',' && *p
!= '\0')
704 /* Convert STRING to uppercase. */
707 upcase_string (char *string
)
711 for (i
= 0; string
[i
]; i
++)
712 string
[i
] = TOUPPER (string
[i
]);
715 /* Add a NAME = VALUE definition to md_constants-style hash table DEFS,
716 where both NAME and VALUE are malloc()ed strings. PARENT_ENUM is the
717 enum to which NAME belongs, or null if NAME is a stand-alone constant. */
719 static struct md_constant
*
720 add_constant (htab_t defs
, char *name
, char *value
,
721 struct enum_type
*parent_enum
)
723 struct md_constant
*def
, tmp_def
;
727 entry_ptr
= htab_find_slot (defs
, &tmp_def
, INSERT
);
730 def
= (struct md_constant
*) *entry_ptr
;
731 if (strcmp (def
->value
, value
) != 0)
732 fatal_with_file_and_line ("redefinition of `%s', was `%s', now `%s'",
733 def
->name
, def
->value
, value
);
734 else if (parent_enum
|| def
->parent_enum
)
735 fatal_with_file_and_line ("redefinition of `%s'", def
->name
);
741 def
= XNEW (struct md_constant
);
744 def
->parent_enum
= parent_enum
;
750 /* Process a define_constants directive, starting with the optional space
751 after the "define_constants". */
754 rtx_reader::handle_constants ()
759 require_char_ws ('[');
761 /* Disable constant expansion during definition processing. */
762 defs
= m_md_constants
;
764 while ( (c
= read_skip_spaces ()) != ']')
766 struct md_name name
, value
;
769 fatal_expected_char ('(', c
);
773 add_constant (defs
, xstrdup (name
.string
), xstrdup (value
.string
), 0);
775 require_char_ws (')');
777 m_md_constants
= defs
;
780 /* For every constant definition, call CALLBACK with two arguments:
781 a pointer a pointer to the constant definition and INFO.
782 Stop when CALLBACK returns zero. */
785 rtx_reader::traverse_md_constants (htab_trav callback
, void *info
)
787 htab_traverse (get_md_constants (), callback
, info
);
790 /* Return a malloc()ed decimal string that represents number NUMBER. */
793 md_decimal_string (int number
)
795 /* A safe overestimate. +1 for sign, +1 for null terminator. */
796 char buffer
[sizeof (int) * CHAR_BIT
+ 1 + 1];
798 sprintf (buffer
, "%d", number
);
799 return xstrdup (buffer
);
802 /* Process a define_enum or define_c_enum directive, starting with
803 the optional space after the "define_enum". LINENO is the line
804 number on which the directive started and MD_P is true if the
805 directive is a define_enum rather than a define_c_enum. */
808 rtx_reader::handle_enum (file_location loc
, bool md_p
)
810 char *enum_name
, *value_name
;
812 struct enum_type
*def
;
813 struct enum_value
*ev
;
817 enum_name
= read_string (false);
818 slot
= htab_find_slot (m_enum_types
, &enum_name
, INSERT
);
821 def
= (struct enum_type
*) *slot
;
822 if (def
->md_p
!= md_p
)
823 error_at (loc
, "redefining `%s' as a different type of enum",
828 def
= XNEW (struct enum_type
);
829 def
->name
= enum_name
;
832 def
->tail_ptr
= &def
->values
;
837 require_char_ws ('[');
839 while ((c
= read_skip_spaces ()) != ']')
843 error_at (loc
, "unterminated construct");
849 ev
= XNEW (struct enum_value
);
853 value_name
= concat (def
->name
, "_", name
.string
, NULL
);
854 upcase_string (value_name
);
855 ev
->name
= xstrdup (name
.string
);
859 value_name
= xstrdup (name
.string
);
860 ev
->name
= value_name
;
862 ev
->def
= add_constant (get_md_constants (), value_name
,
863 md_decimal_string (def
->num_values
), def
);
866 def
->tail_ptr
= &ev
->next
;
871 /* Try to find the definition of the given enum. Return null on failure. */
874 rtx_reader::lookup_enum_type (const char *name
)
876 return (struct enum_type
*) htab_find (m_enum_types
, &name
);
879 /* For every enum definition, call CALLBACK with two arguments:
880 a pointer to the constant definition and INFO. Stop when CALLBACK
884 rtx_reader::traverse_enum_types (htab_trav callback
, void *info
)
886 htab_traverse (m_enum_types
, callback
, info
);
890 /* Constructor for rtx_reader. */
892 rtx_reader::rtx_reader ()
893 : m_toplevel_fname (NULL
),
895 m_read_md_file (NULL
),
896 m_read_md_filename (NULL
),
897 m_read_md_lineno (0),
899 m_first_dir_md_include (NULL
),
900 m_last_dir_md_include_ptr (&m_first_dir_md_include
)
902 /* Set the global singleton pointer. */
903 rtx_reader_ptr
= this;
905 obstack_init (&m_string_obstack
);
907 m_ptr_locs
= htab_create (161, leading_ptr_hash
, leading_ptr_eq_p
, 0);
908 obstack_init (&m_ptr_loc_obstack
);
910 m_joined_conditions
= htab_create (161, leading_ptr_hash
, leading_ptr_eq_p
, 0);
911 obstack_init (&m_joined_conditions_obstack
);
913 m_md_constants
= htab_create (31, leading_string_hash
,
914 leading_string_eq_p
, (htab_del
) 0);
916 m_enum_types
= htab_create (31, leading_string_hash
,
917 leading_string_eq_p
, (htab_del
) 0);
919 /* Unlock the stdio streams. */
920 unlock_std_streams ();
923 /* rtx_reader's destructor. */
925 rtx_reader::~rtx_reader ()
929 htab_delete (m_enum_types
);
931 htab_delete (m_md_constants
);
933 obstack_free (&m_joined_conditions_obstack
, NULL
);
934 htab_delete (m_joined_conditions
);
936 obstack_free (&m_ptr_loc_obstack
, NULL
);
937 htab_delete (m_ptr_locs
);
939 obstack_free (&m_string_obstack
, NULL
);
941 /* Clear the global singleton pointer. */
942 rtx_reader_ptr
= NULL
;
945 /* Process an "include" directive, starting with the optional space
946 after the "include". Read in the file and use HANDLE_DIRECTIVE
947 to process each unknown directive. LINENO is the line number on
948 which the "include" occurred. */
951 rtx_reader::handle_include (file_location loc
)
953 const char *filename
;
954 const char *old_filename
;
955 int old_lineno
, old_colno
;
957 FILE *input_file
, *old_file
;
959 filename
= read_string (false);
962 /* If the specified file name is absolute, skip the include stack. */
963 if (!IS_ABSOLUTE_PATH (filename
))
965 struct file_name_list
*stackp
;
967 /* Search the directory path, trying to open the file. */
968 for (stackp
= m_first_dir_md_include
; stackp
; stackp
= stackp
->next
)
970 static const char sep
[2] = { DIR_SEPARATOR
, '\0' };
972 pathname
= concat (stackp
->fname
, sep
, filename
, NULL
);
973 input_file
= fopen (pathname
, "r");
974 if (input_file
!= NULL
)
980 /* If we haven't managed to open the file yet, try combining the
981 filename with BASE_DIR. */
982 if (input_file
== NULL
)
985 pathname
= concat (m_base_dir
, filename
, NULL
);
987 pathname
= xstrdup (filename
);
988 input_file
= fopen (pathname
, "r");
991 if (input_file
== NULL
)
994 error_at (loc
, "include file `%s' not found", filename
);
998 /* Save the old cursor. Note that the LINENO argument to this
999 function is the beginning of the include statement, while
1000 read_md_lineno has already been advanced. */
1001 old_file
= m_read_md_file
;
1002 old_filename
= m_read_md_filename
;
1003 old_lineno
= m_read_md_lineno
;
1004 old_colno
= m_read_md_colno
;
1006 if (include_callback
)
1007 include_callback (pathname
);
1009 m_read_md_file
= input_file
;
1010 m_read_md_filename
= pathname
;
1014 /* Restore the old cursor. */
1015 m_read_md_file
= old_file
;
1016 m_read_md_filename
= old_filename
;
1017 m_read_md_lineno
= old_lineno
;
1018 m_read_md_colno
= old_colno
;
1020 /* Do not free the pathname. It is attached to the various rtx
1024 /* Process the current file, assuming that read_md_file and
1025 read_md_filename are valid. Use HANDLE_DIRECTIVE to handle
1026 unknown directives. */
1029 rtx_reader::handle_file ()
1031 struct md_name directive
;
1034 m_read_md_lineno
= 1;
1035 m_read_md_colno
= 0;
1036 while ((c
= read_skip_spaces ()) != EOF
)
1038 file_location loc
= get_current_location ();
1040 fatal_expected_char ('(', c
);
1042 read_name (&directive
);
1043 if (strcmp (directive
.string
, "define_constants") == 0)
1044 handle_constants ();
1045 else if (strcmp (directive
.string
, "define_enum") == 0)
1046 handle_enum (loc
, true);
1047 else if (strcmp (directive
.string
, "define_c_enum") == 0)
1048 handle_enum (loc
, false);
1049 else if (strcmp (directive
.string
, "include") == 0)
1050 handle_include (loc
);
1052 handle_unknown_directive (loc
, directive
.string
);
1054 require_char_ws (')');
1056 fclose (m_read_md_file
);
1059 /* Like handle_file, but for top-level files. Set up m_toplevel_fname
1060 and m_base_dir accordingly. */
1063 rtx_reader::handle_toplevel_file ()
1067 m_toplevel_fname
= m_read_md_filename
;
1068 base
= lbasename (m_toplevel_fname
);
1069 if (base
== m_toplevel_fname
)
1072 m_base_dir
= xstrndup (m_toplevel_fname
, base
- m_toplevel_fname
);
1078 rtx_reader::get_current_location () const
1080 return file_location (m_read_md_filename
, m_read_md_lineno
, m_read_md_colno
);
1083 /* Parse a -I option with argument ARG. */
1086 rtx_reader::add_include_path (const char *arg
)
1088 struct file_name_list
*dirtmp
;
1090 dirtmp
= XNEW (struct file_name_list
);
1092 dirtmp
->fname
= arg
;
1093 *m_last_dir_md_include_ptr
= dirtmp
;
1094 m_last_dir_md_include_ptr
= &dirtmp
->next
;
1097 /* The main routine for reading .md files. Try to process all the .md
1098 files specified on the command line and return true if no error occurred.
1100 ARGC and ARGV are the arguments to main.
1102 PARSE_OPT, if nonnull, is passed all unknown command-line arguments.
1103 It should return true if it recognizes the argument or false if a
1104 generic error should be reported. */
1107 rtx_reader::read_md_files (int argc
, const char **argv
,
1108 bool (*parse_opt
) (const char *))
1111 bool no_more_options
;
1112 bool already_read_stdin
;
1115 /* First we loop over all the options. */
1116 for (i
= 1; i
< argc
; i
++)
1117 if (argv
[i
][0] == '-')
1119 /* An argument consisting of exactly one dash is a request to
1120 read stdin. This will be handled in the second loop. */
1121 if (argv
[i
][1] == '\0')
1124 /* An argument consisting of just two dashes causes option
1125 parsing to cease. */
1126 if (argv
[i
][1] == '-' && argv
[i
][2] == '\0')
1129 if (argv
[i
][1] == 'I')
1131 if (argv
[i
][2] != '\0')
1132 add_include_path (argv
[i
] + 2);
1133 else if (++i
< argc
)
1134 add_include_path (argv
[i
]);
1136 fatal ("directory name missing after -I option");
1140 /* The program may have provided a callback so it can
1141 accept its own options. */
1142 if (parse_opt
&& parse_opt (argv
[i
]))
1145 fatal ("invalid option `%s'", argv
[i
]);
1148 /* Now loop over all input files. */
1150 no_more_options
= false;
1151 already_read_stdin
= false;
1152 for (i
= 1; i
< argc
; i
++)
1154 if (argv
[i
][0] == '-')
1156 if (argv
[i
][1] == '\0')
1159 if (already_read_stdin
)
1160 fatal ("cannot read standard input twice");
1162 m_read_md_file
= stdin
;
1163 m_read_md_filename
= "<stdin>";
1164 handle_toplevel_file ();
1165 already_read_stdin
= true;
1168 else if (argv
[i
][1] == '-' && argv
[i
][2] == '\0')
1170 /* No further arguments are to be treated as options. */
1171 no_more_options
= true;
1174 else if (!no_more_options
)
1178 /* If we get here we are looking at a non-option argument, i.e.
1179 a file to be processed. */
1180 m_read_md_filename
= argv
[i
];
1181 m_read_md_file
= fopen (m_read_md_filename
, "r");
1182 if (m_read_md_file
== 0)
1184 perror (m_read_md_filename
);
1187 handle_toplevel_file ();
1191 /* If we get to this point without having seen any files to process,
1192 read the standard input now. */
1193 if (num_files
== 0 && !already_read_stdin
)
1195 m_read_md_file
= stdin
;
1196 m_read_md_filename
= "<stdin>";
1197 handle_toplevel_file ();
1203 /* class noop_reader : public rtx_reader */
1205 /* A dummy implementation which skips unknown directives. */
1207 noop_reader::handle_unknown_directive (file_location loc
, const char *)
1209 read_skip_construct (1, loc
);