aboutsummaryrefslogtreecommitdiff
path: root/sim/igen
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1998-04-04 12:33:11 +0000
committerAndrew Cagney <cagney@redhat.com>1998-04-04 12:33:11 +0000
commit278bda4050efd9f6e59a66f9d1f0972521ced67b (patch)
tree0d5665927e194812e1cce29888c3dfbce161cc00 /sim/igen
parent79cb0c8a2fc8df9735259b524c7a1f39f5518d1e (diff)
downloadgdb-278bda4050efd9f6e59a66f9d1f0972521ced67b.zip
gdb-278bda4050efd9f6e59a66f9d1f0972521ced67b.tar.gz
gdb-278bda4050efd9f6e59a66f9d1f0972521ced67b.tar.bz2
Cleanup INLINE support for simulators using common framework.
Make IGEN responsible for co-ordinating inlining of generated files. By default, aclocal.m4 disabled all inlining.
Diffstat (limited to 'sim/igen')
-rw-r--r--sim/igen/ChangeLog20
-rw-r--r--sim/igen/igen.c150
-rw-r--r--sim/igen/igen.h97
3 files changed, 170 insertions, 97 deletions
diff --git a/sim/igen/ChangeLog b/sim/igen/ChangeLog
index f56c2d3..c62353b 100644
--- a/sim/igen/ChangeLog
+++ b/sim/igen/ChangeLog
@@ -1,3 +1,23 @@
+Fri Apr 3 18:08:16 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * gen.h, igen.c (print_include_inline, print_includes,
+ print_includes): New functions. Generate include list. For for
+ semantics et.al. generate CPP code to inline when
+ C_REVEALS_MODULE_P.
+
+ * igen.c (gen_semantics_c): Call print_includes.
+ * gen-engine.c (gen_engine_c): Ditto.
+
+Sat Apr 4 21:09:11 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * igen.h: (struct _igen_name_option): Replace with struct
+ igen_module_option. Contains both module prefix and suffix.
+ (INIT_OPTIONS): Initialize.
+
+ * igen.c (main): Update -P option to fill in full module info.
+ (gen-engine.c, gen-icache.c, gen-itable.c, gen-semantics.c,
+ gen-support.c): Update.
+
Sat Apr 4 02:15:35 1998 Andrew Cagney <cagney@b1.cygnus.com>
* igen.c (print_itrace): Use TRACE_ANY_P macro to determine if any
diff --git a/sim/igen/igen.c b/sim/igen/igen.c
index efdacaa..fd9b20d 100644
--- a/sim/igen/igen.c
+++ b/sim/igen/igen.c
@@ -61,9 +61,9 @@ print_semantic_function_formal (lf *file,
{
nr += lf_printf (file, "SIM_DESC sd,\n");
nr += lf_printf (file, "%sidecode_cache *cache_entry,\n",
- options.prefix.global.name);
+ options.module.global.prefix.l);
nr += lf_printf (file, "%sinstruction_address cia",
- options.prefix.global.name);
+ options.module.global.prefix.l);
}
else if (options.gen.smp)
{
@@ -71,11 +71,11 @@ print_semantic_function_formal (lf *file,
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
{
nr += lf_printf (file, "%sinstruction_word instruction_%d,\n",
- options.prefix.global.name,
+ options.module.global.prefix.l,
word_nr);
}
nr += lf_printf (file, "%sinstruction_address cia",
- options.prefix.global.name);
+ options.module.global.prefix.l);
}
else
{
@@ -83,11 +83,11 @@ print_semantic_function_formal (lf *file,
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
{
nr += lf_printf (file, "%sinstruction_word instruction_%d,\n",
- options.prefix.global.name,
+ options.module.global.prefix.l,
word_nr);
}
nr += lf_printf (file, "%sinstruction_address cia",
- options.prefix.global.name);
+ options.module.global.prefix.l);
}
return nr;
}
@@ -120,7 +120,7 @@ print_semantic_function_type (lf *file)
{
int nr = 0;
nr += lf_printf (file, "%sinstruction_address",
- options.prefix.global.name);
+ options.module.global.prefix.l);
return nr;
}
@@ -139,11 +139,11 @@ print_icache_function_formal (lf *file,
nr += lf_printf (file, "SIM_DESC sd,\n");
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
nr += lf_printf (file, " %sinstruction_word instruction_%d,\n",
- options.prefix.global.name, word_nr);
+ options.module.global.prefix.l, word_nr);
nr += lf_printf (file, " %sinstruction_address cia,\n",
- options.prefix.global.name);
+ options.module.global.prefix.l);
nr += lf_printf (file, " %sidecode_cache *cache_entry",
- options.prefix.global.name);
+ options.module.global.prefix.l);
return nr;
}
@@ -174,7 +174,7 @@ print_icache_function_type (lf *file)
else
{
nr = lf_printf (file, "%sidecode_semantic *",
- options.prefix.global.name);
+ options.module.global.prefix.l);
}
return nr;
}
@@ -241,22 +241,22 @@ print_function_name (lf *file,
switch (prefix)
{
case function_name_prefix_semantics:
- nr += lf_printf (file, "%s", options.prefix.semantics.name);
+ nr += lf_printf (file, "%s", options.module.semantics.prefix.l);
nr += lf_printf (file, "semantic_");
break;
case function_name_prefix_idecode:
- nr += lf_printf (file, "%s", options.prefix.idecode.name);
+ nr += lf_printf (file, "%s", options.module.idecode.prefix.l);
nr += lf_printf (file, "idecode_");
break;
case function_name_prefix_itable:
- nr += lf_printf (file, "%sitable_", options.prefix.itable.name);
+ nr += lf_printf (file, "%sitable_", options.module.itable.prefix.l);
break;
case function_name_prefix_icache:
- nr += lf_printf (file, "%s", options.prefix.icache.name);
+ nr += lf_printf (file, "%s", options.module.icache.prefix.l);
nr += lf_printf (file, "icache_");
break;
case function_name_prefix_engine:
- nr += lf_printf (file, "%s", options.prefix.engine.name);
+ nr += lf_printf (file, "%s", options.module.engine.prefix.l);
nr += lf_printf (file, "engine_");
default:
break;
@@ -339,8 +339,8 @@ print_itrace_prefix (lf *file)
int indent = strlen (prefix);
lf_printf (file, "%sSD, CPU, cia, CIA, TRACE_LINENUM_P (CPU), \\\n", prefix);
lf_indent (file, +indent);
- lf_printf (file, "%sitable[MY_INDEX].file, \\\n", options.prefix.itable.name);
- lf_printf (file, "%sitable[MY_INDEX].line_nr, \\\n", options.prefix.itable.name);
+ lf_printf (file, "%sitable[MY_INDEX].file, \\\n", options.module.itable.prefix.l);
+ lf_printf (file, "%sitable[MY_INDEX].line_nr, \\\n", options.module.itable.prefix.l);
lf_printf (file, "\"");
return indent;
}
@@ -427,7 +427,7 @@ print_itrace_format (lf *file,
lf_printf (file, "%%s");
else
{
- lf_printf (file, "%sstr_", options.prefix.global.name);
+ lf_printf (file, "%sstr_", options.module.global.prefix.l);
lf_write (file, func, strlen_func);
lf_printf (file, " (SD_, ");
lf_write (file, param, strlen_param);
@@ -567,6 +567,39 @@ print_sim_engine_abort (lf *file,
}
+void
+print_include (lf *file,
+ igen_module module)
+{
+ lf_printf (file, "#include \"%s%s.h\"\n", module.prefix.l, module.suffix.l);
+}
+
+void
+print_include_inline (lf *file,
+ igen_module module)
+{
+ lf_printf (file, "#if C_REVEALS_MODULE_P (%s_INLINE)\n", module.suffix.u);
+ lf_printf (file, "#include \"%s%s.c\"\n", module.prefix.l, module.suffix.l);
+ lf_printf (file, "#else\n");
+ print_include (file, module);
+ lf_printf (file, "#endif\n");
+ lf_printf (file, "\n");
+}
+
+void
+print_includes (lf *file)
+{
+ lf_printf (file, "\n");
+ lf_printf (file, "#include \"sim-inline.c\"\n");
+ lf_printf (file, "\n");
+ lf_printf (file, "#include \"sim-main.h\"\n");
+ lf_printf (file, "\n");
+ print_include_inline (file, options.module.itable);
+ print_include_inline (file, options.module.idecode);
+ print_include_inline (file, options.module.support);
+}
+
+
/****************************************************************/
@@ -582,7 +615,7 @@ gen_semantics_h (lf *file,
lf_printf (file, "typedef ");
print_semantic_function_type (file);
lf_printf (file, " %sidecode_semantic",
- options.prefix.global.name);
+ options.module.global.prefix.l);
if (word_nr >= 0)
lf_printf (file, "_%d", word_nr);
lf_printf (file, "\n(");
@@ -622,17 +655,10 @@ gen_semantics_c (lf *file,
if (options.gen.code == generate_calls)
{
insn_list *semantic;
+ print_includes (file);
+ print_include (file, options.module.semantics);
lf_printf (file, "\n");
- lf_printf (file, "#include \"sim-main.h\"\n");
- lf_printf (file, "#include \"%sitable.h\"\n",
- options.prefix.itable.name);
- lf_printf (file, "#include \"%sidecode.h\"\n",
- options.prefix.idecode.name);
- lf_printf (file, "#include \"%ssemantics.h\"\n",
- options.prefix.semantics.name);
- lf_printf (file, "#include \"%ssupport.h\"\n",
- options.prefix.support.name);
- lf_printf (file, "\n");
+
for (semantic = semantics; semantic != NULL; semantic = semantic->next)
{
/* Ignore any special/internal instructions */
@@ -668,7 +694,7 @@ gen_icache_h (lf *file,
lf_printf (file, "typedef ");
print_icache_function_type(file);
lf_printf (file, " %sidecode_icache_%d\n(",
- options.prefix.global.name,
+ options.module.global.prefix.l,
word_nr);
print_icache_function_formal(file, word_nr);
lf_printf (file, ");\n");
@@ -746,27 +772,27 @@ gen_idecode_h (lf *file,
cache_entry *cache_rules)
{
lf_printf (file, "typedef unsigned%d %sinstruction_word;\n",
- options.insn_bit_size, options.prefix.global.name);
+ options.insn_bit_size, options.module.global.prefix.l);
if (options.gen.delayed_branch)
{
lf_printf (file, "typedef struct _%sinstruction_address {\n",
- options.prefix.global.name);
+ options.module.global.prefix.l);
lf_printf (file, " address_word ip; /* instruction pointer */\n");
lf_printf (file, " address_word dp; /* delayed-slot pointer */\n");
- lf_printf (file, "} %sinstruction_address;\n", options.prefix.global.name);
+ lf_printf (file, "} %sinstruction_address;\n", options.module.global.prefix.l);
}
else
{
lf_printf (file, "typedef address_word %sinstruction_address;\n",
- options.prefix.global.name);
+ options.module.global.prefix.l);
}
if (options.gen.nia == nia_is_invalid
- && strlen (options.prefix.global.uname) > 0)
+ && strlen (options.module.global.prefix.u) > 0)
{
lf_indent_suppress (file);
lf_printf (file, "#define %sINVALID_INSTRUCTION_ADDRESS ",
- options.prefix.global.uname);
+ options.module.global.prefix.u);
lf_printf (file, "INVALID_INSTRUCTION_ADDRESS\n");
}
lf_printf (file, "\n");
@@ -806,12 +832,8 @@ gen_idecode_c (lf *file,
cache_entry *cache_rules)
{
/* the intro */
- lf_printf (file, "#include \"sim-main.h\"\n");
- lf_printf (file, "#include \"%sidecode.h\"\n", options.prefix.global.name);
- lf_printf (file, "#include \"%ssemantics.h\"\n", options.prefix.global.name);
- lf_printf (file, "#include \"%sicache.h\"\n", options.prefix.global.name);
- lf_printf (file, "#include \"%ssupport.h\"\n", options.prefix.global.name);
- lf_printf (file, "\n");
+ print_includes (file);
+ print_include_inline (file, options.module.semantics);
lf_printf (file, "\n");
print_idecode_globals (file);
@@ -838,7 +860,7 @@ gen_idecode_c (lf *file,
lf_printf (file, "{\n");
lf_indent (file, +2);
lf_printf (file, "%sinstruction_address nia;\n",
- options.prefix.global.name);
+ options.module.global.prefix.l);
print_idecode_body (file, entry->table, "nia =");
lf_printf (file, "return nia;");
lf_indent (file, -2);
@@ -995,7 +1017,7 @@ main (int argc,
int ch;
lf *standard_out = lf_open ("-", "stdout", lf_omit_references, lf_is_text, "igen");
- INIT_OPTIONS (options);
+ INIT_OPTIONS ();
if (argc == 1)
{
@@ -1182,12 +1204,12 @@ main (int argc,
case 'P':
{
- igen_prefix_name *names;
+ igen_module *names;
char *chp;
chp = strchr (optarg, '=');
if (chp == NULL)
{
- names = &options.prefix.global;
+ names = &options.module.global;
chp = optarg;
}
else
@@ -1195,31 +1217,31 @@ main (int argc,
chp = chp + 1; /* skip `=' */
if (strncmp (optarg, "global=", chp - optarg) == 0)
{
- names = &options.prefix.global;
+ names = &options.module.global;
}
if (strncmp (optarg, "engine=", chp - optarg) == 0)
{
- names = &options.prefix.engine;
+ names = &options.module.engine;
}
if (strncmp (optarg, "icache=", chp - optarg) == 0)
{
- names = &options.prefix.icache;
+ names = &options.module.icache;
}
if (strncmp (optarg, "idecode=", chp - optarg) == 0)
{
- names = &options.prefix.idecode;
+ names = &options.module.idecode;
}
if (strncmp (optarg, "itable=", chp - optarg) == 0)
{
- names = &options.prefix.itable;
+ names = &options.module.itable;
}
if (strncmp (optarg, "semantics=", chp - optarg) == 0)
{
- names = &options.prefix.semantics;
+ names = &options.module.semantics;
}
if (strncmp (optarg, "support=", chp - optarg) == 0)
{
- names = &options.prefix.support;
+ names = &options.module.support;
}
else
{
@@ -1227,22 +1249,22 @@ main (int argc,
error (NULL, "Prefix `%s' unreconized\n", optarg);
}
}
- names->name = strdup (chp);
- names->uname = strdup (chp);
- chp = names->uname;
+ names->prefix.u = strdup (chp);
+ names->prefix.l = strdup (chp);
+ chp = names->prefix.u;
while (*chp) {
if (islower(*chp))
*chp = toupper(*chp);
chp++;
}
- if (names == &options.prefix.global)
+ if (names == &options.module.global)
{
- options.prefix.engine = options.prefix.global;
- options.prefix.icache = options.prefix.global;
- options.prefix.idecode = options.prefix.global;
- /* options.prefix.itable = options.prefix.global; */
- options.prefix.semantics = options.prefix.global;
- options.prefix.support = options.prefix.global;
+ options.module.engine.prefix = options.module.global.prefix;
+ options.module.icache.prefix = options.module.global.prefix;
+ options.module.idecode.prefix = options.module.global.prefix;
+ /* options.module.itable.prefix = options.module.global.prefix; */
+ options.module.semantics.prefix = options.module.global.prefix;
+ options.module.support.prefix = options.module.global.prefix;
}
break;
}
diff --git a/sim/igen/igen.h b/sim/igen/igen.h
index 188e3e4..7aa70ef 100644
--- a/sim/igen/igen.h
+++ b/sim/igen/igen.h
@@ -1,6 +1,6 @@
/* This file is part of the program psim.
- Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
+ Copyright (C) 1994-1998, 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
@@ -59,6 +59,9 @@ struct _igen_gen_options {
/* should multiple simulators be generated? */
int multi_sim;
+ /* name of the default multi-sim model */
+ char *default_model;
+
/* should the simulator support multi word instructions and if so,
what is the max nr of words. */
int multi_word;
@@ -87,20 +90,24 @@ struct _igen_trace_options {
int combine;
};
-typedef struct _igen_prefix_name {
- char *name;
- char *uname;
-} igen_prefix_name;
-
-typedef struct _igen_prefix_options {
- igen_prefix_name global;
- igen_prefix_name engine;
- igen_prefix_name icache;
- igen_prefix_name idecode;
- igen_prefix_name itable;
- igen_prefix_name semantics;
- igen_prefix_name support;
-} igen_prefix_options;
+typedef struct _igen_name {
+ char *u;
+ char *l;
+} igen_name;
+typedef struct _igen_module {
+ igen_name prefix;
+ igen_name suffix;
+} igen_module;
+
+typedef struct _igen_module_options {
+ igen_module global;
+ igen_module engine;
+ igen_module icache;
+ igen_module idecode;
+ igen_module itable;
+ igen_module semantics;
+ igen_module support;
+} igen_module_options;
typedef struct _igen_decode_options igen_decode_options ;
struct _igen_decode_options {
@@ -131,10 +138,16 @@ struct _igen_decode_options {
typedef struct _igen_warn_options igen_warn_options;
struct _igen_warn_options {
+
+ /* Issue warning about discarded instructions */
int discard;
+
+ /* Issue warning about invalid instruction widths */
+ int width;
};
+
typedef struct _igen_options igen_options;
struct _igen_options {
@@ -145,7 +158,7 @@ struct _igen_options {
int insn_specifying_widths;
/* what should global names be prefixed with? */
- igen_prefix_options prefix;
+ igen_module_options module;
/* See above for options and flags */
igen_gen_options gen;
@@ -153,6 +166,9 @@ struct _igen_options {
/* See above for trace options */
igen_trace_options trace;
+ /* See above for include options */
+ table_include *include;
+
/* See above for decode options */
igen_decode_options decode;
@@ -176,22 +192,37 @@ struct _igen_options {
extern igen_options options;
/* default options - hopefully backward compatible */ \
-#define INIT_OPTIONS(OPTIONS) \
+#define INIT_OPTIONS() \
do { \
- memset (&(OPTIONS), 0, sizeof (OPTIONS)); \
- memset (&(OPTIONS).warn, -1, sizeof ((OPTIONS).warn)); \
- (OPTIONS).hi_bit_nr = 0; \
- (OPTIONS).insn_bit_size = default_insn_bit_size; \
- (OPTIONS).insn_specifying_widths = 0; \
- (OPTIONS).prefix.global.name = ""; \
- (OPTIONS).prefix.global.uname = ""; \
- (OPTIONS).prefix.engine = (OPTIONS).prefix.global; \
- (OPTIONS).prefix.icache = (OPTIONS).prefix.global; \
- (OPTIONS).prefix.idecode = (OPTIONS).prefix.global; \
- (OPTIONS).prefix.itable = (OPTIONS).prefix.global; \
- (OPTIONS).prefix.semantics = (OPTIONS).prefix.global; \
- (OPTIONS).prefix.support = (OPTIONS).prefix.global; \
- (OPTIONS).gen.code = generate_calls; \
- (OPTIONS).gen.icache_size = 1024; \
- (OPTIONS).warning = warning; \
+ memset (&options, 0, sizeof options); \
+ memset (&options.warn, -1, sizeof (options.warn)); \
+ options.hi_bit_nr = 0; \
+ options.insn_bit_size = default_insn_bit_size; \
+ options.insn_specifying_widths = 0; \
+ options.module.global.prefix.u = ""; \
+ options.module.global.prefix.l = ""; \
+ /* the prefixes */ \
+ options.module.engine = options.module.global; \
+ options.module.icache = options.module.global; \
+ options.module.idecode = options.module.global; \
+ options.module.itable = options.module.global; \
+ options.module.semantics = options.module.global; \
+ options.module.support = options.module.global; \
+ /* the suffixes */ \
+ options.module.engine.suffix.l = "engine"; \
+ options.module.engine.suffix.u = "ENGINE"; \
+ options.module.icache.suffix.l = "icache"; \
+ options.module.icache.suffix.u = "ICACHE"; \
+ options.module.idecode.suffix.l = "idecode"; \
+ options.module.idecode.suffix.u = "IDECODE"; \
+ options.module.itable.suffix.l = "itable"; \
+ options.module.itable.suffix.u = "ITABLE"; \
+ options.module.semantics.suffix.l = "semantics"; \
+ options.module.semantics.suffix.u = "SEMANTICS"; \
+ options.module.support.suffix.l = "support"; \
+ options.module.support.suffix.u = "SUPPORT"; \
+ /* misc stuff */ \
+ options.gen.code = generate_calls; \
+ options.gen.icache_size = 1024; \
+ options.warning = warning; \
} while (0)