Debian Codegraph @

src/panfrost/compiler/midgard/midgard_ops.h

raw
1 /*
2 * Copyright (c) 2018-2019 Alyssa Rosenzweig
3 * Copyright (C) 2019-2020 Collabora, Ltd.
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef __MIDGARD_OPS
8 #define __MIDGARD_OPS
9
10 #include "helpers.h"
11
12 /* Forward declare */
13
14 extern struct mir_op_props alu_opcode_props[256];
15 extern struct mir_ldst_op_props load_store_opcode_props[256];
16 extern struct mir_tex_op_props tex_opcode_props[16];
17 extern struct mir_tag_props midgard_tag_props[16];
18
19 #define OP_IS_ATOMIC(op) (load_store_opcode_props[op].props & LDST_ATOMIC)
20 #define OP_USES_ATTRIB(op) (load_store_opcode_props[op].props & LDST_ATTRIB)
21 #define OP_IS_STORE(op) (load_store_opcode_props[op].props & LDST_STORE)
22 #define OP_HAS_ADDRESS(op) (load_store_opcode_props[op].props & LDST_ADDRESS)
23
24 /* Is this opcode that of an integer (regardless of signedness)? Instruction
25 * names authoritatively determine types */
26
27 static inline bool
28 midgard_is_integer_op(int op)
29 {
30 return (op >= 0x40 && op <= 0x7E) || (op >= 0xA0 && op <= 0xC1);
31 }
32
33 static inline bool
34 midgard_is_unsigned_op(int op)
35 {
36 assert(midgard_is_integer_op(op));
37
38 switch (op) {
39 case midgard_alu_op_uaddsat:
40 case midgard_alu_op_usubsat:
41 case midgard_alu_op_uwmul:
42 case midgard_alu_op_umin:
43 case midgard_alu_op_umax:
44 case midgard_alu_op_uavg:
45 case midgard_alu_op_uravg:
46 case midgard_alu_op_ushlsat:
47 case midgard_alu_op_uabsdiff:
48 case midgard_alu_op_ult:
49 case midgard_alu_op_ule:
50 case midgard_alu_op_uball_lt:
51 case midgard_alu_op_uball_lte:
52 case midgard_alu_op_ubany_lt:
53 case midgard_alu_op_ubany_lte:
54 case midgard_alu_op_u2f_rte:
55 case midgard_alu_op_u2f_rtz:
56 case midgard_alu_op_u2f_rtn:
57 case midgard_alu_op_u2f_rtp:
58 return true;
59 default:
60 return false;
61 }
62 }
63
64 /* Does this opcode *write* an integer? Same as is_integer_op, unless it's a
65 * conversion between int<->float in which case we do the opposite */
66
67 static inline bool
68 midgard_is_integer_out_op(int op)
69 {
70 bool is_int = midgard_is_integer_op(op);
71 bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;
72
73 return is_int ^ is_conversion;
74 }
75
76 /* Determines effective writemask, taking quirks and expansion into account */
77
78 static inline unsigned
79 effective_writemask(midgard_alu_op op, unsigned existing_mask)
80 {
81 /* Channel count is off-by-one to fit in two-bits (0 channel makes no
82 * sense) */
83
84 unsigned channel_count = GET_CHANNEL_COUNT(alu_opcode_props[op].props);
85
86 /* If there is a fixed channel count, construct the appropriate mask */
87
88 if (channel_count)
89 return (1 << channel_count) - 1;
90
91 return existing_mask;
92 };
93
94 #endif