OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libgfortran/] [intrinsics/] [mvbits.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Implementation of the MVBITS intrinsic
2
   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
3
   Contributed by Tobias Schlüter
4
 
5
This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public
9
License as published by the Free Software Foundation; either
10
version 2 of the License, or (at your option) any later version.
11
 
12
In addition to the permissions in the GNU General Public License, the
13
Free Software Foundation gives you unlimited permission to link the
14
compiled version of this file into combinations with other programs,
15
and to distribute those combinations without any restriction coming
16
from the use of this file.  (The General Public License restrictions
17
do apply in other respects; for example, they cover modification of
18
the file, and distribution when not linked into a combine
19
executable.)
20
 
21
Libgfortran is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
GNU General Public License for more details.
25
 
26
You should have received a copy of the GNU General Public
27
License along with libgfortran; see the file COPYING.  If not,
28
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29
Boston, MA 02110-1301, USA.  */
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
 
41
extern void SUB_NAME (const TYPE *, const GFC_INTEGER_4 *,
42
                      const GFC_INTEGER_4 *, TYPE *, const GFC_INTEGER_4 *);
43
export_proto(SUB_NAME);
44
 
45
void
46
SUB_NAME (const TYPE *from, const GFC_INTEGER_4 *frompos,
47
          const GFC_INTEGER_4 *len, TYPE *to, const GFC_INTEGER_4 *topos)
48
{
49
  TYPE oldbits, newbits, lenmask;
50
 
51
  lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : ((TYPE)1 << *len) - 1;
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
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
 
76
#  define TYPE GFC_INTEGER_4
77
#  define UTYPE GFC_UINTEGER_4
78
#  define SUB_NAME mvbits_i4
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
86
#  define SUB_NAME mvbits_i8
87
#  include "mvbits.c"
88
#  undef SUB_NAME
89
#  undef TYPE
90
#  undef UTYPE
91
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.