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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [sid-model.scm] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
; Simulator model support, plus misc. things associated with a cpu family.
2
; Copyright (C) 2000, 2002, 2003, 2006, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
 
5
"\
6
/* The properties of this cpu's implementation.  */
7
 
8
static const MACH_IMP_PROPERTIES @cpu@_imp_properties =
9
 
10
  sizeof (@cpu@_cpu),
11
 
12
  sizeof (SCACHE)
13
#else
14
  0
15
#endif
16
 
17
; Generate code to profile hardware elements.
18
; ??? Not currently used.
19
; Fetch profilable input and output operands of the semantic code.
20
; For each operand, record its being get/set.
21
; Return decls of hardware element profilers.
22
; ??? Not currently used.
23
 
24
");\n""extern void @prefix@_model_mark_set_"" (@cpu@_cpu *"""", int"; FIXME: get index type
25
");\n""\n"; Return the name of the class representing the given MODEL.
26
"@prefix@_""_model"; Return name of profiling handler for MODEL, UNIT.
27
; Also called by sim.scm.
28
 
29
"  virtual UINT "" (@cpu@_cpu *cpu, const struct @prefix@_idesc *idesc,"" int unit_num"", unsigned long long referenced"""")\n"; Return decls of all insn model handlers.
30
 
31
"model_""_""::"; Return declaration of function to model INSN.
32
"UINT "" (@cpu@_cpu *current_cpu, @prefix@_scache *sem);\n""  // These methods call the appropriate unit modeller(s) for each insn.\n""  ""  "; Return function to model INSN.
33
 
34
; (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
35
; "];\n"
36
"  int cycles = 0;\n""""  PCADDR UNUSED pc = current_cpu->hardware.h_pc;\n""  @prefix@_insn_word insn = abuf->insn;\n""  ""  "; Emit code to model the insn.  Function units are handled here.
37
"cycles""  return cycles;\n""""}\n\n"; Return insn modeling handlers.
38
; ??? Might wish to reduce the amount of output by combining identical cases.
39
; ??? Modelling of insns could be table driven, but that puts constraints on
40
; generality.
41
"/* Model handlers for each insn.  */\n\n"; Generate the model constructor.
42
"::"" (@cpu@_cpu *cpu)\n""  : cgen_model (cpu)\n""{\n""}\n""\n""\n""  ""unit types""UNIT_"; "apply append" squeezes out nils.
43
; create <model_name>-<unit-name> for each unit
44
"  struct unit {\n""    unit_number unit;\n""    UINT issue;\n""    UINT done;\n""  };\n\n"; FIXME: revisit MAX_UNITS
45
"  static const int MAX_UNITS = "";\n"; Return the C++ class representing the given model.
46
 
47
class "" : public cgen_model
48
{
49
 
50
  "" (@cpu@_cpu *cpu);
51
 
52
  // Call the proper unit modelling function for the given insn.
53
  UINT model_before (@cpu@_cpu *current_cpu, @prefix@_scache* sem)
54
    {
55
      return (this->*(timing[sem->idesc->sem_index].model_before)) (current_cpu, sem);
56
    }
57
  UINT model_after (@cpu@_cpu *current_cpu, @prefix@_scache* sem)
58
    {
59
      return (this->*(timing[sem->idesc->sem_index].model_after)) (current_cpu, sem);
60
    }
61
""\
62
 
63
protected:
64
""\
65
 
66
  typedef UINT (""::*model_function) (@cpu@_cpu* current_cpu, @prefix@_scache* sem);
67
 
68
  struct insn_timing {
69
    // This is an integer that identifies this insn.
70
 
71
    // Functions to handle insn-specific profiling.
72
    model_function model_before;
73
    model_function model_after;
74
    // Array of function units used by this insn.
75
 
76
  };
77
 
78
 
79
};
80
"; Return the C++ classes representing the current list of models.
81
"\n"; Generate timing table entry for function unit U while executing INSN.
82
 
83
; ARGS is a list of overriding arguments from INSN.
84
"{ ""::"", "", "" }, "; Generate timing table entry for MODEL for INSN.
85
; Instruction timing is stored as an associative list based on the model.
86
;(display timing) (newline)
87
"  { "", ""0, 0""& "", ""& "", { "" } },\n"; Generate model timing table for MODEL.
88
"/* Model timing data for `""'.  */\n\n""const ""::insn_timing ""::timing[] = {\n""};\n\n"; Return C code to define model profiling support stuff.
89
"/* We assume UNIT_NONE == 0 because the tables don't always terminate\n""   entries with it.  */\n\n"; Return C code to define the model table for MACH.
90
"\
91
static const MODEL ""_models[] =\n{\n""  { ""\"""\", ""& ""_mach, "", ""TIMING_DATA (& ""_timing[0]), ""_model_init"" },\n""  { 0 }\n""};\n\n"; Return C code to define model init fn.
92
"\
93
static void\n""_model_init (@cpu@_cpu *cpu)
94
{
95
  cpu->model_data = new @PREFIX@_MODEL_DATA;
96
}\n\n"; Return C code to define model data and support fns.
97
"#if WITH_PROFILE_MODEL_P
98
#define TIMING_DATA(td) td
99
#else
100
#define TIMING_DATA(td) 0
101
#endif\n\n"; Return C definitions for this cpu family variant.
102
""; Return C code to define the machine data.
103
"\
104
static void\n""_init_cpu (@cpu@_cpu *cpu)
105
 
106
  @prefix@_init_idesc_table (cpu);
107
 
108
 
109
const MACH ""_mach =
110
{
111
  \"""\", ""\"""\",
112
  "", "; FIXME: addr-bitsize: delete
113
", ""& ""_models[0], ""& ""_imp_properties,
114
  ""_init_cpu
115
};
116
 
117
"; Top level file generators.
118
; Generate model.cxx
119
"Generating ""-model.cxx ...\n"; Turn parallel execution support on if cpu needs it.
120
"Simulator model support for @prefix@.""\
121
 
122
#if HAVE_CONFIG_H
123
#include \"config.h\"
124
#endif
125
#include \"@cpu@.h\"
126
 
127
using namespace @cpu@; // FIXME: namespace organization still wip
128
 
129
/* The profiling data is recorded here, but is accessed via the profiling
130
   mechanism.  After all, this is information for profiling.  */
131
 
132
 
133
;   -gen-model-defns
134
;   -gen-cpu-imp-properties
135
;   -gen-cpu-defns
136
 
137
"Generating ""-model.h ...\n""Simulator model support for @prefix@.""\
138
 
139
#define @PREFIX@_MODEL_H
140
 
141
#include \"cgen-cpu.h\"
142
#include \"cgen-model.h\"
143
 
144
namespace @cpu@
145
{
146
 
147
""\
148
 
149
} // namespace @cpu@
150
 
151
#endif // @PREFIX@_MODEL_H
152
"

powered by: WebSVN 2.1.0

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