| 1 | #!/bin/sh |
| 2 | # ========== Copyright Header Begin ========================================== |
| 3 | # |
| 4 | # OpenSPARC T2 Processor File: implhdr.sh |
| 5 | # Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 7 | # |
| 8 | # The above named program is free software; you can redistribute it and/or |
| 9 | # modify it under the terms of the GNU General Public |
| 10 | # License version 2 as published by the Free Software Foundation. |
| 11 | # |
| 12 | # The above named program is distributed in the hope that it will be |
| 13 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | # General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public |
| 18 | # License along with this work; if not, write to the Free Software |
| 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | # |
| 21 | # ========== Copyright Header End ============================================ |
| 22 | |
| 23 | usage() |
| 24 | { |
| 25 | echo "" |
| 26 | echo "`basename $0` [-p <prefix>] <srcname> <funcprefix> <destfile>" |
| 27 | echo "" |
| 28 | echo "\tgenerate a .h file for instruction IMPL types" |
| 29 | exit 1 |
| 30 | } |
| 31 | |
| 32 | prefix="_" |
| 33 | if [ $# -gt 1 ]; then |
| 34 | if [ $1 = "-p" ] ; then |
| 35 | prefix=$2; |
| 36 | prefix="_`echo $prefix | sed -e 's/\.h$//g' | tr '[a-z]-/' '[A-Z]__'`_" |
| 37 | shift |
| 38 | shift |
| 39 | fi |
| 40 | fi |
| 41 | |
| 42 | if [ ! "$#" = "3" ] ; then |
| 43 | usage |
| 44 | fi |
| 45 | |
| 46 | |
| 47 | srcname=$1 |
| 48 | funcbase=$2 |
| 49 | name=$3 |
| 50 | |
| 51 | if [ ! "`echo $name | egrep '\.h$'`" = $name ] ;then |
| 52 | echo $name is not a .h filename ! |
| 53 | exit 1 |
| 54 | fi |
| 55 | |
| 56 | # |
| 57 | # ok dig out the base filename |
| 58 | # |
| 59 | |
| 60 | bname=`basename $name | sed -e 's/\.h$//g' | tr '[a-z] -/' '[A-Z]___' | sed -e 's/__/_/g'` |
| 61 | |
| 62 | cat << END > $name |
| 63 | |
| 64 | #ifndef ${prefix}${bname}_H_ |
| 65 | #define ${prefix}${bname}_H_ |
| 66 | |
| 67 | /* This file is autogenerated from $srcname - DO NOT EDIT */ |
| 68 | |
| 69 | #define IMPL(_n) void ${funcbase}##_n(simcpu_t *, xicache_instn_t *) |
| 70 | |
| 71 | END |
| 72 | |
| 73 | list=`egrep '^IMPL\(' $srcname | sed -e 's?IMPL(??' -e 's?).*??'` |
| 74 | |
| 75 | for n in $list ; do |
| 76 | echo "IMPL(${n});">> $name |
| 77 | done |
| 78 | |
| 79 | # egrep '^IMPL\(' $srcname >> $name |
| 80 | |
| 81 | cat <<END >> $name |
| 82 | |
| 83 | #undef IMPL |
| 84 | #endif /* #ifndef ${prefix}${bname}_H_ */ |
| 85 | |
| 86 | END |
| 87 | |
| 88 | exit 0 |
| 89 | |