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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [sim/] [ppc/] [gen-itable.c] - Blame information for rev 819

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

Line No. Rev Author Line
1 24 jeremybenn
/*  This file is part of the program psim.
2
 
3
    Copyright (C) 1994-1995, 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
 
23
#include "misc.h"
24
#include "lf.h"
25
#include "table.h"
26
 
27
#include "filter.h"
28
 
29
#include "ld-cache.h"
30
#include "ld-decode.h"
31
#include "ld-insn.h"
32
 
33
#include "igen.h"
34
#include "gen-itable.h"
35
 
36
#ifndef NULL
37
#define NULL 0
38
#endif
39
 
40
 
41
 
42
static void
43
itable_h_insn(insn_table *entry,
44
              lf *file,
45
              void *data,
46
              insn *instruction,
47
              int depth)
48
{
49
  lf_printf(file, "  ");
50
  print_function_name(file,
51
                      instruction->file_entry->fields[insn_name],
52
                      NULL,
53
                      function_name_prefix_itable);
54
  lf_printf(file, ",\n");
55
}
56
 
57
 
58
extern void
59
gen_itable_h(insn_table *table, lf *file)
60
{
61
  /* output an enumerated type for each instruction */
62
  lf_printf(file, "typedef enum {\n");
63
  insn_table_traverse_insn(table,
64
                           file, NULL,
65
                           itable_h_insn);
66
  lf_printf(file, "  nr_itable_entries,\n");
67
  lf_printf(file, "} itable_index;\n");
68
  lf_printf(file, "\n");
69
 
70
  /* output the table that contains the actual instruction info */
71
  lf_printf(file, "typedef struct _itable_instruction_info {\n");
72
  lf_printf(file, "  itable_index nr;\n");
73
  lf_printf(file, "  char *format;\n");
74
  lf_printf(file, "  char *form;\n");
75
  lf_printf(file, "  char *flags;\n");
76
  lf_printf(file, "  char *mnemonic;\n");
77
  lf_printf(file, "  char *name;\n");
78
  lf_printf(file, "  char *file;\n");
79
  lf_printf(file, "  int line_nr;\n");
80
  lf_printf(file, "} itable_info;\n");
81
  lf_printf(file, "\n");
82
  lf_printf(file, "extern itable_info itable[nr_itable_entries];\n");
83
}
84
 
85
/****************************************************************/
86
 
87
static void
88
itable_c_insn(insn_table *entry,
89
              lf *file,
90
              void *data,
91
              insn *instruction,
92
              int depth)
93
{
94
  char **fields = instruction->file_entry->fields;
95
  lf_printf(file, "  { ");
96
  print_function_name(file,
97
                      instruction->file_entry->fields[insn_name],
98
                      NULL,
99
                      function_name_prefix_itable);
100
  lf_printf(file, ",\n");
101
  lf_printf(file, "    \"%s\",\n", fields[insn_format]);
102
  lf_printf(file, "    \"%s\",\n", fields[insn_form]);
103
  lf_printf(file, "    \"%s\",\n", fields[insn_flags]);
104
  lf_printf(file, "    \"%s\",\n", fields[insn_mnemonic]);
105
  lf_printf(file, "    \"%s\",\n", fields[insn_name]);
106
  lf_printf(file, "    \"%s\",\n", filter_filename (instruction->file_entry->file_name));
107
  lf_printf(file, "    %d,\n", instruction->file_entry->line_nr);
108
  lf_printf(file, "    },\n");
109
}
110
 
111
 
112
extern void
113
gen_itable_c(insn_table *table, lf *file)
114
{
115
  /* output the table that contains the actual instruction info */
116
  lf_printf(file, "#include \"itable.h\"\n");
117
  lf_printf(file, "\n");
118
  lf_printf(file, "itable_info itable[nr_itable_entries] = {\n");
119
  insn_table_traverse_insn(table,
120
                           file, NULL,
121
                           itable_c_insn);
122
  lf_printf(file, "};\n");
123
}

powered by: WebSVN 2.1.0

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