From efec4a282c17a6814a2ff28b15d6305af8aaf2bb Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 23 Feb 1997 22:23:12 +0000 Subject: * itbl-parse.y: Fix indentation mistakes from indent program. * itbl-lex.l: Fix indentation mistakes from indent program. * itbl-ops.h: Add include for ansidecl.h. Add PARAMS around function arguments. Add declaration for itbl_have_entries. * itbl-ops.c: Add PARAMS around function arguments. * Makefile.in: Add itbl build rules. Add dependancies for itbl files to mips target. * as.c: Add itbl support. Add new option "--insttbl" for dynamically extending instruction set. * as.h: Declare insttbl_file_name; the name of file defining extensions to the basic instruction set * configure.in, configure: Add itbl-parse.o, itbl-lex.o, and itbl-ops.o to extra_objects for mips configuration. Add include file link from itbl-cpu.h to config/itbl-${target_cpu_type}.h. * config/tc-mips.c: Allow copz instructions. Add notes for future additions to the itbl support. Add debug macros. (macro): Call itbl_assemble to assemble itbl instructions. See if an unknown register is specified in an itbl entry. --- gas/as.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'gas/as.c') diff --git a/gas/as.c b/gas/as.c index 475fa8e..927580b 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1,5 +1,5 @@ /* as.c - GAS main program. - Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 1996 + Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -35,7 +35,6 @@ */ #include "ansidecl.h" -#include "libiberty.h" #define COMMON @@ -85,6 +84,16 @@ struct defsym_list }; static struct defsym_list *defsyms; + +/* Keep a record of the itbl files we read in. */ + +struct itbl_file_list +{ + struct itbl_file_list *next; + char *name; +}; + +static struct itbl_file_list *itbl_files; void print_version_id () @@ -134,6 +143,8 @@ Options:\n\ --statistics print various measured statistics from execution\n\ --version print assembler version number and exit\n\ -W suppress warnings\n\ +-t,--itbl INSTTBL extend instruction set to include instrictions\n\ + matching the specifications defined in file INSTTBL\n\ -w ignored\n\ -X ignored\n\ -Z generate object file even after errors\n"); @@ -267,6 +278,8 @@ parse_args (pargc, pargv) 'v', #endif 'w', 'X', + /* New option for extending instruction set (see also --itbl below) */ + 't', '\0' }; struct option *longopts; @@ -289,7 +302,15 @@ parse_args (pargc, pargv) #define OPTION_EMULATION (OPTION_STD_BASE + 6) {"emulation", required_argument, NULL, OPTION_EMULATION}, #define OPTION_DEFSYM (OPTION_STD_BASE + 7) - {"defsym", required_argument, NULL, OPTION_DEFSYM} + {"defsym", required_argument, NULL, OPTION_DEFSYM}, +#define OPTION_INSTTBL (OPTION_STD_BASE + 8) + /* New option for extending instruction set (see also -t above). + * The "-t file" or "--itbl file" option extends the basic set + * of valid instructions by reading "file", a text file containing + * a list of instruction formats. The additional opcodes and their + * formats are added to the built-in set of instructions, and + * mnemonics for new registers may also be defined. */ + {"itbl", required_argument, NULL, OPTION_INSTTBL} }; /* Construct the option lists from the standard list and the @@ -422,6 +443,32 @@ the GNU General Public License. This program has absolutely no warranty.\n"); } break; + case OPTION_INSTTBL: + case 't': + { + /* optarg is the name of the file containing the instruction + formats, opcodes, register names, etc. */ + struct itbl_file_list *n; + + n = (struct itbl_file_list *) xmalloc (sizeof *n); + n->next = itbl_files; + n->name = optarg; + itbl_files = n; + + /* Parse the file and add the new instructions to our internal + table. If multiple instruction tables are specified, the + information from this table gets appended onto the existing + internal table. */ + itbl_files->name = xstrdup (optarg); + if (itbl_parse(itbl_files->name) != 0) + { + fprintf (stderr, "Failed to read instruction table %s\n", + itbl_files->name); + exit (EXIT_SUCCESS); + } + } + break; + case 'J': flag_signed_overflow_ok = 1; break; @@ -543,6 +590,7 @@ main (argc, argv) start_time = get_run_time (); + if (debug_memory) { #ifdef BFD_ASSEMBLER @@ -581,7 +629,7 @@ main (argc, argv) symbol_begin (); frag_init (); subsegs_begin (); - parse_args (&argc, &argv); + parse_args (&argc, &argv); read_begin (); input_scrub_begin (); expr_begin (); @@ -614,6 +662,8 @@ main (argc, argv) tc_init_after_args (); #endif + itbl_init (); + /* Now that we have fully initialized, and have created the output file, define any symbols requested by --defsym command line arguments. */ @@ -639,8 +689,7 @@ main (argc, argv) #endif if (seen_at_least_1_file () - && !((had_warnings () && flag_always_generate_output) - || had_errors () > 0)) + && (flag_always_generate_output || had_errors () == 0)) keep_it = 1; else keep_it = 0; @@ -659,6 +708,9 @@ main (argc, argv) output_file_close (out_file_name); #endif + if (had_errors () > 0 && ! flag_always_generate_output) + keep_it = 0; + if (!keep_it) unlink (out_file_name); @@ -668,8 +720,7 @@ main (argc, argv) /* Use xexit instead of return, because under VMS environments they may not place the same interpretation on the value given. */ - if ((had_warnings () && flag_always_generate_output) - || had_errors () > 0) + if (had_errors () > 0) xexit (EXIT_FAILURE); xexit (EXIT_SUCCESS); } -- cgit v1.1