]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/intrinsics/mvbits.c
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libgfortran / intrinsics / mvbits.c
CommitLineData
1ee3acfb 1/* Implementation of the MVBITS intrinsic
43ff4e9a 2 Copyright (C) 2004, 2006 Free Software Foundation, Inc.
56746a07 3 Contributed by Tobias Schlüter
1ee3acfb
AP
4
5This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
7Libgfortran is free software; you can redistribute it and/or
57dea9f6 8modify it under the terms of the GNU General Public
1ee3acfb 9License as published by the Free Software Foundation; either
57dea9f6
TM
10version 2 of the License, or (at your option) any later version.
11
12In addition to the permissions in the GNU General Public License, the
13Free Software Foundation gives you unlimited permission to link the
14compiled version of this file into combinations with other programs,
15and to distribute those combinations without any restriction coming
16from the use of this file. (The General Public License restrictions
17do apply in other respects; for example, they cover modification of
18the file, and distribution when not linked into a combine
19executable.)
1ee3acfb
AP
20
21Libgfortran is distributed in the hope that it will be useful,
22but WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57dea9f6 24GNU General Public License for more details.
1ee3acfb 25
57dea9f6
TM
26You should have received a copy of the GNU General Public
27License along with libgfortran; see the file COPYING. If not,
fe2ae685
KC
28write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29Boston, MA 02110-1301, USA. */
1ee3acfb
AP
30
31/* TODO: This should be replaced by a compiler builtin. */
32
33#ifndef SUB_NAME
34#include <libgfortran.h>
35#endif
36
37#ifdef SUB_NAME
38/* MVBITS copies LEN bits starting at bit position FROMPOS from FROM
39 into TO, starting at bit position TOPOS. */
40
37058415
FXC
41extern void SUB_NAME (const TYPE *, const int *, const int *, TYPE *,
42 const int *);
7d7b8bfe
RH
43export_proto(SUB_NAME);
44
1ee3acfb 45void
37058415
FXC
46SUB_NAME (const TYPE *from, const int *frompos, const int *len, TYPE *to,
47 const int *topos)
1ee3acfb
AP
48{
49 TYPE oldbits, newbits, lenmask;
50
43ff4e9a 51 lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : ((TYPE)1 << *len) - 1;
1ee3acfb
AP
52 newbits = (((UTYPE)(*from) >> *frompos) & lenmask) << *topos;
53 oldbits = *to & (~(lenmask << *topos));
54
55 *to = newbits | oldbits;
56}
57#endif
58
59#ifndef SUB_NAME
56746a07
TS
60# define TYPE GFC_INTEGER_1
61# define UTYPE GFC_UINTEGER_1
62# define SUB_NAME mvbits_i1
63# include "mvbits.c"
64# undef SUB_NAME
65# undef TYPE
66# undef UTYPE
67
68# define TYPE GFC_INTEGER_2
69# define UTYPE GFC_UINTEGER_2
70# define SUB_NAME mvbits_i2
71# include "mvbits.c"
72# undef SUB_NAME
73# undef TYPE
74# undef UTYPE
75
1ee3acfb
AP
76# define TYPE GFC_INTEGER_4
77# define UTYPE GFC_UINTEGER_4
7d7b8bfe 78# define SUB_NAME mvbits_i4
1ee3acfb
AP
79# include "mvbits.c"
80# undef SUB_NAME
81# undef TYPE
82# undef UTYPE
83
84# define TYPE GFC_INTEGER_8
85# define UTYPE GFC_UINTEGER_8
7d7b8bfe 86# define SUB_NAME mvbits_i8
1ee3acfb
AP
87# include "mvbits.c"
88# undef SUB_NAME
89# undef TYPE
90# undef UTYPE
91#endif