OSDN Git Service

* config/i386/mmx.md (mmx_nand<mode>3): Rename to mmx_andnot<mode>3.
[pf3gnuchains/gcc-fork.git] / gcc / config / spu / mfc_multi_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 a sequential group of tags from exclusive use. The sequential
33    group of tags is the range starting from <first_tag> through
34    <first_tag>+<number_of_tags>-1. Upon sucessful release, MFC_DMA_TAG_VALID
35    is returned and the tags become available for future reservation.
36
37    If the specified tags were not previously reserved, no action is
38    taken and MFC_DMA_TAG_INVALID is returned.  */
39
40 unsigned int
41 __mfc_multi_tag_release (unsigned int first_tag, unsigned int number_of_tags)
42 {
43   vector unsigned int table_copy, tmp, tmp1;
44   vector unsigned int one = (vector unsigned int)
45         { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
46   vector unsigned int is_invalid;
47   unsigned int last_tag;
48   vector unsigned int has_been_reserved;
49
50   last_tag = first_tag + number_of_tags;
51
52   table_copy = spu_sl (one, number_of_tags);
53   table_copy = spu_rl (table_copy, -last_tag);
54   table_copy = spu_xor (table_copy, -1);
55
56   /* Make sure the tags are in range and valid.  */
57   tmp = spu_cmpgt (spu_promote(last_tag, 0), 32);
58   tmp1 = spu_cmpgt (spu_promote(number_of_tags, 0), 32);
59   is_invalid =  spu_cmpgt (spu_promote(first_tag, 0), 31);
60
61   /* All bits are set to 1 if invalid, 0 if valid.  */
62   is_invalid = spu_or (tmp, is_invalid);
63   is_invalid = spu_or (tmp1, is_invalid);
64
65   /* check whether these tags have been reserved */
66   tmp = spu_rlmask (one, (int)-number_of_tags);
67   tmp1 = spu_sl (__mfc_tag_table, first_tag);
68   has_been_reserved = spu_cmpgt(tmp1, tmp);
69
70   is_invalid = spu_or (has_been_reserved, is_invalid);
71
72   table_copy = spu_sel (__mfc_tag_table, table_copy, table_copy);
73   __mfc_tag_table = spu_sel (table_copy, __mfc_tag_table, is_invalid);
74
75   return spu_extract (is_invalid, 0);
76 }
77