gdb: add target_ops::supports_displaced_step
[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
9ab46d53 17cgen="$3"
604259a0
FCE
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
2c2a86d7
DE
53# avoid collisions in parallel makes
54tmp=tmp-$$
55
604259a0
FCE
56case $action in
57arch)
2c2a86d7
DE
58 rm -f ${tmp}-arch.h1 ${tmp}-arch.h
59 rm -f ${tmp}-arch.c1 ${tmp}-arch.c
60 rm -f ${tmp}-all.h1 ${tmp}-all.h
604259a0 61
9ab46d53 62 ${cgen} ${cgendir}/cgen-sim.scm \
604259a0
FCE
63 -s ${cgendir} \
64 ${cgenflags} \
65 -f "${archflags}" \
66 -m ${mach} \
ea52ff81 67 -a ${archfile} \
e4f5c43e 68 -i ${isa} \
2c2a86d7
DE
69 -A ${tmp}-arch.h1 \
70 -B ${tmp}-arch.c1 \
71 -N ${tmp}-all.h1
72 sed $sedscript < ${tmp}-arch.h1 > ${tmp}-arch.h
73 ${rootdir}/move-if-change ${tmp}-arch.h ${srcdir}/arch.h
74 sed $sedscript < ${tmp}-arch.c1 > ${tmp}-arch.c
75 ${rootdir}/move-if-change ${tmp}-arch.c ${srcdir}/arch.c
76 sed $sedscript < ${tmp}-all.h1 > ${tmp}-all.h
77 ${rootdir}/move-if-change ${tmp}-all.h ${srcdir}/cpuall.h
78
79 rm -f ${tmp}-arch.h1 ${tmp}-arch.c1 ${tmp}-all.h1
604259a0
FCE
80 ;;
81
82cpu | decode | cpu-decode)
83
84 fileopts=""
2c2a86d7 85
604259a0
FCE
86 case $action in
87 *cpu*)
2c2a86d7
DE
88 rm -f ${tmp}-cpu.h1 ${tmp}-cpu.c1
89 rm -f ${tmp}-ext.c1 ${tmp}-read.c1 ${tmp}-write.c1
90 rm -f ${tmp}-sem.c1 ${tmp}-semsw.c1
91 rm -f ${tmp}-mod.c1
92 rm -f ${tmp}-cpu.h ${tmp}-cpu.c
93 rm -f ${tmp}-ext.c ${tmp}-read.c ${tmp}-write.c
94 rm -f ${tmp}-sem.c ${tmp}-semsw.c ${tmp}-mod.c
604259a0 95 fileopts="$fileopts \
2c2a86d7
DE
96 -C ${tmp}-cpu.h1 \
97 -U ${tmp}-cpu.c1 \
98 -M ${tmp}-mod.c1"
604259a0
FCE
99 ;;
100 esac
2c2a86d7 101
604259a0
FCE
102 case $action in
103 *decode*)
2c2a86d7 104 rm -f ${tmp}-dec.h1 ${tmp}-dec.h ${tmp}-dec.c1 ${tmp}-dec.c
604259a0 105 fileopts="$fileopts \
2c2a86d7
DE
106 -T ${tmp}-dec.h1 \
107 -D ${tmp}-dec.c1"
604259a0
FCE
108 ;;
109 esac
110
2c2a86d7
DE
111 case "$extrafiles" in
112 */extr/*) fileopts="${fileopts} -E ${tmp}-ext.c1" ;;
113 esac
114 case "$extrafiles" in
115 */read/*) fileopts="${fileopts} -R ${tmp}-read.c1" ;;
116 esac
117 case "$extrafiles" in
118 */write/*) fileopts="${fileopts} -W ${tmp}-write.c1" ;;
119 esac
120 case "$extrafiles" in
121 */sem/*) fileopts="${fileopts} -S ${tmp}-sem.c1" ;;
122 esac
123 case "$extrafiles" in
124 */semsw/*) fileopts="${fileopts} -X ${tmp}-semsw.c1" ;;
125 esac
126
9ab46d53 127 ${cgen} ${cgendir}/cgen-sim.scm \
604259a0
FCE
128 -s ${cgendir} \
129 ${cgenflags} \
130 -f "${archflags}" \
131 -m ${mach} \
ea52ff81 132 -a ${archfile} \
e4f5c43e 133 -i ${isa} \
604259a0
FCE
134 ${fileopts}
135
136 case $action in
137 *cpu*)
2c2a86d7
DE
138 sed $sedscript < ${tmp}-cpu.h1 > ${tmp}-cpu.h
139 ${rootdir}/move-if-change ${tmp}-cpu.h ${srcdir}/cpu${suffix}.h
140 sed $sedscript < ${tmp}-cpu.c1 > ${tmp}-cpu.c
141 ${rootdir}/move-if-change ${tmp}-cpu.c ${srcdir}/cpu${suffix}.c
142 sed $sedscript < ${tmp}-mod.c1 > ${tmp}-mod.c
143 ${rootdir}/move-if-change ${tmp}-mod.c ${srcdir}/model${suffix}.c
144 rm -f ${tmp}-cpu.h1 ${tmp}-cpu.c1 ${tmp}-mod.c1
604259a0
FCE
145 ;;
146 esac
147
148 case $action in
149 *decode*)
2c2a86d7
DE
150 sed $sedscript < ${tmp}-dec.h1 > ${tmp}-dec.h
151 ${rootdir}/move-if-change ${tmp}-dec.h ${srcdir}/decode${suffix}.h
152 sed $sedscript < ${tmp}-dec.c1 > ${tmp}-dec.c
153 ${rootdir}/move-if-change ${tmp}-dec.c ${srcdir}/decode${suffix}.c
154 rm -f ${tmp}-dec.h1 ${tmp}-dec.c1
604259a0
FCE
155 ;;
156 esac
157
2c2a86d7
DE
158 if test -f ${tmp}-ext.c1 ; then \
159 sed $sedscript < ${tmp}-ext.c1 > ${tmp}-ext.c ; \
160 ${rootdir}/move-if-change ${tmp}-ext.c ${srcdir}/extract${suffix}.c ; \
161 rm -f ${tmp}-ext.c1
162 fi
163 if test -f ${tmp}-read.c1 ; then \
164 sed $sedscript < ${tmp}-read.c1 > ${tmp}-read.c ; \
165 ${rootdir}/move-if-change ${tmp}-read.c ${srcdir}/read${suffix}.c ; \
166 rm -f ${tmp}-read.c1
167 fi
168 if test -f ${tmp}-write.c1 ; then \
169 sed $sedscript < ${tmp}-write.c1 > ${tmp}-write.c ; \
170 ${rootdir}/move-if-change ${tmp}-write.c ${srcdir}/write${suffix}.c ; \
171 rm -f ${tmp}-write.c1
172 fi
173 if test -f ${tmp}-sem.c1 ; then \
174 sed $sedscript < ${tmp}-sem.c1 > ${tmp}-sem.c ; \
175 ${rootdir}/move-if-change ${tmp}-sem.c ${srcdir}/sem${suffix}.c ; \
176 rm -f ${tmp}-sem.c1
177 fi
178 if test -f ${tmp}-semsw.c1 ; then \
179 sed $sedscript < ${tmp}-semsw.c1 > ${tmp}-semsw.c ; \
180 ${rootdir}/move-if-change ${tmp}-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
181 rm -f ${tmp}-semsw.c1
182 fi
183
604259a0
FCE
184 ;;
185
fd5d712e 186defs)
2c2a86d7 187 rm -f ${tmp}-defs.h1 ${tmp}-defs.h
fd5d712e 188
9ab46d53 189 ${cgen} ${cgendir}/cgen-sim.scm \
fd5d712e
BE
190 -s ${cgendir} \
191 ${cgenflags} \
192 -f "${archflags}" \
193 -m ${mach} \
ea52ff81 194 -a ${archfile} \
fd5d712e 195 -i ${isa} \
2c2a86d7
DE
196 -G ${tmp}-defs.h1
197 sed $sedscript < ${tmp}-defs.h1 > ${tmp}-defs.h
198 ${rootdir}/move-if-change ${tmp}-defs.h ${srcdir}/defs${suffix}.h
199 rm -f ${tmp}-defs.h1
fd5d712e
BE
200 ;;
201
604259a0 202desc)
2c2a86d7
DE
203 rm -f ${tmp}-desc.h1 ${tmp}-desc.h
204 rm -f ${tmp}-desc.c1 ${tmp}-desc.c
205 rm -f ${tmp}-opc.h1 ${tmp}-opc.h
604259a0 206
9ab46d53 207 ${cgen} ${cgendir}/cgen-opc.scm \
604259a0
FCE
208 -s ${cgendir} \
209 ${cgenflags} \
ad6e5d2e 210 -OPC ${opcfile} \
604259a0
FCE
211 -f "${archflags}" \
212 -m ${mach} \
ea52ff81 213 -a ${archfile} \
e4f5c43e 214 -i ${isa} \
2c2a86d7
DE
215 -H ${tmp}-desc.h1 \
216 -C ${tmp}-desc.c1 \
217 -O ${tmp}-opc.h1
218 sed $sedscript < ${tmp}-desc.h1 > ${tmp}-desc.h
219 ${rootdir}/move-if-change ${tmp}-desc.h ${srcdir}/${arch}-desc.h
220 sed $sedscript < ${tmp}-desc.c1 > ${tmp}-desc.c
221 ${rootdir}/move-if-change ${tmp}-desc.c ${srcdir}/${arch}-desc.c
222 sed $sedscript < ${tmp}-opc.h1 > ${tmp}-opc.h
223 ${rootdir}/move-if-change ${tmp}-opc.h ${srcdir}/${arch}-opc.h
224
225 rm -f ${tmp}-desc.h1 ${tmp}-desc.c1 ${tmp}-opc.h1
604259a0
FCE
226 ;;
227
228*)
fd5d712e 229 echo "`basename $0`: unknown action: ${action}" >&2
604259a0
FCE
230 exit 1
231 ;;
232
233esac
234
235exit 0
This page took 1.65547 seconds and 4 git commands to generate.