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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [sim/] [igen/] [ld-cache.c] - Blame information for rev 1775

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

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

powered by: WebSVN 2.1.0

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