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"
44 (string-list-map (lambda (cpu)
45 (let* ((cpu-name (gen-sym cpu))
46 (CPU-NAME (string-upcase cpu-name)))
47 (string-list "#ifdef WANT_CPU_" CPU-NAME "\n"
48 (/gen-cpu-header cpu "eng")
49 "#include \"cgen-engine.h\"\n"
50 (/gen-cpu-header cpu "cpu")
51 ; FIXME: Shorten "decode" to "dec".
52 (/gen-cpu-header cpu "decode")
58 ; Subroutine of /gen-cpuall-decls to generate cpu-specific structure entries.
59 ; The result is "struct <cpu>_<type-name> <member-name>;".
60 ; INDENT is the amount to indent by.
61 ; CPU is the cpu object.
63 (define (/gen-cpu-specific-decl indent cpu type-name member-name)
64 (let* ((cpu-name (gen-sym cpu))
65 (CPU-NAME (string-upcase cpu-name)))
67 "#ifdef WANT_CPU_" CPU-NAME "\n"
69 "struct " cpu-name "_" type-name " " member-name ";\n"
73 ; Return C declarations of cpu-specific structs.
74 ; These are defined here to achieve a simple and moderately type-safe
75 ; inheritance. In the non-cpu-specific files, these structs consist of
76 ; just the baseclass. In cpu-specific files, the baseclass is augmented
77 ; with the cpu-specific data.
79 (define (/gen-cpuall-decls)
86 ; Top level generators for non-cpu-specific files.
89 ; This file defines non cpu family specific data about the architecture
90 ; and also data structures that combine all variants (e.g. cpu struct).
91 ; It is intended to be included before sim-basics.h and sim-base.h.
94 (logit 1 "Generating " (current-arch-name) "'s arch.h ...\n")
97 (gen-c-copyright "Simulator header for @arch@."
98 CURRENT-COPYRIGHT CURRENT-PACKAGE)
99 "#ifndef @ARCH@_ARCH_H\n"
100 "#define @ARCH@_ARCH_H\n"
102 "#define TARGET_BIG_ENDIAN 1\n\n" ; FIXME
104 ;"/* FIXME: split into 32/64 parts */\n"
107 ;"#define AI USI\n\n"
110 /gen-arch-model-decls
111 "#endif /* @ARCH@_ARCH_H */\n"
116 ; This file defines non cpu family specific data about the architecture.
118 (define (cgen-arch.c)
119 (logit 1 "Generating " (current-arch-name) "'s arch.c ...\n")
122 (gen-c-copyright "Simulator support for @arch@."
123 CURRENT-COPYRIGHT CURRENT-PACKAGE)
125 #include \"sim-main.h\"
134 ; This file pulls together all of the cpu variants .h's.
135 ; It is intended to be included after sim-base.h/cgen-sim.h.
137 (define (cgen-cpuall.h)
138 (logit 1 "Generating " (current-arch-name) "'s cpuall.h ...\n")
141 (gen-c-copyright "Simulator CPU header for @arch@."
142 CURRENT-COPYRIGHT CURRENT-PACKAGE)
143 "#ifndef @ARCH@_CPUALL_H\n"
144 "#define @ARCH@_CPUALL_H\n"
149 "#endif /* @ARCH@_CPUALL_H */\n"
157 (logit 1 "Generating " (current-arch-name) "'s ops.c ...\n")
160 (gen-c-copyright "Simulator operational support for @arch@."
161 CURRENT-COPYRIGHT CURRENT-PACKAGE)
163 #define MEMOPS_DEFINE_INLINE
165 #include \"config.h\"
167 #include \"ansidecl.h\"
169 #include \"tconfig.h\"
170 #include \"cgen-sim.h\"
171 #include \"memops.h\"
175 0, 0, 1, -1, 3, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, 15