X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=sim%2Figen%2Fld-decode.c;h=dd54c0b1a7ed12dd8660ead813afedf3c39ba0dd;hb=fdb38a1c7fddcde318081b7c4602406fa61c7035;hp=baea404d5a9c1bf6918ece78b9223d8953464de1;hpb=1996fae84682e8ddd146215dd2959ad1ec924c09;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c index baea404d5a..dd54c0b1a7 100644 --- a/sim/igen/ld-decode.c +++ b/sim/igen/ld-decode.c @@ -1,22 +1,24 @@ -/* This file is part of the program psim. - - Copyright (C) 1994,1995,1996, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - */ +/* The IGEN simulator generator for GDB, the GNU Debugger. + + Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Contributed by Andrew Cagney. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + /* load the opcode stat structure */ @@ -35,45 +37,44 @@ static const name_map decode_type_map[] = { - { "normal", normal_decode_rule }, - { "boolean", boolean_rule }, - { NULL, normal_decode_rule }, + {"normal", normal_decode_rule}, + {"boolean", boolean_rule}, + {NULL, normal_decode_rule}, }; static const name_map decode_gen_map[] = { - { "array", array_gen }, - { "switch", switch_gen }, - { "padded-switch", padded_switch_gen }, - { "goto-switch", goto_switch_gen }, - { NULL, -1 }, + {"array", array_gen}, + {"switch", switch_gen}, + {"padded-switch", padded_switch_gen}, + {"goto-switch", goto_switch_gen}, + {NULL, -1}, }; static const name_map decode_reserved_map[] = { - { "zero-reserved", 1 }, - { NULL, 0 }, + {"zero-reserved", 1}, + {NULL, 0}, }; static const name_map decode_duplicates_map[] = { - { "duplicate", 1 }, - { NULL, 0 }, + {"duplicate", 1}, + {NULL, 0}, }; static const name_map decode_combine_map[] = { - { "combine", 1 }, - { NULL, 0 }, + {"combine", 1}, + {NULL, 0}, }; static const name_map decode_search_map[] = { - { "constants", decode_find_constants }, - { "mixed", decode_find_mixed }, - { "strings", decode_find_strings }, - { NULL, decode_find_mixed }, + {"constants", decode_find_constants}, + {"mixed", decode_find_mixed}, + {"strings", decode_find_strings}, + {NULL, decode_find_mixed}, }; static void -set_bits (int bit[max_insn_bit_size], - unsigned64 value) +set_bits (int bit[max_insn_bit_size], unsigned64 value) { int bit_nr; for (bit_nr = 0; bit_nr < max_insn_bit_size; bit_nr++) @@ -86,7 +87,7 @@ set_bits (int bit[max_insn_bit_size], } decode_table * -load_decode_table(char *file_name) +load_decode_table (char *file_name) { table *file = table_open (file_name); table_entry *entry; @@ -103,20 +104,22 @@ load_decode_table(char *file_name) /* the options field */ new_rule->type = name2i (decode_options, decode_type_map); if (options.decode.overriding_gen != NULL) - new_rule->gen = name2i (options.decode.overriding_gen, decode_gen_map); + new_rule->gen = + name2i (options.decode.overriding_gen, decode_gen_map); else new_rule->gen = name2i (decode_options, decode_gen_map); - if (new_rule->gen == padded_switch_gen - && options.decode.switch_as_goto) + if (new_rule->gen == padded_switch_gen && options.decode.switch_as_goto) new_rule->gen = goto_switch_gen; if (options.decode.zero_reserved) new_rule->with_zero_reserved = 1; else - new_rule->with_zero_reserved = name2i (decode_options, decode_reserved_map); + new_rule->with_zero_reserved = + name2i (decode_options, decode_reserved_map); if (options.decode.duplicate) new_rule->with_duplicates = 1; else - new_rule->with_duplicates = name2i (decode_options, decode_duplicates_map); + new_rule->with_duplicates = + name2i (decode_options, decode_duplicates_map); if (options.decode.combine) new_rule->with_combine = 1; else @@ -165,7 +168,9 @@ load_decode_table(char *file_name) && strlen (entry->field[decode_force_first_field]) > 0) { new_rule->force_first = target_a2i (options.hi_bit_nr, - entry->field[decode_force_first_field]); + entry-> + field + [decode_force_first_field]); if (new_rule->force_first < new_rule->first || new_rule->force_first > new_rule->last + 1) error (new_rule->line, "Force first out of range\n"); @@ -176,7 +181,8 @@ load_decode_table(char *file_name) && strlen (entry->field[decode_force_last_field]) > 0) { new_rule->force_last = target_a2i (options.hi_bit_nr, - entry->field[decode_force_last_field]); + entry-> + field[decode_force_last_field]); if (new_rule->force_last > new_rule->last || new_rule->force_last < new_rule->first - 1) error (new_rule->line, "Force-last out of range\n"); @@ -213,7 +219,7 @@ load_decode_table(char *file_name) { (*last) = ZALLOC (decode_path_list); /* extra root/zero entry */ - (*last)->path = ZALLOC (decode_path); + (*last)->path = ZALLOC (decode_path); do { decode_path *entry = ZALLOC (decode_path); @@ -240,22 +246,32 @@ load_decode_table(char *file_name) decode_cond *cond = ZALLOC (decode_cond); decode_cond **last; if (entry->nr_fields > field_nr + decode_cond_mask_field) - set_bits (cond->mask, a2i (entry->field[field_nr + decode_cond_mask_field])); + set_bits (cond->mask, + a2i (entry-> + field[field_nr + decode_cond_mask_field])); if (entry->nr_fields > field_nr + decode_cond_value_field) - { - if (entry->field[field_nr + decode_cond_value_field][0] == '!') - { - cond->is_equal = 0; - set_bits (cond->value, a2i (entry->field[field_nr + decode_cond_value_field] + 1)); - } - else - { - cond->is_equal = 1; - set_bits (cond->value, a2i (entry->field[field_nr + decode_cond_value_field])); - } - } + { + if (entry->field[field_nr + decode_cond_value_field][0] == + '!') + { + cond->is_equal = 0; + set_bits (cond->value, + a2i (entry-> + field[field_nr + decode_cond_value_field] + + 1)); + } + else + { + cond->is_equal = 1; + set_bits (cond->value, + a2i (entry-> + field[field_nr + + decode_cond_value_field])); + } + } if (entry->nr_fields > field_nr + decode_cond_word_nr_field) - cond->word_nr = a2i (entry->field[field_nr + decode_cond_word_nr_field]); + cond->word_nr = + a2i (entry->field[field_nr + decode_cond_word_nr_field]); field_nr += nr_decode_cond_fields; /* insert it */ last = &new_rule->conditions; @@ -270,7 +286,7 @@ load_decode_table(char *file_name) return table; } - + int decode_table_max_word_nr (decode_table *entry) { @@ -293,10 +309,7 @@ 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, char *prefix, decode_cond *cond, char *suffix) { lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); if (cond != NULL) @@ -314,10 +327,7 @@ dump_decode_cond (lf *file, static void -dump_decode_conds (lf *file, - char *prefix, - decode_cond *cond, - char *suffix) +dump_decode_conds (lf *file, char *prefix, decode_cond *cond, char *suffix) { lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); while (cond != NULL) @@ -330,23 +340,21 @@ dump_decode_conds (lf *file, void -dump_decode_rule (lf *file, - char *prefix, - decode_table *rule, - char *suffix) +dump_decode_rule (lf *file, char *prefix, decode_table *rule, char *suffix) { lf_printf (file, "%s(decode_table *) 0x%lx", prefix, (long) rule); if (rule != NULL) { lf_indent (file, +1); dump_line_ref (file, "\n(line ", rule->line, ")"); - lf_printf (file, "\n(type %s)", i2name(rule->type, decode_type_map)); - lf_printf (file, "\n(gen %s)", i2name(rule->gen, decode_gen_map)); + lf_printf (file, "\n(type %s)", i2name (rule->type, decode_type_map)); + lf_printf (file, "\n(gen %s)", i2name (rule->gen, decode_gen_map)); lf_printf (file, "\n(first %d)", rule->first); lf_printf (file, "\n(last %d)", rule->last); lf_printf (file, "\n(force_first %d)", rule->force_first); lf_printf (file, "\n(force_last %d)", rule->force_last); - dump_filter (file, "\n(constant_field_names \"", rule->constant_field_names, "\")"); + dump_filter (file, "\n(constant_field_names \"", + rule->constant_field_names, "\")"); lf_printf (file, "\n(constant 0x%x)", rule->constant); lf_printf (file, "\n(word_nr %d)", rule->word_nr); lf_printf (file, "\n(with_zero_reserved %d)", rule->with_zero_reserved); @@ -365,10 +373,7 @@ dump_decode_rule (lf *file, #ifdef MAIN static void -dump_decode_rules (lf *file, - char *prefix, - decode_table *rule, - char *suffix) +dump_decode_rules (lf *file, char *prefix, decode_table *rule, char *suffix) { lf_printf (file, "%s", prefix); while (rule != NULL) @@ -384,7 +389,7 @@ dump_decode_rules (lf *file, igen_options options; int -main(int argc, char **argv) +main (int argc, char **argv) { lf *l; decode_table *rules;