aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc
diff options
context:
space:
mode:
authorMichael Meissner <gnu@the-meissners.org>1995-11-12 14:20:39 +0000
committerMichael Meissner <gnu@the-meissners.org>1995-11-12 14:20:39 +0000
commit28816f45f574ca788dd4e05b8ee7a140e01f3d84 (patch)
treeae6525ea117a94aa6fa239a43eb8633513158742 /sim/ppc
parentc05c182dd679dd98f39e59fd567f767c679fa13f (diff)
downloadgdb-28816f45f574ca788dd4e05b8ee7a140e01f3d84.zip
gdb-28816f45f574ca788dd4e05b8ee7a140e01f3d84.tar.gz
gdb-28816f45f574ca788dd4e05b8ee7a140e01f3d84.tar.bz2
Add support for setting model name and other things
Diffstat (limited to 'sim/ppc')
-rw-r--r--sim/ppc/ChangeLog67
-rw-r--r--sim/ppc/Makefile.in21
-rw-r--r--sim/ppc/igen.c152
-rw-r--r--sim/ppc/main.c6
-rw-r--r--sim/ppc/options.c27
-rw-r--r--sim/ppc/ppc-instructions40
-rw-r--r--sim/ppc/psim.c5
-rw-r--r--sim/ppc/sim_calls.c31
-rw-r--r--sim/ppc/std-config.h27
9 files changed, 309 insertions, 67 deletions
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index d6d00f6..3261d47 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,5 +1,72 @@
+Sun Nov 12 07:58:09 1995 Michael Meissner <meissner@wogglebug.tiac.net>
+
+ * options.c (print_options): Print out WITH_{,DEFAULT_}MODEL, not
+ WITH_PPC_{,DEFAULT_}_MODEL.
+ (options_ppc): Delete now unused function.
+ (cpu.h): Include cpu.h, not just basics.h.
+
+ * std-config.h (WITH_{,DEFAULT_}MODEL): Define.
+
+ * igen.c (model_macros, last_model_macro): New statics to keep
+ track of macros to go in model.h.
+ (insn_table_load_insns): Add model-macros to model_macros linked
+ list.
+ (model_table_fields): Add field for printable name.
+ (gen_model_h): If there are model macros defined, print them out.
+ Print out DEFAULT_MODEL as the first model if there any models
+ specified, otherwise MODEL_NONE. Print out external decl for
+ current_model. Print out decl for model_set.
+ (gen_model_c): Add function model_set. Switch to use printable
+ name for the model, not the internal identifier used.
+
+ * psim.c (current_model): New global variable.
+
+ * ppc-instructions: Add macros for flag defines. Switch first
+ model so 604 is first.
+
+ * main.c (main): Call model_set, not function_unit_model.
+ * sim_calls.c (sim_open): Ditto.
+ * sim_calls.c, Makefile.in: sim_calls.c now includes cpu.h.
+
Sat Nov 11 07:27:41 1995 Michael Meissner <meissner@tiktok.cygnus.com>
+ * mon.h (mon_events): New enumeration for other events we want to
+ handle.
+ (mon_event): Add declaration for function.
+
+ * mon.c (mon_event): New function.
+ (mon_print_info): Print icache misses.
+
+ * psim.c (run_until_stop): Monitor icache misses.
+
+ * configure.in (--enable-sim-inline): Fix typos in handling comma
+ separated inline options.
+ (--enable-sim-icache): Echo icache size.
+ * configure: Regenerate.
+
+ * igen.c (semantics_h_print_function): Emit STATIC_SEMANTICS
+ instead of INLINE_SEMANTICS so that the compiler won't keep all of
+ the semantic functions as inline RTL, given that the address of
+ the function is taken which forces outline calls anyway.
+ (lf_print_c_semantic_function_header): Ditto.
+ (gen_semantics_h): Define STATIC_SEMANTICS as nothing if not
+ defined.
+ (lf_print_c_cracker_function): Emit STATIC_IDECODE instead of
+ STATIC_INLINE_IDECODE.
+ (gen_idecode_c): Define STATIC_IDECODE if not defined.
+ (gen_model_h): Use #ifdefs to define types to hold model units,
+ cycles, and flags.
+ (model_table_insert): Add a sentinel functional unit at the end to
+ simplify loop processing.
+ (model_c_insn): Use <function-unit>_SENTINAL instead of 0 for any
+ instruction not specifing a function unit for the current model.
+ (gen_model_{c,h}): Provide bounds for model_time_mapping.
+
+ * inline.h (STATIC_SEMANTICS): Define to be static if
+ SEMANTICS_INLINE is defined.
+ (STATIC_IDECODE): Define to be static if IDECODE_INLINE is
+ defined.
+
* options.c (print_options): Fix typo.
Fri Nov 10 06:39:46 1995 Michael Meissner <meissner@tiktok.cygnus.com>
diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index ed3ef3f..48d9452 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -80,6 +80,7 @@ ALIGNMENT_CFLAGS = @sim_alignment@
FLOAT_CFLAGS = @sim_float@
TRACE_CFLAGS = @sim_trace@
ASSERT_CFLAGS = @sim_assert@
+RESERVED_CFLAGS = @sim_reserved@
MONITOR_CFLAGS = @sim_monitor@
FUNC_CFLAGS = @sim_func@
MODEL_CFLAGS = @sim_model@ @sim_default_model@
@@ -96,6 +97,7 @@ CONFIG_CFLAGS = $(BSWAP_CFLAGS) \
$(FLOAT_CFLAGS) \
$(TRACE_CFLAGS) \
$(ASSERT_CFLAGS) \
+ $(RESERVED_CFLAGS) \
$(MONITOR_CFLAGS) \
$(FUNC_CFLAGS) \
$(MODEL_CFLAGS)
@@ -172,7 +174,8 @@ CPU_H = \
icache.h \
itable.h \
mon.h \
- function_unit.h
+ function_unit.h \
+ model.h
EMUL_GENERIC_H = \
$(CPU_H) \
@@ -190,7 +193,8 @@ BUILT_SRC_WO_CONFIG = \
idecode.h idecode.c \
semantics.h semantics.c \
itable.h itable.c \
- spreg.h spreg.c
+ spreg.h spreg.c \
+ model.h model.c
BUILT_SRC = \
$(BUILT_SRC_WO_CONFIG) \
@@ -239,6 +243,7 @@ LIB_OBJ = \
registers.o \
vm.o \
corefile.o \
+ model.o \
function_unit.o \
spreg.o \
cpu.o \
@@ -302,9 +307,11 @@ corefile.o: corefile.c corefile.h $(BASICS_H) device_tree.h
function_unit.o: function_unit.c $(CPU_H)
+model.o: model.c $(CPU_H)
+
events.o: events.c events.h $(BASICS_H)
-sim_calls.o: sim_calls.c $(PSIM_H) function_unit.h itable.h ../../gdb/tm.h devices.h options.h
+sim_calls.o: sim_calls.c $(CPU_H) $(PSIM_H) ../../gdb/tm.h devices.h options.h
spreg.o: spreg.h spreg.c words.h
@@ -355,7 +362,9 @@ tmp-igen: igen ppc-instructions $(IGEN_OPCODE_RULES) ppc-cache-rules $(srcdir)/.
-n idecode.h -D tmp-idecode.h \
-n idecode.c -d tmp-idecode.c \
-n itable.h -T tmp-itable.h \
- -n itable.c -t tmp-itable.c
+ -n itable.c -t tmp-itable.c \
+ -n model.h -M tmp-model.h \
+ -n model.c -m tmp-model.c
$(srcdir)/../../move-if-change tmp-icache.h icache.h
$(srcdir)/../../move-if-change tmp-idecode.h idecode.h
$(srcdir)/../../move-if-change tmp-idecode.c idecode.c
@@ -363,13 +372,15 @@ tmp-igen: igen ppc-instructions $(IGEN_OPCODE_RULES) ppc-cache-rules $(srcdir)/.
$(srcdir)/../../move-if-change tmp-semantics.c semantics.c
$(srcdir)/../../move-if-change tmp-itable.h itable.h
$(srcdir)/../../move-if-change tmp-itable.c itable.c
+ $(srcdir)/../../move-if-change tmp-model.h model.h
+ $(srcdir)/../../move-if-change tmp-model.c model.c
touch tmp-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
-itable.h itable.c icache.h idecode.h idecode.c semantics.h semantics.c: tmp-igen
+itable.h itable.c icache.h idecode.h idecode.c semantics.h semantics.c model.h model.c: tmp-igen
spreg.h spreg.c: tmp-dgen
dgen: dgen.o table.o lf.o misc.o filter_filename.o
diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c
index f9940d8..ae5a1b0 100644
--- a/sim/ppc/igen.c
+++ b/sim/ppc/igen.c
@@ -588,7 +588,8 @@ typedef enum {
} function_table_fields;
typedef enum {
- model_name = insn_name,
+ model_name = insn_nmemonic,
+ model_identifer = insn_name,
model_func = insn_comment,
} model_table_fields;
@@ -612,6 +613,7 @@ typedef struct _model model;
struct _model {
model *next;
char *name;
+ char *printable_name;
model_func_unit *func_unit_start;
model_func_unit *func_unit_end;
};
@@ -646,6 +648,8 @@ typedef enum {
static model *models;
static model *last_model;
+static insn *model_macros;
+static insn *last_model_macro;
static void
insn_table_insert_function(insn_table *table,
@@ -678,7 +682,8 @@ model_table_insert(insn_table *table,
unsigned unit, mask;
int number;
- new_model->name = file_entry->fields[model_name];
+ new_model->name = file_entry->fields[model_identifer];
+ new_model->printable_name = file_entry->fields[model_name];
name_len = strlen(new_model->name);
/* append it to the end of the model list */
@@ -763,6 +768,29 @@ model_table_insert(insn_table *table,
memcpy(func_unit->comment, comment, end - comment);
}
}
+
+ /* Add an 'sentinel' function unit at the end to simpify the loop */
+ func_unit = ZALLOC(model_func_unit);
+ if (new_model->func_unit_end)
+ new_model->func_unit_end->next = func_unit;
+ else
+ new_model->func_unit_start = func_unit;
+
+ new_model->func_unit_end = func_unit;
+
+ /* Record function unit name as model name _ unit name */
+ func_name_len = name_len + sizeof("_SENTINEL");
+ if (table->max_func_unit_name_len < func_name_len)
+ table->max_func_unit_name_len = func_name_len;
+
+ func_unit->name = name = (char *)zalloc(func_name_len);
+ func_unit->number = 0;
+ func_unit->mask = unit;
+ func_unit->comment = "dummy";
+ table->max_func_unit_mask |= unit;
+
+ memcpy(name, new_model->name, name_len);
+ strcpy(name + name_len, "_SENTINEL");
}
@@ -1081,6 +1109,15 @@ insn_table_load_insns(char *file_name)
else if (it_is("model", file_entry->fields[insn_flags])) {
model_table_insert(table, file_entry);
}
+ else if (it_is("model-macro", file_entry->fields[insn_flags])) {
+ insn *macro = ZALLOC(insn);
+ macro->file_entry = file_entry;
+ if (last_model_macro)
+ last_model_macro->next = macro;
+ else
+ model_macros = macro;
+ last_model_macro = macro;
+ }
else {
insn_fields *fields;
/* skip instructions that aren't relevant to the mode */
@@ -1558,7 +1595,7 @@ semantics_h_print_function(lf *file,
insn_bits *expanded_bits)
{
lf_printf(file, "\n");
- lf_printf(file, "INLINE_SEMANTICS unsigned_word ");
+ lf_printf(file, "STATIC_SEMANTICS unsigned_word ");
lf_print_function_name(file,
basename,
expanded_bits,
@@ -1626,6 +1663,10 @@ gen_semantics_h(insn_table *table, lf *file)
lf_printf(file, "#define INLINE_SEMANTICS\n");
lf_printf(file, "#endif\n");
lf_printf(file, "\n");
+ lf_printf(file, "#ifndef STATIC_SEMANTICS\n");
+ lf_printf(file, "#define STATIC_SEMANTICS\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
lf_printf(file, "\n");
/* output a declaration for all functions */
@@ -2200,7 +2241,7 @@ lf_print_c_semantic_function_header(lf *file,
insn_bits *expanded_bits)
{
lf_printf(file, "\n");
- lf_printf(file, "INLINE_SEMANTICS unsigned_word\n");
+ lf_printf(file, "STATIC_SEMANTICS unsigned_word\n");
lf_print_function_name(file,
basename,
expanded_bits,
@@ -2609,7 +2650,7 @@ lf_print_c_cracker_function(lf *file,
{
/* if needed, generate code to enter this routine into a cache */
lf_printf(file, "\n");
- lf_printf(file, "STATIC_INLINE_IDECODE idecode_semantic *\n");
+ lf_printf(file, "STATIC_IDECODE idecode_semantic *\n");
lf_print_function_name(file,
instruction->file_entry->fields[insn_name],
expanded_bits,
@@ -2701,6 +2742,10 @@ gen_idecode_c(insn_table *table, lf *file)
lf_printf(file, "#define STATIC_INLINE_IDECODE STATIC_INLINE\n");
lf_printf(file, "#endif\n");
lf_printf(file, "\n");
+ lf_printf(file, "#ifndef STATIC_IDECODE\n");
+ lf_printf(file, "#define STATIC_IDECODE\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
lf_printf(file, "#include \"cpu.h\"\n");
lf_printf(file, "#include \"idecode.h\"\n");
lf_printf(file, "#include \"semantics.h\"\n");
@@ -2900,6 +2945,7 @@ gen_model_h(insn_table *table, lf *file)
{
model *model_ptr;
model_func_unit *func_unit_ptr;
+ insn *macro;
int hex_size;
lf_print_copyleft(file);
@@ -2910,21 +2956,46 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "#ifndef INLINE_MODEL\n");
lf_printf(file, "#define INLINE_MODEL\n");
lf_printf(file, "#endif\n");
+ lf_printf(file, "#ifndef STATIC_INLINE_MODEL\n");
+ lf_printf(file, "#define STATIC_INLINE_MODEL STATIC_INLINE\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
lf_printf(file, "\n");
- lf_printf(file, "typedef struct _model_time {\t/* Instruction cycle time */\n");
if (table->max_func_unit_mask > 0xffff) {
hex_size = 8;
- lf_printf(file, " unsigned32 units;\n");
- lf_printf(file, " unsigned16 initial;\n");
- lf_printf(file, " unsigned16 finish;\n");
+ lf_printf(file, "#ifndef MODEL_UNITS\n");
+ lf_printf(file, "#define MODEL_UNITS unsigned32\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
+
+ lf_printf(file, "#ifndef MODEL_CYCLES\n");
+ lf_printf(file, "#define MODEL_CYCLES unsigned16\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
} else {
hex_size = 4;
- lf_printf(file, " unsigned16 units;\n");
- lf_printf(file, " unsigned8 initial;\n");
- lf_printf(file, " unsigned8 finish;\n");
+ lf_printf(file, "#ifndef MODEL_UNITS\n");
+ lf_printf(file, "#define MODEL_UNITS unsigned16\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
+
+ lf_printf(file, "#ifndef MODEL_CYCLES\n");
+ lf_printf(file, "#define MODEL_CYCLES unsigned8\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
}
- lf_printf(file, " unsigned32 flags;\n");
+
+ lf_printf(file, "#ifndef MODEL_FLAGS\n");
+ lf_printf(file, "#define MODEL_FLAGS unsigned32\n");
+ lf_printf(file, "#endif\n");
+ lf_printf(file, "\n");
+
+ lf_printf(file, "typedef struct _model_time {\t/* Instruction cycle time */\n");
+ lf_printf(file, " MODEL_UNITS units;\n");
+ lf_printf(file, " MODEL_CYCLES initial;\n");
+ lf_printf(file, " MODEL_CYCLES finish;\n");
+ lf_printf(file, " MODEL_FLAGS flags;\n");
lf_printf(file, "} model_time;\n");
lf_printf(file, "\n");
@@ -2937,6 +3008,9 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "} model_enum;\n");
lf_printf(file, "\n");
+ lf_printf(file, "#define DEFAULT_MODEL MODEL_%s\n", (models) ? models->name : "NONE");
+ lf_printf(file, "\n");
+
for (model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
for (func_unit_ptr = model_ptr->func_unit_start; func_unit_ptr; func_unit_ptr = func_unit_ptr->next) {
if (func_unit_ptr->comment) {
@@ -2953,9 +3027,19 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "\n");
}
+ if (model_macros) {
+ for(macro = model_macros; macro; macro = macro->next)
+ lf_printf(file, "%s\n", macro->file_entry->fields[insn_comment]);
+ lf_printf(file, "\n");
+ }
+
+ lf_printf(file, "extern model_enum current_model;\n");
lf_printf(file, "extern const char *model_name[ (int)nr_models ];\n");
lf_printf(file, "extern const char *const *const model_func_unit_name[ (int)nr_models ];\n");
- lf_printf(file, "extern const model_time *const model_time_mapping[];\n");
+ lf_printf(file, "extern const model_time *const model_time_mapping[ (int)nr_models ];\n");
+ lf_printf(file, "\n");
+ lf_printf(file, "INLINE_MODEL void model_set\n");
+ lf_printf(file, "(const char *name);\n");
lf_printf(file, "\n");
lf_printf(file, "#endif /* _MODEL_H_ */\n");
}
@@ -2975,12 +3059,12 @@ model_c_insn(insn_table *entry,
{
model_c_data *data_ptr = (model_c_data *)data;
lf *file = data_ptr->file;
- model *current_model = data_ptr->model_ptr;
+ char *current_name = data_ptr->model_ptr->name;
table_model_entry *model_ptr = instruction->file_entry->model_first;
int i;
while (model_ptr) {
- if (model_ptr->fields[insn_model_name] == current_model->name) {
+ if (model_ptr->fields[insn_model_name] == current_name) {
lf_printf(file, " {");
for(i = insn_model_unit; i < nr_insn_model_table_fields; i++) {
lf_printf(file, " %s,", model_ptr->fields[i]);
@@ -2992,7 +3076,7 @@ model_c_insn(insn_table *entry,
model_ptr = model_ptr->next;
}
- lf_printf(file, " { 0 },\n");
+ lf_printf(file, " { %s_SENTINEL },\n", current_name);
}
static void
@@ -3007,10 +3091,6 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "#ifndef _MODEL_C_\n");
lf_printf(file, "#define _MODEL_C_\n");
lf_printf(file, "\n");
- lf_printf(file, "#ifndef STATIC_INLINE_MODEL\n");
- lf_printf(file, "#define STATIC_INLINE_MODEL STATIC_INLINE\n");
- lf_printf(file, "#endif\n");
- lf_printf(file, "\n");
lf_printf(file, "#include \"cpu.h\"\n");
lf_printf(file, "\n");
@@ -3018,7 +3098,7 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "const char *model_name[ (int)nr_models ] = {\n");
lf_printf(file, " \"NONE\",\n");
for (model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- lf_printf(file, " \"%s\",\n", model_ptr->name);
+ lf_printf(file, " \"%s\",\n", model_ptr->printable_name);
}
lf_printf(file, "};\n");
lf_printf(file, "\n");
@@ -3078,7 +3158,7 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "\n");
}
- lf_printf(file, "const model_time *const model_time_mapping[] = {\n");
+ lf_printf(file, "const model_time *const model_time_mapping[ (int)nr_models ] = {\n");
lf_printf(file, " (const model_time *const)0,\n");
for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
lf_printf(file, " model_time_%s,\n", model_ptr->name);
@@ -3086,6 +3166,32 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "};\n");
lf_printf(file, "\n");
+ lf_printf(file, "INLINE_MODEL void\n");
+ lf_printf(file, "model_set(const char *name)\n");
+ lf_printf(file, "{\n");
+ if (models) {
+ lf_printf(file, " model_enum model;\n");
+ lf_printf(file, " for(model = MODEL_%s; model < nr_models; model++) {\n", models->name);
+ lf_printf(file, " if(strcasecmp(name, model_name[model]) == 0) {\n");
+ lf_printf(file, " current_model = model;\n");
+ lf_printf(file, " return;\n");
+ lf_printf(file, " }\n");
+ lf_printf(file, " }\n");
+ lf_printf(file, "\n");
+ lf_printf(file, " error(\"Unknown model '%%s', Models which are known are:%%s\n\",\n");
+ lf_printf(file, " name,\n");
+ lf_printf(file, " \"");
+ for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
+ lf_printf(file, "\\n\\t%s", model_ptr->printable_name);
+ }
+ lf_printf(file, "\");\n");
+ } else {
+ lf_printf(file, " error(\"No models are currently known about\");\n");
+ }
+
+ lf_printf(file, "}\n");
+ lf_printf(file, "\n");
+
lf_printf(file, "#endif /* _MODEL_C_ */\n");
}
diff --git a/sim/ppc/main.c b/sim/ppc/main.c
index 80b993f..0b3ad07 100644
--- a/sim/ppc/main.c
+++ b/sim/ppc/main.c
@@ -24,6 +24,7 @@
#include "psim.h"
#include "function_unit.h"
+#include "options.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -109,7 +110,7 @@ main(int argc, char **argv)
trace_option(optarg);
break;
case 'm':
- function_unit_model(optarg);
+ model_set(optarg);
break;
case 'i':
print_info = 1;
@@ -125,6 +126,9 @@ main(int argc, char **argv)
usage();
name_of_file = argv[optind];
+ if (ppc_trace[trace_opts])
+ print_options ();
+
/* create the simulator */
system = psim_create(name_of_file);
diff --git a/sim/ppc/options.c b/sim/ppc/options.c
index 161b0d1..a48a3b7 100644
--- a/sim/ppc/options.c
+++ b/sim/ppc/options.c
@@ -21,7 +21,7 @@
#ifndef _OPTIONS_C_
#define _OPTIONS_C_
-#include "basics.h"
+#include "cpu.h"
#include "options.h"
STATIC_INLINE const char *
@@ -85,25 +85,6 @@ options_mon (int mon)
return "UNKNOWN";
}
-STATIC_INLINE const char *
-options_ppc (ppc_model ppc)
-{
- switch (ppc) {
- case PPC_MODEL_UNKNOWN: return "NONE";
- case PPC_MODEL_601: return "601";
- case PPC_MODEL_602: return "602";
- case PPC_MODEL_603: return "603";
- case PPC_MODEL_603e: return "603e";
- case PPC_MODEL_604: return "604";
- case PPC_MODEL_403: return "403";
- case PPC_MODEL_505: return "505";
- case PPC_MODEL_821: return "821";
- case PPC_MODEL_860: return "860";
- }
-
- return "UNKNOWN";
-}
-
void
print_options (void)
{
@@ -129,9 +110,9 @@ print_options (void)
printf_filtered ("WITH_ASSERT = %d\n", WITH_ASSERT);
printf_filtered ("WITH_MON = %s\n", options_mon (WITH_MON));
printf_filtered ("WITH_FUNCTION_UNIT = %d\n", WITH_FUNCTION_UNIT);
- printf_filtered ("WITH_DEFAULT_PPC_MODEL = %s\n", options_ppc (WITH_DEFAULT_PPC_MODEL));
- printf_filtered ("WITH_PPC_MODEL = %s\n", options_ppc (WITH_PPC_MODEL));
- printf_filtered ("WITH_RESERVE_BITS = %d\n", WITH_RESERVE_BITS);
+ printf_filtered ("WITH_DEFAULT_MODEL = %s\n", model_name[WITH_DEFAULT_MODEL]);
+ printf_filtered ("WITH_MODEL = %s\n", model_name[WITH_MODEL]);
+ printf_filtered ("WITH_RESERVED_BITS = %d\n", WITH_RESERVED_BITS);
printf_filtered ("DEFAULT_INLINE = %d\n", DEFAULT_INLINE);
printf_filtered ("SIM_ENDIAN_INLINE = %d\n", SIM_ENDIAN_INLINE);
printf_filtered ("BITS_INLINE = %d\n", BITS_INLINE);
diff --git a/sim/ppc/ppc-instructions b/sim/ppc/ppc-instructions
index 67ec1dd..c8fa910 100644
--- a/sim/ppc/ppc-instructions
+++ b/sim/ppc/ppc-instructions
@@ -50,6 +50,31 @@
#
# 5 Description
#
+#
+# For flags marked 'model', the fields are interpreted as follows:
+#
+# 1 Not used
+#
+# 2 Not used
+#
+# 3 "macro"
+#
+# 4 String name for model
+#
+# 5 Specific CPU model, must be an identifier
+#
+# 6 Comma separated list of functional units
+
+# Flags for model.h
+::model-macro:::#define PPC_LOAD 0x00000001
+::model-macro:::#define PPC_STORE 0x00000002
+::model-macro:::#define PPC_SERIALIZE 0x00000004
+
+# PowerPC models
+::model:604:PPC604:SCIU=2 single cycle integer,MCIU=1 multiple cycle integer,FPU=1 floating point,LSU=1 memory,BPU=1 branch
+::model:603e:PPC603e:IU=1 integer,FPU=1 floating point,LSU=1 memory,SRU=1 system register,BPU=1 branch
+::model:603:PPC603:IU=1 integer,FPU=1 floating point,LSU=1 memory,SRU=1 system register,BPU=1 branch
+
# The following (illegal) instruction is `known' by gen and is
# called when ever an illegal instruction is encountered
@@ -526,10 +551,16 @@ void::function::invalid_arithemetic_operation:cpu *processor, unsigned_word cia,
# I.2.4.1 Branch Instructions
#
0.18,6.LI,30.AA,31.LK:I:t::Branch
+*PPC603:PPC603_BPU:1:1:0
+*PPC603e:PPC603_BPU:1:1:0
+*PPC604:PPC603_BPU:1:1:0
if (AA) NIA = IEA(EXTS(LI_0b00));
else NIA = IEA(CIA + EXTS(LI_0b00));
if (LK) LR = (spreg)CIA+4;
0.16,6.BO,11.BI,16.BD,30.AA,31.LK:B:t::Branch Conditional
+*PPC603:PPC603_BPU:1:1:0
+*PPC603e:PPC603_BPU:1:1:0
+*PPC604:PPC603_BPU:1:1:0
int M, ctr_ok, cond_ok;
if (is_64bit_implementation && is_64bit_mode) M = 0;
else M = 32;
@@ -541,6 +572,9 @@ void::function::invalid_arithemetic_operation:cpu *processor, unsigned_word cia,
else NIA = IEA(CIA + EXTS(BD_0b00));
if (LK) LR = (spreg)IEA(CIA + 4);
0.19,6.BO,11.BI,16./,21.16,31.LK:XL:t::Branch Conditional to Link Register
+*PPC603:PPC603_BPU:1:1:0
+*PPC603e:PPC603_BPU:1:1:0
+*PPC604:PPC603_BPU:1:1:0
int M, ctr_ok, cond_ok;
if (is_64bit_implementation && is_64bit_mode) M = 0;
else M = 32;
@@ -550,6 +584,9 @@ void::function::invalid_arithemetic_operation:cpu *processor, unsigned_word cia,
if (ctr_ok && cond_ok) NIA = IEA(LR_0b00);
if (LK) LR = (spreg)IEA(CIA + 4);
0.19,6.BO,11.BI,16./,21.528,31.LK:XL:t::Branch Conditional to Count Register
+*PPC603:PPC603_BPU:1:1:0
+*PPC603e:PPC603_BPU:1:1:0
+*PPC604:PPC603_BPU:1:1:0
int cond_ok;
cond_ok = BO{0} || (CR{BI} == BO{1});
if (cond_ok) NIA = IEA(CTR_0b00);
@@ -1035,6 +1072,9 @@ void::function::invalid_arithemetic_operation:cpu *processor, unsigned_word cia,
#
0.14,6.RT,11.RA,16.SI:D:T::Add Immediate
+*PPC603:PPC603_IU:1:1:0
+*PPC603e:PPC603e_IU|PPC603e_SRU:1:1:0
+*PPC604:PPC604_SCIU:1:1:0
if (RA_is_0) *rT = EXTS(SI);
else *rT = *rA + EXTS(SI);
0.15,6.RT,11.RA,16.SI:D:::Add Immediate Shifted
diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c
index b696ab0..89a9fff 100644
--- a/sim/ppc/psim.c
+++ b/sim/ppc/psim.c
@@ -98,6 +98,7 @@ int current_environment;
int current_alignment;
int current_floating_point;
ppc_model current_ppc_model = WITH_DEFAULT_PPC_MODEL;
+model_enum current_model = WITH_DEFAULT_MODEL;
/* create a device tree from the image */
@@ -653,6 +654,8 @@ run_until_stop(psim *system,
instruction,
cia,
cache_entry);
+
+ mon_event(mon_event_icache_miss, processor, cia);
cache_entry->address = cia;
cache_entry->semantic = semantic;
cia = semantic(processor, cache_entry, cia);
@@ -746,6 +749,8 @@ run_until_stop(psim *system,
instruction,
cia,
cache_entry);
+
+ mon_event(mon_event_icache_miss, system->processors[current_cpu], cia);
cache_entry->address = cia;
cache_entry->semantic = semantic;
cpu_set_program_counter(processor,
diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c
index 5a61e53..c59d3e1 100644
--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -23,9 +23,9 @@
#include <stdarg.h>
#include <ctype.h>
-#include "basics.h"
-#include "function_unit.h"
+#include "cpu.h"
#include "psim.h"
+#include "options.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -93,13 +93,13 @@ sim_open (char *args)
break;
case 'm':
if (p[1])
- function_unit_model(p+1);
+ model_set(p+1);
else {
argp += 1;
if (argv[argp] == NULL)
error("Missing <trace> option for -t\n");
else
- function_unit_model(argv[argp]);
+ model_set(argv[argp]);
}
break;
case 'i':
@@ -116,6 +116,9 @@ sim_open (char *args)
}
}
+ if (ppc_trace[trace_opts])
+ print_options ();
+
/* do something */
TRACE(trace_tbd, ("sim_open() - TBD - should parse the arguments\n"));
TRACE(trace_tbd, ("sim_open() - TBD - can not create simulator here as do not have description of it\n"));
@@ -173,8 +176,8 @@ sim_read (SIM_ADDR mem, unsigned char *buf, int length)
{
int result = psim_read_memory(simulator, MAX_NR_PROCESSORS,
buf, mem, length);
- TRACE(trace_gdb, ("sim_read(mem=0x%x, buf=0x%x, length=%d) = %d\n",
- mem, buf, length, result));
+ TRACE(trace_gdb, ("sim_read(mem=0x%lx, buf=0x%lx, length=%d) = %d\n",
+ (long)mem, (long)buf, length, result));
return result;
}
@@ -185,8 +188,8 @@ sim_write (SIM_ADDR mem, unsigned char *buf, int length)
int result = psim_write_memory(simulator, MAX_NR_PROCESSORS,
buf, mem, length,
1/*violate_ro*/);
- TRACE(trace_gdb, ("sim_write(mem=0x%x, buf=0x%x, length=%d) = %d\n",
- mem, buf, length, result));
+ TRACE(trace_gdb, ("sim_write(mem=0x%lx, buf=0x%lx, length=%d) = %d\n",
+ (long)mem, (long)buf, length, result));
return result;
}
@@ -197,8 +200,8 @@ sim_fetch_register (int regno, unsigned char *buf)
if (simulator == NULL) {
return;
}
- TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%x)\n",
- regno, register_names[regno], buf));
+ TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%lx)\n",
+ regno, register_names[regno], (long)buf));
psim_read_register(simulator, MAX_NR_PROCESSORS,
buf, register_names[regno],
raw_transfer);
@@ -210,8 +213,8 @@ sim_store_register (int regno, unsigned char *buf)
{
if (simulator == NULL)
return;
- TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%x)\n",
- regno, register_names[regno], buf));
+ TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n",
+ regno, register_names[regno], (long)buf));
psim_write_register(simulator, MAX_NR_PROCESSORS,
buf, register_names[regno],
raw_transfer);
@@ -286,8 +289,8 @@ sim_stop_reason (enum sim_stop *reason, int *sigrc)
}
- TRACE(trace_gdb, ("sim_stop_reason(reason=0x%x(%d), sigrc=0x%x(%d))\n",
- reason, *reason, sigrc, *sigrc));
+ TRACE(trace_gdb, ("sim_stop_reason(reason=0x%lx(%ld), sigrc=0x%lx(%ld))\n",
+ (long)reason, (long)*reason, (long)sigrc, (long)*sigrc));
}
diff --git a/sim/ppc/std-config.h b/sim/ppc/std-config.h
index ace2888..8a77d3a 100644
--- a/sim/ppc/std-config.h
+++ b/sim/ppc/std-config.h
@@ -236,6 +236,12 @@ extern int current_floating_point;
#define WITH_ASSERT 1
#endif
+/* Whether to check instructions for reserved bits being set */
+
+#ifndef WITH_RESERVED_BITS
+#define WITH_RESERVED_BITS 1
+#endif
+
/* include monitoring code */
#define MONITOR_INSTRUCTION_ISSUE 1
@@ -282,6 +288,19 @@ extern ppc_model current_ppc_model;
? WITH_PPC_MODEL \
: current_ppc_model)
+/* Current CPU model (models are in the generated models.h include file) */
+#ifndef WITH_MODEL
+#define WITH_MODEL 0
+#endif
+
+#define CURRENT_MODEL (WITH_MODEL \
+ ? WITH_MODEL \
+ : current_model)
+
+#ifndef WITH_DEFAULT_MODEL
+#define WITH_DEFAULT_MODEL DEFAULT_MODEL
+#endif
+
/* INLINE CODE SELECTION:
GCC -O3 attempts to inline any function or procedure in scope. The
@@ -454,7 +473,13 @@ extern ppc_model current_ppc_model;
#define IDECODE_INLINE DEFAULT_INLINE
#endif
-/* Code to simule functional units of real machines */
+/* Model specific code used in simulating functional units */
+
+#ifndef MODEL_INLINE
+#define MODEL_INLINE DEFAULT_INLINE
+#endif
+
+/* Code to simulate functional units of real machines */
#ifndef FUNCTION_UNIT_INLINE
#define FUNCTION_UNIT_INLINE DEFAULT_INLINE