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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [sim/] [ppc/] [gen-itable.c] - Blame information for rev 1765

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

powered by: WebSVN 2.1.0

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