1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* Copyright (C) 2020 Collabora Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors (Collabora):
* Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
*/
#include "pan_ir.h"
#include "util/macros.h"
/* Converts a per-component mask to a byte mask */
uint16_t
pan_to_bytemask(unsigned bytes, unsigned mask)
{
switch (bytes) {
case 8:
return mask;
case 16: {
unsigned space =
(mask & 0x1) |
((mask & 0x2) << (2 - 1)) |
((mask & 0x4) << (4 - 2)) |
((mask & 0x8) << (6 - 3)) |
((mask & 0x10) << (8 - 4)) |
((mask & 0x20) << (10 - 5)) |
((mask & 0x40) << (12 - 6)) |
((mask & 0x80) << (14 - 7));
return space | (space << 1);
}
case 32: {
unsigned space =
(mask & 0x1) |
((mask & 0x2) << (4 - 1)) |
((mask & 0x4) << (8 - 2)) |
((mask & 0x8) << (12 - 3));
return space | (space << 1) | (space << 2) | (space << 3);
}
case 64: {
unsigned A = (mask & 0x1) ? 0xFF : 0x00;
unsigned B = (mask & 0x2) ? 0xFF : 0x00;
return A | (B << 8);
}
default:
unreachable("Invalid register mode");
}
}
void
pan_block_add_successor(pan_block *block, pan_block *successor)
{
assert(block);
assert(successor);
for (unsigned i = 0; i < ARRAY_SIZE(block->successors); ++i) {
if (block->successors[i]) {
if (block->successors[i] == successor)
return;
else
continue;
}
block->successors[i] = successor;
_mesa_set_add(successor->predecessors, block);
return;
}
unreachable("Too many successors");
}
/* Prints a NIR ALU type in Bifrost-style ".f32" ".i8" etc */
void
pan_print_alu_type(nir_alu_type t, FILE *fp)
{
unsigned size = nir_alu_type_get_type_size(t);
nir_alu_type base = nir_alu_type_get_base_type(t);
switch (base) {
case nir_type_int:
fprintf(fp, ".i");
break;
case nir_type_uint:
fprintf(fp, ".u");
break;
case nir_type_bool:
fprintf(fp, ".b");
break;
case nir_type_float:
fprintf(fp, ".f");
break;
default:
fprintf(fp, ".unknown");
break;
}
fprintf(fp, "%u", size);
}
|