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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [common/] [cgen.sh] - Blame information for rev 438

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
#! /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 archfile extrafiles opcfile
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 ; archfile=$9
28
shift ; extrafiles=$9
29
shift ; opcfile=$9
30
 
31
rootdir=${srcdir}/../..
32
 
33
test -z "${opcfile}" && opcfile=/dev/null
34
 
35
if test -z "$isa" ; then
36
  isa=all
37
  prefix=$cpu
38
else
39
  prefix=${cpu}_$isa
40
fi
41
 
42
lowercase='abcdefghijklmnopqrstuvwxyz'
43
uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
44
ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
45
CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
46
PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
47
 
48
sedscript="\
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"
52
 
53
case $action in
54
arch)
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} ${cgendir}/cgen-sim.scm \
60
                -s ${cgendir} \
61
                ${cgenflags} \
62
                -f "${archflags}" \
63
                -m ${mach} \
64
                -a ${archfile} \
65
                -i ${isa} \
66
                -A tmp-arch.h1 \
67
                -B tmp-arch.c1 \
68
                -N tmp-all.h1
69
        sed $sedscript < tmp-arch.h1 > tmp-arch.h
70
        ${rootdir}/move-if-change tmp-arch.h ${srcdir}/arch.h
71
        sed $sedscript < tmp-arch.c1 > tmp-arch.c
72
        ${rootdir}/move-if-change tmp-arch.c ${srcdir}/arch.c
73
        sed $sedscript < tmp-all.h1 > tmp-all.h
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
 
79
cpu | 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"
104
                case "$extrafiles" in
105
                  ignored) # Do nothing.
106
                           ;;
107
                  *)       fileopts="$fileopts $extrafiles"
108
                           ;;
109
                esac
110
                ;;
111
        esac
112
 
113
        ${cgen} ${cgendir}/cgen-sim.scm \
114
                -s ${cgendir} \
115
                ${cgenflags} \
116
                -f "${archflags}" \
117
                -m ${mach} \
118
                -a ${archfile} \
119
                -i ${isa} \
120
                ${fileopts}
121
 
122
        case $action in
123
        *cpu*)
124
                sed $sedscript < tmp-cpu.h1 > tmp-cpu.h
125
                ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
126
                sed $sedscript < tmp-cpu.c1 > tmp-cpu.c
127
                ${rootdir}/move-if-change tmp-cpu.c ${srcdir}/cpu${suffix}.c
128
                sed $sedscript < tmp-mod.c1 > tmp-mod.c
129
                ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
130
                if test -f tmp-ext.c1 ; then \
131
                        sed $sedscript < tmp-ext.c1 > tmp-ext.c ; \
132
                        ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c ; \
133
                fi
134
                if test -f tmp-read.c1 ; then \
135
                        sed $sedscript < tmp-read.c1 > tmp-read.c ; \
136
                        ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c ; \
137
                fi
138
                if test -f tmp-write.c1 ; then \
139
                        sed $sedscript < tmp-write.c1 > tmp-write.c ; \
140
                        ${rootdir}/move-if-change tmp-write.c ${srcdir}/write${suffix}.c ; \
141
                fi
142
                if test -f tmp-sem.c1 ; then \
143
                        sed $sedscript < tmp-sem.c1 > tmp-sem.c ; \
144
                        ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
145
                fi
146
                if test -f tmp-semsw.c1 ; then \
147
                        sed $sedscript < tmp-semsw.c1 > tmp-semsw.c ; \
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*)
159
                sed $sedscript < tmp-dec.h1 > tmp-dec.h
160
                ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
161
                sed $sedscript < tmp-dec.c1 > tmp-dec.c
162
                ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
163
 
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
 
173
                rm -f tmp-dec.h1 tmp-dec.c1
174
                ;;
175
        esac
176
 
177
        ;;
178
 
179
defs)
180
        rm -f tmp-defs.h1 tmp-defs.h
181
 
182
        ${cgen} ${cgendir}/cgen-sim.scm \
183
                -s ${cgendir} \
184
                ${cgenflags} \
185
                -f "${archflags}" \
186
                -m ${mach} \
187
                -a ${archfile} \
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
 
194
desc)
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} ${cgendir}/cgen-opc.scm \
200
                -s ${cgendir} \
201
                ${cgenflags} \
202
                -OPC ${opcfile} \
203
                -f "${archflags}" \
204
                -m ${mach} \
205
                -a ${archfile} \
206
                -i ${isa} \
207
                -H tmp-desc.h1 \
208
                -C tmp-desc.c1 \
209
                -O tmp-opc.h1
210
        sed $sedscript < tmp-desc.h1 > tmp-desc.h
211
        ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${arch}-desc.h
212
        sed $sedscript < tmp-desc.c1 > tmp-desc.c
213
        ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${arch}-desc.c
214
        sed $sedscript < tmp-opc.h1 > tmp-opc.h
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
*)
221
        echo "`basename $0`: unknown action: ${action}" >&2
222
        exit 1
223
        ;;
224
 
225
esac
226
 
227
exit 0

powered by: WebSVN 2.1.0

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