Remove space == 0 restriction in the simulator (dv-core)
[deliverable/binutils-gdb.git] / sim / common / cgen.sh
CommitLineData
604259a0
FCE
1#! /bin/sh
2# Generate CGEN simulator files.
3#
4# Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"|"cpu-decode"} srcdir \
5# cgen cgendir cgenflags \
6# arch archflags cpu mach suffix extrafiles
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
604259a0 24# bring parms past 9 portably into view
e4f5c43e 25shift ; mach=$9
604259a0
FCE
26shift ; suffix=$9
27shift ; extrafiles=$9
28
29rootdir=${srcdir}/../..
30
31lowercase='abcdefghijklmnopqrstuvwxyz'
32uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
33ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
34CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
35
e4f5c43e
EZ
36if test -z "$isa" ; then
37 isa=all
38fi
39
604259a0
FCE
40case $action in
41arch)
42 rm -f tmp-arch.h1 tmp-arch.h
43 rm -f tmp-arch.c1 tmp-arch.c
44 rm -f tmp-all.h1 tmp-all.h
45
46 ${cgen} -s ${cgendir}/cgen-sim.scm \
47 -s ${cgendir} \
48 ${cgenflags} \
49 -f "${archflags}" \
50 -m ${mach} \
51 -a ${arch} \
e4f5c43e 52 -i ${isa} \
604259a0
FCE
53 -A tmp-arch.h1 \
54 -B tmp-arch.c1 \
55 -N tmp-all.h1
56 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.h1 > tmp-arch.h
57 ${rootdir}/move-if-change tmp-arch.h ${srcdir}/arch.h
58 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.c1 > tmp-arch.c
59 ${rootdir}/move-if-change tmp-arch.c ${srcdir}/arch.c
60 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-all.h1 > tmp-all.h
61 ${rootdir}/move-if-change tmp-all.h ${srcdir}/cpuall.h
62
63 rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
64 ;;
65
66cpu | decode | cpu-decode)
67
68 fileopts=""
69 case $action in
70 *cpu*)
71 rm -f tmp-cpu.h1 tmp-cpu.c1
72 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
73 rm -f tmp-sem.c1 tmp-semsw.c1
74 rm -f tmp-mod.c1
75 rm -f tmp-cpu.h tmp-cpu.c
76 rm -f tmp-ext.c tmp-read.c tmp-write.c
77 rm -f tmp-sem.c tmp-semsw.c tmp-mod.c
78 fileopts="$fileopts \
79 -C tmp-cpu.h1 \
80 -U tmp-cpu.c1 \
81 -M tmp-mod.c1 \
82 ${extrafiles}"
83 ;;
84 esac
85 case $action in
86 *decode*)
87 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
88 fileopts="$fileopts \
89 -T tmp-dec.h1 \
90 -D tmp-dec.c1"
91 ;;
92 esac
93
94 ${cgen} -s ${cgendir}/cgen-sim.scm \
95 -s ${cgendir} \
96 ${cgenflags} \
97 -f "${archflags}" \
98 -m ${mach} \
99 -a ${arch} \
e4f5c43e 100 -i ${isa} \
604259a0
FCE
101 ${fileopts}
102
103 case $action in
104 *cpu*)
105 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.h1 > tmp-cpu.h
106 ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
107 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.c1 > tmp-cpu.c
108 ${rootdir}/move-if-change tmp-cpu.c ${srcdir}/cpu${suffix}.c
109 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-mod.c1 > tmp-mod.c
110 ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
111 if test -f tmp-ext.c1 ; then \
112 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-ext.c1 > tmp-ext.c ; \
113 ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c ; \
114 fi
115 if test -f tmp-read.c1 ; then \
116 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-read.c1 > tmp-read.c ; \
117 ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c ; \
118 fi
119 if test -f tmp-write.c1 ; then \
120 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-write.c1 > tmp-write.c ; \
121 ${rootdir}/move-if-change tmp-write.c ${srcdir}/write${suffix}.c ; \
122 fi
123 if test -f tmp-sem.c1 ; then \
124 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-sem.c1 > tmp-sem.c ; \
125 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
126 fi
127 if test -f tmp-semsw.c1 ; then \
128 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-semsw.c1 > tmp-semsw.c ; \
129 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
130 fi
131
132 rm -f tmp-cpu.h1 tmp-cpu.c1
133 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
134 rm -f tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
135 ;;
136 esac
137
138 case $action in
139 *decode*)
140 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.h1 > tmp-dec.h
141 ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
142 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.c1 > tmp-dec.c
143 ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
144
145 rm -f tmp-dec.h1 tmp-dec.c1
146 ;;
147 esac
148
149 ;;
150
151desc)
152 rm -f tmp-desc.h1 tmp-desc.h
153 rm -f tmp-desc.c1 tmp-desc.c
154 rm -f tmp-opc.h1 tmp-opc.h
155
156 ${cgen} -s ${cgendir}/cgen-opc.scm \
157 -s ${cgendir} \
158 ${cgenflags} \
159 -f "${archflags}" \
160 -m ${mach} \
161 -a ${arch} \
e4f5c43e 162 -i ${isa} \
604259a0
FCE
163 -H tmp-desc.h1 \
164 -C tmp-desc.c1 \
165 -O tmp-opc.h1
166 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1 > tmp-desc.h
167 ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${arch}-desc.h
168 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
169 -e "s/@prefix@/${arch}/" < tmp-desc.c1 > tmp-desc.c
170 ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${arch}-desc.c
171 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h
172 ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${arch}-opc.h
173
174 rm -f tmp-desc.h1 tmp-desc.c1 tmp-opc.h1
175 ;;
176
177*)
178 echo "cgen.sh: bad action: ${action}" >&2
179 exit 1
180 ;;
181
182esac
183
184exit 0
This page took 0.034825 seconds and 4 git commands to generate.