Annotation of tme/ic/m68k/m6888x-auto.sh, revision 1.1

1.1     ! root        1: #! /bin/sh
        !             2: 
        !             3: # $Id: m6888x-auto.sh,v 1.1 2005/02/17 12:18:26 fredette Exp $
        !             4: 
        !             5: # ic/m6888x-auto.sh - automatically generates C code for many m6888x
        !             6: # emulation instructions:
        !             7: 
        !             8: #
        !             9: # Copyright (c) 2004 Matt Fredette
        !            10: # All rights reserved.
        !            11: #
        !            12: # Redistribution and use in source and binary forms, with or without
        !            13: # modification, are permitted provided that the following conditions
        !            14: # are met:
        !            15: # 1. Redistributions of source code must retain the above copyright
        !            16: #    notice, this list of conditions and the following disclaimer.
        !            17: # 2. Redistributions in binary form must reproduce the above copyright
        !            18: #    notice, this list of conditions and the following disclaimer in the
        !            19: #    documentation and/or other materials provided with the distribution.
        !            20: # 3. All advertising materials mentioning features or use of this software
        !            21: #    must display the following acknowledgement:
        !            22: #      This product includes software developed by Matt Fredette.
        !            23: # 4. The name of the author may not be used to endorse or promote products
        !            24: #    derived from this software without specific prior written permission.
        !            25: #
        !            26: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            27: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            28: # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            29: # DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
        !            30: # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            31: # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            32: # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            33: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            34: # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        !            35: # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            36: # POSSIBILITY OF SUCH DAMAGE.
        !            37: #
        !            38: 
        !            39: header=false
        !            40: 
        !            41: for option
        !            42: do
        !            43:     case $option in
        !            44:     --header) header=true ;;
        !            45:     esac
        !            46: done
        !            47: 
        !            48: PROG=`basename $0`
        !            49: cat <<EOF
        !            50: /* automatically generated by $PROG, do not edit! */
        !            51: _TME_RCSID("\$Id: m6888x-auto.sh,v 1.1 2005/02/17 12:18:26 fredette Exp $");
        !            52: 
        !            53: EOF
        !            54: 
        !            55: # placeholder for a permutation over FPU types:
        !            56: #
        !            57: fpu=m6888x
        !            58: 
        !            59:     # generate the FPgen opmode bitmap and table:
        !            60:     #
        !            61:     for what in bitmap table; do
        !            62: 
        !            63:        # when we're doing the m68040, we only make the bitmap:
        !            64:        #
        !            65:        if test ${fpu} = m68040 && test ${what} != bitmap; then
        !            66:            continue
        !            67:        fi
        !            68: 
        !            69:        # dispatch on the what:
        !            70:        #
        !            71:        case ${what} in
        !            72: 
        !            73:        bitmap)
        !            74:            cat <<EOF
        !            75: 
        !            76: /* the ${fpu} FPgen opmode bitmap: */
        !            77: const tme_uint8_t _tme_${fpu}_fpgen_opmode_bitmap[128 / 8] = {
        !            78: EOF
        !            79: 
        !            80:        # reset the bitmap:
        !            81:        #
        !            82:        opmode_bitmap=0
        !            83:        opmode_bit=1
        !            84:        echo -n "  "
        !            85:        ;;
        !            86: 
        !            87:        table)
        !            88:            cat <<EOF
        !            89: 
        !            90: /* the ${fpu} FPgen opmode table: */
        !            91: static const struct tme_m6888x_fpgen _tme_${fpu}_fpgen_opmode_table[128] = {
        !            92: EOF
        !            93:            ;;
        !            94:        esac
        !            95:     
        !            96:        # loop over the FPgen opmodes:
        !            97:        #
        !            98:        opmode=-1
        !            99:        while test ${opmode} != 127; do
        !           100:            opmode=`expr ${opmode} + 1`
        !           101: 
        !           102:            # if we're generating the opmode bitmap, and this opmode
        !           103:            # is in a new byte, emit the previous byte and reset for
        !           104:            # this byte:
        !           105:            #
        !           106:            if test ${what} = bitmap && test ${opmode_bit} = 256; then
        !           107:                echo -n "${opmode_bitmap}, "
        !           108:                opmode_bitmap=0
        !           109:                opmode_bit=1
        !           110:            fi
        !           111: 
        !           112:            # characterize this opmode:
        !           113:            #
        !           114:            name=''
        !           115:            optype=MONADIC
        !           116:            rounding_precision=CTL
        !           117:            rounding_mode=NULL
        !           118:            fpu_types=TME_M68K_FPU_ANY
        !           119:            name_ieee754=x
        !           120:            case "${opmode}" in
        !           121: 
        !           122:            # fabs pp 305:
        !           123:            #
        !           124:            24) name=abs ;;
        !           125:            88) name=abs ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           126:            92) name=abs ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           127: 
        !           128:            28) name=acos ; fpu_types='TME_M68K_FPU_M6888X' ;;  # facos pp 309
        !           129: 
        !           130:            # fadd pp 312:
        !           131:            #
        !           132:            34) name=add ; optype=SRC_DST ;;
        !           133:            98) name=add ; optype=SRC_DST ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           134:            102) name=add ; optype=SRC_DST ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           135: 
        !           136:            12) name=asin ; fpu_types=TME_M68K_FPU_M6888X ;;    # fasin pp 315
        !           137:            10) name=atan ; fpu_types=TME_M68K_FPU_M6888X ;;    # fatan pp 318
        !           138:            13) name=atanh ; fpu_types=TME_M68K_FPU_M6888X ;;   # fatanh pp 321
        !           139:            56) name=cmp ; name_ieee754=sub ; optype=DST_SRC ;; # fcmp pp 326
        !           140:            29) name=cos ; fpu_types=TME_M68K_FPU_M6888X ;;     # fcos pp 329
        !           141:            25) name=cosh ; fpu_types=TME_M68K_FPU_M6888X ;;    # fcosh pp 332
        !           142: 
        !           143:            # fdiv pp 337:
        !           144:            #
        !           145:            32) name=div ; optype=DST_SRC ;;
        !           146:            96) name=div ; optype=DST_SRC ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           147:            100) name=div ; optype=DST_SRC ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           148:        
        !           149:            16) name=etox ; name_ieee754=exp ; fpu_types=TME_M68K_FPU_M6888X ;; # fetox pp 341
        !           150:            8) name=etoxm1 ; name_ieee754=expm1 ; fpu_types=TME_M68K_FPU_M6888X ;;      # fetoxm1 pp 344
        !           151:            30) name=getexp ; fpu_types=TME_M68K_FPU_M6888X ;;  # fgetexp pp 347
        !           152:            31) name=getman ; fpu_types=TME_M68K_FPU_M6888X ;;  # fgetman pp 350
        !           153:            1) name=int ; name_ieee754=rint ; fpu_types=TME_M68K_FPU_M6888X ;;  # fint pp 353
        !           154:            3) name=intrz ; name_ieee754=rint ; rounding_mode=TO_ZERO ; fpu_types=TME_M68K_FPU_M6888X ;; # fintrz pp 356
        !           155:            21) name=log10 ; fpu_types=TME_M68K_FPU_M6888X ;;   # flog10 pp 359
        !           156:            22) name=log2 ; name_ieee754= ; fpu_types=TME_M68K_FPU_M6888X ;;    # flog2 pp 362
        !           157:            20) name=logn ; name_ieee754=log ; fpu_types=TME_M68K_FPU_M6888X ;; # flogn pp 365
        !           158:            6) name=lognp1 ; name_ieee754=log1p ; fpu_types=TME_M68K_FPU_M6888X ;;      # flognp1 pp 368
        !           159:            33) name=mod ; name_ieee754= ; fpu_types=TME_M68K_FPU_M6888X ; optype=DST_SRC ;;    # fmod pp 371
        !           160: 
        !           161:            # fmove pp 374:
        !           162:            #
        !           163:            0) name=move ;;
        !           164:            64) name=move ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           165:            68) name=move ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           166: 
        !           167:            # fmul pp 395:
        !           168:            #
        !           169:            35) name=mul ; optype=SRC_DST ;;
        !           170:            99) name=mul ; optype=SRC_DST ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           171:            103) name=mul ; optype=SRC_DST ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           172: 
        !           173:            # fneg pp 399:
        !           174:            #
        !           175:            26) name=neg ;;
        !           176:            90) name=neg ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           177:            94) name=neg ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           178:        
        !           179:            37) name=rem ; name_ieee754= ; optype=DST_SRC ; fpu_types=TME_M68K_FPU_M6888X ;;    # frem pp 405
        !           180:            38) name=scale ; optype=DST_SRC ; fpu_types=TME_M68K_FPU_M6888X ;;  # fscale pp 408
        !           181:            36) name=sgldiv ; name_ieee754= ; optype=DST_SRC ;; # fsgldiv pp 413
        !           182:            39) name=sglmul ; name_ieee754= ; optype=DST_SRC ;; # fsglmul pp 416
        !           183:            14) name=sin ;;             # fsin pp 419
        !           184: 
        !           185:            48|49|50|51|52|53|54|55) name=sincos ; fpu_types=TME_M68K_FPU_M6888X ; name_ieee754= ;;     # fsincos pp 422
        !           186:            2) name=sinh ; fpu_types=TME_M68K_FPU_M6888X ;;             # fsinh pp 426
        !           187: 
        !           188:            # fsqrt pp 429:
        !           189:            #
        !           190:            4) name=sqrt ;;
        !           191:            65) name=sqrt ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           192:            69) name=sqrt ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           193: 
        !           194:            # fsub pp 433:
        !           195:            #
        !           196:            40) name=sub ; optype=DST_SRC ;;
        !           197:            104) name=sub ; optype=DST_SRC ; rounding_precision=SINGLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           198:            108) name=sub ; optype=DST_SRC ; rounding_precision=DOUBLE ; fpu_types=TME_M68K_FPU_M68040 ;;
        !           199: 
        !           200:            15) name=tan ; fpu_types=TME_M68K_FPU_M6888X ;;             # ftan pp 437
        !           201:            9) name=tanh ; fpu_types=TME_M68K_FPU_M6888X ;;             # ftanh pp 440
        !           202:            18) name=tentox ; name_ieee754= ; fpu_types=TME_M68K_FPU_M6888X ;;  # ftentox pp 443
        !           203:            58) name=tst ; name_ieee754= ;;                             # ftst pp 448
        !           204:            17) name=twotox ; name_ieee754= ; fpu_types=TME_M68K_FPU_M6888X ;;  # ftwotox pp 451
        !           205: 
        !           206:            esac
        !           207: 
        !           208:            # fix up the ieee754 name:
        !           209:            #
        !           210:            if test "x${name_ieee754}" = xx; then name_ieee754=${name}; fi
        !           211: 
        !           212:            # dispatch on the what:
        !           213:            #
        !           214:            case ${what} in
        !           215: 
        !           216:            bitmap)
        !           217:                if test ${fpu_types} = TME_M68K_FPU_M68040 && test ${fpu} != m68040; then
        !           218:                    name=
        !           219:                fi
        !           220:                if test "x${name}" != x; then
        !           221:                    opmode_bitmap=`expr ${opmode_bitmap} + ${opmode_bit}`
        !           222:                fi
        !           223:                opmode_bit=`expr ${opmode_bit} \* 2`
        !           224:                ;;
        !           225: 
        !           226:            table)
        !           227:            
        !           228:                echo ""
        !           229:                echo "  /* opmode ${opmode}: */"
        !           230:                echo -n "  { "
        !           231: 
        !           232:                # the function:
        !           233:                #
        !           234:                if test "x${name}" = x; then
        !           235:                    echo -n "NULL"
        !           236:                    echo -n ", 0"
        !           237:                    fpu_types=TME_M68K_FPU_NONE
        !           238:                elif test "x${name_ieee754}" != x; then
        !           239:                    echo -n "NULL"
        !           240:                    echo -n ", TME_M6888X_IEEE754_OP(tme_ieee754_ops_extended80_${name_ieee754})"
        !           241:                else
        !           242:                    echo -n "_tme_m6888x_f${name}"
        !           243:                    echo -n ", 0"
        !           244:                fi
        !           245: 
        !           246:                # the m6888x types:
        !           247:                #
        !           248:                echo -n ", ${fpu_types}"
        !           249: 
        !           250:                # the operation type:
        !           251:                #
        !           252:                if test ${optype} != MONADIC; then optype="DYADIC_${optype}"; fi
        !           253:                echo -n ", TME_M6888X_OPTYPE_${optype}"
        !           254: 
        !           255:                # the rounding mode:
        !           256:                #
        !           257:                echo -n ", TME_FLOAT_ROUND_${rounding_mode}"
        !           258:        
        !           259:                # the rounding precision:
        !           260:                #
        !           261:                echo -n ", TME_M6888X_ROUNDING_PRECISION_${rounding_precision}"
        !           262: 
        !           263:                echo " },"
        !           264:                ;;
        !           265:            esac
        !           266:        done
        !           267: 
        !           268:        # dispatch on the what:
        !           269:        #
        !           270:        case ${what} in
        !           271: 
        !           272:        bitmap)
        !           273:            echo "${opmode_bitmap}"
        !           274:            echo "};"
        !           275:            ;;
        !           276: 
        !           277:        table)
        !           278:            echo "};"
        !           279:            ;;
        !           280:        esac
        !           281: 
        !           282:     done
        !           283: 
        !           284: 
        !           285: # done:
        !           286: #
        !           287: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.