OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [sim/] [ppc/] [ld-cache.c] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/*  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 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
 
32
enum {
33
  ca_type,
34
  ca_field_name,
35
  ca_derived_name,
36
  ca_type_def,
37
  ca_expression,
38
  nr_cache_rule_fields,
39
};
40
 
41
static const name_map cache_type_map[] = {
42
  { "cache", cache_value },
43
  { "compute", compute_value },
44
  { "scratch", scratch_value },
45
  { NULL, 0 },
46
};
47
 
48
 
49
void
50
append_cache_rule (cache_table **table, char *type, char *field_name,
51
                   char *derived_name, char *type_def,
52
                   char *expression, table_entry *file_entry)
53
{
54
  while ((*table) != NULL)
55
    table = &(*table)->next;
56
  (*table) = ZALLOC(cache_table);
57
  (*table)->type = name2i(type, cache_type_map);
58
  (*table)->field_name = field_name;
59
  (*table)->derived_name = derived_name;
60
  (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL);
61
  (*table)->expression = (strlen(expression) > 0 ? expression : NULL);
62
  (*table)->file_entry = file_entry;
63
  (*table)->next = NULL;
64
}
65
 
66
 
67
cache_table *
68
load_cache_table(char *file_name,
69
                 int hi_bit_nr)
70
{
71
  table *file = table_open(file_name, nr_cache_rule_fields, 0);
72
  table_entry *entry;
73
  cache_table *table = NULL;
74
  cache_table **curr_rule = &table;
75
  while ((entry = table_entry_read(file)) != NULL) {
76
    append_cache_rule (curr_rule, entry->fields[ca_type],
77
                       entry->fields[ca_field_name],
78
                       entry->fields[ca_derived_name],
79
                       entry->fields[ca_type_def],
80
                       entry->fields[ca_expression],
81
                       entry);
82
    curr_rule = &(*curr_rule)->next;
83
  }
84
  return table;
85
}
86
 
87
 
88
 
89
#ifdef MAIN
90
 
91
static void
92
dump_cache_rule(cache_table* rule,
93
                int indent)
94
{
95
  dumpf(indent, "((cache_table*)0x%x\n", rule);
96
  dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
97
  dumpf(indent, " (field_name \"%s\")\n", rule->field_name);
98
  dumpf(indent, " (derived_name \"%s\")\n", rule->derived_name);
99
  dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
100
  dumpf(indent, " (expression \"%s\")\n", rule->expression);
101
  dumpf(indent, " (next 0x%x)\n", rule->next);
102
  dumpf(indent, " )\n");
103
}
104
 
105
 
106
static void
107
dump_cache_rules(cache_table* rule,
108
                 int indent)
109
{
110
  while (rule) {
111
    dump_cache_rule(rule, indent);
112
    rule = rule->next;
113
  }
114
}
115
 
116
 
117
int
118
main(int argc, char **argv)
119
{
120
  cache_table *rules;
121
  if (argc != 3)
122
    error("Usage: cache <cache-file> <hi-bit-nr>\n");
123
  rules = load_cache_table(argv[1], a2i(argv[2]));
124
  dump_cache_rules(rules, 0);
125
  return 0;
126
}
127
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.