2 * Copyright (c) 2013 Rob Clark <robdclark@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include "util/bitset.h"
32 typedef BITSET_DECLARE(regmaskstate_t
, 2 * MAX_REG
);
40 __regmask_get(regmask_t
*regmask
, bool half
, unsigned n
)
42 if (regmask
->mergedregs
) {
43 /* a6xx+ case, with merged register file, we track things in terms
44 * of half-precision registers, with a full precisions register
45 * using two half-precision slots:
48 return BITSET_TEST(regmask
->mask
, n
);
51 return BITSET_TEST(regmask
->mask
, n
) ||
52 BITSET_TEST(regmask
->mask
, n
+1);
55 /* pre a6xx case, with separate register file for half and full
60 return BITSET_TEST(regmask
->mask
, n
);
65 __regmask_set(regmask_t
*regmask
, bool half
, unsigned n
)
67 if (regmask
->mergedregs
) {
68 /* a6xx+ case, with merged register file, we track things in terms
69 * of half-precision registers, with a full precisions register
70 * using two half-precision slots:
73 BITSET_SET(regmask
->mask
, n
);
76 BITSET_SET(regmask
->mask
, n
);
77 BITSET_SET(regmask
->mask
, n
+1);
80 /* pre a6xx case, with separate register file for half and full
85 BITSET_SET(regmask
->mask
, n
);
90 __regmask_clear(regmask_t
*regmask
, bool half
, unsigned n
)
92 if (regmask
->mergedregs
) {
93 /* a6xx+ case, with merged register file, we track things in terms
94 * of half-precision registers, with a full precisions register
95 * using two half-precision slots:
98 BITSET_CLEAR(regmask
->mask
, n
);
101 BITSET_CLEAR(regmask
->mask
, n
);
102 BITSET_CLEAR(regmask
->mask
, n
+1);
105 /* pre a6xx case, with separate register file for half and full
110 BITSET_CLEAR(regmask
->mask
, n
);
115 regmask_init(regmask_t
*regmask
, bool mergedregs
)
117 memset(®mask
->mask
, 0, sizeof(regmask
->mask
));
118 regmask
->mergedregs
= mergedregs
;
122 regmask_or(regmask_t
*dst
, regmask_t
*a
, regmask_t
*b
)
124 assert(dst
->mergedregs
== a
->mergedregs
);
125 assert(dst
->mergedregs
== b
->mergedregs
);
127 for (unsigned i
= 0; i
< ARRAY_SIZE(dst
->mask
); i
++)
128 dst
->mask
[i
] = a
->mask
[i
] | b
->mask
[i
];
131 #endif /* REGMASK_H_ */