OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [sim/] [ppc/] [ld-cache.c] - Diff between revs 24 and 157

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
    Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
 
 
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
    */
    */
 
 
 
 
#include "misc.h"
#include "misc.h"
#include "lf.h"
#include "lf.h"
#include "table.h"
#include "table.h"
#include "ld-cache.h"
#include "ld-cache.h"
 
 
#ifndef NULL
#ifndef NULL
#define NULL 0
#define NULL 0
#endif
#endif
 
 
 
 
enum {
enum {
  ca_type,
  ca_type,
  ca_field_name,
  ca_field_name,
  ca_derived_name,
  ca_derived_name,
  ca_type_def,
  ca_type_def,
  ca_expression,
  ca_expression,
  nr_cache_rule_fields,
  nr_cache_rule_fields,
};
};
 
 
static const name_map cache_type_map[] = {
static const name_map cache_type_map[] = {
  { "cache", cache_value },
  { "cache", cache_value },
  { "compute", compute_value },
  { "compute", compute_value },
  { "scratch", scratch_value },
  { "scratch", scratch_value },
  { NULL, 0 },
  { NULL, 0 },
};
};
 
 
 
 
void
void
append_cache_rule (cache_table **table, char *type, char *field_name,
append_cache_rule (cache_table **table, char *type, char *field_name,
                   char *derived_name, char *type_def,
                   char *derived_name, char *type_def,
                   char *expression, table_entry *file_entry)
                   char *expression, table_entry *file_entry)
{
{
  while ((*table) != NULL)
  while ((*table) != NULL)
    table = &(*table)->next;
    table = &(*table)->next;
  (*table) = ZALLOC(cache_table);
  (*table) = ZALLOC(cache_table);
  (*table)->type = name2i(type, cache_type_map);
  (*table)->type = name2i(type, cache_type_map);
  (*table)->field_name = field_name;
  (*table)->field_name = field_name;
  (*table)->derived_name = derived_name;
  (*table)->derived_name = derived_name;
  (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL);
  (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL);
  (*table)->expression = (strlen(expression) > 0 ? expression : NULL);
  (*table)->expression = (strlen(expression) > 0 ? expression : NULL);
  (*table)->file_entry = file_entry;
  (*table)->file_entry = file_entry;
  (*table)->next = NULL;
  (*table)->next = NULL;
}
}
 
 
 
 
cache_table *
cache_table *
load_cache_table(char *file_name,
load_cache_table(char *file_name,
                 int hi_bit_nr)
                 int hi_bit_nr)
{
{
  table *file = table_open(file_name, nr_cache_rule_fields, 0);
  table *file = table_open(file_name, nr_cache_rule_fields, 0);
  table_entry *entry;
  table_entry *entry;
  cache_table *table = NULL;
  cache_table *table = NULL;
  cache_table **curr_rule = &table;
  cache_table **curr_rule = &table;
  while ((entry = table_entry_read(file)) != NULL) {
  while ((entry = table_entry_read(file)) != NULL) {
    append_cache_rule (curr_rule, entry->fields[ca_type],
    append_cache_rule (curr_rule, entry->fields[ca_type],
                       entry->fields[ca_field_name],
                       entry->fields[ca_field_name],
                       entry->fields[ca_derived_name],
                       entry->fields[ca_derived_name],
                       entry->fields[ca_type_def],
                       entry->fields[ca_type_def],
                       entry->fields[ca_expression],
                       entry->fields[ca_expression],
                       entry);
                       entry);
    curr_rule = &(*curr_rule)->next;
    curr_rule = &(*curr_rule)->next;
  }
  }
  return table;
  return table;
}
}
 
 
 
 
 
 
#ifdef MAIN
#ifdef MAIN
 
 
static void
static void
dump_cache_rule(cache_table* rule,
dump_cache_rule(cache_table* rule,
                int indent)
                int indent)
{
{
  dumpf(indent, "((cache_table*)0x%x\n", rule);
  dumpf(indent, "((cache_table*)0x%x\n", rule);
  dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
  dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
  dumpf(indent, " (field_name \"%s\")\n", rule->field_name);
  dumpf(indent, " (field_name \"%s\")\n", rule->field_name);
  dumpf(indent, " (derived_name \"%s\")\n", rule->derived_name);
  dumpf(indent, " (derived_name \"%s\")\n", rule->derived_name);
  dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
  dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
  dumpf(indent, " (expression \"%s\")\n", rule->expression);
  dumpf(indent, " (expression \"%s\")\n", rule->expression);
  dumpf(indent, " (next 0x%x)\n", rule->next);
  dumpf(indent, " (next 0x%x)\n", rule->next);
  dumpf(indent, " )\n");
  dumpf(indent, " )\n");
}
}
 
 
 
 
static void
static void
dump_cache_rules(cache_table* rule,
dump_cache_rules(cache_table* rule,
                 int indent)
                 int indent)
{
{
  while (rule) {
  while (rule) {
    dump_cache_rule(rule, indent);
    dump_cache_rule(rule, indent);
    rule = rule->next;
    rule = rule->next;
  }
  }
}
}
 
 
 
 
int
int
main(int argc, char **argv)
main(int argc, char **argv)
{
{
  cache_table *rules;
  cache_table *rules;
  if (argc != 3)
  if (argc != 3)
    error("Usage: cache <cache-file> <hi-bit-nr>\n");
    error("Usage: cache <cache-file> <hi-bit-nr>\n");
  rules = load_cache_table(argv[1], a2i(argv[2]));
  rules = load_cache_table(argv[1], a2i(argv[2]));
  dump_cache_rules(rules, 0);
  dump_cache_rules(rules, 0);
  return 0;
  return 0;
}
}
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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