sim: ppc: drop old dgen.c generator
The spreg.[ch] files live in the source tree now and are created with the dgen.py script, so we don't need this old tool anymore.
This commit is contained in:
parent
ee3314c436
commit
897903a210
@ -101,7 +101,6 @@ IGEN_FILTER = @sim_filter@
|
||||
IGEN_ICACHE = @sim_icache@
|
||||
IGEN_SMP = @sim_igen_smp@
|
||||
IGEN_LINE_NR = @sim_line_nr@
|
||||
DGEN_FLAGS =
|
||||
|
||||
IGEN_FLAGS = \
|
||||
$(IGEN_DECODE_MECHANISM) \
|
||||
@ -112,11 +111,10 @@ IGEN_FLAGS = \
|
||||
$(IGEN_SMP) \
|
||||
$(IGEN_LINE_NR)
|
||||
|
||||
# igen/dgen leak memory, and therefore makes AddressSanitizer unhappy. Disable
|
||||
# leak detection while running them.
|
||||
# igen leaks memory, and therefore makes AddressSanitizer unhappy. Disable
|
||||
# leak detection while running it.
|
||||
|
||||
IGEN = ASAN_OPTIONS=detect_leaks=0 ./igen
|
||||
DGEN = ASAN_OPTIONS=detect_leaks=0 ./dgen
|
||||
|
||||
.NOEXPORT:
|
||||
MAKEOVERRIDES=
|
||||
@ -416,7 +414,6 @@ BUILT_SRC_WO_CONFIG = \
|
||||
idecode.h idecode.c \
|
||||
semantics.h semantics.c \
|
||||
itable.h itable.c \
|
||||
spreg.h spreg.c \
|
||||
model.h model.c \
|
||||
support.h support.c \
|
||||
pk.h \
|
||||
@ -516,7 +513,7 @@ PACKAGE_SRC = pk_disklabel.c
|
||||
PACKAGE_OBJ = $(PACKAGE_SRC:.c=.o)
|
||||
|
||||
|
||||
$(TARGETLIB): tmp-igen tmp-dgen tmp-hw tmp-defines $(LIB_OBJ) $(GDB_OBJ)
|
||||
$(TARGETLIB): tmp-igen tmp-hw tmp-defines $(LIB_OBJ) $(GDB_OBJ)
|
||||
$(ECHO_AR) $(AR) $(AR_FLAGS) $(TARGETLIB) $(LIB_OBJ) $(GDB_OBJ)
|
||||
$(ECHO_RANLIB) $(RANLIB) $(TARGETLIB)
|
||||
|
||||
@ -588,7 +585,7 @@ sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(CONFIG_H)
|
||||
|
||||
# Rebuild options whenever something changes so the date/time is up to date.
|
||||
options.o: options.c $(CPU_H) $(OPTIONS_H) $(DEFINES_H) $(BASICS_H) $(IDECODE_H) $(INLINE) $(LIB_SRC) $(BUILT_SRC) config.status Makefile
|
||||
$(ECHO_CC) $(CC) -c $(STD_CFLAGS) '-DOPCODE_RULES="@sim_opcode@"' '-DIGEN_FLAGS="$(IGEN_FLAGS)"' '-DDGEN_FLAGS="$(DGEN_FLAGS)"' $(srcdir)/options.c
|
||||
$(ECHO_CC) $(CC) -c $(STD_CFLAGS) '-DOPCODE_RULES="@sim_opcode@"' '-DIGEN_FLAGS="$(IGEN_FLAGS)"' $(srcdir)/options.c
|
||||
|
||||
defines.h: tmp-defines; @true
|
||||
tmp-defines: config.h Makefile
|
||||
@ -600,15 +597,6 @@ tmp-defines: config.h Makefile
|
||||
# Rules to create the built c source code files
|
||||
#
|
||||
|
||||
tmp-dgen: dgen ppc-spr-table $(srcroot)/move-if-change
|
||||
$(ECHO_GEN) $(DGEN) $(DGEN_FLAGS) \
|
||||
-r $(srcdir)/ppc-spr-table \
|
||||
-n spreg.h -hp tmp-spreg.h \
|
||||
-n spreg.c -p tmp-spreg.c
|
||||
$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-spreg.h spreg.h
|
||||
$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-spreg.c spreg.c
|
||||
$(SILENCE) touch $@
|
||||
|
||||
tmp-igen: igen $(srcdir)/powerpc.igen $(srcdir)/altivec.igen $(srcdir)/e500.igen $(IGEN_OPCODE_RULES) $(srcroot)/move-if-change
|
||||
$(ECHO_GEN) $(IGEN) $(IGEN_FLAGS) \
|
||||
-o $(srcdir)/$(IGEN_OPCODE_RULES) \
|
||||
@ -642,12 +630,8 @@ tmp-igen: igen $(srcdir)/powerpc.igen $(srcdir)/altivec.igen $(srcdir)/e500.igen
|
||||
# NOTE: Some versions of make don't handle files created as side-effects
|
||||
# uncomment the below if that is the case.
|
||||
|
||||
$(TARGETLIB): tmp-igen tmp-dgen
|
||||
$(TARGETLIB): tmp-igen
|
||||
itable.h itable.c icache.h icache.c idecode.h idecode.c semantics.h semantics.c model.h model.c support.h support.c: tmp-igen
|
||||
spreg.h spreg.c: tmp-dgen
|
||||
|
||||
dgen: dgen.o table.o lf.o misc.o filter_host.o
|
||||
$(ECHO_CCLD) $(LINK_FOR_BUILD) dgen.o table.o lf.o misc.o filter_host.o
|
||||
|
||||
igen: igen.o table.o lf.o misc.o filter_host.o ld-decode.o ld-cache.o filter.o ld-insn.o gen-model.o gen-itable.o gen-icache.o gen-semantics.o gen-idecode.o gen-support.o
|
||||
$(ECHO_CCLD) $(LINK_FOR_BUILD) igen.o table.o lf.o misc.o filter_host.o ld-decode.o ld-cache.o filter.o ld-insn.o gen-model.o gen-itable.o gen-icache.o gen-semantics.o gen-idecode.o gen-support.o
|
||||
@ -702,9 +686,6 @@ gen-idecode.o: gen-idecode.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECOD
|
||||
gen-support.o: gen-support.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_SEMANTICS_H) $(GEN_SUPPORT_H)
|
||||
$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-support.c
|
||||
|
||||
dgen.o: dgen.c $(CONFIG_H) $(MISC_H) $(LF_H) $(TABLE_H)
|
||||
$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/dgen.c
|
||||
|
||||
igen.o: igen.c $(MISC_H) $(LF_H) $(TABLE_H) $(CONFIG_H) $(FILTER_H) $(LD_CACHE_H) $(LD_DECODE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_MODEL_H) $(GEN_ICACHE_H) $(GEN_ITABLE_H) $(GEN_IDECODE_H) $(GEN_SEMANTICS_H) $(GEN_SUPPORT_H)
|
||||
$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/igen.c
|
||||
|
||||
@ -801,7 +782,7 @@ TAGS: $(BUILT_SRC)
|
||||
etags $(srcdir)/*.h $(srcdir)/*.c $(BUILT_SRC)
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f tmp-* *.[oasi] core igen dgen $(BUILT_SRC_WO_CONFIG)
|
||||
rm -f tmp-* *.[oasi] core igen $(BUILT_SRC_WO_CONFIG)
|
||||
|
||||
distclean realclean: clean
|
||||
rm -f TAGS Makefile config.cache config.status config.h defines.h stamp-h config.log
|
||||
|
334
sim/ppc/dgen.c
334
sim/ppc/dgen.c
@ -1,334 +0,0 @@
|
||||
/* This file is part of the program psim.
|
||||
|
||||
Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(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
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "build-config.h"
|
||||
#include "misc.h"
|
||||
#include "lf.h"
|
||||
#include "table.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
enum {
|
||||
nr_of_sprs = 1024,
|
||||
};
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
|
||||
typedef enum {
|
||||
spreg_name,
|
||||
spreg_reg_nr,
|
||||
spreg_readonly,
|
||||
spreg_length,
|
||||
nr_spreg_fields,
|
||||
} spreg_fields;
|
||||
|
||||
typedef struct _spreg_table_entry spreg_table_entry;
|
||||
struct _spreg_table_entry {
|
||||
char *name;
|
||||
int spreg_nr;
|
||||
int is_readonly;
|
||||
int length;
|
||||
table_entry *entry;
|
||||
spreg_table_entry *next;
|
||||
};
|
||||
|
||||
typedef struct _spreg_table spreg_table;
|
||||
struct _spreg_table {
|
||||
spreg_table_entry *sprs;
|
||||
};
|
||||
|
||||
static void
|
||||
spreg_table_insert(spreg_table *table, table_entry *entry)
|
||||
{
|
||||
/* create a new spr entry */
|
||||
spreg_table_entry *new_spr = ZALLOC(spreg_table_entry);
|
||||
new_spr->next = NULL;
|
||||
new_spr->entry = entry;
|
||||
new_spr->spreg_nr = atoi(entry->fields[spreg_reg_nr]);
|
||||
new_spr->is_readonly = (entry->fields[spreg_readonly]
|
||||
? atoi(entry->fields[spreg_readonly])
|
||||
: 0);
|
||||
new_spr->length = atoi(entry->fields[spreg_length]);
|
||||
new_spr->name = (char*)zalloc(strlen(entry->fields[spreg_name]) + 1);
|
||||
ASSERT(new_spr->name != NULL);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; entry->fields[spreg_name][i] != '\0'; i++) {
|
||||
if (isupper(entry->fields[spreg_name][i]))
|
||||
new_spr->name[i] = tolower(entry->fields[spreg_name][i]);
|
||||
else
|
||||
new_spr->name[i] = entry->fields[spreg_name][i];
|
||||
}
|
||||
}
|
||||
|
||||
/* insert, by spreg_nr order */
|
||||
{
|
||||
spreg_table_entry **ptr_to_spreg_entry = &table->sprs;
|
||||
spreg_table_entry *spreg_entry = *ptr_to_spreg_entry;
|
||||
while (spreg_entry != NULL && spreg_entry->spreg_nr < new_spr->spreg_nr) {
|
||||
ptr_to_spreg_entry = &spreg_entry->next;
|
||||
spreg_entry = *ptr_to_spreg_entry;
|
||||
}
|
||||
ASSERT(spreg_entry == NULL || spreg_entry->spreg_nr != new_spr->spreg_nr);
|
||||
*ptr_to_spreg_entry = new_spr;
|
||||
new_spr->next = spreg_entry;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static spreg_table *
|
||||
spreg_table_load(char *file_name)
|
||||
{
|
||||
table *file = table_open(file_name, nr_spreg_fields, 0);
|
||||
spreg_table *table = ZALLOC(spreg_table);
|
||||
|
||||
{
|
||||
table_entry *entry;
|
||||
while ((entry = table_entry_read(file)) != NULL) {
|
||||
spreg_table_insert(table, entry);
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
char *spreg_attributes[] = {
|
||||
"is_valid",
|
||||
"is_readonly",
|
||||
"name",
|
||||
"index",
|
||||
"length",
|
||||
0
|
||||
};
|
||||
|
||||
static void
|
||||
gen_spreg_h(spreg_table *table, lf *file)
|
||||
{
|
||||
spreg_table_entry *entry;
|
||||
char **attribute;
|
||||
|
||||
lf_print__gnu_copyleft(file);
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "#ifndef _SPREG_H_\n");
|
||||
lf_printf(file, "#define _SPREG_H_\n");
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "typedef unsigned_word spreg;\n");
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "typedef enum {\n");
|
||||
|
||||
for (entry = table->sprs;
|
||||
entry != NULL ;
|
||||
entry = entry->next) {
|
||||
lf_printf(file, " spr_%s = %d,\n", entry->name, entry->spreg_nr);
|
||||
}
|
||||
|
||||
lf_printf(file, " nr_of_sprs = %d\n", nr_of_sprs);
|
||||
lf_printf(file, "} sprs;\n");
|
||||
lf_printf(file, "\n");
|
||||
for (attribute = spreg_attributes;
|
||||
*attribute != NULL;
|
||||
attribute++) {
|
||||
if (strcmp(*attribute, "name") == 0) {
|
||||
lf_print_function_type(file, "const char *", "INLINE_SPREG", " ");
|
||||
lf_printf(file, "spr_%s(sprs spr);\n", *attribute);
|
||||
}
|
||||
else {
|
||||
lf_print_function_type(file, "int", "INLINE_SPREG", " ");
|
||||
lf_printf(file, "spr_%s(sprs spr);\n", *attribute);
|
||||
}
|
||||
}
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "#endif /* _SPREG_H_ */\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gen_spreg_c(spreg_table *table, lf *file)
|
||||
{
|
||||
spreg_table_entry *entry;
|
||||
char **attribute;
|
||||
int spreg_nr;
|
||||
int spreg_lookup_table;
|
||||
|
||||
lf_print__gnu_copyleft(file);
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "#ifndef _SPREG_C_\n");
|
||||
lf_printf(file, "#define _SPREG_C_\n");
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "#include \"basics.h\"\n");
|
||||
lf_printf(file, "#include \"spreg.h\"\n");
|
||||
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "typedef struct _spreg_info {\n");
|
||||
lf_printf(file, " const char *name;\n");
|
||||
lf_printf(file, " int is_valid;\n");
|
||||
lf_printf(file, " int length;\n");
|
||||
lf_printf(file, " int is_readonly;\n");
|
||||
lf_printf(file, " int index;\n");
|
||||
lf_printf(file, "} spreg_info;\n");
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "static const spreg_info spr_info[nr_of_sprs+1] = {\n");
|
||||
entry = table->sprs;
|
||||
for (spreg_nr = 0; spreg_nr < nr_of_sprs+1; spreg_nr++) {
|
||||
if (entry == NULL || spreg_nr < entry->spreg_nr)
|
||||
lf_printf(file, " { 0, 0, 0, 0, %d},\n", spreg_nr);
|
||||
else {
|
||||
lf_printf(file, " { \"%s\", %d, %d, %d, spr_%s /*%d*/ },\n",
|
||||
entry->name, 1, entry->length, entry->is_readonly,
|
||||
entry->name, entry->spreg_nr);
|
||||
entry = entry->next;
|
||||
}
|
||||
}
|
||||
lf_printf(file, "};\n");
|
||||
|
||||
for (attribute = spreg_attributes;
|
||||
*attribute != NULL;
|
||||
attribute++) {
|
||||
lf_printf(file, "\n");
|
||||
if (strcmp(*attribute, "name") == 0) {
|
||||
lf_print_function_type(file, "const char *", "INLINE_SPREG", "\n");
|
||||
}
|
||||
else {
|
||||
lf_print_function_type(file, "int", "INLINE_SPREG", "\n");
|
||||
}
|
||||
lf_printf(file, "spr_%s(sprs spr)\n", *attribute);
|
||||
lf_printf(file, "{\n");
|
||||
spreg_lookup_table = !(strcmp(*attribute, "name") == 0
|
||||
|| strcmp(*attribute, "index") == 0);
|
||||
if (spreg_lookup_table) {
|
||||
spreg_table_entry *entry;
|
||||
lf_printf(file, "#ifdef WITH_SPREG_SWITCH_TABLE\n");
|
||||
lf_printf(file, " switch (spr) {\n");
|
||||
for (entry = table->sprs; entry != NULL; entry = entry->next) {
|
||||
if (strcmp(*attribute, "is_valid") == 0) {
|
||||
lf_printf(file, " case %d:\n", entry->spreg_nr);
|
||||
/* No return -- see below. */;
|
||||
} else if (strcmp(*attribute, "is_readonly") == 0) {
|
||||
/* Since we return 0 by default, only output non-zero entries. */
|
||||
if (entry->is_readonly) {
|
||||
lf_printf(file, " case %d:\n", entry->spreg_nr);
|
||||
lf_printf(file, " return %d;\n", entry->is_readonly);
|
||||
}
|
||||
} else if (strcmp(*attribute, "length") == 0) {
|
||||
/* Since we return 0 by default, only output non-zero entries. */
|
||||
if (entry->length) {
|
||||
lf_printf(file, " case %d:\n", entry->spreg_nr);
|
||||
lf_printf(file, " return %d;\n", entry->length);
|
||||
}
|
||||
} else
|
||||
ASSERT(0);
|
||||
}
|
||||
/* Output a single return for is_valid. */
|
||||
if (strcmp(*attribute, "is_valid") == 0)
|
||||
lf_printf(file, " return 1;\n");
|
||||
lf_printf(file, " }\n");
|
||||
lf_printf(file, " return 0;\n");
|
||||
lf_printf(file, "#else\n");
|
||||
}
|
||||
lf_printf(file, " return spr_info[spr].%s;\n",
|
||||
*attribute);
|
||||
if (spreg_lookup_table)
|
||||
lf_printf(file, "#endif\n");
|
||||
lf_printf(file, "}\n");
|
||||
}
|
||||
|
||||
lf_printf(file, "\n");
|
||||
lf_printf(file, "#endif /* _SPREG_C_ */\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
|
||||
int
|
||||
main(int argc,
|
||||
char **argv,
|
||||
char **envp)
|
||||
{
|
||||
lf_file_references file_references = lf_include_references;
|
||||
spreg_table *sprs = NULL;
|
||||
static const struct option longopts[] = { { 0 } };
|
||||
char *real_file_name = NULL;
|
||||
int is_header = 0;
|
||||
int ch;
|
||||
|
||||
if (argc <= 1) {
|
||||
printf("Usage: dgen ...\n");
|
||||
printf("-n <file-name> Use this as cpp line numbering name\n");
|
||||
printf("-h Output header file\n");
|
||||
printf("-p <spreg-file> Output spreg.h(P) or spreg.c(p)\n");
|
||||
}
|
||||
|
||||
while ((ch = getopt_long (argc, argv, "hsn:r:p:", longopts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
#if 0 /* For debugging. */
|
||||
fprintf(stderr, "\t-%c %s\n", ch, ( optarg ? optarg : ""));
|
||||
#endif
|
||||
switch(ch) {
|
||||
case 'r':
|
||||
sprs = spreg_table_load(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
real_file_name = strdup(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
is_header = 1;
|
||||
break;
|
||||
case 'p':
|
||||
{
|
||||
lf *file = lf_open(optarg, real_file_name, file_references,
|
||||
(is_header ? lf_is_h : lf_is_c),
|
||||
argv[0]);
|
||||
if (is_header)
|
||||
gen_spreg_h(sprs, file);
|
||||
else
|
||||
gen_spreg_c(sprs, file);
|
||||
lf_close(file);
|
||||
is_header = 0;
|
||||
}
|
||||
real_file_name = NULL;
|
||||
break;
|
||||
default:
|
||||
error("unknown option\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -155,10 +155,6 @@ print_options (void)
|
||||
printf_filtered ("IGEN_FLAGS = %s\n", IGEN_FLAGS);
|
||||
#endif
|
||||
|
||||
#ifdef DGEN_FLAGS
|
||||
printf_filtered ("DGEN_FLAGS = %s\n", DGEN_FLAGS);
|
||||
#endif
|
||||
|
||||
{
|
||||
static const char *const defines[] = {
|
||||
#ifdef __GNUC__
|
||||
|
Loading…
x
Reference in New Issue
Block a user