diff options
Diffstat (limited to 'src/pmie/src/binary.sk')
-rw-r--r-- | src/pmie/src/binary.sk | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/src/pmie/src/binary.sk b/src/pmie/src/binary.sk new file mode 100644 index 0000000..26ada2a --- /dev/null +++ b/src/pmie/src/binary.sk @@ -0,0 +1,179 @@ +/* + * Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved. + * + * 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 of the License, 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/*********************************************************************** + * skeleton: binary.sk - binary operator + ***********************************************************************/ + +/* + * operator: @FUN + */ + +#define @OP + +void +@FUN_n_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + @ITYPE *ip1; + @ITYPE *ip2; + @OTYPE *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid && x->tspan > 0 && x->tspan == arg1->tspan && x->tspan == arg2->tspan) { + ip1 = (@ITYPE *)is1->ptr; + ip2 = (@ITYPE *)is2->ptr; + op = (@OTYPE *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OP(*ip1, *ip2); + ip1++; + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "@FUN_n_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +@FUN_n_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + @ITYPE *ip1; + @ITYPE iv2; + @OTYPE *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid && x->tspan > 0 && x->tspan == arg1->tspan) { + ip1 = (@ITYPE *)is1->ptr; + iv2 = *(@ITYPE *)is2->ptr; + op = (@OTYPE *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OP(*ip1, iv2); + ip1++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "@FUN_n_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +@FUN_1_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + @ITYPE iv1; + @ITYPE *ip2; + @OTYPE *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid && x->tspan > 0 && x->tspan == arg2->tspan) { + iv1 = *(@ITYPE *)is1->ptr; + ip2 = (@ITYPE *)is2->ptr; + op = (@OTYPE *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OP(iv1, *ip2); + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "@FUN_1_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +@FUN_1_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + *(@OTYPE *)os->ptr = OP(*(@ITYPE *)is1->ptr, *(@ITYPE *)is2->ptr); + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "@FUN_1_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +#undef OP + |