Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / legion / src / support / hasnative.sh
#!/bin/sh
# ========== Copyright Header Begin ==========================================
#
# OpenSPARC T2 Processor File: hasnative.sh
# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
#
# The above named program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License version 2 as published by the Free Software Foundation.
#
# The above named 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 work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ========== Copyright Header End ============================================
usage()
{
echo ""
echo "`basename $0` [-p <prefix>] <srcname> <destfile>"
echo ""
echo "\tgenerate a .h file for instruction IMPL types"
exit 1
}
prefix="_"
if [ $# -gt 1 ]; then
if [ $1 = "-p" ] ; then
prefix=$2;
prefix="_`echo $prefix | sed -e 's/\.h$//g' | tr '[a-z]-/' '[A-Z]__'`_"
shift
shift
fi
fi
if [ ! "$#" = "2" ] ; then
usage
fi
srcname=$1
name=$2
if [ ! "`echo $name | egrep '\.h$'`" = $name ] ;then
echo $name is not a .h filename !
exit 1
fi
#
# ok dig out the base filename
#
bname=`basename $name | sed -e 's/\.h$//g' | tr '[a-z] -/' '[A-Z]___' | sed -e 's/__/_/g'`
cat << END > $name
#ifndef ${prefix}${bname}_H_
#define ${prefix}${bname}_H_
/* This file is autogenerated from $srcname - DO NOT EDIT */
END
list=`egrep '^IMPL\(' $srcname | sed -e 's?IMPL(??' -e 's?).*??'`
for n in $list ; do
cat <<END >> $name
#define HAS_NATIVE_${n} 1
END
done
cat <<END >> $name
#endif /* #ifndef ${prefix}${bname}_H_ */
END
exit 0