diff options
author | Mike Frysinger <vapier@gentoo.org> | 2022-11-10 23:09:00 +0700 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2022-11-11 01:39:49 +0700 |
commit | fa654e74f23fa6e18222a47b05dddb87abd5d5ad (patch) | |
tree | cb956f4ee7b00e9bb7be9935efff10971b618205 | |
parent | 689c2b4b65fb5d0ce6b6414685e1f5c6f97d7c25 (diff) | |
download | gdb-fa654e74f23fa6e18222a47b05dddb87abd5d5ad.zip gdb-fa654e74f23fa6e18222a47b05dddb87abd5d5ad.tar.gz gdb-fa654e74f23fa6e18222a47b05dddb87abd5d5ad.tar.bz2 |
sim: igen: constify various func arguments
-rw-r--r-- | sim/igen/filter.c | 27 | ||||
-rw-r--r-- | sim/igen/filter.h | 15 | ||||
-rw-r--r-- | sim/igen/gen-engine.c | 14 | ||||
-rw-r--r-- | sim/igen/gen-engine.h | 8 | ||||
-rw-r--r-- | sim/igen/gen-icache.c | 47 | ||||
-rw-r--r-- | sim/igen/gen-icache.h | 20 | ||||
-rw-r--r-- | sim/igen/gen-idecode.c | 60 | ||||
-rw-r--r-- | sim/igen/gen-idecode.h | 10 | ||||
-rw-r--r-- | sim/igen/gen-itable.c | 24 | ||||
-rw-r--r-- | sim/igen/gen-itable.h | 4 | ||||
-rw-r--r-- | sim/igen/gen-model.c | 4 | ||||
-rw-r--r-- | sim/igen/gen-model.h | 4 | ||||
-rw-r--r-- | sim/igen/gen-semantics.c | 41 | ||||
-rw-r--r-- | sim/igen/gen-semantics.h | 19 | ||||
-rw-r--r-- | sim/igen/gen-support.c | 10 | ||||
-rw-r--r-- | sim/igen/gen-support.h | 4 | ||||
-rw-r--r-- | sim/igen/gen.c | 49 | ||||
-rw-r--r-- | sim/igen/gen.h | 28 | ||||
-rw-r--r-- | sim/igen/igen.c | 41 | ||||
-rw-r--r-- | sim/igen/ld-cache.c | 2 | ||||
-rw-r--r-- | sim/igen/ld-cache.h | 2 | ||||
-rw-r--r-- | sim/igen/ld-decode.c | 19 | ||||
-rw-r--r-- | sim/igen/ld-decode.h | 6 | ||||
-rw-r--r-- | sim/igen/ld-insn.c | 105 | ||||
-rw-r--r-- | sim/igen/ld-insn.h | 37 | ||||
-rw-r--r-- | sim/igen/lf.c | 6 | ||||
-rw-r--r-- | sim/igen/lf.h | 6 | ||||
-rw-r--r-- | sim/igen/misc.c | 6 | ||||
-rw-r--r-- | sim/igen/misc.h | 2 | ||||
-rw-r--r-- | sim/igen/table.c | 16 | ||||
-rw-r--r-- | sim/igen/table.h | 9 |
31 files changed, 380 insertions, 265 deletions
diff --git a/sim/igen/filter.c b/sim/igen/filter.c index 7a7dc44..641d1fd 100644 --- a/sim/igen/filter.c +++ b/sim/igen/filter.c @@ -75,7 +75,7 @@ filter_parse (filter **filters, const char *filt) void -filter_add (filter **set, filter *add) +filter_add (filter **set, const filter *add) { while (add != NULL) { @@ -109,7 +109,7 @@ filter_add (filter **set, filter *add) int -filter_is_subset (filter *superset, filter *subset) +filter_is_subset (const filter *superset, const filter *subset) { while (1) { @@ -130,7 +130,7 @@ filter_is_subset (filter *superset, filter *subset) int -filter_is_common (filter *l, filter *r) +filter_is_common (const filter *l, const filter *r) { while (1) { @@ -151,7 +151,7 @@ filter_is_common (filter *l, filter *r) int -filter_is_member (filter *filt, const char *flag) +filter_is_member (const filter *filt, const char *flag) { int index = 1; while (filt != NULL) @@ -166,15 +166,15 @@ filter_is_member (filter *filt, const char *flag) int -is_filtered_out (filter *filters, const char *flags) +is_filtered_out (const filter *filters, const char *flags) { while (strlen (flags) > 0) { int present; - filter *filt = filters; + const filter *filt = filters; /* break the string up */ - char *end = strchr (flags, ','); - char *next; + const char *end = strchr (flags, ','); + const char *next; unsigned /*size_t */ len; if (end == NULL) { @@ -207,8 +207,8 @@ is_filtered_out (filter *filters, const char *flags) } -char * -filter_next (filter *set, char *member) +const char * +filter_next (const filter *set, const char *member) { while (set != NULL) { @@ -221,9 +221,12 @@ filter_next (filter *set, char *member) void -dump_filter (lf *file, char *prefix, filter *set, char *suffix) +dump_filter (lf *file, + const char *prefix, + const filter *set, + const char *suffix) { - char *member; + const char *member; lf_printf (file, "%s", prefix); member = filter_next (set, ""); if (member != NULL) diff --git a/sim/igen/filter.h b/sim/igen/filter.h index cae51bf..3930edd 100644 --- a/sim/igen/filter.h +++ b/sim/igen/filter.h @@ -31,39 +31,40 @@ extern void filter_parse (filter **filters, const char *filt); /* add the second filter to the first */ -extern void filter_add (filter **filters, filter *add); +extern void filter_add (filter **filters, const filter *add); /* returns true if SUB is a strict subset of SUPER. For an empty set is a member of any set */ -extern int filter_is_subset (filter *superset, filter *subset); +extern int filter_is_subset (const filter *superset, const filter *subset); /* return true if there is at least one member common to the two filters */ -extern int filter_is_common (filter *l, filter *r); +extern int filter_is_common (const filter *l, const filter *r); /* returns the index (pos + 1) if the name is in the filter. */ -extern int filter_is_member (filter *set, const char *flag); +extern int filter_is_member (const filter *set, const char *flag); /* returns true if one of the flags is not present in the filter. === !filter_is_subset (filter_parse (NULL, flags), filters) */ -int is_filtered_out (filter *filters, const char *flags); +int is_filtered_out (const filter *filters, const char *flags); /* returns the next member of the filter set that follows MEMBER. Member does not need to be an elememt of the filter set. Next of "" is the first non-empty member */ -char *filter_next (filter *set, char *member); +const char *filter_next (const filter *set, const char *member); /* for debugging */ -extern void dump_filter (lf *file, char *prefix, filter *filt, char *suffix); +extern void dump_filter + (lf *file, const char *prefix, const filter *filt, const char *suffix); diff --git a/sim/igen/gen-engine.c b/sim/igen/gen-engine.c index 25d9071..7c0559f 100644 --- a/sim/igen/gen-engine.c +++ b/sim/igen/gen-engine.c @@ -63,7 +63,7 @@ print_engine_issue_postfix_hook (lf *file) static void -print_run_body (lf *file, gen_entry *table) +print_run_body (lf *file, const gen_entry *table) { /* Output the function to execute real code: @@ -335,7 +335,7 @@ after all the other CPU's and the event queue have been processed */\n\ void print_engine_run_function_header (lf *file, - char *processor, + const char *processor, function_decl_type decl_type) { int indent; @@ -390,7 +390,9 @@ print_engine_run_function_header (lf *file, void gen_engine_h (lf *file, - gen_table *gen, insn_table *isa, cache_entry *cache_rules) + const gen_table *gen, + const insn_table *isa, + cache_entry *cache_rules) { gen_list *entry; for (entry = gen->tables; entry != NULL; entry = entry->next) @@ -405,9 +407,11 @@ gen_engine_h (lf *file, void gen_engine_c (lf *file, - gen_table *gen, insn_table *isa, cache_entry *cache_rules) + const gen_table *gen, + const insn_table *isa, + cache_entry *cache_rules) { - gen_list *entry; + const gen_list *entry; /* the intro */ print_includes (file); print_include_inline (file, options.module.semantics); diff --git a/sim/igen/gen-engine.h b/sim/igen/gen-engine.h index e1a0fdf..6b1b380 100644 --- a/sim/igen/gen-engine.h +++ b/sim/igen/gen-engine.h @@ -20,10 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern void gen_engine_h - (lf *file, gen_table *gen, insn_table *isa, cache_entry *cache_rules); + (lf *file, const gen_table *gen, const insn_table *isa, + cache_entry *cache_rules); extern void gen_engine_c - (lf *file, gen_table *gen, insn_table *isa, cache_entry *cache_rules); + (lf *file, const gen_table *gen, const insn_table *isa, + cache_entry *cache_rules); extern void print_engine_run_function_header - (lf *file, char *processor, function_decl_type decl_type); + (lf *file, const char *processor, function_decl_type decl_type); diff --git a/sim/igen/gen-icache.c b/sim/igen/gen-icache.c index 3e04a8d..8ed933b 100644 --- a/sim/igen/gen-icache.c +++ b/sim/igen/gen-icache.c @@ -42,7 +42,7 @@ static void print_icache_function_header (lf *file, const char *basename, const char *format_name, - opcode_bits *expanded_bits, + const opcode_bits *expanded_bits, int is_function_definition, int nr_prefetched_words) { @@ -63,9 +63,10 @@ print_icache_function_header (lf *file, void print_icache_declaration (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, int nr_prefetched_words) + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + int nr_prefetched_words) { print_icache_function_header (file, insn->name, @@ -84,16 +85,16 @@ print_icache_extraction (lf *file, const char *entry_name, const char *entry_type, const char *entry_expression, - char *single_insn_field, + const char *single_insn_field, line_ref *line, insn_field_entry *cur_field, - opcode_bits *expanded_bits, + const opcode_bits *expanded_bits, icache_decl_type what_to_declare, icache_body_type what_to_do) { const char *expression; - opcode_bits *bits; - char *reason; + const opcode_bits *bits; + const char *reason; ASSERT (format_name != NULL); ASSERT (entry_name != NULL); @@ -323,8 +324,8 @@ print_icache_extraction (lf *file, void print_icache_body (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, + const insn_entry *instruction, + const opcode_bits *expanded_bits, cache_entry *cache_rules, icache_decl_type what_to_declare, icache_body_type what_to_do, int nr_prefetched_words) @@ -479,7 +480,7 @@ print_icache_body (lf *file, cache_rule->original_fields) && !filter_is_member (instruction->field_names, cache_rule->name)) { - char *single_field = + const char *single_field = filter_next (cache_rule->original_fields, ""); if (filter_next (cache_rule->original_fields, single_field) != NULL) @@ -505,7 +506,7 @@ struct _form_fields }; static form_fields * -insn_table_cache_fields (insn_table *isa) +insn_table_cache_fields (const insn_table *isa) { form_fields *forms = NULL; insn_entry *insn; @@ -538,7 +539,7 @@ insn_table_cache_fields (insn_table *isa) extern void -print_icache_struct (lf *file, insn_table *isa, cache_entry *cache_rules) +print_icache_struct (lf *file, const insn_table *isa, cache_entry *cache_rules) { /* Create a list of all the different instruction formats with their corresponding field names. */ @@ -568,7 +569,7 @@ print_icache_struct (lf *file, insn_table *isa, cache_entry *cache_rules) lf_indent (file, +2); { cache_entry *cache_rule; - char *field; + const char *field; /* space for any instruction words */ if (options.gen.insn_in_icache) lf_printf (file, "instruction_word insn[%d];\n", @@ -582,7 +583,7 @@ print_icache_struct (lf *file, insn_table *isa, cache_entry *cache_rules) if (filter_is_subset (format->fields, cache_rule->original_fields)) { - char *memb; + const char *memb; lf_printf (file, "%s %s;", (cache_rule->type == NULL ? "unsigned" @@ -642,9 +643,9 @@ print_icache_struct (lf *file, insn_table *isa, cache_entry *cache_rules) static void print_icache_function (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, + const insn_entry *instruction, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words) { int indent; @@ -742,9 +743,9 @@ print_icache_function (lf *file, void print_icache_definition (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words) { print_icache_function (file, @@ -757,7 +758,7 @@ print_icache_definition (lf *file, void print_icache_internal_function_declaration (lf *file, - function_entry * function, + const function_entry *function, void *data) { ASSERT (options.gen.icache); @@ -778,7 +779,7 @@ print_icache_internal_function_declaration (lf *file, void print_icache_internal_function_definition (lf *file, - function_entry * function, + const function_entry *function, void *data) { ASSERT (options.gen.icache); diff --git a/sim/igen/gen-icache.h b/sim/igen/gen-icache.h index 6918bcb..e5a94e0 100644 --- a/sim/igen/gen-icache.h +++ b/sim/igen/gen-icache.h @@ -42,8 +42,8 @@ icache_body_type; extern void print_icache_body (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, + const insn_entry *instruction, + const opcode_bits *expanded_bits, cache_entry *cache_rules, icache_decl_type what_to_declare, icache_body_type what_to_do, int nr_prefetched_words); @@ -53,15 +53,17 @@ extern void print_icache_body extern void print_icache_declaration (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, int nr_prefetched_words); + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + int nr_prefetched_words); extern void print_icache_definition (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words); + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + cache_entry *cache_rules, int nr_prefetched_words); /* Output an instruction cache support function */ @@ -73,7 +75,7 @@ extern function_entry_handler print_icache_internal_function_definition; /* Output the instruction cache table data structure */ extern void print_icache_struct - (lf *file, insn_table *instructions, cache_entry *cache_rules); + (lf *file, const insn_table *instructions, cache_entry *cache_rules); /* Output a single instructions decoder */ diff --git a/sim/igen/gen-idecode.c b/sim/igen/gen-idecode.c index d16cab5..5715e8c 100644 --- a/sim/igen/gen-idecode.c +++ b/sim/igen/gen-idecode.c @@ -38,7 +38,7 @@ static void -lf_print_opcodes (lf *file, gen_entry *table) +lf_print_opcodes (lf *file, const gen_entry *table) { if (table !=NULL) { @@ -80,7 +80,7 @@ print_idecode_ifetch (lf *file, static void -lf_print_table_name (lf *file, gen_entry *table) +lf_print_table_name (lf *file, const gen_entry *table) { lf_printf (file, "idecode_table"); lf_print_opcodes (file, table); @@ -89,7 +89,7 @@ lf_print_table_name (lf *file, gen_entry *table) static void -print_idecode_table (lf *file, gen_entry *entry, const char *result) +print_idecode_table (lf *file, const gen_entry *entry, const char *result) { lf_printf (file, "/* prime the search */\n"); lf_printf (file, "idecode_table_entry *table = "); @@ -154,7 +154,8 @@ print_idecode_table (lf *file, gen_entry *entry, const char *result) static void -print_idecode_table_start (lf *file, gen_entry *table, int depth, void *data) +print_idecode_table_start (lf *file, + const gen_entry *table, int depth, void *data) { ASSERT (depth == 0); /* start of the table */ @@ -168,9 +169,10 @@ print_idecode_table_start (lf *file, gen_entry *table, int depth, void *data) } static void -print_idecode_table_leaf (lf *file, gen_entry *entry, int depth, void *data) +print_idecode_table_leaf (lf *file, + const gen_entry *entry, int depth, void *data) { - gen_entry *master_entry; + const gen_entry *master_entry; ASSERT (entry->parent != NULL); ASSERT (depth == 0); if (entry->combined_parent == NULL) @@ -241,7 +243,8 @@ print_idecode_table_leaf (lf *file, gen_entry *entry, int depth, void *data) } static void -print_idecode_table_end (lf *file, gen_entry *table, int depth, void *data) +print_idecode_table_end (lf *file, + const gen_entry *table, int depth, void *data) { ASSERT (depth == 0); if (table->opcode_rule->gen == array_gen) @@ -254,7 +257,7 @@ print_idecode_table_end (lf *file, gen_entry *table, int depth, void *data) static void -print_goto_switch_name (lf *file, gen_entry *entry) +print_goto_switch_name (lf *file, const gen_entry *entry) { lf_printf (file, "case_"); if (entry->opcode == NULL) @@ -276,7 +279,7 @@ print_goto_switch_name (lf *file, gen_entry *entry) static void print_goto_switch_table_leaf (lf *file, - gen_entry *entry, int depth, void *data) + const gen_entry *entry, int depth, void *data) { ASSERT (entry->parent != NULL); ASSERT (depth == 0); @@ -292,7 +295,7 @@ print_goto_switch_table_leaf (lf *file, } static void -print_goto_switch_break (lf *file, gen_entry *entry) +print_goto_switch_break (lf *file, const gen_entry *entry) { lf_printf (file, "goto break_"); lf_print_table_name (file, entry->parent); @@ -301,7 +304,7 @@ print_goto_switch_break (lf *file, gen_entry *entry) static void -print_goto_switch_table (lf *file, gen_entry *table) +print_goto_switch_table (lf *file, const gen_entry *table) { lf_printf (file, "const static void *"); lf_print_table_name (file, table); @@ -315,10 +318,12 @@ print_goto_switch_table (lf *file, gen_entry *table) } -void print_idecode_switch (lf *file, gen_entry *table, const char *result); +void print_idecode_switch + (lf *file, const gen_entry *table, const char *result); static void -print_idecode_switch_start (lf *file, gen_entry *table, int depth, void *data) +print_idecode_switch_start (lf *file, + const gen_entry *table, int depth, void *data) { /* const char *result = data; */ ASSERT (depth == 0); @@ -373,7 +378,8 @@ print_idecode_switch_start (lf *file, gen_entry *table, int depth, void *data) static void -print_idecode_switch_leaf (lf *file, gen_entry *entry, int depth, void *data) +print_idecode_switch_leaf (lf *file, + const gen_entry *entry, int depth, void *data) { const char *result = data; ASSERT (entry->parent != NULL); @@ -401,7 +407,7 @@ print_idecode_switch_leaf (lf *file, gen_entry *entry, int depth, void *data) || entry->parent->opcode_rule->gen == padded_switch_gen) { /* case: <opcode-nr> - switch */ - gen_entry *cob; + const gen_entry *cob; for (cob = entry; cob != NULL; cob = cob->combined_next) lf_printf (file, "case %d:\n", cob->opcode_nr); } @@ -505,7 +511,8 @@ print_idecode_switch_illegal (lf *file, const char *result) } static void -print_idecode_switch_end (lf *file, gen_entry *table, int depth, void *data) +print_idecode_switch_end (lf *file, + const gen_entry *table, int depth, void *data) { const char *result = data; ASSERT (depth == 0); @@ -565,7 +572,7 @@ print_idecode_switch_end (lf *file, gen_entry *table, int depth, void *data) void -print_idecode_switch (lf *file, gen_entry *table, const char *result) +print_idecode_switch (lf *file, const gen_entry *table, const char *result) { gen_entry_traverse_tree (file, table, 0, @@ -577,7 +584,7 @@ print_idecode_switch (lf *file, gen_entry *table, const char *result) static void print_idecode_switch_function_header (lf *file, - gen_entry *table, + const gen_entry *table, int is_function_definition, int nr_prefetched_words) { @@ -622,7 +629,8 @@ print_idecode_switch_function_header (lf *file, static void -idecode_declare_if_switch (lf *file, gen_entry *table, int depth, void *data) +idecode_declare_if_switch (lf *file, + const gen_entry *table, int depth, void *data) { if ((table->opcode_rule->gen == switch_gen || table->opcode_rule->gen == goto_switch_gen || table->opcode_rule->gen == padded_switch_gen) &&table->parent != NULL /* don't declare the top one yet */ && table->parent->opcode_rule->gen == array_gen) @@ -636,7 +644,8 @@ idecode_declare_if_switch (lf *file, gen_entry *table, int depth, void *data) static void -idecode_expand_if_switch (lf *file, gen_entry *table, int depth, void *data) +idecode_expand_if_switch (lf *file, + const gen_entry *table, int depth, void *data) { if ((table->opcode_rule->gen == switch_gen || table->opcode_rule->gen == goto_switch_gen || table->opcode_rule->gen == padded_switch_gen) &&table->parent != NULL /* don't expand the top one yet */ && table->parent->opcode_rule->gen == array_gen) @@ -664,7 +673,9 @@ idecode_expand_if_switch (lf *file, gen_entry *table, int depth, void *data) void -print_idecode_lookups (lf *file, gen_entry *table, cache_entry *cache_rules) +print_idecode_lookups (lf *file, + const gen_entry *table, + cache_entry *cache_rules) { int depth; @@ -689,7 +700,7 @@ print_idecode_lookups (lf *file, gen_entry *table, cache_entry *cache_rules) void -print_idecode_body (lf *file, gen_entry *table, const char *result) +print_idecode_body (lf *file, const gen_entry *table, const char *result) { if (table->opcode_rule->gen == switch_gen || table->opcode_rule->gen == goto_switch_gen @@ -713,7 +724,8 @@ print_idecode_body (lf *file, gen_entry *table, const char *result) void print_idecode_validate (lf *file, - insn_entry * instruction, insn_opcodes *opcode_paths) + const insn_entry *instruction, + const insn_opcodes *opcode_paths) { /* Validate: unchecked instruction fields @@ -764,7 +776,7 @@ print_idecode_validate (lf *file, relevant bit */ if (opcode_paths != NULL) { - insn_opcodes *entry; + const insn_opcodes *entry; for (entry = opcode_paths; entry != NULL; entry = entry->next) { opcode_field *opcode; diff --git a/sim/igen/gen-idecode.h b/sim/igen/gen-idecode.h index 41a1ee4..416119c 100644 --- a/sim/igen/gen-idecode.h +++ b/sim/igen/gen-idecode.h @@ -28,9 +28,11 @@ void print_idecode_issue_function_header void print_idecode_globals (lf *file); void print_idecode_lookups - (lf *file, gen_entry *table, cache_entry *cache_rules); + (lf *file, + const gen_entry *table, + cache_entry *cache_rules); -void print_idecode_body (lf *file, gen_entry *table, const char *result); +void print_idecode_body (lf *file, const gen_entry *table, const char *result); @@ -40,4 +42,6 @@ void print_idecode_body (lf *file, gen_entry *table, const char *result); hardware isn't disabled */ extern void print_idecode_validate - (lf *file, insn_entry * instruction, insn_opcodes *opcode_paths); + (lf *file, + const insn_entry *instruction, + const insn_opcodes *opcode_paths); diff --git a/sim/igen/gen-itable.c b/sim/igen/gen-itable.c index edd9c70..21c13c9 100644 --- a/sim/igen/gen-itable.c +++ b/sim/igen/gen-itable.c @@ -46,7 +46,9 @@ itable_info; static void itable_h_insn (lf *file, - insn_table *entry, insn_entry * instruction, void *data) + const insn_table *entry, + const insn_entry *instruction, + void *data) { int len; itable_info *info = data; @@ -73,9 +75,9 @@ itable_h_insn (lf *file, /* print the list of all the different options */ static void -itable_print_enum (lf *file, filter *set, char *name) +itable_print_enum (lf *file, const filter *set, const char *name) { - char *elem; + const char *elem; lf_printf (file, "typedef enum {\n"); lf_indent (file, +2); for (elem = filter_next (set, ""); @@ -109,9 +111,9 @@ itable_print_enum (lf *file, filter *set, char *name) /* print an array of the option names as strings */ static void -itable_print_names (lf *file, filter *set, char *name) +itable_print_names (lf *file, const filter *set, const char *name) { - char *elem; + const char *elem; lf_printf (file, "const char *%sitable_%s_names[nr_%sitable_%ss + 1] = {\n", options.module.itable.prefix.l, name, options.module.itable.prefix.l, name); @@ -127,7 +129,7 @@ itable_print_names (lf *file, filter *set, char *name) } extern void -gen_itable_h (lf *file, insn_table *isa) +gen_itable_h (lf *file, const insn_table *isa) { itable_info *info = ZALLOC (itable_info); @@ -206,9 +208,9 @@ gen_itable_h (lf *file, insn_table *isa) /****************************************************************/ static void -itable_print_set (lf *file, filter *set, filter *members) +itable_print_set (lf *file, const filter *set, const filter *members) { - char *elem; + const char *elem; lf_printf (file, "\""); elem = filter_next (members, ""); if (elem != NULL) @@ -245,7 +247,9 @@ itable_print_set (lf *file, filter *set, filter *members) static void itable_c_insn (lf *file, - insn_table *isa, insn_entry * instruction, void *data) + const insn_table *isa, + const insn_entry *instruction, + void *data) { lf_printf (file, "{ "); lf_indent (file, +2); @@ -273,7 +277,7 @@ itable_c_insn (lf *file, extern void -gen_itable_c (lf *file, insn_table *isa) +gen_itable_c (lf *file, const insn_table *isa) { /* leader */ lf_printf (file, "#include \"%sitable.h\"\n", diff --git a/sim/igen/gen-itable.h b/sim/igen/gen-itable.h index acf759c..0c5182a 100644 --- a/sim/igen/gen-itable.h +++ b/sim/igen/gen-itable.h @@ -23,6 +23,6 @@ /* Output a table of all the instructions */ -extern void gen_itable_h (lf *file, insn_table *table); +extern void gen_itable_h (lf *file, const insn_table *table); -extern void gen_itable_c (lf *file, insn_table *table); +extern void gen_itable_c (lf *file, const insn_table *table); diff --git a/sim/igen/gen-model.c b/sim/igen/gen-model.c index 52bb04a..e2726aa 100644 --- a/sim/igen/gen-model.c +++ b/sim/igen/gen-model.c @@ -33,14 +33,14 @@ void -gen_model_h (lf *file, insn_table *table) +gen_model_h (lf *file, const insn_table *table) { lf_print__this_file_is_empty (file, "suffering bit rot"); } void -gen_model_c (lf *file, insn_table *table) +gen_model_c (lf *file, const insn_table *table) { lf_print__this_file_is_empty (file, "suffering bit rot"); } diff --git a/sim/igen/gen-model.h b/sim/igen/gen-model.h index 6d372bb..bd65acc 100644 --- a/sim/igen/gen-model.h +++ b/sim/igen/gen-model.h @@ -21,6 +21,6 @@ -extern void gen_model_h (lf *file, insn_table *isa); +extern void gen_model_h (lf *file, const insn_table *isa); -extern void gen_model_c (lf *file, insn_table *isa); +extern void gen_model_c (lf *file, const insn_table *isa); diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c index 38f70f3..92fd2cb 100644 --- a/sim/igen/gen-semantics.c +++ b/sim/igen/gen-semantics.c @@ -41,7 +41,7 @@ static void print_semantic_function_header (lf *file, const char *basename, const char *format_name, - opcode_bits *expanded_bits, + const opcode_bits *expanded_bits, int is_function_definition, int nr_prefetched_words) { @@ -83,9 +83,10 @@ print_semantic_function_header (lf *file, void print_semantic_declaration (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, int nr_prefetched_words) + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + int nr_prefetched_words) { print_semantic_function_header (file, insn->name, @@ -143,8 +144,9 @@ print_idecode_invalid (lf *file, const char *result, invalid_type type) void print_semantic_body (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, insn_opcodes *opcodes) + const insn_entry *instruction, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes) { /* validate the instruction, if a cache this has already been done */ if (!options.gen.icache) @@ -300,10 +302,11 @@ print_semantic_body (lf *file, static void print_c_semantic (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, - cache_entry *cache_rules, int nr_prefetched_words) + const insn_entry *instruction, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + cache_entry *cache_rules, + int nr_prefetched_words) { lf_printf (file, "{\n"); @@ -348,10 +351,11 @@ print_c_semantic (lf *file, static void print_c_semantic_function (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, - cache_entry *cache_rules, int nr_prefetched_words) + const insn_entry *instruction, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + cache_entry *cache_rules, + int nr_prefetched_words) { /* build the semantic routine to execute the instruction */ print_semantic_function_header (file, @@ -367,10 +371,11 @@ print_c_semantic_function (lf *file, void print_semantic_definition (lf *file, - insn_entry * insn, - opcode_bits *expanded_bits, - insn_opcodes *opcodes, - cache_entry *cache_rules, int nr_prefetched_words) + const insn_entry *insn, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes, + cache_entry *cache_rules, + int nr_prefetched_words) { print_c_semantic_function (file, insn, diff --git a/sim/igen/gen-semantics.h b/sim/igen/gen-semantics.h index 6c57851..81c2e6b 100644 --- a/sim/igen/gen-semantics.h +++ b/sim/igen/gen-semantics.h @@ -72,14 +72,18 @@ extern void print_semantic_declaration (lf *file, - insn_entry * insn, - opcode_bits *bits, insn_opcodes *opcodes, int nr_prefetched_words); + const insn_entry *insn, + const opcode_bits *bits, + const insn_opcodes *opcodes, + int nr_prefetched_words); extern void print_semantic_definition (lf *file, - insn_entry * insn, - opcode_bits *bits, - insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words); + const insn_entry *insn, + const opcode_bits *bits, + const insn_opcodes *opcodes, + cache_entry *cache_rules, + int nr_prefetched_words); typedef enum @@ -95,5 +99,6 @@ extern void print_idecode_invalid extern void print_semantic_body (lf *file, - insn_entry * instruction, - opcode_bits *expanded_bits, insn_opcodes *opcodes); + const insn_entry *instruction, + const opcode_bits *expanded_bits, + const insn_opcodes *opcodes); diff --git a/sim/igen/gen-support.c b/sim/igen/gen-support.c index d9d0f7c..d0ea8d5 100644 --- a/sim/igen/gen-support.c +++ b/sim/igen/gen-support.c @@ -37,7 +37,7 @@ static void print_support_function_name (lf *file, - function_entry * function, + const function_entry *function, int is_function_definition) { if (function->is_internal) @@ -90,7 +90,7 @@ print_support_function_name (lf *file, static void -support_h_function (lf *file, function_entry * function, void *data) +support_h_function (lf *file, const function_entry *function, void *data) { ASSERT (function->type != NULL); print_support_function_name (file, function, 0 /*!is_definition */ ); @@ -99,7 +99,7 @@ support_h_function (lf *file, function_entry * function, void *data) extern void -gen_support_h (lf *file, insn_table *table) +gen_support_h (lf *file, const insn_table *table) { /* output the definition of `SD_' */ if (options.gen.smp) @@ -173,7 +173,7 @@ gen_support_h (lf *file, insn_table *table) } static void -support_c_function (lf *file, function_entry * function, void *data) +support_c_function (lf *file, const function_entry *function, void *data) { ASSERT (function->type != NULL); print_support_function_name (file, function, 1 /*!is_definition */ ); @@ -197,7 +197,7 @@ support_c_function (lf *file, function_entry * function, void *data) void -gen_support_c (lf *file, insn_table *table) +gen_support_c (lf *file, const insn_table *table) { lf_printf (file, "#include \"sim-main.h\"\n"); lf_printf (file, "#include \"%sidecode.h\"\n", diff --git a/sim/igen/gen-support.h b/sim/igen/gen-support.h index e70977f..14a1ce4 100644 --- a/sim/igen/gen-support.h +++ b/sim/igen/gen-support.h @@ -20,6 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -extern void gen_support_h (lf *file, insn_table *table); +extern void gen_support_h (lf *file, const insn_table *table); -extern void gen_support_c (lf *file, insn_table *table); +extern void gen_support_c (lf *file, const insn_table *table); diff --git a/sim/igen/gen.c b/sim/igen/gen.c index 3882b5b..9f48e5c 100644 --- a/sim/igen/gen.c +++ b/sim/igen/gen.c @@ -38,7 +38,7 @@ sub_val (insn_uint val, int val_last_pos, int first_pos, int last_pos) } static void -update_depth (lf *file, gen_entry *entry, int depth, void *data) +update_depth (lf *file, const gen_entry *entry, int depth, void *data) { int *max_depth = (int *) data; if (*max_depth < depth) @@ -47,7 +47,7 @@ update_depth (lf *file, gen_entry *entry, int depth, void *data) int -gen_entry_depth (gen_entry *table) +gen_entry_depth (const gen_entry *table) { int depth = 0; gen_entry_traverse_tree (NULL, table, 1, NULL, /*start */ @@ -58,7 +58,9 @@ gen_entry_depth (gen_entry *table) static void -print_gen_entry_path (line_ref *line, gen_entry *table, error_func *print) +print_gen_entry_path (const line_ref *line, + const gen_entry *table, + error_func *print) { if (table->parent == NULL) { @@ -75,12 +77,13 @@ print_gen_entry_path (line_ref *line, gen_entry *table, error_func *print) } static void -print_gen_entry_insns (gen_entry *table, +print_gen_entry_insns (const gen_entry *table, error_func *print, - char *first_message, char *next_message) + const char *first_message, + const char *next_message) { insn_list *i; - char *message; + const char *message; message = first_message; for (i = table->insns; i != NULL; i = i->next) { @@ -94,7 +97,7 @@ print_gen_entry_insns (gen_entry *table, /* same as strcmp */ static int -insn_field_cmp (insn_word_entry *l, insn_word_entry *r) +insn_field_cmp (const insn_word_entry *l, const insn_word_entry *r) { while (1) { @@ -170,7 +173,7 @@ insn_field_cmp (insn_word_entry *l, insn_word_entry *r) /* same as strcmp */ static int -insn_word_cmp (insn_word_entry *l, insn_word_entry *r) +insn_word_cmp (const insn_word_entry *l, const insn_word_entry *r) { while (1) { @@ -199,7 +202,7 @@ insn_word_cmp (insn_word_entry *l, insn_word_entry *r) /* same as strcmp */ static int -opcode_bit_cmp (opcode_bits *l, opcode_bits *r) +opcode_bit_cmp (const opcode_bits *l, const opcode_bits *r) { if (l == NULL && r == NULL) return 0; /* all previous bits the same */ @@ -233,7 +236,7 @@ opcode_bit_cmp (opcode_bits *l, opcode_bits *r) /* same as strcmp */ static int -opcode_bits_cmp (opcode_bits *l, opcode_bits *r) +opcode_bits_cmp (const opcode_bits *l, const opcode_bits *r) { while (1) { @@ -452,7 +455,7 @@ insn_list_insert (insn_list **cur_insn_ptr, extern void gen_entry_traverse_tree (lf *file, - gen_entry *table, + const gen_entry *table, int depth, gen_entry_handler * start, gen_entry_handler * leaf, @@ -498,7 +501,9 @@ gen_entry_traverse_tree (lf *file, /* create a list element containing a single gen_table entry */ static gen_list * -make_table (insn_table *isa, decode_table *rules, model_entry *model) +make_table (const insn_table *isa, + const decode_table *rules, + const model_entry *model) { insn_entry *insn; gen_list *entry = ZALLOC (gen_list); @@ -524,7 +529,7 @@ make_table (insn_table *isa, decode_table *rules, model_entry *model) gen_table * -make_gen_tables (insn_table *isa, decode_table *rules) +make_gen_tables (const insn_table *isa, const decode_table *rules) { gen_table *gen = ZALLOC (gen_table); gen->isa = isa; @@ -560,9 +565,9 @@ make_gen_tables (insn_table *isa, decode_table *rules) /* Is the bit, according to the decode rule, identical across all the instructions? */ static int -insns_bit_useless (insn_list *insns, decode_table *rule, int bit_nr) +insns_bit_useless (const insn_list *insns, const decode_table *rule, int bit_nr) { - insn_list *entry; + const insn_list *entry; int value = -1; int is_useless = 1; /* cleared if something actually found */ @@ -710,7 +715,7 @@ insns_bit_useless (insn_list *insns, decode_table *rule, int bit_nr) static opcode_field * gen_entry_find_opcode_field (insn_list *insns, - decode_table *rule, int string_only) + const decode_table *rule, int string_only) { opcode_field curr_opcode; ASSERT (rule != NULL); @@ -1118,9 +1123,9 @@ insns_match_conditions (insn_list *insns, decode_cond *conditions) } static int -insns_match_nr_words (insn_list *insns, int nr_words) +insns_match_nr_words (const insn_list *insns, int nr_words) { - insn_list *i; + const insn_list *i; for (i = insns; i != NULL; i = i->next) { if (i->insn->nr_words < nr_words) @@ -1130,11 +1135,11 @@ insns_match_nr_words (insn_list *insns, int nr_words) } static int -insn_list_cmp (insn_list *l, insn_list *r) +insn_list_cmp (const insn_list *l, const insn_list *r) { while (1) { - insn_entry *insn; + const insn_entry *insn; if (l == NULL && r == NULL) return 0; if (l == NULL) @@ -1157,7 +1162,7 @@ insn_list_cmp (insn_list *l, insn_list *r) static void gen_entry_expand_insns (gen_entry *table) { - decode_table *opcode_rule; + const decode_table *opcode_rule; ASSERT (table->nr_insns >= 1); @@ -1456,7 +1461,7 @@ gen_tables_expand_insns (gen_table *gen) worked. */ static void -make_gen_semantics_list (lf *file, gen_entry *entry, int depth, void *data) +make_gen_semantics_list (lf *file, const gen_entry *entry, int depth, void *data) { gen_table *gen = (gen_table *) data; insn_list *insn; diff --git a/sim/igen/gen.h b/sim/igen/gen.h index 1bdbd08..270e1cf 100644 --- a/sim/igen/gen.h +++ b/sim/igen/gen.h @@ -83,7 +83,7 @@ struct _gen_entry gen_entry *parent; /* parent has the opcode* data */ /* as a table containing entries */ - decode_table *opcode_rule; + const decode_table *opcode_rule; opcode_field *opcode; int nr_prefetched_words; int nr_entries; @@ -104,8 +104,8 @@ struct _gen_entry struct _gen_list { - model_entry *model; - insn_table *isa; + const model_entry *model; + const insn_table *isa; gen_entry *table; gen_list *next; }; @@ -115,9 +115,9 @@ typedef struct _gen_table gen_table; struct _gen_table { /* list of all the instructions */ - insn_table *isa; + const insn_table *isa; /* list of all the semantic functions */ - decode_table *rules; + const decode_table *rules; /* list of all the generated instruction tables */ gen_list *tables; /* list of all the semantic functions */ @@ -126,25 +126,26 @@ struct _gen_table }; -extern gen_table *make_gen_tables (insn_table *isa, decode_table *rules); +extern gen_table *make_gen_tables + (const insn_table *isa, const decode_table *rules); extern void gen_tables_expand_insns (gen_table *gen); extern void gen_tables_expand_semantics (gen_table *gen); -extern int gen_entry_depth (gen_entry *table); +extern int gen_entry_depth (const gen_entry *table); /* Traverse the created data structure */ typedef void gen_entry_handler - (lf *file, gen_entry *entry, int depth, void *data); + (lf *file, const gen_entry *entry, int depth, void *data); extern void gen_entry_traverse_tree (lf *file, - gen_entry *table, + const gen_entry *table, int depth, gen_entry_handler * start, gen_entry_handler * leaf, gen_entry_handler * end, void *data); @@ -196,13 +197,16 @@ extern int print_function_name const char *basename, const char *format_name, const char *model_name, - opcode_bits *expanded_bits, lf_function_name_prefixes prefix); + const opcode_bits *expanded_bits, + lf_function_name_prefixes prefix); extern void print_my_defines (lf *file, - const char *basename, const char *format_name, opcode_bits *expanded_bits); + const char *basename, + const char *format_name, + const opcode_bits *expanded_bits); -extern void print_itrace (lf *file, insn_entry * insn, int idecode); +extern void print_itrace (lf *file, const insn_entry *insn, int idecode); extern void print_sim_engine_abort (lf *file, const char *message); diff --git a/sim/igen/igen.c b/sim/igen/igen.c index b0a0774..0af6642 100644 --- a/sim/igen/igen.c +++ b/sim/igen/igen.c @@ -176,7 +176,7 @@ print_icache_function_type (lf *file) /* Function names */ static int -print_opcode_bits (lf *file, opcode_bits *bits) +print_opcode_bits (lf *file, const opcode_bits *bits) { int nr = 0; if (bits == NULL) @@ -227,7 +227,7 @@ print_function_name (lf *file, const char *basename, const char *format_name, const char *model_name, - opcode_bits *expanded_bits, + const opcode_bits *expanded_bits, lf_function_name_prefixes prefix) { int nr = 0; @@ -282,7 +282,8 @@ print_function_name (lf *file, void print_my_defines (lf *file, const char *basename, - const char *format_name, opcode_bits *expanded_bits) + const char *format_name, + const opcode_bits *expanded_bits) { /* #define MY_INDEX xxxxx */ lf_indent_suppress (file); @@ -339,7 +340,7 @@ print_itrace_prefix (lf *file) static void -print_itrace_format (lf *file, insn_mnemonic_entry *assembler) +print_itrace_format (lf *file, const insn_mnemonic_entry *assembler) { /* pass=1 is fmt string; pass=2 is arguments */ int pass; @@ -476,7 +477,7 @@ print_itrace_format (lf *file, insn_mnemonic_entry *assembler) void -print_itrace (lf *file, insn_entry * insn, int idecode) +print_itrace (lf *file, const insn_entry *insn, int idecode) { /* NB: Here we escape each EOLN. This is so that the the compiler treats a trace function call as a single line. Consequently any @@ -604,10 +605,10 @@ print_includes (lf *file) static void -gen_semantics_h (lf *file, insn_list *semantics, int max_nr_words) +gen_semantics_h (lf *file, const insn_list *semantics, int max_nr_words) { int word_nr; - insn_list *semantic; + const insn_list *semantic; for (word_nr = -1; word_nr <= max_nr_words; word_nr++) { lf_printf (file, "typedef "); @@ -645,11 +646,11 @@ gen_semantics_h (lf *file, insn_list *semantics, int max_nr_words) static void -gen_semantics_c (lf *file, insn_list *semantics, cache_entry *cache_rules) +gen_semantics_c (lf *file, const insn_list *semantics, cache_entry *cache_rules) { if (options.gen.code == generate_calls) { - insn_list *semantic; + const insn_list *semantic; print_includes (file); print_include (file, options.module.semantics); lf_printf (file, "\n"); @@ -679,8 +680,8 @@ gen_semantics_c (lf *file, insn_list *semantics, cache_entry *cache_rules) static void gen_icache_h (lf *file, - insn_list *semantic, - function_entry * functions, int max_nr_words) + const insn_list *semantic, + const function_entry *functions, int max_nr_words) { int word_nr; for (word_nr = 0; word_nr <= max_nr_words; word_nr++) @@ -716,8 +717,8 @@ gen_icache_h (lf *file, static void gen_icache_c (lf *file, - insn_list *semantic, - function_entry * functions, cache_entry *cache_rules) + const insn_list *semantic, + const function_entry *functions, cache_entry *cache_rules) { /* output `internal' invalid/floating-point unavailable functions where needed */ @@ -757,7 +758,9 @@ gen_icache_c (lf *file, static void gen_idecode_h (lf *file, - gen_table *gen, insn_table *insns, cache_entry *cache_rules) + const gen_table *gen, + const insn_table *insns, + cache_entry *cache_rules) { lf_printf (file, "typedef uint%d_t %sinstruction_word;\n", options.insn_bit_size, options.module.global.prefix.l); @@ -816,7 +819,9 @@ gen_idecode_h (lf *file, static void gen_idecode_c (lf *file, - gen_table *gen, insn_table *isa, cache_entry *cache_rules) + const gen_table *gen, + const insn_table *isa, + cache_entry *cache_rules) { /* the intro */ print_includes (file); @@ -869,7 +874,7 @@ gen_idecode_c (lf *file, static void -gen_run_c (lf *file, gen_table *gen) +gen_run_c (lf *file, const gen_table *gen) { gen_list *entry; lf_printf (file, "#include \"sim-main.h\"\n"); @@ -959,7 +964,7 @@ gen_run_c (lf *file, gen_table *gen) /****************************************************************/ static gen_table * -do_gen (insn_table *isa, decode_table *decode_rules) +do_gen (const insn_table *isa, const decode_table *decode_rules) { gen_table *gen; if (decode_rules == NULL) @@ -1185,7 +1190,7 @@ main (int argc, char **argv, char **envp) case 'D': if (strcmp (optarg, "processor-names")) { - char *processor; + const char *processor; for (processor = filter_next (options.model_filter, ""); processor != NULL; processor = filter_next (options.model_filter, processor)) diff --git a/sim/igen/ld-cache.c b/sim/igen/ld-cache.c index 6c5e62f..3500c03 100644 --- a/sim/igen/ld-cache.c +++ b/sim/igen/ld-cache.c @@ -50,7 +50,7 @@ static const name_map cache_type_map[] = { cache_entry * -load_cache_table (char *file_name) +load_cache_table (const char *file_name) { cache_entry *cache = NULL; cache_entry **last = &cache; diff --git a/sim/igen/ld-cache.h b/sim/igen/ld-cache.h index d0ba4ea..955fc53 100644 --- a/sim/igen/ld-cache.h +++ b/sim/igen/ld-cache.h @@ -63,4 +63,4 @@ new name had better be the same. */ -extern cache_entry *load_cache_table (char *file_name); +extern cache_entry *load_cache_table (const char *file_name); diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c index da0e9da..d1c9046 100644 --- a/sim/igen/ld-decode.c +++ b/sim/igen/ld-decode.c @@ -83,7 +83,7 @@ set_bits (int bit[max_insn_bit_size], uint64_t value) } decode_table * -load_decode_table (char *file_name) +load_decode_table (const char *file_name) { table *file = table_open (file_name); table_entry *entry; @@ -284,7 +284,7 @@ load_decode_table (char *file_name) int -decode_table_max_word_nr (decode_table *entry) +decode_table_max_word_nr (const decode_table *entry) { int max_word_nr = 0; while (entry != NULL) @@ -303,9 +303,9 @@ decode_table_max_word_nr (decode_table *entry) } - static void -dump_decode_cond (lf *file, char *prefix, decode_cond *cond, char *suffix) +dump_decode_cond (lf *file, const char *prefix, const decode_cond *cond, + const char *suffix) { lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); if (cond != NULL) @@ -323,7 +323,8 @@ dump_decode_cond (lf *file, char *prefix, decode_cond *cond, char *suffix) static void -dump_decode_conds (lf *file, char *prefix, decode_cond *cond, char *suffix) +dump_decode_conds (lf *file, const char *prefix, const decode_cond *cond, + const char *suffix) { lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); while (cond != NULL) @@ -336,7 +337,8 @@ dump_decode_conds (lf *file, char *prefix, decode_cond *cond, char *suffix) void -dump_decode_rule (lf *file, char *prefix, decode_table *rule, char *suffix) +dump_decode_rule (lf *file, const char *prefix, const decode_table *rule, + const char *suffix) { lf_printf (file, "%s(decode_table *) 0x%lx", prefix, (long) rule); if (rule != NULL) @@ -369,7 +371,10 @@ dump_decode_rule (lf *file, char *prefix, decode_table *rule, char *suffix) #ifdef MAIN static void -dump_decode_rules (lf *file, char *prefix, decode_table *rule, char *suffix) +dump_decode_rules (lf *file, + const char *prefix, + const decode_table *rule, + const char *suffix) { lf_printf (file, "%s", prefix); while (rule != NULL) diff --git a/sim/igen/ld-decode.h b/sim/igen/ld-decode.h index 83f7d07..5dc8460 100644 --- a/sim/igen/ld-decode.h +++ b/sim/igen/ld-decode.h @@ -236,9 +236,9 @@ struct _decode_table }; -extern decode_table *load_decode_table (char *file_name); +extern decode_table *load_decode_table (const char *file_name); -extern int decode_table_max_word_nr (decode_table *rule); +extern int decode_table_max_word_nr (const decode_table *rule); extern void dump_decode_rule - (lf *file, char *prefix, decode_table *rule, char *suffix); + (lf *file, const char *prefix, const decode_table *rule, const char *suffix); diff --git a/sim/igen/ld-insn.c b/sim/igen/ld-insn.c index 435bf48..aa9688d 100644 --- a/sim/igen/ld-insn.c +++ b/sim/igen/ld-insn.c @@ -28,7 +28,7 @@ #include "ld-insn.h" static insn_word_entry * -parse_insn_word (line_ref *line, char *string, int word_nr) +parse_insn_word (const line_ref *line, char *string, int word_nr) { char *chp; insn_word_entry *word = ZALLOC (insn_word_entry); @@ -849,7 +849,7 @@ parse_insn_model_record (table *file, /* Find the corresponding master model record for each name so that they can be linked in. */ int index; - char *name = ""; + const char *name = ""; while (1) { name = filter_next (new_insn_model->names, name); @@ -938,7 +938,7 @@ parse_macro_record (table *file, table_entry *record) insn_table * -load_insn_table (char *file_name, cache_entry *cache) +load_insn_table (const char *file_name, cache_entry *cache) { table *file = table_open (file_name); table_entry *record = table_read (file); @@ -1279,7 +1279,7 @@ load_insn_table (char *file_name, cache_entry *cache) void -print_insn_words (lf *file, insn_entry * insn) +print_insn_words (lf *file, const insn_entry *insn) { insn_word_entry *word = insn->words; if (word != NULL) @@ -1359,10 +1359,10 @@ print_insn_words (lf *file, insn_entry * insn) void function_entry_traverse (lf *file, - function_entry * functions, + const function_entry *functions, function_entry_handler * handler, void *data) { - function_entry *function; + const function_entry *function; for (function = functions; function != NULL; function = function->next) { handler (file, function, data); @@ -1371,10 +1371,10 @@ function_entry_traverse (lf *file, void insn_table_traverse_insn (lf *file, - insn_table *isa, + const insn_table *isa, insn_entry_handler * handler, void *data) { - insn_entry *insn; + const insn_entry *insn; for (insn = isa->insns; insn != NULL; insn = insn->next) { handler (file, isa, insn, data); @@ -1384,7 +1384,9 @@ insn_table_traverse_insn (lf *file, static void dump_function_entry (lf *file, - char *prefix, function_entry * entry, char *suffix) + const char *prefix, + const function_entry *entry, + const char *suffix) { lf_printf (file, "%s(function_entry *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1403,7 +1405,9 @@ dump_function_entry (lf *file, static void dump_function_entries (lf *file, - char *prefix, function_entry * entry, char *suffix) + const char *prefix, + const function_entry *entry, + const char *suffix) { lf_printf (file, "%s", prefix); lf_indent (file, +1); @@ -1433,7 +1437,10 @@ cache_entry_type_to_str (cache_entry_type type) } static void -dump_cache_entry (lf *file, char *prefix, cache_entry *entry, char *suffix) +dump_cache_entry (lf *file, + const char *prefix, + const cache_entry *entry, + const char *suffix) { lf_printf (file, "%s(cache_entry *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1452,7 +1459,10 @@ dump_cache_entry (lf *file, char *prefix, cache_entry *entry, char *suffix) } void -dump_cache_entries (lf *file, char *prefix, cache_entry *entry, char *suffix) +dump_cache_entries (lf *file, + const char *prefix, + const cache_entry *entry, + const char *suffix) { lf_printf (file, "%s", prefix); lf_indent (file, +1); @@ -1466,7 +1476,10 @@ dump_cache_entries (lf *file, char *prefix, cache_entry *entry, char *suffix) } static void -dump_model_data (lf *file, char *prefix, model_data *entry, char *suffix) +dump_model_data (lf *file, + const char *prefix, + const model_data *entry, + const char *suffix) { lf_printf (file, "%s(model_data *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1483,7 +1496,10 @@ dump_model_data (lf *file, char *prefix, model_data *entry, char *suffix) } static void -dump_model_datas (lf *file, char *prefix, model_data *entry, char *suffix) +dump_model_datas (lf *file, + const char *prefix, + const model_data *entry, + const char *suffix) { lf_printf (file, "%s", prefix); lf_indent (file, +1); @@ -1497,7 +1513,10 @@ dump_model_datas (lf *file, char *prefix, model_data *entry, char *suffix) } static void -dump_model_entry (lf *file, char *prefix, model_entry *entry, char *suffix) +dump_model_entry (lf *file, + const char *prefix, + const model_entry *entry, + const char *suffix) { lf_printf (file, "%s(model_entry *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1515,7 +1534,10 @@ dump_model_entry (lf *file, char *prefix, model_entry *entry, char *suffix) } static void -dump_model_entries (lf *file, char *prefix, model_entry *entry, char *suffix) +dump_model_entries (lf *file, + const char *prefix, + const model_entry *entry, + const char *suffix) { lf_printf (file, "%s", prefix); lf_indent (file, +1); @@ -1530,7 +1552,10 @@ dump_model_entries (lf *file, char *prefix, model_entry *entry, char *suffix) static void -dump_model_table (lf *file, char *prefix, model_table *entry, char *suffix) +dump_model_table (lf *file, + const char *prefix, + const model_table *entry, + const char *suffix) { lf_printf (file, "%s(model_table *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1573,7 +1598,9 @@ insn_field_type_to_str (insn_field_type type) void dump_insn_field (lf *file, - char *prefix, insn_field_entry *field, char *suffix) + const char *prefix, + const insn_field_entry *field, + const char *suffix) { char *sep = " "; lf_printf (file, "%s(insn_field_entry *) 0x%lx", prefix, (long) field); @@ -1612,7 +1639,9 @@ dump_insn_field (lf *file, void dump_insn_word_entry (lf *file, - char *prefix, insn_word_entry *word, char *suffix) + const char *prefix, + const insn_word_entry *word, + const char *suffix) { lf_printf (file, "%s(insn_word_entry *) 0x%lx", prefix, (long) word); if (word != NULL) @@ -1639,7 +1668,9 @@ dump_insn_word_entry (lf *file, static void dump_insn_word_entries (lf *file, - char *prefix, insn_word_entry *word, char *suffix) + const char *prefix, + const insn_word_entry *word, + const char *suffix) { lf_printf (file, "%s", prefix); while (word != NULL) @@ -1652,7 +1683,9 @@ dump_insn_word_entries (lf *file, static void dump_insn_model_entry (lf *file, - char *prefix, insn_model_entry *model, char *suffix) + const char *prefix, + const insn_model_entry *model, + const char *suffix) { lf_printf (file, "%s(insn_model_entry *) 0x%lx", prefix, (long) model); if (model != NULL) @@ -1672,7 +1705,9 @@ dump_insn_model_entry (lf *file, static void dump_insn_model_entries (lf *file, - char *prefix, insn_model_entry *model, char *suffix) + const char *prefix, + const insn_model_entry *model, + const char *suffix) { lf_printf (file, "%s", prefix); while (model != NULL) @@ -1686,8 +1721,9 @@ dump_insn_model_entries (lf *file, static void dump_insn_mnemonic_entry (lf *file, - char *prefix, - insn_mnemonic_entry *mnemonic, char *suffix) + const char *prefix, + const insn_mnemonic_entry *mnemonic, + const char *suffix) { lf_printf (file, "%s(insn_mnemonic_entry *) 0x%lx", prefix, (long) mnemonic); @@ -1708,8 +1744,9 @@ dump_insn_mnemonic_entry (lf *file, static void dump_insn_mnemonic_entries (lf *file, - char *prefix, - insn_mnemonic_entry *mnemonic, char *suffix) + const char *prefix, + const insn_mnemonic_entry *mnemonic, + const char *suffix) { lf_printf (file, "%s", prefix); while (mnemonic != NULL) @@ -1721,7 +1758,10 @@ dump_insn_mnemonic_entries (lf *file, } void -dump_insn_entry (lf *file, char *prefix, insn_entry * entry, char *suffix) +dump_insn_entry (lf *file, + const char *prefix, + const insn_entry *entry, + const char *suffix) { lf_printf (file, "%s(insn_entry *) 0x%lx", prefix, (long) entry); if (entry != NULL) @@ -1757,7 +1797,10 @@ dump_insn_entry (lf *file, char *prefix, insn_entry * entry, char *suffix) } static void -dump_insn_entries (lf *file, char *prefix, insn_entry * entry, char *suffix) +dump_insn_entries (lf *file, + const char *prefix, + const insn_entry *entry, + const char *suffix) { lf_printf (file, "%s", prefix); lf_indent (file, +1); @@ -1771,9 +1814,11 @@ dump_insn_entries (lf *file, char *prefix, insn_entry * entry, char *suffix) } - void -dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix) +dump_insn_table (lf *file, + const char *prefix, + const insn_table *isa, + const char *suffix) { lf_printf (file, "%s(insn_table *) 0x%lx", prefix, (long) isa); if (isa != NULL) diff --git a/sim/igen/ld-insn.h b/sim/igen/ld-insn.h index 4859bae..9b144da 100644 --- a/sim/igen/ld-insn.h +++ b/sim/igen/ld-insn.h @@ -219,11 +219,12 @@ struct _function_entry typedef void function_entry_handler - (lf *file, function_entry * function, void *data); + (lf *file, const function_entry *function, void *data); extern void function_entry_traverse (lf *file, - function_entry * functions, function_entry_handler * handler, void *data); + const function_entry *functions, + function_entry_handler * handler, void *data); /* cache-macro: @@ -670,37 +671,37 @@ struct _insn_table filter *flags; }; -extern insn_table *load_insn_table (char *file_name, cache_entry *cache); +extern insn_table *load_insn_table (const char *file_name, cache_entry *cache); typedef void insn_entry_handler - (lf *file, insn_table *isa, insn_entry * insn, void *data); + (lf *file, const insn_table *isa, const insn_entry *insn, void *data); extern void insn_table_traverse_insn - (lf *file, insn_table *isa, insn_entry_handler * handler, void *data); + (lf *file, const insn_table *isa, insn_entry_handler *handler, void *data); /* Printing */ -extern void print_insn_words (lf *file, insn_entry * insn); +extern void print_insn_words (lf *file, const insn_entry *insn); /* Debugging */ -void - dump_insn_field - (lf *file, char *prefix, insn_field_entry *field, char *suffix); +void dump_insn_field + (lf *file, const char *prefix, const insn_field_entry *field, + const char *suffix); -void - dump_insn_word_entry - (lf *file, char *prefix, insn_word_entry *word, char *suffix); +void dump_insn_word_entry + (lf *file, const char *prefix, const insn_word_entry *word, + const char *suffix); -void - dump_insn_entry (lf *file, char *prefix, insn_entry * insn, char *suffix); +void dump_insn_entry + (lf *file, const char *prefix, const insn_entry *insn, const char *suffix); -void - dump_cache_entries - (lf *file, char *prefix, cache_entry *entry, char *suffix); +void dump_cache_entries + (lf *file, const char *prefix, const cache_entry *entry, const char *suffix); -void dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix); +void dump_insn_table + (lf *file, const char *prefix, const insn_table *isa, const char *suffix); diff --git a/sim/igen/lf.c b/sim/igen/lf.c index dbaa14f..ca7a56a 100644 --- a/sim/igen/lf.c +++ b/sim/igen/lf.c @@ -45,8 +45,8 @@ struct _lf lf * -lf_open (char *name, - char *real_name, +lf_open (const char *name, + const char *real_name, lf_file_references references, lf_file_type type, const char *program) { @@ -205,7 +205,7 @@ lf_printf (lf *file, const char *fmt, ...) int -lf_print__line_ref (lf *file, line_ref *line) +lf_print__line_ref (lf *file, const line_ref *line) { return lf_print__external_ref (file, line->line_nr, line->file_name); } diff --git a/sim/igen/lf.h b/sim/igen/lf.h index 84d82fe..93b461e 100644 --- a/sim/igen/lf.h +++ b/sim/igen/lf.h @@ -49,8 +49,8 @@ lf_file_references; the print messages below. */ extern lf *lf_open - (char *name, - char *real_name, + (const char *name, + const char *real_name, lf_file_references file_references, lf_file_type type, const char *program); @@ -101,7 +101,7 @@ extern int lf_print__internal_ref (lf *file); extern int lf_print__external_ref (lf *file, int line_nr, const char *file_name); -extern int lf_print__line_ref (lf *file, line_ref *line); +extern int lf_print__line_ref (lf *file, const line_ref *line); extern int lf_print__ucase_filename (lf *file); diff --git a/sim/igen/misc.c b/sim/igen/misc.c index c5c494b..2b61c7e 100644 --- a/sim/igen/misc.c +++ b/sim/igen/misc.c @@ -34,7 +34,7 @@ trailing '\n' */ void -error (const line_ref *line, char *msg, ...) +error (const line_ref *line, const char *msg, ...) { va_list ap; if (line != NULL) @@ -46,7 +46,7 @@ error (const line_ref *line, char *msg, ...) } void -warning (const line_ref *line, char *msg, ...) +warning (const line_ref *line, const char *msg, ...) { va_list ap; if (line != NULL) @@ -57,7 +57,7 @@ warning (const line_ref *line, char *msg, ...) } void -notify (const line_ref *line, char *msg, ...) +notify (const line_ref *line, const char *msg, ...) { va_list ap; if (line != NULL) diff --git a/sim/igen/misc.h b/sim/igen/misc.h index 214505a..163ffe4 100644 --- a/sim/igen/misc.h +++ b/sim/igen/misc.h @@ -52,7 +52,7 @@ struct _line_ref }; /* Error appends a new line, warning and notify do not */ -typedef void error_func (const line_ref *line, char *msg, ...); +typedef void error_func (const line_ref *line, const char *msg, ...); extern error_func error; extern error_func warning; diff --git a/sim/igen/table.c b/sim/igen/table.c index e0bb665..acf6e1c 100644 --- a/sim/igen/table.c +++ b/sim/igen/table.c @@ -80,7 +80,9 @@ set_nr_table_entry_fields (table_entry *entry, int nr_fields) void table_push (table *root, - line_ref *line, table_include *includes, const char *file_name) + const line_ref *line, + table_include *includes, + const char *file_name) { FILE *ff; open_table *file; @@ -485,7 +487,7 @@ table_read (table *root) } extern void -table_print_code (lf *file, table_entry *entry) +table_print_code (lf *file, const table_entry *entry) { int field_nr; int nr = 0; @@ -528,9 +530,11 @@ table_print_code (lf *file, table_entry *entry) } - void -dump_line_ref (lf *file, char *prefix, const line_ref *line, char *suffix) +dump_line_ref (lf *file, + const char *prefix, + const line_ref *line, + const char *suffix) { lf_printf (file, "%s(line_ref*) 0x%lx", prefix, (long) line); if (line != NULL) @@ -559,7 +563,9 @@ table_entry_type_to_str (table_entry_type type) void dump_table_entry (lf *file, - char *prefix, const table_entry *entry, char *suffix) + const char *prefix, + const table_entry *entry, + const char *suffix) { lf_printf (file, "%s(table_entry*) 0x%lx", prefix, (long) entry); if (entry != NULL) diff --git a/sim/igen/table.h b/sim/igen/table.h index 3d38c57..358c12a 100644 --- a/sim/igen/table.h +++ b/sim/igen/table.h @@ -102,7 +102,8 @@ extern table_entry *table_read (table *file); the end of FILE_NAME is reached, return to the pushed file */ extern void table_push - (table *file, line_ref *line, table_include *search, const char *file_name); + (table *file, const line_ref *line, table_include *search, + const char *file_name); /* Expand the specified field_nr using the internal expansion table. @@ -115,16 +116,16 @@ extern void table_expand_field (table_entry *entry, int field_nr); leading/trailing braces were striped as part of the read, they are not written. */ -extern void table_print_code (lf *file, table_entry *entry); +extern void table_print_code (lf *file, const table_entry *entry); /* Debugging */ extern void dump_line_ref - (lf *file, char *prefix, const line_ref *line, char *suffix); + (lf *file, const char *prefix, const line_ref *line, const char *suffix); extern void dump_table_entry - (lf *file, char *prefix, const table_entry *entry, char *suffix); + (lf *file, const char *prefix, const table_entry *entry, const char *suffix); |