Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / legion / src / support / implhdr.sh
CommitLineData
920dae64
AT
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
23usage()
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
32prefix="_"
33if [ $# -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
40fi
41
42if [ ! "$#" = "3" ] ; then
43 usage
44fi
45
46
47srcname=$1
48funcbase=$2
49name=$3
50
51if [ ! "`echo $name | egrep '\.h$'`" = $name ] ;then
52 echo $name is not a .h filename !
53 exit 1
54fi
55
56#
57# ok dig out the base filename
58#
59
60bname=`basename $name | sed -e 's/\.h$//g' | tr '[a-z] -/' '[A-Z]___' | sed -e 's/__/_/g'`
61
62cat << 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
71END
72
73list=`egrep '^IMPL\(' $srcname | sed -e 's?IMPL(??' -e 's?).*??'`
74
75for n in $list ; do
76 echo "IMPL(${n});">> $name
77done
78
79# egrep '^IMPL\(' $srcname >> $name
80
81cat <<END >> $name
82
83#undef IMPL
84#endif /* #ifndef ${prefix}${bname}_H_ */
85
86END
87
88exit 0
89