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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [igen/] [ld-cache.c] - Blame information for rev 307

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

Line No. Rev Author Line
1 24 jeremybenn
/* The IGEN simulator generator for GDB, the GNU Debugger.
2
 
3
   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
4
 
5
   Contributed by Andrew Cagney.
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
 
22
 
23
 
24
#include "misc.h"
25
#include "lf.h"
26
#include "table.h"
27
#include "filter.h"
28
#include "igen.h"
29
 
30
#include "ld-insn.h"
31
#include "ld-cache.h"
32
 
33
#ifndef NULL
34
#define NULL 0
35
#endif
36
 
37
 
38
enum
39
{
40
  ca_type,
41
  ca_field_name,
42
  ca_derived_name,
43
  ca_type_def,
44
  ca_expression,
45
  nr_cache_rule_fields,
46
};
47
 
48
static const name_map cache_type_map[] = {
49
  {"cache", cache_value},
50
  {"compute", compute_value},
51
  {"scratch", scratch_value},
52
  {NULL, 0},
53
};
54
 
55
 
56
cache_entry *
57
load_cache_table (char *file_name)
58
{
59
  cache_entry *cache = NULL;
60
  cache_entry **last = &cache;
61
  table *file = table_open (file_name);
62
  table_entry *entry;
63
  while ((entry = table_read (file)) != NULL)
64
    {
65
      cache_entry *new_rule = ZALLOC (cache_entry);
66
      new_rule->line = entry->line;
67
      new_rule->entry_type = name2i (entry->field[ca_type], cache_type_map);
68
      new_rule->name = entry->field[ca_derived_name];
69
      filter_parse (&new_rule->original_fields, entry->field[ca_field_name]);
70
      new_rule->type = entry->field[ca_type_def];
71
      /* expression is the concatenation of the remaining fields */
72
      if (entry->nr_fields > ca_expression)
73
        {
74
          int len = 0;
75
          int chi;
76
          for (chi = ca_expression; chi < entry->nr_fields; chi++)
77
            {
78
              len += strlen (" : ") + strlen (entry->field[chi]);
79
            }
80
          new_rule->expression = NZALLOC (char, len);
81
          strcpy (new_rule->expression, entry->field[ca_expression]);
82
          for (chi = ca_expression + 1; chi < entry->nr_fields; chi++)
83
            {
84
              strcat (new_rule->expression, " : ");
85
              strcat (new_rule->expression, entry->field[chi]);
86
            }
87
        }
88
      /* insert it */
89
      *last = new_rule;
90
      last = &new_rule->next;
91
    }
92
  return cache;
93
}
94
 
95
 
96
 
97
#ifdef MAIN
98
 
99
igen_options options;
100
 
101
int
102
main (int argc, char **argv)
103
{
104
  cache_entry *rules = NULL;
105
  lf *l;
106
 
107
  if (argc != 2)
108
    error (NULL, "Usage: cache <cache-file>\n");
109
 
110
  rules = load_cache_table (argv[1]);
111
  l = lf_open ("-", "stdout", lf_omit_references, lf_is_text, "tmp-ld-insn");
112
  dump_cache_entries (l, "(", rules, ")\n");
113
 
114
  return 0;
115
}
116
#endif

powered by: WebSVN 2.1.0

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