gcc/libgfortran/intrinsics/ishftc.c
Tobias Schlüter 56746a0745 trans-intrinsic.c (gfc_conv_intrinsic_ishft): Change to logicalshift.
gcc/fortran/
* trans-intrinsic.c (gfc_conv_intrinsic_ishft): Change to
logicalshift.  Call fold.  Remove 0-bit shift shortcut.
(gfc_conv_intrinsic_ishftc): Convert first argument to at least
4 bytes bits.  Convert 2nd and 3rd argument to 4 bytes.  Convert
result if width(arg 1) < 4 bytes.  Call fold.

libgfortran/
* libgfortran/libgfortran.h (GFC_UINTEGER_1, GFC_UINTEGER_2):
Define.
* intrinsics/ishftc.c: Update copyright years.
(ishftc8): Change 'shift' and 'size' to GFC_INTEGER_4.
* intrinsics/mvbits.c: Correcty non-ASCII character in my name.
Add implementations for GFC_INTEGER_1 and GFC_INTEGER_2.

gcc/testsuite/
* gfortran.dg/g77/f90-intrinsic-bit.f: New.

From-SVN: r92642
2004-12-27 17:43:25 +01:00

63 lines
1.8 KiB
C

/* Implementation of ishftc intrinsic.
Copyright 2002, 2004 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfor).
Libgfortran is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Libgfortran 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with libgfor; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "libgfortran.h"
extern GFC_INTEGER_4 ishftc4 (GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4);
export_proto(ishftc4);
GFC_INTEGER_4
ishftc4 (GFC_INTEGER_4 i, GFC_INTEGER_4 shift, GFC_INTEGER_4 size)
{
GFC_INTEGER_4 mask;
GFC_UINTEGER_4 bits;
if (shift < 0)
shift = shift + size;
if (shift == 0 || shift == size)
return i;
mask = (~(GFC_INTEGER_4)0) << size;
bits = i & ~mask;
return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
}
extern GFC_INTEGER_8 ishftc8 (GFC_INTEGER_8, GFC_INTEGER_4, GFC_INTEGER_4);
export_proto(ishftc8);
GFC_INTEGER_8
ishftc8 (GFC_INTEGER_8 i, GFC_INTEGER_4 shift, GFC_INTEGER_4 size)
{
GFC_INTEGER_8 mask;
GFC_UINTEGER_8 bits;
if (shift < 0)
shift = shift + size;
if (shift == 0 || shift == size)
return i;
mask = (~(GFC_INTEGER_8)0) << size;
bits = i & ~mask;
return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
}