comparison gcc/config/spu/mfc_tag_reserve.c @ 0:a06113de4d67

first commit
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2009 14:47:48 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a06113de4d67
1 /* Copyright (C) 2007, 2009 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 3, or (at your option) any later
8 version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
24 #include <spu_mfcio.h>
25 extern vector unsigned int __mfc_tag_table;
26
27 /* Reserves a DMA tag for exclusive use. This routine returns an available
28 tag id in the range 0 to 31 and marks the tag as reserved. If no tags
29 are available, MFC_DMA_TAG_INVALID is returned indicating that all tags
30 are already reserved. */
31
32 unsigned int
33 __mfc_tag_reserve (void)
34 {
35 vector unsigned int mask = (vector unsigned int)
36 { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
37 vector unsigned int count_zeros, is_valid;
38 vector signed int count_neg;
39
40 count_zeros = spu_cntlz (__mfc_tag_table);
41 count_neg = spu_sub (0, (vector signed int) count_zeros);
42
43 mask = spu_rlmask (mask, (vector signed int) count_neg);
44 __mfc_tag_table = spu_andc (__mfc_tag_table, mask);
45
46 is_valid = spu_cmpeq (count_zeros, 32);
47 count_zeros = spu_sel (count_zeros, is_valid, is_valid);
48
49 return spu_extract (count_zeros, 0);
50 }
51