OSDN Git Service

Support scheduling for ColdFire V1 and V3 microarchitecture.
[pf3gnuchains/gcc-fork.git] / gcc / config / spu / mfc_tag_release.c
1 /* Copyright (C) 2007 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version.
9
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file.  (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
17 executable.)
18
19 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with GCC; see the file COPYING.  If not, write to the Free
26 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
27 02110-1301, USA.  */
28
29 #include <spu_mfcio.h>
30 extern vector unsigned int __mfc_tag_table;
31
32 /* Release the specified DMA tag from exclusive use.  Once released, the
33    tag is available for future reservation.  Upon sucessful release,
34    MFC_DMA_TAG_VALID is returned.  If the specified tag is not in the
35    range 0 to 31, or had not been reserved, no action is taken and
36    MFC_DMA_TAG_INVALID is returned.  */
37
38 unsigned int
39 __mfc_tag_release (unsigned int tag)
40 {
41   vector unsigned int is_invalid;
42   vector unsigned int mask = (vector unsigned int)
43         { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
44   vector signed int zero = (vector signed int) { 0, 0, 0, 0 };
45
46   vector signed int has_been_reserved;
47
48   /* Check if the tag is out of range.  */
49   is_invalid = spu_cmpgt (spu_promote (tag, 0), 31);
50
51   /* Check whether the tag has been reserved, set to all 1 if has not
52      been reserved, 0 otherwise.  */
53   has_been_reserved = (vector signed int) spu_rl (__mfc_tag_table, tag);
54   has_been_reserved = (vector signed int) spu_cmpgt (zero, has_been_reserved);
55
56   /* Set invalid.  */
57   is_invalid = spu_or ((vector unsigned int) has_been_reserved, is_invalid);
58
59   mask = spu_rlmask (mask, (int)(-tag));
60   __mfc_tag_table = spu_or (__mfc_tag_table, mask);
61
62   return spu_extract(is_invalid, 0);
63 }
64