gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / sim / ppc / ld-cache.c
1 /* This file is part of the program psim.
2
3 Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20
21 #include "misc.h"
22 #include "lf.h"
23 #include "table.h"
24 #include "ld-cache.h"
25
26 #ifndef NULL
27 #define NULL 0
28 #endif
29
30
31 enum {
32 ca_type,
33 ca_field_name,
34 ca_derived_name,
35 ca_type_def,
36 ca_expression,
37 nr_cache_rule_fields,
38 };
39
40 static const name_map cache_type_map[] = {
41 { "cache", cache_value },
42 { "compute", compute_value },
43 { "scratch", scratch_value },
44 { NULL, 0 },
45 };
46
47
48 void
49 append_cache_rule (cache_table **table, char *type, char *field_name,
50 char *derived_name, char *type_def,
51 char *expression, table_entry *file_entry)
52 {
53 while ((*table) != NULL)
54 table = &(*table)->next;
55 (*table) = ZALLOC(cache_table);
56 (*table)->type = name2i(type, cache_type_map);
57 (*table)->field_name = field_name;
58 (*table)->derived_name = derived_name;
59 (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL);
60 (*table)->expression = (strlen(expression) > 0 ? expression : NULL);
61 (*table)->file_entry = file_entry;
62 (*table)->next = NULL;
63 }
64
65
66 cache_table *
67 load_cache_table(char *file_name,
68 int hi_bit_nr)
69 {
70 table *file = table_open(file_name, nr_cache_rule_fields, 0);
71 table_entry *entry;
72 cache_table *table = NULL;
73 cache_table **curr_rule = &table;
74 while ((entry = table_entry_read(file)) != NULL) {
75 append_cache_rule (curr_rule, entry->fields[ca_type],
76 entry->fields[ca_field_name],
77 entry->fields[ca_derived_name],
78 entry->fields[ca_type_def],
79 entry->fields[ca_expression],
80 entry);
81 curr_rule = &(*curr_rule)->next;
82 }
83 return table;
84 }
85
86
87
88 #ifdef MAIN
89
90 static void
91 dump_cache_rule(cache_table* rule,
92 int indent)
93 {
94 dumpf(indent, "((cache_table*)0x%x\n", rule);
95 dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
96 dumpf(indent, " (field_name \"%s\")\n", rule->field_name);
97 dumpf(indent, " (derived_name \"%s\")\n", rule->derived_name);
98 dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
99 dumpf(indent, " (expression \"%s\")\n", rule->expression);
100 dumpf(indent, " (next 0x%x)\n", rule->next);
101 dumpf(indent, " )\n");
102 }
103
104
105 static void
106 dump_cache_rules(cache_table* rule,
107 int indent)
108 {
109 while (rule) {
110 dump_cache_rule(rule, indent);
111 rule = rule->next;
112 }
113 }
114
115
116 int
117 main(int argc, char **argv)
118 {
119 cache_table *rules;
120 if (argc != 3)
121 error("Usage: cache <cache-file> <hi-bit-nr>\n");
122 rules = load_cache_table(argv[1], a2i(argv[2]));
123 dump_cache_rules(rules, 0);
124 return 0;
125 }
126 #endif
This page took 0.031053 seconds and 4 git commands to generate.