Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/midgard/midgard_ops.h
4564 views
1
/* Copyright (c) 2018-2019 Alyssa Rosenzweig ([email protected])
2
* Copyright (C) 2019-2020 Collabora, Ltd.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#ifndef __MIDGARD_OPS
24
#define __MIDGARD_OPS
25
26
#include "helpers.h"
27
28
/* Forward declare */
29
30
extern struct mir_op_props alu_opcode_props[256];
31
extern struct mir_ldst_op_props load_store_opcode_props[256];
32
extern struct mir_tex_op_props tex_opcode_props[16];
33
extern struct mir_tag_props midgard_tag_props[16];
34
35
#define OP_IS_ATOMIC(op) (load_store_opcode_props[op].props & LDST_ATOMIC)
36
#define OP_USES_ATTRIB(op) (load_store_opcode_props[op].props & LDST_ATTRIB)
37
#define OP_IS_STORE(op) (load_store_opcode_props[op].props & LDST_STORE)
38
#define OP_HAS_ADDRESS(op) (load_store_opcode_props[op].props & LDST_ADDRESS)
39
40
/* Is this opcode that of an integer (regardless of signedness)? Instruction
41
* names authoritatively determine types */
42
43
static inline bool
44
midgard_is_integer_op(int op)
45
{
46
return (op >= 0x40 && op <= 0x7E) || (op >= 0xA0 && op <= 0xC1);
47
}
48
49
static inline bool
50
midgard_is_unsigned_op(int op)
51
{
52
assert(midgard_is_integer_op(op));
53
54
switch (op) {
55
case midgard_alu_op_uaddsat:
56
case midgard_alu_op_usubsat:
57
case midgard_alu_op_uwmul:
58
case midgard_alu_op_umin:
59
case midgard_alu_op_umax:
60
case midgard_alu_op_uavg:
61
case midgard_alu_op_uravg:
62
case midgard_alu_op_ushlsat:
63
case midgard_alu_op_uabsdiff:
64
case midgard_alu_op_ult:
65
case midgard_alu_op_ule:
66
case midgard_alu_op_uball_lt:
67
case midgard_alu_op_uball_lte:
68
case midgard_alu_op_ubany_lt:
69
case midgard_alu_op_ubany_lte:
70
case midgard_alu_op_u2f_rte:
71
case midgard_alu_op_u2f_rtz:
72
case midgard_alu_op_u2f_rtn:
73
case midgard_alu_op_u2f_rtp:
74
return true;
75
default:
76
return false;
77
}
78
}
79
80
/* Does this opcode *write* an integer? Same as is_integer_op, unless it's a
81
* conversion between int<->float in which case we do the opposite */
82
83
static inline bool
84
midgard_is_integer_out_op(int op)
85
{
86
bool is_int = midgard_is_integer_op(op);
87
bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;
88
89
return is_int ^ is_conversion;
90
}
91
92
/* Determines effective writemask, taking quirks and expansion into account */
93
94
static inline unsigned
95
effective_writemask(midgard_alu_op op, unsigned existing_mask)
96
{
97
/* Channel count is off-by-one to fit in two-bits (0 channel makes no
98
* sense) */
99
100
unsigned channel_count = GET_CHANNEL_COUNT(alu_opcode_props[op].props);
101
102
/* If there is a fixed channel count, construct the appropriate mask */
103
104
if (channel_count)
105
return (1 << channel_count) - 1;
106
107
return existing_mask;
108
};
109
110
#endif
111
112