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

Subversion Repositories or1k

[/] [or1k/] [tags/] [VER_5_3/] [gdb-5.3/] [sim/] [igen/] [ld-cache.c] - Blame information for rev 1181

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

Line No. Rev Author Line
1 1181 sfurman
/* The IGEN simulator generator for GDB, the GNU Debugger.
2
 
3
   Copyright 2002 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 2 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, write to the Free Software
21
   Foundation, Inc., 59 Temple Place - Suite 330,
22
   Boston, MA 02111-1307, USA.  */
23
 
24
 
25
 
26
#include "misc.h"
27
#include "lf.h"
28
#include "table.h"
29
#include "filter.h"
30
#include "igen.h"
31
 
32
#include "ld-insn.h"
33
#include "ld-cache.h"
34
 
35
#ifndef NULL
36
#define NULL 0
37
#endif
38
 
39
 
40
enum
41
{
42
  ca_type,
43
  ca_field_name,
44
  ca_derived_name,
45
  ca_type_def,
46
  ca_expression,
47
  nr_cache_rule_fields,
48
};
49
 
50
static const name_map cache_type_map[] = {
51
  {"cache", cache_value},
52
  {"compute", compute_value},
53
  {"scratch", scratch_value},
54
  {NULL, 0},
55
};
56
 
57
 
58
cache_entry *
59
load_cache_table (char *file_name)
60
{
61
  cache_entry *cache = NULL;
62
  cache_entry **last = &cache;
63
  table *file = table_open (file_name);
64
  table_entry *entry;
65
  while ((entry = table_read (file)) != NULL)
66
    {
67
      cache_entry *new_rule = ZALLOC (cache_entry);
68
      new_rule->line = entry->line;
69
      new_rule->entry_type = name2i (entry->field[ca_type], cache_type_map);
70
      new_rule->name = entry->field[ca_derived_name];
71
      filter_parse (&new_rule->original_fields, entry->field[ca_field_name]);
72
      new_rule->type = entry->field[ca_type_def];
73
      /* expression is the concatenation of the remaining fields */
74
      if (entry->nr_fields > ca_expression)
75
        {
76
          int len = 0;
77
          int chi;
78
          for (chi = ca_expression; chi < entry->nr_fields; chi++)
79
            {
80
              len += strlen (" : ") + strlen (entry->field[chi]);
81
            }
82
          new_rule->expression = NZALLOC (char, len);
83
          strcpy (new_rule->expression, entry->field[ca_expression]);
84
          for (chi = ca_expression + 1; chi < entry->nr_fields; chi++)
85
            {
86
              strcat (new_rule->expression, " : ");
87
              strcat (new_rule->expression, entry->field[chi]);
88
            }
89
        }
90
      /* insert it */
91
      *last = new_rule;
92
      last = &new_rule->next;
93
    }
94
  return cache;
95
}
96
 
97
 
98
 
99
#ifdef MAIN
100
 
101
igen_options options;
102
 
103
int
104
main (int argc, char **argv)
105
{
106
  cache_entry *rules = NULL;
107
  lf *l;
108
 
109
  if (argc != 2)
110
    error (NULL, "Usage: cache <cache-file>\n");
111
 
112
  rules = load_cache_table (argv[1]);
113
  l = lf_open ("-", "stdout", lf_omit_references, lf_is_text, "tmp-ld-insn");
114
  dump_cache_entries (l, "(", rules, ")\n");
115
 
116
  return 0;
117
}
118
#endif

powered by: WebSVN 2.1.0

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