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

Subversion Repositories openrisc_me

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

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

Line No. Rev Author Line
1 227 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
# avoid collisions in parallel makes
54
tmp=tmp-$$
55
 
56
case $action in
57
arch)
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
61
 
62
        ${cgen} ${cgendir}/cgen-sim.scm \
63
                -s ${cgendir} \
64
                ${cgenflags} \
65
                -f "${archflags}" \
66
                -m ${mach} \
67
                -a ${archfile} \
68
                -i ${isa} \
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
80
        ;;
81
 
82
cpu | decode | cpu-decode)
83
 
84
        fileopts=""
85
 
86
        case $action in
87
        *cpu*)
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
95
                fileopts="$fileopts \
96
                        -C ${tmp}-cpu.h1 \
97
                        -U ${tmp}-cpu.c1 \
98
                        -M ${tmp}-mod.c1"
99
                ;;
100
        esac
101
 
102
        case $action in
103
        *decode*)
104
                rm -f ${tmp}-dec.h1 ${tmp}-dec.h ${tmp}-dec.c1 ${tmp}-dec.c
105
                fileopts="$fileopts \
106
                        -T ${tmp}-dec.h1 \
107
                        -D ${tmp}-dec.c1"
108
                ;;
109
        esac
110
 
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
 
127
        ${cgen} ${cgendir}/cgen-sim.scm \
128
                -s ${cgendir} \
129
                ${cgenflags} \
130
                -f "${archflags}" \
131
                -m ${mach} \
132
                -a ${archfile} \
133
                -i ${isa} \
134
                ${fileopts}
135
 
136
        case $action in
137
        *cpu*)
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
145
                ;;
146
        esac
147
 
148
        case $action in
149
        *decode*)
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
155
                ;;
156
        esac
157
 
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
 
184
        ;;
185
 
186
defs)
187
        rm -f ${tmp}-defs.h1 ${tmp}-defs.h
188
 
189
        ${cgen} ${cgendir}/cgen-sim.scm \
190
                -s ${cgendir} \
191
                ${cgenflags} \
192
                -f "${archflags}" \
193
                -m ${mach} \
194
                -a ${archfile} \
195
                -i ${isa} \
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
200
        ;;
201
 
202
desc)
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
206
 
207
        ${cgen} ${cgendir}/cgen-opc.scm \
208
                -s ${cgendir} \
209
                ${cgenflags} \
210
                -OPC ${opcfile} \
211
                -f "${archflags}" \
212
                -m ${mach} \
213
                -a ${archfile} \
214
                -i ${isa} \
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
226
        ;;
227
 
228
*)
229
        echo "`basename $0`: unknown action: ${action}" >&2
230
        exit 1
231
        ;;
232
 
233
esac
234
 
235
exit 0

powered by: WebSVN 2.1.0

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