OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [gdb-5.3/] [sim/] [common/] [cgen.sh] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.