Index: arm/ChangeLog
[deliverable/binutils-gdb.git] / sim / common / cgen.sh
CommitLineData
604259a0
FCE
1#! /bin/sh
2# Generate CGEN simulator files.
3#
fd5d712e
BE
4# Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"|"defs"|"cpu-decode"} \
5# srcdir cgen cgendir cgenflags \
ad6e5d2e 6# arch archflags cpu mach suffix archfile extrafiles opcfile
604259a0
FCE
7#
8# We store the generated files in the source directory until we decide to
9# ship a Scheme interpreter (or other implementation) with gdb/binutils.
10# Maybe we never will.
11
12# We want to behave like make, any error forces us to stop.
13set -e
14
15action=$1
16srcdir=$2
17cgen=$3
18cgendir=$4
19cgenflags=$5
20arch=$6
21archflags=$7
22cpu=$8
e4f5c43e 23isa=$9
fd5d712e 24# portably bring parameters beyond $9 into view
e4f5c43e 25shift ; mach=$9
604259a0 26shift ; suffix=$9
ea52ff81 27shift ; archfile=$9
604259a0 28shift ; extrafiles=$9
ad6e5d2e 29shift ; opcfile=$9
604259a0
FCE
30
31rootdir=${srcdir}/../..
32
ad6e5d2e
HPN
33test -z "${opcfile}" && opcfile=/dev/null
34
fd5d712e
BE
35if test -z "$isa" ; then
36 isa=all
37 prefix=$cpu
38else
39 prefix=${cpu}_$isa
40fi
41
604259a0
FCE
42lowercase='abcdefghijklmnopqrstuvwxyz'
43uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
44ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
45CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
fd5d712e 46PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
604259a0 47
fd5d712e
BE
48sedscript="\
49-e s/@ARCH@/${ARCH}/g -e s/@arch@/${arch}/g \
50-e s/@CPU@/${CPU}/g -e s/@cpu@/${cpu}/g \
51-e s/@PREFIX@/${PREFIX}/g -e s/@prefix@/${prefix}/g"
e4f5c43e 52
604259a0
FCE
53case $action in
54arch)
55 rm -f tmp-arch.h1 tmp-arch.h
56 rm -f tmp-arch.c1 tmp-arch.c
57 rm -f tmp-all.h1 tmp-all.h
58
59 ${cgen} -s ${cgendir}/cgen-sim.scm \
60 -s ${cgendir} \
61 ${cgenflags} \
62 -f "${archflags}" \
63 -m ${mach} \
ea52ff81 64 -a ${archfile} \
e4f5c43e 65 -i ${isa} \
604259a0
FCE
66 -A tmp-arch.h1 \
67 -B tmp-arch.c1 \
68 -N tmp-all.h1
fd5d712e 69 sed $sedscript < tmp-arch.h1 > tmp-arch.h
604259a0 70 ${rootdir}/move-if-change tmp-arch.h ${srcdir}/arch.h
fd5d712e 71 sed $sedscript < tmp-arch.c1 > tmp-arch.c
604259a0 72 ${rootdir}/move-if-change tmp-arch.c ${srcdir}/arch.c
fd5d712e 73 sed $sedscript < tmp-all.h1 > tmp-all.h
604259a0
FCE
74 ${rootdir}/move-if-change tmp-all.h ${srcdir}/cpuall.h
75
76 rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
77 ;;
78
79cpu | decode | cpu-decode)
80
81 fileopts=""
82 case $action in
83 *cpu*)
84 rm -f tmp-cpu.h1 tmp-cpu.c1
85 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
86 rm -f tmp-sem.c1 tmp-semsw.c1
87 rm -f tmp-mod.c1
88 rm -f tmp-cpu.h tmp-cpu.c
89 rm -f tmp-ext.c tmp-read.c tmp-write.c
90 rm -f tmp-sem.c tmp-semsw.c tmp-mod.c
91 fileopts="$fileopts \
92 -C tmp-cpu.h1 \
93 -U tmp-cpu.c1 \
94 -M tmp-mod.c1 \
95 ${extrafiles}"
96 ;;
97 esac
98 case $action in
99 *decode*)
100 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
101 fileopts="$fileopts \
102 -T tmp-dec.h1 \
103 -D tmp-dec.c1"
63fe1038
BE
104 case "$extrafiles" in
105 ignored) # Do nothing.
106 ;;
107 *) fileopts="$fileopts $extrafiles"
108 ;;
109 esac
604259a0
FCE
110 ;;
111 esac
112
113 ${cgen} -s ${cgendir}/cgen-sim.scm \
114 -s ${cgendir} \
115 ${cgenflags} \
116 -f "${archflags}" \
117 -m ${mach} \
ea52ff81 118 -a ${archfile} \
e4f5c43e 119 -i ${isa} \
604259a0
FCE
120 ${fileopts}
121
122 case $action in
123 *cpu*)
fd5d712e 124 sed $sedscript < tmp-cpu.h1 > tmp-cpu.h
604259a0 125 ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
fd5d712e 126 sed $sedscript < tmp-cpu.c1 > tmp-cpu.c
604259a0 127 ${rootdir}/move-if-change tmp-cpu.c ${srcdir}/cpu${suffix}.c
fd5d712e 128 sed $sedscript < tmp-mod.c1 > tmp-mod.c
604259a0
FCE
129 ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
130 if test -f tmp-ext.c1 ; then \
fd5d712e 131 sed $sedscript < tmp-ext.c1 > tmp-ext.c ; \
604259a0
FCE
132 ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c ; \
133 fi
134 if test -f tmp-read.c1 ; then \
fd5d712e 135 sed $sedscript < tmp-read.c1 > tmp-read.c ; \
604259a0
FCE
136 ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c ; \
137 fi
138 if test -f tmp-write.c1 ; then \
fd5d712e 139 sed $sedscript < tmp-write.c1 > tmp-write.c ; \
604259a0
FCE
140 ${rootdir}/move-if-change tmp-write.c ${srcdir}/write${suffix}.c ; \
141 fi
142 if test -f tmp-sem.c1 ; then \
fd5d712e 143 sed $sedscript < tmp-sem.c1 > tmp-sem.c ; \
604259a0
FCE
144 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
145 fi
146 if test -f tmp-semsw.c1 ; then \
fd5d712e 147 sed $sedscript < tmp-semsw.c1 > tmp-semsw.c ; \
604259a0
FCE
148 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
149 fi
150
151 rm -f tmp-cpu.h1 tmp-cpu.c1
152 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
153 rm -f tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
154 ;;
155 esac
156
157 case $action in
158 *decode*)
fd5d712e 159 sed $sedscript < tmp-dec.h1 > tmp-dec.h
604259a0 160 ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
fd5d712e 161 sed $sedscript < tmp-dec.c1 > tmp-dec.c
604259a0
FCE
162 ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
163
63fe1038
BE
164 if test -f tmp-sem.c1 ; then \
165 sed $sedscript < tmp-sem.c1 > tmp-sem.c ; \
166 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
167 fi
168 if test -f tmp-semsw.c1 ; then \
169 sed $sedscript < tmp-semsw.c1 > tmp-semsw.c ; \
170 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
171 fi
172
604259a0
FCE
173 rm -f tmp-dec.h1 tmp-dec.c1
174 ;;
175 esac
176
177 ;;
178
fd5d712e
BE
179defs)
180 rm -f tmp-defs.h1 tmp-defs.h
181
182 ${cgen} -s ${cgendir}/cgen-sim.scm \
183 -s ${cgendir} \
184 ${cgenflags} \
185 -f "${archflags}" \
186 -m ${mach} \
ea52ff81 187 -a ${archfile} \
fd5d712e
BE
188 -i ${isa} \
189 -G tmp-defs.h1
190 sed $sedscript < tmp-defs.h1 > tmp-defs.h
191 ${rootdir}/move-if-change tmp-defs.h ${srcdir}/defs${suffix}.h
192 ;;
193
604259a0
FCE
194desc)
195 rm -f tmp-desc.h1 tmp-desc.h
196 rm -f tmp-desc.c1 tmp-desc.c
197 rm -f tmp-opc.h1 tmp-opc.h
198
199 ${cgen} -s ${cgendir}/cgen-opc.scm \
200 -s ${cgendir} \
201 ${cgenflags} \
ad6e5d2e 202 -OPC ${opcfile} \
604259a0
FCE
203 -f "${archflags}" \
204 -m ${mach} \
ea52ff81 205 -a ${archfile} \
e4f5c43e 206 -i ${isa} \
604259a0
FCE
207 -H tmp-desc.h1 \
208 -C tmp-desc.c1 \
209 -O tmp-opc.h1
fd5d712e 210 sed $sedscript < tmp-desc.h1 > tmp-desc.h
604259a0 211 ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${arch}-desc.h
fd5d712e 212 sed $sedscript < tmp-desc.c1 > tmp-desc.c
604259a0 213 ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${arch}-desc.c
fd5d712e 214 sed $sedscript < tmp-opc.h1 > tmp-opc.h
604259a0
FCE
215 ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${arch}-opc.h
216
217 rm -f tmp-desc.h1 tmp-desc.c1 tmp-opc.h1
218 ;;
219
220*)
fd5d712e 221 echo "`basename $0`: unknown action: ${action}" >&2
604259a0
FCE
222 exit 1
223 ;;
224
225esac
226
227exit 0
This page took 0.265013 seconds and 4 git commands to generate.