2 * Copyright (C) 2020 Collabora Ltd.
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
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
28 #include "util/macros.h"
30 /* Converts a per-component mask to a byte mask */
33 pan_to_bytemask(unsigned bytes
, unsigned mask
)
46 ((mask
& 0x2) << (2 - 1)) |
47 ((mask
& 0x4) << (4 - 2)) |
48 ((mask
& 0x8) << (6 - 3)) |
49 ((mask
& 0x10) << (8 - 4)) |
50 ((mask
& 0x20) << (10 - 5)) |
51 ((mask
& 0x40) << (12 - 6)) |
52 ((mask
& 0x80) << (14 - 7));
54 return space
| (space
<< 1);
60 ((mask
& 0x2) << (4 - 1)) |
61 ((mask
& 0x4) << (8 - 2)) |
62 ((mask
& 0x8) << (12 - 3));
64 return space
| (space
<< 1) | (space
<< 2) | (space
<< 3);
68 unsigned A
= (mask
& 0x1) ? 0xFF : 0x00;
69 unsigned B
= (mask
& 0x2) ? 0xFF : 0x00;
74 unreachable("Invalid register mode");
79 pan_block_add_successor(pan_block
*block
, pan_block
*successor
)
84 for (unsigned i
= 0; i
< ARRAY_SIZE(block
->successors
); ++i
) {
85 if (block
->successors
[i
]) {
86 if (block
->successors
[i
] == successor
)
92 block
->successors
[i
] = successor
;
93 _mesa_set_add(successor
->predecessors
, block
);
97 unreachable("Too many successors");
100 /* Prints a NIR ALU type in Bifrost-style ".f32" ".i8" etc */
103 pan_print_alu_type(nir_alu_type t
, FILE *fp
)
105 unsigned size
= nir_alu_type_get_type_size(t
);
106 nir_alu_type base
= nir_alu_type_get_base_type(t
);
122 fprintf(fp
, ".unknown");
126 fprintf(fp
, "%u", size
);