2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:09:40 +08:00
|
|
|
/* The IGEN simulator generator for GDB, the GNU Debugger.
|
|
|
|
|
2008-01-02 06:53:26 +08:00
|
|
|
Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:09:40 +08:00
|
|
|
|
|
|
|
Contributed by Andrew Cagney.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 22:30:15 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:09:40 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 22:30:15 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:09:40 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "lf.h"
|
|
|
|
#include "table.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _open_table open_table;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
struct _open_table
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
size_t size;
|
|
|
|
char *buffer;
|
|
|
|
char *pos;
|
|
|
|
line_ref pseudo_line;
|
|
|
|
line_ref real_line;
|
|
|
|
open_table *parent;
|
|
|
|
table *root;
|
|
|
|
};
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
struct _table
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
open_table *current;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static line_ref *
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
current_line (open_table * file)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
line_ref *entry = ZALLOC (line_ref);
|
|
|
|
*entry = file->pseudo_line;
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static table_entry *
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
new_table_entry (open_table * file, table_entry_type type)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
table_entry *entry;
|
|
|
|
entry = ZALLOC (table_entry);
|
|
|
|
entry->file = file->root;
|
|
|
|
entry->line = current_line (file);
|
|
|
|
entry->type = type;
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
set_nr_table_entry_fields (table_entry *entry, int nr_fields)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
entry->field = NZALLOC (char *, nr_fields + 1);
|
1999-04-16 09:35:26 +08:00
|
|
|
entry->nr_fields = nr_fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
table_push (table *root,
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
line_ref *line, table_include *includes, const char *file_name)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
FILE *ff;
|
|
|
|
open_table *file;
|
|
|
|
table_include dummy;
|
|
|
|
table_include *include = &dummy;
|
|
|
|
|
|
|
|
/* dummy up a search of this directory */
|
|
|
|
dummy.next = includes;
|
|
|
|
dummy.dir = "";
|
|
|
|
|
|
|
|
/* create a file descriptor */
|
|
|
|
file = ZALLOC (open_table);
|
|
|
|
if (file == NULL)
|
|
|
|
{
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
file->root = root;
|
|
|
|
file->parent = root->current;
|
|
|
|
root->current = file;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* save the file name */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
char *dup_name =
|
|
|
|
NZALLOC (char, strlen (include->dir) + strlen (file_name) + 2);
|
1999-04-16 09:35:26 +08:00
|
|
|
if (dup_name == NULL)
|
|
|
|
{
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
if (include->dir[0] != '\0')
|
|
|
|
{
|
|
|
|
strcat (dup_name, include->dir);
|
|
|
|
strcat (dup_name, "/");
|
|
|
|
}
|
|
|
|
strcat (dup_name, file_name);
|
|
|
|
file->real_line.file_name = dup_name;
|
|
|
|
file->pseudo_line.file_name = dup_name;
|
|
|
|
/* open the file */
|
|
|
|
|
|
|
|
ff = fopen (dup_name, "rb");
|
|
|
|
if (ff)
|
|
|
|
break;
|
|
|
|
/* zfree (dup_name); */
|
|
|
|
if (include->next == NULL)
|
|
|
|
{
|
|
|
|
if (line != NULL)
|
|
|
|
error (line, "Problem opening file `%s'\n", file_name);
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
include = include->next;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* determine the size */
|
|
|
|
fseek (ff, 0, SEEK_END);
|
|
|
|
file->size = ftell (ff);
|
|
|
|
fseek (ff, 0, SEEK_SET);
|
|
|
|
|
|
|
|
/* allocate this much memory */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
file->buffer = (char *) zalloc (file->size + 1);
|
1999-04-16 09:35:26 +08:00
|
|
|
if (file->buffer == NULL)
|
|
|
|
{
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
file->pos = file->buffer;
|
|
|
|
|
|
|
|
/* read it all in */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
if (fread (file->buffer, 1, file->size, ff) < file->size)
|
|
|
|
{
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
file->buffer[file->size] = '\0';
|
|
|
|
|
|
|
|
/* set the initial line numbering */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
file->real_line.line_nr = 1; /* specifies current line */
|
|
|
|
file->pseudo_line.line_nr = 1; /* specifies current line */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* done */
|
|
|
|
fclose (ff);
|
|
|
|
}
|
|
|
|
|
|
|
|
table *
|
|
|
|
table_open (const char *file_name)
|
|
|
|
{
|
|
|
|
table *root;
|
|
|
|
|
|
|
|
/* create a file descriptor */
|
|
|
|
root = ZALLOC (table);
|
|
|
|
if (root == NULL)
|
|
|
|
{
|
|
|
|
perror (file_name);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
table_push (root, NULL, NULL, file_name);
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
skip_spaces (char *chp)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
if (*chp == '\0' || *chp == '\n' || !isspace (*chp))
|
1999-04-16 09:35:26 +08:00
|
|
|
return chp;
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
back_spaces (char *start, char *chp)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
if (chp <= start || !isspace (chp[-1]))
|
1999-04-16 09:35:26 +08:00
|
|
|
return chp;
|
|
|
|
chp--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
skip_digits (char *chp)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
if (*chp == '\0' || *chp == '\n' || !isdigit (*chp))
|
1999-04-16 09:35:26 +08:00
|
|
|
return chp;
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
skip_to_separator (char *chp, char *separators)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
char *sep = separators;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (*chp == *sep)
|
|
|
|
return chp;
|
|
|
|
if (*sep == '\0')
|
|
|
|
break;
|
|
|
|
sep++;
|
|
|
|
}
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
skip_to_null (char *chp)
|
|
|
|
{
|
|
|
|
return skip_to_separator (chp, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
skip_to_nl (char *chp)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
return skip_to_separator (chp, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
next_line (open_table * file)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
file->pos = skip_to_nl (file->pos);
|
|
|
|
if (*file->pos == '0')
|
|
|
|
error (&file->pseudo_line, "Missing <nl> at end of line\n");
|
|
|
|
*file->pos = '\0';
|
|
|
|
file->pos += 1;
|
|
|
|
file->real_line.line_nr += 1;
|
|
|
|
file->pseudo_line.line_nr += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern table_entry *
|
|
|
|
table_read (table *root)
|
|
|
|
{
|
|
|
|
open_table *file = root->current;
|
|
|
|
table_entry *entry = NULL;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
while (1)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
/* end-of-file? */
|
|
|
|
while (*file->pos == '\0')
|
|
|
|
{
|
|
|
|
if (file->parent != NULL)
|
|
|
|
{
|
|
|
|
file = file->parent;
|
|
|
|
root->current = file;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* code_block? */
|
|
|
|
if (*file->pos == '{')
|
|
|
|
{
|
|
|
|
char *chp;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
next_line (file); /* discard leading brace */
|
1999-04-16 09:35:26 +08:00
|
|
|
entry = new_table_entry (file, table_code_entry);
|
|
|
|
chp = file->pos;
|
|
|
|
/* determine how many lines are involved - look for <nl> "}" */
|
|
|
|
{
|
|
|
|
int nr_lines = 0;
|
|
|
|
while (*file->pos != '}')
|
|
|
|
{
|
|
|
|
next_line (file);
|
|
|
|
nr_lines++;
|
|
|
|
}
|
|
|
|
set_nr_table_entry_fields (entry, nr_lines);
|
|
|
|
}
|
|
|
|
/* now enter each line */
|
|
|
|
{
|
|
|
|
int line_nr;
|
|
|
|
for (line_nr = 0; line_nr < entry->nr_fields; line_nr++)
|
|
|
|
{
|
|
|
|
if (strncmp (chp, " ", 2) == 0)
|
|
|
|
entry->field[line_nr] = chp + 2;
|
|
|
|
else
|
|
|
|
entry->field[line_nr] = chp;
|
|
|
|
chp = skip_to_null (chp) + 1;
|
|
|
|
}
|
|
|
|
/* skip trailing brace */
|
|
|
|
ASSERT (*file->pos == '}');
|
|
|
|
next_line (file);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tab block? */
|
|
|
|
if (*file->pos == '\t')
|
|
|
|
{
|
|
|
|
char *chp = file->pos;
|
|
|
|
entry = new_table_entry (file, table_code_entry);
|
|
|
|
/* determine how many lines are involved - look for <nl> !<tab> */
|
|
|
|
{
|
|
|
|
int nr_lines = 0;
|
|
|
|
int nr_blank_lines = 0;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (*file->pos == '\t')
|
|
|
|
{
|
|
|
|
nr_lines = nr_lines + nr_blank_lines + 1;
|
|
|
|
nr_blank_lines = 0;
|
|
|
|
next_line (file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file->pos = skip_spaces (file->pos);
|
|
|
|
if (*file->pos != '\n')
|
|
|
|
break;
|
|
|
|
nr_blank_lines++;
|
|
|
|
next_line (file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_nr_table_entry_fields (entry, nr_lines);
|
|
|
|
}
|
|
|
|
/* now enter each line */
|
|
|
|
{
|
|
|
|
int line_nr;
|
|
|
|
for (line_nr = 0; line_nr < entry->nr_fields; line_nr++)
|
|
|
|
{
|
|
|
|
if (*chp == '\t')
|
|
|
|
entry->field[line_nr] = chp + 1;
|
|
|
|
else
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
entry->field[line_nr] = ""; /* blank */
|
1999-04-16 09:35:26 +08:00
|
|
|
chp = skip_to_null (chp) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cpp directive? */
|
|
|
|
if (file->pos[0] == '#')
|
|
|
|
{
|
|
|
|
char *chp = skip_spaces (file->pos + 1);
|
|
|
|
|
|
|
|
/* cpp line-nr directive - # <line-nr> "<file>" */
|
|
|
|
if (isdigit (*chp)
|
|
|
|
&& *skip_digits (chp) == ' '
|
|
|
|
&& *skip_spaces (skip_digits (chp)) == '"')
|
|
|
|
{
|
|
|
|
int line_nr;
|
|
|
|
char *file_name;
|
|
|
|
file->pos = chp;
|
|
|
|
/* parse the number */
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
line_nr = atoi (file->pos) - 1;
|
1999-04-16 09:35:26 +08:00
|
|
|
/* skip to the file name */
|
|
|
|
while (file->pos[0] != '0'
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
&& file->pos[0] != '"' && file->pos[0] != '\0')
|
1999-04-16 09:35:26 +08:00
|
|
|
file->pos++;
|
|
|
|
if (file->pos[0] != '"')
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
error (&file->real_line,
|
|
|
|
"Missing opening quote in cpp directive\n");
|
1999-04-16 09:35:26 +08:00
|
|
|
/* parse the file name */
|
|
|
|
file->pos++;
|
|
|
|
file_name = file->pos;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
while (file->pos[0] != '"' && file->pos[0] != '\0')
|
1999-04-16 09:35:26 +08:00
|
|
|
file->pos++;
|
|
|
|
if (file->pos[0] != '"')
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
error (&file->real_line,
|
|
|
|
"Missing closing quote in cpp directive\n");
|
1999-04-16 09:35:26 +08:00
|
|
|
file->pos[0] = '\0';
|
|
|
|
file->pos++;
|
|
|
|
file->pos = skip_to_nl (file->pos);
|
|
|
|
if (file->pos[0] != '\n')
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
error (&file->real_line,
|
|
|
|
"Missing newline in cpp directive\n");
|
1999-04-16 09:35:26 +08:00
|
|
|
file->pseudo_line.file_name = file_name;
|
|
|
|
file->pseudo_line.line_nr = line_nr;
|
|
|
|
next_line (file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* #define and #undef - not implemented yet */
|
|
|
|
|
|
|
|
/* Old style # comment */
|
|
|
|
next_line (file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* blank line or end-of-file? */
|
|
|
|
file->pos = skip_spaces (file->pos);
|
|
|
|
if (*file->pos == '\0')
|
|
|
|
error (&file->pseudo_line, "Missing <nl> at end of file\n");
|
|
|
|
if (*file->pos == '\n')
|
|
|
|
{
|
|
|
|
next_line (file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* comment - leading // or # - skip */
|
|
|
|
if ((file->pos[0] == '/' && file->pos[1] == '/')
|
|
|
|
|| (file->pos[0] == '#'))
|
|
|
|
{
|
|
|
|
next_line (file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* colon field */
|
|
|
|
{
|
|
|
|
char *chp = file->pos;
|
|
|
|
entry = new_table_entry (file, table_colon_entry);
|
|
|
|
next_line (file);
|
|
|
|
/* figure out how many fields */
|
|
|
|
{
|
|
|
|
int nr_fields = 1;
|
|
|
|
char *tmpch = chp;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
tmpch = skip_to_separator (tmpch, "\\:");
|
|
|
|
if (*tmpch == '\\')
|
|
|
|
{
|
|
|
|
/* eat the escaped character */
|
|
|
|
char *cp = tmpch;
|
|
|
|
while (cp[1] != '\0')
|
|
|
|
{
|
|
|
|
cp[0] = cp[1];
|
|
|
|
cp++;
|
|
|
|
}
|
|
|
|
cp[0] = '\0';
|
|
|
|
tmpch++;
|
|
|
|
}
|
|
|
|
else if (*tmpch != ':')
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*tmpch = '\0';
|
|
|
|
tmpch++;
|
|
|
|
nr_fields++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_nr_table_entry_fields (entry, nr_fields);
|
|
|
|
}
|
|
|
|
/* now parse them */
|
|
|
|
{
|
|
|
|
int field_nr;
|
|
|
|
for (field_nr = 0; field_nr < entry->nr_fields; field_nr++)
|
|
|
|
{
|
|
|
|
chp = skip_spaces (chp);
|
|
|
|
entry->field[field_nr] = chp;
|
|
|
|
chp = skip_to_null (chp);
|
|
|
|
*back_spaces (entry->field[field_nr], chp) = '\0';
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT (entry == NULL || entry->field[entry->nr_fields] == NULL);
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
table_print_code (lf *file, table_entry *entry)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
int field_nr;
|
|
|
|
int nr = 0;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
for (field_nr = 0; field_nr < entry->nr_fields; field_nr++)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
char *chp = entry->field[field_nr];
|
|
|
|
int in_bit_field = 0;
|
|
|
|
if (*chp == '#')
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
lf_indent_suppress (file);
|
|
|
|
while (*chp != '\0')
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
if (chp[0] == '{' && !isspace (chp[1]) && chp[1] != '\0')
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
in_bit_field = 1;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
nr += lf_putchr (file, '_');
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
else if (in_bit_field && chp[0] == ':')
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
nr += lf_putchr (file, '_');
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
else if (in_bit_field && *chp == '}')
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
nr += lf_putchr (file, '_');
|
1999-04-16 09:35:26 +08:00
|
|
|
in_bit_field = 0;
|
|
|
|
}
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
else
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
nr += lf_putchr (file, *chp);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
if (in_bit_field)
|
|
|
|
{
|
|
|
|
line_ref line = *entry->line;
|
|
|
|
line.line_nr += field_nr;
|
|
|
|
error (&line, "Bit field brace miss match\n");
|
|
|
|
}
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
nr += lf_putchr (file, '\n');
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
dump_line_ref (lf *file, char *prefix, const line_ref *line, char *suffix)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
lf_printf (file, "%s(line_ref*) 0x%lx", prefix, (long) line);
|
|
|
|
if (line != NULL)
|
|
|
|
{
|
|
|
|
lf_indent (file, +1);
|
|
|
|
lf_printf (file, "\n(line_nr %d)", line->line_nr);
|
|
|
|
lf_printf (file, "\n(file_name %s)", line->file_name);
|
|
|
|
lf_indent (file, -1);
|
|
|
|
}
|
|
|
|
lf_printf (file, "%s", suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
table_entry_type_to_str (table_entry_type type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
case table_code_entry:
|
|
|
|
return "code-entry";
|
|
|
|
case table_colon_entry:
|
|
|
|
return "colon-entry";
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
return "*invalid*";
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
dump_table_entry (lf *file,
|
|
|
|
char *prefix, const table_entry *entry, char *suffix)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
lf_printf (file, "%s(table_entry*) 0x%lx", prefix, (long) entry);
|
|
|
|
if (entry != NULL)
|
|
|
|
{
|
|
|
|
int field;
|
|
|
|
lf_indent (file, +1);
|
|
|
|
dump_line_ref (file, "\n(line ", entry->line, ")");
|
|
|
|
lf_printf (file, "\n(type %s)", table_entry_type_to_str (entry->type));
|
|
|
|
lf_printf (file, "\n(nr_fields %d)", entry->nr_fields);
|
|
|
|
lf_printf (file, "\n(fields");
|
|
|
|
lf_indent (file, +1);
|
|
|
|
for (field = 0; field < entry->nr_fields; field++)
|
|
|
|
lf_printf (file, "\n\"%s\"", entry->field[field]);
|
|
|
|
lf_indent (file, -1);
|
|
|
|
lf_printf (file, ")");
|
|
|
|
lf_indent (file, -1);
|
|
|
|
}
|
|
|
|
lf_printf (file, "%s", suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef MAIN
|
|
|
|
int
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
main (int argc, char **argv)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
table *t;
|
|
|
|
table_entry *entry;
|
|
|
|
lf *l;
|
|
|
|
int line_nr;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
printf ("Usage: table <file>\n");
|
1999-04-16 09:35:26 +08:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
t = table_open (argv[1]);
|
|
|
|
l = lf_open ("-", "stdout", lf_omit_references, lf_is_text, "tmp-table");
|
|
|
|
|
|
|
|
line_nr = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
char line[10];
|
|
|
|
entry = table_read (t);
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 12:20:49 +08:00
|
|
|
line_nr++;
|
1999-04-16 09:35:26 +08:00
|
|
|
sprintf (line, "(%d ", line_nr);
|
|
|
|
dump_table_entry (l, line, entry, ")\n");
|
|
|
|
}
|
|
|
|
while (entry != NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|