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
|
/* Copyright (c) 2018-2019 Alyssa Rosenzweig (alyssa@rosenzweig.io)
*
* 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 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.
*/
#include "helpers.h"
/* Forward declare */
extern struct mir_op_props alu_opcode_props[256];
extern struct mir_ldst_op_props load_store_opcode_props[256];
#define OP_IS_STORE(op) (load_store_opcode_props[op].props & LDST_STORE)
/* Is this opcode that of an integer (regardless of signedness)? Instruction
* names authoritatively determine types */
static inline bool
midgard_is_integer_op(int op)
{
const char *name = alu_opcode_props[op].name;
if (!name)
return false;
return (name[0] == 'i') || (name[0] == 'u');
}
/* Does this opcode *write* an integer? Same as is_integer_op, unless it's a
* conversion between int<->float in which case we do the opposite */
static inline bool
midgard_is_integer_out_op(int op)
{
bool is_int = midgard_is_integer_op(op);
bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;
return is_int ^ is_conversion;
}
/* Determines effective writemask, taking quirks and expansion into account */
static inline unsigned
effective_writemask(midgard_vector_alu *alu, unsigned existing_mask)
{
/* Channel count is off-by-one to fit in two-bits (0 channel makes no
* sense) */
unsigned channel_count = GET_CHANNEL_COUNT(alu_opcode_props[alu->op].props);
/* If there is a fixed channel count, construct the appropriate mask */
if (channel_count)
return (1 << channel_count) - 1;
return existing_mask;
};
|