panfrost/midgard: Refactor schedule/emit pipeline
[mesa.git] / src / gallium / drivers / panfrost / midgard / midgard_ops.h
1 /* Copyright (c) 2018-2019 Alyssa Rosenzweig (alyssa@rosenzweig.io)
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 */
21
22 #include "helpers.h"
23
24 /* Forward declare */
25
26 extern struct mir_op_props alu_opcode_props[256];
27 extern const char *load_store_opcode_names[256];
28
29 /* Is this opcode that of an integer (regardless of signedness)? Instruction
30 * names authoritatively determine types */
31
32 static inline bool
33 midgard_is_integer_op(int op)
34 {
35 const char *name = alu_opcode_props[op].name;
36
37 if (!name)
38 return false;
39
40 return (name[0] == 'i') || (name[0] == 'u');
41 }
42
43 /* Does this opcode *write* an integer? Same as is_integer_op, unless it's a
44 * conversion between int<->float in which case we do the opposite */
45
46 static inline bool
47 midgard_is_integer_out_op(int op)
48 {
49 bool is_int = midgard_is_integer_op(op);
50 bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;
51
52 return is_int ^ is_conversion;
53 }
54
55 /* Determines effective writemask, taking quirks and expansion into account */
56 static inline unsigned
57 effective_writemask(midgard_vector_alu *alu)
58 {
59 /* Channel count is off-by-one to fit in two-bits (0 channel makes no
60 * sense) */
61
62 unsigned channel_count = GET_CHANNEL_COUNT(alu_opcode_props[alu->op].props);
63
64 /* If there is a fixed channel count, construct the appropriate mask */
65
66 if (channel_count)
67 return (1 << channel_count) - 1;
68
69 /* Otherwise, just squeeze the existing mask */
70 return squeeze_writemask(alu->mask);
71 }
72
73
74