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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [opcodes/] [cgen.sh] - Blame information for rev 300

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

Line No. Rev Author Line
1 38 julius
#! /bin/sh
2
# CGEN generic assembler support code.
3
#
4
#   Copyright 2000, 2003, 2005, 2007 Free Software Foundation, Inc.
5
#
6
#   This file is part of the GNU opcodes library.
7
#
8
#   This library is free software; you can redistribute it and/or modify
9
#   it under the terms of the GNU General Public License as published by
10
#   the Free Software Foundation; either version 3, or (at your option)
11
#   any later version.
12
#
13
#   It is distributed in the hope that it will be useful, but WITHOUT
14
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
#   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
#   License for more details.
17
#
18
#   You should have received a copy of the GNU General Public License along
19
#   with this program; if not, write to the Free Software Foundation, Inc.,
20
#   51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
21
#
22
# Generate CGEN opcode files: arch-desc.[ch], arch-opc.[ch],
23
# arch-asm.c, arch-dis.c, arch-opinst.c, arch-ibld.[ch].
24
#
25
# Usage:
26
# cgen.sh action srcdir cgen cgendir cgenflags arch prefix \
27
#         arch-file opc-file options [extrafiles]
28
#
29
# ACTION is currently always "opcodes". It exists to be consistent with the
30
# simulator.
31
# ARCH is the name of the architecture.
32
# It is substituted into @arch@ and @ARCH@ in the generated files.
33
# PREFIX is both the generated file prefix and is substituted into
34
# @prefix@ in the generated files.
35
# ARCH-FILE is the name of the .cpu file (including path).
36
# OPC-FILE is the name of the .opc file (including path).
37
# OPTIONS is comma separated list of options (???).
38
# EXTRAFILES is a space separated list (1 arg still) of extra files to build:
39
#       - opinst - arch-opinst.c is being made, causes semantic analysis
40
#
41
# We store the generated files in the source directory until we decide to
42
# ship a Scheme interpreter (or other implementation) with gdb/binutils.
43
# Maybe we never will.
44
 
45
# We want to behave like make, any error forces us to stop.
46
set -e
47
 
48
action=$1
49
srcdir=$2
50
cgen="$3"
51
cgendir=$4
52
cgenflags=$5
53
arch=$6
54
prefix=$7
55
archfile=$8
56
opcfile=$9
57
shift ; options=$9
58
 
59
# List of extra files to build.
60
# Values: opinst (only 1 extra file at present)
61
shift ; extrafiles=$9
62
 
63
rootdir=${srcdir}/..
64
 
65
# $arch is $6, as passed on the command line.
66
# $ARCH is the same argument but in all uppercase.
67
# Both forms are used in this script.
68
 
69
lowercase='abcdefghijklmnopqrstuvwxyz'
70
uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
71
ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
72
 
73
extrafile_args=""
74
for ef in .. $extrafiles
75
do
76
    case $ef in
77
    ..) ;;
78
    opinst) extrafile_args="-Q tmp-opinst.c1 $extrafile_args" ;;
79
    esac
80
done
81
 
82
case $action in
83
opcodes)
84
        # Remove residual working files.
85
        rm -f tmp-desc.h tmp-desc.h1
86
        rm -f tmp-desc.c tmp-desc.c1
87
        rm -f tmp-opc.h tmp-opc.h1
88
        rm -f tmp-opc.c tmp-opc.c1
89
        rm -f tmp-opinst.c tmp-opinst.c1
90
        rm -f tmp-ibld.h tmp-ibld.h1
91
        rm -f tmp-ibld.c tmp-ibld.in1
92
        rm -f tmp-asm.c tmp-asm.in1
93
        rm -f tmp-dis.c tmp-dis.in1
94
 
95
        # Run CGEN.
96
        ${cgen} ${cgendir}/cgen-opc.scm \
97
                -s ${cgendir} \
98
                ${cgenflags} \
99
                -f "${options}" \
100
                -m all \
101
                -a ${archfile} \
102
                -OPC ${opcfile} \
103
                -H tmp-desc.h1 \
104
                -C tmp-desc.c1 \
105
                -O tmp-opc.h1 \
106
                -P tmp-opc.c1 \
107
                -L tmp-ibld.in1 \
108
                -A tmp-asm.in1 \
109
                -D tmp-dis.in1 \
110
                ${extrafile_args}
111
 
112
        # Customise generated files for the particular architecture.
113
        sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1 > tmp-desc.h
114
        ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${prefix}-desc.h
115
 
116
        sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
117
                -e "s/@prefix@/${prefix}/" < tmp-desc.c1 > tmp-desc.c
118
        ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${prefix}-desc.c
119
 
120
        sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h
121
        ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${prefix}-opc.h
122
 
123
        sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
124
                -e "s/@prefix@/${prefix}/" < tmp-opc.c1 > tmp-opc.c
125
        ${rootdir}/move-if-change tmp-opc.c ${srcdir}/${prefix}-opc.c
126
 
127
        case $extrafiles in
128
        *opinst*)
129
          sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
130
                -e "s/@prefix@/${prefix}/" < tmp-opinst.c1 >tmp-opinst.c
131
          ${rootdir}/move-if-change tmp-opinst.c ${srcdir}/${prefix}-opinst.c
132
          ;;
133
        esac
134
 
135
        cat ${srcdir}/cgen-ibld.in tmp-ibld.in1 | \
136
          sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
137
                -e "s/@prefix@/${prefix}/" > tmp-ibld.c
138
        ${rootdir}/move-if-change tmp-ibld.c ${srcdir}/${prefix}-ibld.c
139
 
140
        sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.in \
141
          | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
142
                -e "s/@prefix@/${prefix}/" > tmp-asm.c
143
        ${rootdir}/move-if-change tmp-asm.c ${srcdir}/${prefix}-asm.c
144
 
145
        sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.in \
146
          | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
147
                -e "s/@prefix@/${prefix}/" > tmp-dis.c
148
        ${rootdir}/move-if-change tmp-dis.c ${srcdir}/${prefix}-dis.c
149
 
150
        # Remove temporary files.
151
        rm -f tmp-desc.h1 tmp-desc.c1
152
        rm -f tmp-opc.h1 tmp-opc.c1
153
        rm -f tmp-opinst.c1
154
        rm -f tmp-ibld.h1 tmp-ibld.in1
155
        rm -f tmp-asm.in1 tmp-dis.in1
156
        ;;
157
 
158
*)
159
        echo "$0: bad action: ${action}" >&2
160
        exit 1
161
        ;;
162
 
163
esac
164
 
165
exit 0

powered by: WebSVN 2.1.0

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