]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/ppc/ld-cache.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / ppc / ld-cache.c
CommitLineData
30c87b55
MM
1/* This file is part of the program psim.
2
3 Copyright (C) 1994,1995,1996, Andrew Cagney <cagney@highland.com.au>
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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21
22#include "misc.h"
23#include "lf.h"
24#include "table.h"
25#include "ld-cache.h"
26
27#ifndef NULL
28#define NULL 0
29#endif
30
31
32enum {
33 ca_type,
34 ca_old_name,
35 ca_new_name,
36 ca_type_def,
37 ca_expression,
38 nr_cache_rule_fields,
39};
40
41static const name_map cache_type_map[] = {
42 { "cache", cache_value },
43 { "compute", compute_value },
44 { NULL, 0 },
45};
46
47
48cache_table *
49load_cache_table(char *file_name,
50 int hi_bit_nr)
51{
52 table *file = table_open(file_name, nr_cache_rule_fields, 0);
53 table_entry *entry;
54 cache_table *table = NULL;
55 cache_table **curr_rule = &table;
56 while ((entry = table_entry_read(file)) != NULL) {
57 cache_table *new_rule = ZALLOC(cache_table);
58 new_rule->type = name2i(entry->fields[ca_type], cache_type_map);
59 new_rule->old_name = entry->fields[ca_old_name];
60 new_rule->new_name = entry->fields[ca_new_name];
61 new_rule->type_def = (strlen(entry->fields[ca_type_def])
62 ? entry->fields[ca_type_def]
63 : NULL);
64 new_rule->expression = (strlen(entry->fields[ca_expression]) > 0
65 ? entry->fields[ca_expression]
66 : NULL);
67 new_rule->file_entry = entry;
68 *curr_rule = new_rule;
69 curr_rule = &new_rule->next;
70 }
71 return table;
72}
73
74
75
76#ifdef MAIN
77
78static void
79dump_cache_rule(cache_table* rule,
80 int indent)
81{
82 dumpf(indent, "((cache_table*)0x%x\n", rule);
83 dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
84 dumpf(indent, " (old_name \"%s\")\n", rule->old_name);
85 dumpf(indent, " (new_name \"%s\")\n", rule->new_name);
86 dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
87 dumpf(indent, " (expression \"%s\")\n", rule->expression);
88 dumpf(indent, " (next 0x%x)\n", rule->next);
89 dumpf(indent, " )\n");
90}
91
92
93static void
94dump_cache_rules(cache_table* rule,
95 int indent)
96{
97 while (rule) {
98 dump_cache_rule(rule, indent);
99 rule = rule->next;
100 }
101}
102
103
104int
105main(int argc, char **argv)
106{
107 cache_table *rules;
108 if (argc != 3)
109 error("Usage: cache <cache-file> <hi-bit-nr>\n");
110 rules = load_cache_table(argv[1], a2i(argv[2]));
111 dump_cache_rules(rules, 0);
112 return 0;
113}
114#endif