]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/read-md.h
Add PR target/71395 marker to 71395 fix
[thirdparty/gcc.git] / gcc / read-md.h
CommitLineData
960ebfe7 1/* MD reader definitions.
f1717362 2 Copyright (C) 1987-2016 Free Software Foundation, Inc.
960ebfe7 3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
ce6bb0f3 20#ifndef GCC_READ_MD_H
21#define GCC_READ_MD_H
22
960ebfe7 23#include "obstack.h"
ac0640e5 24
36d192df 25/* Records a position in the file. */
26struct file_location {
27 file_location () {}
28 file_location (const char *, int);
29
30 const char *filename;
31 int lineno;
32};
33
34inline file_location::file_location (const char *filename_in, int lineno_in)
35 : filename (filename_in), lineno (lineno_in) {}
36
ac0640e5 37/* Holds one symbol or number in the .md file. */
38struct md_name {
39 /* The name as it appeared in the .md file. Names are syntactically
40 limited to the length of this buffer. */
41 char buffer[256];
42
43 /* The name that should actually be used by the generator programs.
44 This is an expansion of NAME, after things like constant substitution. */
45 char *string;
46};
47
5d54fceb 48/* This structure represents a constant defined by define_constant,
49 define_enum, or such-like. */
ac0640e5 50struct md_constant {
5d54fceb 51 /* The name of the constant. */
ac0640e5 52 char *name;
5d54fceb 53
54 /* The string to which the constants expands. */
ac0640e5 55 char *value;
5d54fceb 56
57 /* If the constant is associated with a enumeration, this field
58 points to that enumeration, otherwise it is null. */
59 struct enum_type *parent_enum;
60};
61
62/* This structure represents one value in an enum_type. */
63struct enum_value {
64 /* The next value in the enum, or null if this is the last. */
65 struct enum_value *next;
66
67 /* The name of the value as it appears in the .md file. */
68 char *name;
69
70 /* The definition of the related C value. */
71 struct md_constant *def;
72};
73
74/* This structure represents an enum defined by define_enum or the like. */
75struct enum_type {
76 /* The C name of the enumeration. */
77 char *name;
78
79 /* True if this is an md-style enum (DEFINE_ENUM) rather than
80 a C-style enum (DEFINE_C_ENUM). */
81 bool md_p;
82
83 /* The values of the enumeration. There is always at least one. */
84 struct enum_value *values;
85
86 /* A pointer to the null terminator in VALUES. */
87 struct enum_value **tail_ptr;
88
89 /* The number of enumeration values. */
90 unsigned int num_values;
ac0640e5 91};
960ebfe7 92
77ba95d0 93/* A callback that handles a single .md-file directive, up to but not
36d192df 94 including the closing ')'. It takes two arguments: the file position
95 at which the directive started, and the name of the directive. The next
77ba95d0 96 unread character is the optional space after the directive name. */
36d192df 97typedef void (*directive_handler_t) (file_location, const char *);
77ba95d0 98
99extern const char *in_fname;
b3453c30 100extern FILE *read_md_file;
77c2564f 101extern int read_md_lineno;
102extern const char *read_md_filename;
960ebfe7 103extern struct obstack string_obstack;
77ba95d0 104extern void (*include_callback) (const char *);
960ebfe7 105
b3453c30 106/* Read the next character from the MD file. */
107
108static inline int
109read_char (void)
110{
606cf8b8 111 int ch;
112
113 ch = getc (read_md_file);
114 if (ch == '\n')
115 read_md_lineno++;
116 return ch;
b3453c30 117}
118
119/* Put back CH, which was the last character read from the MD file. */
120
121static inline void
122unread_char (int ch)
123{
606cf8b8 124 if (ch == '\n')
125 read_md_lineno--;
b3453c30 126 ungetc (ch, read_md_file);
127}
128
ac0640e5 129extern hashval_t leading_string_hash (const void *);
130extern int leading_string_eq_p (const void *, const void *);
77c2564f 131extern void copy_md_ptr_loc (const void *, const void *);
132extern void print_md_ptr_loc (const void *);
73ed0c67 133extern void fprint_md_ptr_loc (FILE *, const void *);
960ebfe7 134extern const char *join_c_conditions (const char *, const char *);
135extern void print_c_condition (const char *);
73ed0c67 136extern void fprint_c_condition (FILE *, const char *);
36d192df 137extern void message_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
138extern void error_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
e7ff515f 139extern void fatal_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
b3453c30 140extern void fatal_with_file_and_line (const char *, ...)
141 ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
142extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;
143extern int read_skip_spaces (void);
3604118d 144extern void require_char_ws (char expected);
ac0640e5 145extern void read_name (struct md_name *);
b3453c30 146extern char *read_quoted_string (void);
147extern char *read_string (int);
960ebfe7 148extern int n_comma_elts (const char *);
149extern const char *scan_comma_elt (const char **);
5d54fceb 150extern void upcase_string (char *);
ac0640e5 151extern void traverse_md_constants (htab_trav, void *);
5d54fceb 152extern void traverse_enum_types (htab_trav, void *);
d37b1ac9 153extern struct enum_type *lookup_enum_type (const char *);
16570c04 154extern bool read_md_files (int, const char **, bool (*) (const char *),
77ba95d0 155 directive_handler_t);
ce6bb0f3 156
157#endif /* GCC_READ_MD_H */