]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/spu/mfc_tag_reserve.c
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / spu / mfc_tag_reserve.c
CommitLineData
f1717362 1/* Copyright (C) 2007-2016 Free Software Foundation, Inc.
1ed5a748 2
3This file is part of GCC.
4
5GCC is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free
6bc9506f 7Software Foundation; either version 3, or (at your option) any later
1ed5a748 8version.
9
1ed5a748 10GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or
12FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13for more details.
14
6bc9506f 15Under Section 7 of GPL version 3, you are granted additional
16permissions described in the GCC Runtime Library Exception, version
173.1, as published by the Free Software Foundation.
18
19You should have received a copy of the GNU General Public License and
20a copy of the GCC Runtime Library Exception along with this program;
21see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22<http://www.gnu.org/licenses/>. */
1ed5a748 23
24#include <spu_mfcio.h>
25extern 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
32unsigned 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