GCC Middle and Back End API Reference
read-md.c File Reference

Data Structures

struct  ptr_loc
struct  file_name_list

Functions

static void handle_file (directive_handler_t)
hashval_t leading_string_hash ()
int leading_string_eq_p ()
static hashval_t leading_ptr_hash ()
static int leading_ptr_eq_p ()
static void set_md_ptr_loc ()
static struct ptr_locget_md_ptr_loc ()
void copy_md_ptr_loc ()
void fprint_md_ptr_loc ()
void print_md_ptr_loc ()
const char * join_c_conditions ()
void fprint_c_condition ()
void print_c_condition ()
static void ATTRIBUTE_PRINTF (2, 0)
void message_with_line ()
void error_with_line ()
void fatal_with_file_and_line ()
void fatal_expected_char ()
int read_skip_spaces ()
void read_name ()
static void read_escape ()
char * read_quoted_string ()
static char * read_braced_string ()
char * read_string ()
void read_skip_construct ()
int n_comma_elts ()
const char * scan_comma_elt ()
void upcase_string ()
static struct md_constantadd_constant (htab_t defs, char *name, char *value, struct enum_type *parent_enum)
static void handle_constants ()
void traverse_md_constants ()
static char * decimal_string ()
static void handle_enum ()
struct enum_typelookup_enum_type ()
void traverse_enum_types ()
static void handle_include ()
static void handle_file ()
static void handle_toplevel_file ()
static void parse_include ()
bool read_md_files (int argc, char **argv, bool(*parse_opt)(const char *), directive_handler_t handle_directive)

Variables

struct obstack string_obstack
static htab_t ptr_locs
static struct obstack ptr_loc_obstack
static htab_t joined_conditions
static struct obstack joined_conditions_obstack
FILE * read_md_file
const char * read_md_filename
int read_md_lineno
const char * in_fname
static char * base_dir
static struct file_name_listfirst_dir_md_include
static struct file_name_list ** last_dir_md_include_ptr = &first_dir_md_include
void(* include_callback )(const char *)
static size_t max_include_len
static htab_t md_constants
static htab_t enum_types

Function Documentation

static struct md_constant* add_constant ( htab_t  defs,
char *  name,
char *  value,
struct enum_type parent_enum 
)
staticread
Add a NAME = VALUE definition to md_constants-style hash table DEFS,
   where both NAME and VALUE are malloc()ed strings.  PARENT_ENUM is the
   enum to which NAME belongs, or null if NAME is a stand-alone constant.   

References fatal_with_file_and_line(), free(), md_constant::name, md_constant::parent_enum, and md_constant::value.

Referenced by handle_constants(), and handle_enum().

static void ATTRIBUTE_PRINTF ( ,
 
)
static
A vfprintf-like function for reporting an error against line LINENO
   of the current MD file.   

References read_md_filename.

void copy_md_ptr_loc ( )
Associate NEW_PTR with the same file position as OLD_PTR.   

References ptr_loc::filename, get_md_ptr_loc(), ptr_loc::lineno, and set_md_ptr_loc().

Referenced by apply_iterator_to_string(), attr_string(), and process_rtx().

static char* decimal_string ( )
static
Return a malloc()ed decimal string that represents number NUMBER.   

References buffer.

Referenced by handle_enum().

void fatal_expected_char ( )
Report that we found character ACTUAL when we expected to find
   character EXPECTED.   

References fatal_with_file_and_line().

Referenced by handle_constants(), handle_enum(), handle_file(), read_conditions(), read_mapping(), read_nested_rtx(), read_rtx_code(), and read_string().

void fatal_with_file_and_line ( )
void fprint_c_condition ( )
Print condition COND to OUTF, wrapped in brackets.  If COND was created
   by join_c_conditions, recursively invoke this function for the original
   conditions and join the result with "&&".  Otherwise print a #line
   directive for COND if its original file position is known.   

References fprint_md_ptr_loc(), and joined_conditions.

Referenced by print_c_condition(), write_attr_value(), and write_test_expr().

void fprint_md_ptr_loc ( )
If PTR is associated with a known file position, print a #line
   directive for it to OUTF.   

References ptr_loc::filename, get_md_ptr_loc(), and ptr_loc::lineno.

Referenced by fprint_c_condition(), and print_md_ptr_loc().

static struct ptr_loc* get_md_ptr_loc ( )
staticread
Return the position associated with pointer PTR.  Return null if no
   position was set.   

References ptr_locs.

Referenced by copy_md_ptr_loc(), and fprint_md_ptr_loc().

static void handle_constants ( )
static
Process a define_constants directive, starting with the optional space
   after the "define_constants".   

References add_constant(), defs, fatal_expected_char(), md_constants, read_name(), read_skip_spaces(), and md_name::string.

Referenced by handle_file().

static void handle_enum ( )
static
Process a define_enum or define_c_enum directive, starting with
   the optional space after the "define_enum".  LINENO is the line
   number on which the directive started and MD_P is true if the
   directive is a define_enum rather than a define_c_enum.   

References add_constant(), decimal_string(), enum_value::def, enum_types, error_with_line(), fatal_expected_char(), md_constants, enum_type::md_p, enum_value::name, enum_type::name, enum_value::next, enum_type::num_values, read_name(), read_skip_spaces(), read_string(), md_name::string, enum_type::tail_ptr, unread_char(), upcase_string(), and enum_type::values.

Referenced by handle_file().

static void handle_file ( directive_handler_t  )
static
static void handle_file ( )
static
Process the current file, assuming that read_md_file and
   read_md_filename are valid.  Use HANDLE_DIRECTIVE to handle
   unknown directives.   

References fatal_expected_char(), handle_constants(), handle_enum(), handle_include(), read_md_file, read_md_lineno, read_name(), read_skip_construct(), read_skip_spaces(), and md_name::string.

static void handle_include ( )
static
Process an "include" directive, starting with the optional space
   after the "include".  Read in the file and use HANDLE_DIRECTIVE
   to process each unknown directive.  LINENO is the line number on
   which the "include" occurred.   

References base_dir, error_with_line(), file_name_list::fname, free(), handle_file(), include_callback, file_name_list::next, read_md_file, read_md_filename, read_md_lineno, and read_string().

Referenced by handle_file().

static void handle_toplevel_file ( )
static
Like handle_file, but for top-level files.  Set up in_fname and
   base_dir accordingly.   

References base_dir, handle_file(), in_fname, and read_md_filename.

Referenced by read_md_files().

const char* join_c_conditions ( )
Return a condition that satisfies both COND1 and COND2.  Either string
   may be null or empty.   

References joined_conditions, and joined_conditions_obstack.

Referenced by add_condition_to_string(), alter_test_for_insn(), apply_iterators(), process_rtx(), and process_substs_on_one_elem().

static int leading_ptr_eq_p ( )
static
Return true if DEF1 and DEF2 are pointers to the same pointer.   

Referenced by read_md_files().

static hashval_t leading_ptr_hash ( )
static
Return a hash value for the pointer pointed to by DEF.   

Referenced by read_md_files().

int leading_string_eq_p ( )
Given two objects that start with char * name fields, return true if
   they have the same name.   

Referenced by bind_subst_iter_and_attr(), initialize_iterators(), and read_md_files().

hashval_t leading_string_hash ( )
Given an object that starts with a char * name field, return a hash
   code for its name.   

Referenced by bind_subst_iter_and_attr(), initialize_iterators(), and read_md_files().

struct enum_type* lookup_enum_type ( )
read
Try to find the definition of the given enum.  Return null on failure.   

References enum_types.

Referenced by gen_attr().

void message_with_line ( )
int n_comma_elts ( )
Given a string, return the number of comma-separated elements in it.
   Return 0 for the null string.   

Referenced by check_attr_test(), convert_set_attr(), and count_alternatives().

static void parse_include ( )
static
Parse a -I option with argument ARG.   

References file_name_list::fname, max_include_len, file_name_list::next, and strlen().

Referenced by read_md_files().

void print_c_condition ( )
Special fprint_c_condition for writing to STDOUT.   

References fprint_c_condition().

Referenced by write_cond(), write_one_condition(), and write_predicate_expr().

void print_md_ptr_loc ( )
Special fprint_md_ptr_loc for writing to STDOUT.   

References fprint_md_ptr_loc().

Referenced by gen_expand(), gen_split(), process_template(), write_one_condition(), and write_predicate_subfunction().

static char* read_braced_string ( )
static
Read a braced string (a la Tcl) onto the string obstack.  Caller
   has scanned the leading brace.  Note that unlike quoted strings,
   the outermost braces _are_ included in the string constant.   

References fatal_with_file_and_line(), read_char(), read_escape(), read_md_lineno, and string_obstack.

Referenced by read_string().

static void read_escape ( )
static
Subroutine of the string readers.  Handles backslash escapes.
   Caller has read the backslash, but not placed it into the obstack.   

References read_char(), read_md_filename, read_md_lineno, and string_obstack.

Referenced by read_braced_string(), and read_quoted_string().

bool read_md_files ( int  argc,
char **  argv,
bool(*)(const char *)  parse_opt,
directive_handler_t  handle_directive 
)
The main routine for reading .md files.  Try to process all the .md
   files specified on the command line and return true if no error occurred.

   ARGC and ARGV are the arguments to main.

   PARSE_OPT, if nonnull, is passed all unknown command-line arguments.
   It should return true if it recognizes the argument or false if a
   generic error should be reported.

   If HANDLE_DIRECTIVE is nonnull, the parser calls it for each
   unknown directive, otherwise it just skips such directives.
   See the comment above the directive_handler_t definition for
   details about the callback's interface.   

References enum_types, fatal(), handle_toplevel_file(), have_error, joined_conditions, joined_conditions_obstack, leading_ptr_eq_p(), leading_ptr_hash(), leading_string_eq_p(), leading_string_hash(), md_constants, parse_include(), ptr_loc_obstack, ptr_locs, read_md_file, read_md_filename, and string_obstack.

Referenced by init_rtx_reader_args_cb(), and main().

void read_name ( )
char* read_quoted_string ( void  )
Read a double-quoted string onto the obstack.  Caller has scanned
   the leading quote.   

References read_char(), read_escape(), and string_obstack.

Referenced by read_conditions(), and read_string().

void read_skip_construct ( )
Skip the rest of a construct that started at line LINENO and that
   is currently nested by DEPTH levels of parentheses.   

References error_with_line(), read_name(), read_skip_spaces(), read_string(), and unread_char().

Referenced by handle_file().

int read_skip_spaces ( void  )
Read chars from the MD file until a non-whitespace char and return that.
   Comments, both Lisp style and C style, are treated as whitespace.   

References fatal_with_file_and_line(), read_char(), and unread_char().

Referenced by handle_constants(), handle_enum(), handle_file(), read_conditions(), read_mapping(), read_name(), read_nested_rtx(), read_rtx_code(), read_rtx_variadic(), read_skip_construct(), and read_string().

char* read_string ( )
Read some kind of string constant.  This is the high-level routine
   used by read_rtx.  It handles surrounding parentheses, leading star,
   and dispatch to the appropriate string constant reader.   

References fatal_expected_char(), fatal_with_file_and_line(), read_braced_string(), read_md_filename, read_md_lineno, read_quoted_string(), read_skip_spaces(), set_md_ptr_loc(), and string_obstack.

Referenced by handle_enum(), handle_include(), read_mapping(), read_rtx_code(), read_skip_construct(), and read_subst_mapping().

const char* scan_comma_elt ( )
Given a pointer to a (char *), return a pointer to the beginning of the
   next comma-separated element in the string.  Advance the pointer given
   to the end of that element.  Return NULL if at end of string.  Caller
   is responsible for copying the string if necessary.  White space between
   a comma and an element is ignored.   

Referenced by compute_predicate_codes(), gen_attr(), gen_mnemonic_attr(), next_comma_elt(), write_match_code(), and write_match_code_switch().

static void set_md_ptr_loc ( )
static
Associate PTR with the file position given by FILENAME and LINENO.   

References ptr_loc::filename, ptr_loc::lineno, ptr_loc::ptr, ptr_loc_obstack, and ptr_locs.

Referenced by copy_md_ptr_loc(), and read_string().

void traverse_enum_types ( )
For every enum definition, call CALLBACK with two arguments:
   a pointer to the constant definition and INFO.  Stop when CALLBACK
   returns zero.   

References enum_types.

Referenced by main().

void traverse_md_constants ( )
For every constant definition, call CALLBACK with two arguments:
   a pointer a pointer to the constant definition and INFO.
   Stop when CALLBACK returns zero.   

References md_constants.

Referenced by main().

void upcase_string ( )
Convert STRING to uppercase.   

Referenced by handle_enum(), and print_enum_type().


Variable Documentation

char* base_dir
static
The directory part of IN_FNAME.  NULL if IN_FNAME is a bare filename.   

Referenced by handle_include(), and handle_toplevel_file().

htab_t enum_types
static
A table of enum_type structures, hashed by name.   

Referenced by handle_enum(), lookup_enum_type(), read_md_files(), and traverse_enum_types().

struct file_name_list* first_dir_md_include
static
The first directory to search.   
const char* in_fname
The name of the toplevel file that indirectly included READ_MD_FILE.   

Referenced by handle_toplevel_file(), write_insn_preds_c(), write_tm_constrs_h(), and write_tm_preds_h().

void(* include_callback)(const char *)
This callback will be invoked whenever an md include directive is
   processed.  To be used for creation of the dependency file.   

Referenced by handle_include(), and main().

htab_t joined_conditions
static
A hash table of triples (A, B, C), where each of A, B and C is a condition
   and A is equivalent to "B && C".  This is used to keep track of the source
   of conditions that are made up of separate MD strings (such as the split
   condition of a define_insn_and_split).   

Referenced by fprint_c_condition(), join_c_conditions(), and read_md_files().

struct obstack joined_conditions_obstack
static
An obstack for allocating joined_conditions entries.   

Referenced by join_c_conditions(), and read_md_files().

struct file_name_list** last_dir_md_include_ptr = &first_dir_md_include
static
A pointer to the null terminator of the md include chain.   
size_t max_include_len
static
The current maximum length of directory names in the search path
   for include files.  (Altered as we get more of them.)   

Referenced by parse_include().

htab_t md_constants
static
A table of md_constant structures, hashed by name.  Null if no
   constant expansion should occur.   

Referenced by handle_constants(), handle_enum(), read_md_files(), read_name(), and traverse_md_constants().

struct obstack ptr_loc_obstack
static
An obstack for the above.  Plain xmalloc is a bit heavyweight for a
   small structure like ptr_loc.   

Referenced by read_md_files(), and set_md_ptr_loc().

htab_t ptr_locs
static
A table of ptr_locs, hashed on the PTR field.   

Referenced by get_md_ptr_loc(), read_md_files(), and set_md_ptr_loc().

FILE* read_md_file
The file we are reading.   

Referenced by handle_file(), handle_include(), read_char(), read_md_files(), and unread_char().

int read_md_lineno