]> Git Repo - binutils.git/blob - sim/common/cgen.sh
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[binutils.git] / sim / common / cgen.sh
1 #! /bin/sh
2 # Generate CGEN simulator files.
3 #
4 # Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"} srcdir \
5 #       scheme schemeflags \
6 #       cgendir cgenflags \
7 #       arch archflags cpu mach suffix extrafiles
8 #
9 # We store the generated files in the source directory until we decide to
10 # ship a Scheme interpreter with gdb/binutils.  Maybe we never will.
11
12 # We want to behave like make, any error forces us to stop.
13 set -e
14
15 action=$1
16 srcdir=$2
17 scheme=$3
18 schemeflags=$4
19 cgendir=$5
20 cgenflags=$6
21 arch=$7
22 archflags=$8
23 cpu=$9
24 mach=${10}
25 suffix=${11}
26 extrafiles=${12}
27
28 lowercase='abcdefghijklmnopqrstuvwxyz'
29 uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
30 # FIXME: May have to rewrite this.
31 ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
32 CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
33
34 rootdir=${srcdir}/../..
35
36 case $action in
37 arch)
38         rm -f tmp-arch.h1 tmp-arch.h
39         rm -f tmp-arch.c1 tmp-arch.c
40         rm -f tmp-all.h1 tmp-all.h
41
42         ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
43                 -s ${cgendir} \
44                 ${cgenflags} \
45                 -f "${archflags}" \
46                 -m all \
47                 -a ${arch} \
48                 -A tmp-arch.h1 \
49                 -B tmp-arch.c1 \
50                 -N tmp-all.h1
51         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.h1 > tmp-arch.h
52         ${rootdir}/move-if-change tmp-arch.h ${srcdir}/arch.h
53         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.c1 > tmp-arch.c
54         ${rootdir}/move-if-change tmp-arch.c ${srcdir}/arch.c
55         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-all.h1 > tmp-all.h
56         ${rootdir}/move-if-change tmp-all.h ${srcdir}/cpuall.h
57
58         rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
59         ;;
60
61 cpu)
62         rm -f tmp-cpu.h1 tmp-ext.c1 tmp-read.c1 tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
63         rm -f tmp-cpu.h tmp-ext.c tmp-read.c tmp-sem.c tmp-semsw.c tmp-mod.c
64
65         ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
66                 -s ${cgendir} \
67                 ${cgenflags} \
68                 -f "${archflags}" \
69                 -m ${mach} \
70                 -a ${arch} \
71                 -C tmp-cpu.h1 \
72                 -M tmp-mod.c1 \
73                 ${extrafiles}
74         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.h1 > tmp-cpu.h
75         ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
76         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-mod.c1 > tmp-mod.c
77         ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
78         if test -f tmp-ext.c1 ; then \
79                 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-ext.c1 > tmp-ext.c ; \
80                 ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c ; \
81         fi
82         if test -f tmp-read.c1 ; then \
83                 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-read.c1 > tmp-read.c ; \
84                 ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c ; \
85         fi
86         if test -f tmp-sem.c1 ; then \
87                 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-sem.c1 > tmp-sem.c ; \
88                 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
89         fi
90         if test -f tmp-semsw.c1 ; then \
91                 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-semsw.c1 > tmp-semsw.c ; \
92                 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
93         fi
94
95         rm -f tmp-cpu.h1 tmp-mod.c1
96         rm -f tmp-read.c1 tmp-ext.c1 tmp-sem.c1 tmp-semsw.c1
97         ;;
98
99 decode)
100         rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
101
102         ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
103                 -s ${cgendir} \
104                 ${cgenflags} \
105                 -f "${archflags}" \
106                 -m ${mach} \
107                 -a ${arch} \
108                 -T tmp-dec.h1 \
109                 -D tmp-dec.c1
110         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.h1 > tmp-dec.h
111         ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
112         sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.c1 > tmp-dec.c
113         ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
114
115         rm -f tmp-dec.h1 tmp-dec.c1
116         ;;
117
118 *)
119         echo "cgen.sh: bad action: ${action}" >&2
120         exit 1
121         ;;
122
123 esac
124
125 exit 0
This page took 0.03121 seconds and 4 git commands to generate.