X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fcgen.sh;h=a9483bdb972f476e4f9af9d0fea84d5287ce02ce;hb=a3982d4858ac407c7e879a57762bc4130d54d4b8;hp=f6171f47aa7c30bd92a1ed13353fcf871277b073;hpb=fa803dc60f0bf01297674c41d001798e18ade4dc;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/cgen.sh b/opcodes/cgen.sh index f6171f47aa..a9483bdb97 100644 --- a/opcodes/cgen.sh +++ b/opcodes/cgen.sh @@ -1,43 +1,154 @@ #! /bin/sh -# Generate CGEN opcode files: arch-opc.[ch], arch-asm.c, arch-asm.c. +# CGEN generic assembler support code. +# +# Copyright 2001 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils and GDB, the GNU debugger. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +# +# Generate CGEN opcode files: arch-desc.[ch], arch-opc.[ch], +# arch-asm.c, arch-dis.c, arch-opinst.c, arch-ibld.[ch]. +# +# Usage: +# cgen.sh action srcdir cgen cgendir cgenflags arch prefix options +# +# ACTION is currently always "opcodes". It exists to be consistent with the +# simulator. +# OPTIONS is comma separated list of options: +# - opinst - arch-opinst.c is being made, causes semantic analysis # # We store the generated files in the source directory until we decide to -# ship a scheme with gdb/binutils. Maybe we never will. +# ship a Scheme interpreter (or other implementation) with gdb/binutils. +# Maybe we never will. # We want to behave like make, any error forces us to stop. set -e -srcdir=$1 -cgendir=$2 -cgenflags=$3 -scheme=$4 -schemeflags=$5 +action=$1 +srcdir=$2 +cgen=$3 +cgendir=$4 +cgenflags=$5 arch=$6 +prefix=$7 +options=$8 + +# List of extra files to build. +# Values: opinst (only 1 extra file at present) +extrafiles=$9 + +rootdir=${srcdir}/.. + +# $arch is $6, as passed on the command line. +# $ARCH is the same argument but in all uppercase. +# Both forms are used in this script. + +lowercase='abcdefghijklmnopqrstuvwxyz' +uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"` + +extrafile_args="" +for ef in .. $extrafiles +do + case $ef in + ..) ;; + opinst) extrafile_args="-Q tmp-opinst.c1 $extrafile_args" ;; + esac +done + +case $action in +opcodes) + # Remove residual working files. + rm -f tmp-desc.h tmp-desc.h1 + rm -f tmp-desc.c tmp-desc.c1 + rm -f tmp-opc.h tmp-opc.h1 + rm -f tmp-opc.c tmp-opc.c1 + rm -f tmp-opinst.c tmp-opinst.c1 + rm -f tmp-ibld.h tmp-ibld.h1 + rm -f tmp-ibld.c tmp-ibld.in1 + rm -f tmp-asm.c tmp-asm.in1 + rm -f tmp-dis.c tmp-dis.in1 + + # Run CGEN. + ${cgen} -s ${cgendir}/cgen-opc.scm \ + -s ${cgendir} \ + ${cgenflags} \ + -f "${options}" \ + -m all \ + -a ${arch} \ + -H tmp-desc.h1 \ + -C tmp-desc.c1 \ + -O tmp-opc.h1 \ + -P tmp-opc.c1 \ + -L tmp-ibld.in1 \ + -A tmp-asm.in1 \ + -D tmp-dis.in1 \ + ${extrafile_args} + + # Customise generated files for the particular architecture. + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1 > tmp-desc.h + ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${prefix}-desc.h + + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" < tmp-desc.c1 > tmp-desc.c + ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${prefix}-desc.c + + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h + ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${prefix}-opc.h + + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" < tmp-opc.c1 > tmp-opc.c + ${rootdir}/move-if-change tmp-opc.c ${srcdir}/${prefix}-opc.c + + case $extrafiles in + *opinst*) + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" < tmp-opinst.c1 >tmp-opinst.c + ${rootdir}/move-if-change tmp-opinst.c ${srcdir}/${prefix}-opinst.c + ;; + esac + + cat ${srcdir}/cgen-ibld.in tmp-ibld.in1 | \ + sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" > tmp-ibld.c + ${rootdir}/move-if-change tmp-ibld.c ${srcdir}/${prefix}-ibld.c + + sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.in \ + | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" > tmp-asm.c + ${rootdir}/move-if-change tmp-asm.c ${srcdir}/${prefix}-asm.c + + sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.in \ + | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \ + -e "s/@prefix@/${prefix}/" > tmp-dis.c + ${rootdir}/move-if-change tmp-dis.c ${srcdir}/${prefix}-dis.c + + # Remove temporary files. + rm -f tmp-desc.h1 tmp-desc.c1 + rm -f tmp-opc.h1 tmp-opc.c1 + rm -f tmp-opinst.c1 + rm -f tmp-ibld.h1 tmp-ibld.in1 + rm -f tmp-asm.in1 tmp-dis.in1 + ;; + +*) + echo "$0: bad action: ${action}" >&2 + exit 1 + ;; + +esac -rm -f tmp-opc.h tmp-opc.c tmp-asm.c tmp-dis.c -rm -f tmp-opc.h1 tmp-opc.c1 tmp-asm.c1 tmp-dis.c1 -rm -f tmp-asm.in tmp-asm.in1 tmp-dis.in tmp-dis.in1 - -$scheme $schemeflags $cgendir/cgen-opc.scm \ - -s $cgendir \ - $cgenflags \ - -m all \ - -a $arch \ - -h tmp-opc.h1 \ - -t tmp-opc.c1 \ - -A tmp-asm.in1 \ - -D tmp-dis.in1 - -sed -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h -${srcdir}/../move-if-change tmp-opc.h ${srcdir}/${arch}-opc.h -sed -e "s/@arch@/${arch}/g" < tmp-opc.c1 > tmp-opc.c -${srcdir}/../move-if-change tmp-opc.c ${srcdir}/${arch}-opc.c -sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.in \ - | sed -e "s/@arch@/${arch}/g" > tmp-asm.c -${srcdir}/../move-if-change tmp-asm.c ${srcdir}/${arch}-asm.c -sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.in \ - | sed -e "s/@arch@/${arch}/g" > tmp-dis.c -${srcdir}/../move-if-change tmp-dis.c ${srcdir}/${arch}-dis.c - -rm -f tmp-opc.h1 tmp-opc.c1 tmp-asm.c1 tmp-dis.c1 -rm -f tmp-asm.in tmp-asm.in1 tmp-dis.in tmp-dis.in1 +exit 0