1 ; Simulator generator support routines.
2 ; Copyright (C) 2000, 2009 Red Hat, Inc.
3 ; This file is part of CGEN.
5 ; Utilities of cgen-arch.h.
7 ; Return C macro definitions of the various supported cpus.
9 (define (/gen-cpuall-defines)
13 ; Return C declarations of misc. support stuff.
14 ; ??? Modes are now defined in sim/common/cgen-types.h but we will need
15 ; target specific modes.
17 (define (/gen-support-decls)
19 ; (gen-enum-decl 'mode_type "mode types"
21 ; ; Aliases are not distinct from their real mode so ignore
23 ; (append (map list (map obj:name
24 ; (mode-list-non-alias-values)))
26 ; "#define MAX_MODES ((int) MODE_MAX)\n\n"
30 ; Utilities of cgen-cpuall.h.
32 ; Subroutine of /gen-cpuall-includes.
34 (define (/gen-cpu-header cpu prefix)
35 (string-append "#include \"" prefix (cpu-file-transform cpu) ".h\"\n")
38 ; Return C code to include all the relevant headers for each cpu family,
39 ; conditioned on ifdef WANT_CPU_@CPU@.
41 (define (/gen-cpuall-includes)
43 "/* Include files for each cpu family. */\n\n"
46 (let* ((cpu-name (gen-sym cpu))
47 (CPU-NAME (string-upcase cpu-name)))
48 (string-list "#ifdef WANT_CPU_" CPU-NAME "\n"
49 (/gen-cpu-header cpu "eng")
50 (/gen-cpu-header cpu "cpu")
51 (/gen-cpu-header cpu "decode")
57 ; Subroutine of /gen-cpuall-decls to generate cpu-specific structure entries.
58 ; The result is "struct <cpu>_<type-name> <member-name>;".
59 ; INDENT is the amount to indent by.
60 ; CPU is the cpu object.
62 (define (/gen-cpu-specific-decl indent cpu type-name member-name)
63 (let* ((cpu-name (gen-sym cpu))
64 (CPU-NAME (string-upcase cpu-name)))
66 "#ifdef WANT_CPU_" CPU-NAME "\n"
68 "struct " cpu-name "_" type-name " " member-name ";\n"
72 ; Return C declarations of cpu-specific structs.
73 ; These are defined here to achieve a simple and moderately type-safe
74 ; inheritance. In the non-cpu-specific files, these structs consist of
75 ; just the baseclass. In cpu-specific files, the baseclass is augmented
76 ; with the cpu-specific data.
78 (define (/gen-cpuall-decls)
85 ; Top level generators for non-cpu-specific files.
88 ; This file defines non cpu family specific data about the architecture
89 ; and also data structures that combine all variants (e.g. cpu struct).
90 ; It is intended to be included before sim-basics.h and sim-base.h.
93 (logit 1 "Generating " (current-arch-name) "'s arch.h ...\n")
96 (gen-c-copyright "Simulator header for @arch@."
97 CURRENT-COPYRIGHT CURRENT-PACKAGE)
98 "#ifndef @ARCH@_ARCH_H\n"
99 "#define @ARCH@_ARCH_H\n"
101 "#define TARGET_BIG_ENDIAN 1\n\n" ; FIXME
103 ;"/* FIXME: split into 32/64 parts */\n"
106 ;"#define AI USI\n\n"
109 /gen-arch-model-decls
110 "#endif /* @ARCH@_ARCH_H */\n"
115 ; This file defines non cpu family specific data about the architecture.
117 (define (cgen-arch.c)
118 (logit 1 "Generating " (current-arch-name) "'s arch.c ...\n")
121 (gen-c-copyright "Simulator support for @arch@."
122 CURRENT-COPYRIGHT CURRENT-PACKAGE)
124 #include \"sim-main.h\"
133 ; This file pulls together all of the cpu variants .h's.
134 ; It is intended to be included after sim-base.h/cgen-sim.h.
136 (define (cgen-cpuall.h)
137 (logit 1 "Generating " (current-arch-name) "'s cpuall.h ...\n")
140 (gen-c-copyright "Simulator CPU header for @arch@."
141 CURRENT-COPYRIGHT CURRENT-PACKAGE)
142 "#ifndef @ARCH@_CPUALL_H\n"
143 "#define @ARCH@_CPUALL_H\n"
148 "#endif /* @ARCH@_CPUALL_H */\n"
156 (logit 1 "Generating " (current-arch-name) "'s ops.c ...\n")
159 (gen-c-copyright "Simulator operational support for @arch@."
160 CURRENT-COPYRIGHT CURRENT-PACKAGE)
162 #define MEMOPS_DEFINE_INLINE
164 #include \"config.h\"
166 #include \"ansidecl.h\"
168 #include \"tconfig.h\"
169 #include \"cgen-sim.h\"
170 #include \"memops.h\"
174 0, 0, 1, -1, 3, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, 15