Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/freedreno/isa/decode.h
4564 views
1
/*
2
* Copyright © 2020 Google, Inc.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
* SOFTWARE.
22
*/
23
24
#ifndef _DECODE_H_
25
#define _DECODE_H_
26
27
#include <stdbool.h>
28
#include <stdint.h>
29
30
/*
31
* Defines the tables which are generated from xml for disassembly
32
*/
33
34
struct decode_scope;
35
36
/* TODO we could maybe make this a uint8_t array, with some helpers, to
37
* support arbitrary sized patterns.. or add AND/OR/SHIFT support to
38
* util/bitset.h?
39
*/
40
typedef uint64_t bitmask_t;
41
42
struct isa_bitset;
43
44
/**
45
* Table of enum values
46
*/
47
struct isa_enum {
48
unsigned num_values;
49
struct {
50
unsigned val;
51
const char *display;
52
} values[];
53
};
54
55
/**
56
* An expression used to for conditional overrides, derived fields, etc
57
*/
58
typedef uint64_t (*isa_expr_t)(struct decode_scope *scope);
59
60
/**
61
* Used by generated expr functions
62
*/
63
uint64_t isa_decode_field(struct decode_scope *scope, const char *field_name);
64
65
/**
66
* For bitset fields, there are some cases where we want to "remap" field
67
* names, essentially allowing one to parameterize a nested bitset when
68
* it resolves fields in an enclosing bitset.
69
*/
70
struct isa_field_params {
71
unsigned num_params;
72
struct {
73
const char *name;
74
const char *as;
75
} params[];
76
};
77
78
/**
79
* Description of a single field within a bitset case.
80
*/
81
struct isa_field {
82
const char *name;
83
isa_expr_t expr; /* for virtual "derived" fields */
84
unsigned low;
85
unsigned high;
86
enum {
87
/* Basic types: */
88
TYPE_BRANCH, /* branch target, like INT but optional labeling*/
89
TYPE_INT,
90
TYPE_UINT,
91
TYPE_HEX,
92
TYPE_OFFSET, /* Like INT but formated with +/- or omitted if ==0 */
93
TYPE_UOFFSET, /* Like UINT but formated with + or omitted if ==0 */
94
TYPE_FLOAT,
95
TYPE_BOOL,
96
TYPE_ENUM,
97
98
/* To assert a certain value in a given range of bits.. not
99
* used for pattern matching, but allows an override to specify
100
* that a certain bitpattern in some "unused" bits is expected
101
*/
102
TYPE_ASSERT,
103
104
/* For fields that are decoded with another bitset hierarchy: */
105
TYPE_BITSET,
106
} type;
107
union {
108
const struct isa_bitset **bitsets; /* if type==BITSET */
109
uint64_t val; /* if type==ASSERT */
110
const struct isa_enum *enums; /* if type==ENUM */
111
const char *display; /* if type==BOOL */
112
};
113
114
/**
115
* type==BITSET fields can also optionally provide remapping for
116
* field names
117
*/
118
const struct isa_field_params *params;
119
};
120
121
/**
122
* A bitset consists of N "cases", with the last one (with case->expr==NULL)
123
* being the default.
124
*
125
* When resolving a field, display template string, etc, all the cases with
126
* an expression that evaluates to non-zero are consider, falling back to
127
* the last (default) case.
128
*/
129
struct isa_case {
130
isa_expr_t expr;
131
const char *display;
132
unsigned num_fields;
133
struct isa_field fields[];
134
};
135
136
/**
137
* An individual bitset, the leaves of a bitset inheritance hiearchy will
138
* have the match and mask to match a single instruction (or arbitrary
139
* bit-pattern) against.
140
*/
141
struct isa_bitset {
142
const struct isa_bitset *parent;
143
const char *name;
144
struct {
145
unsigned min;
146
unsigned max;
147
} gen;
148
bitmask_t match;
149
bitmask_t dontcare;
150
bitmask_t mask;
151
unsigned num_cases;
152
const struct isa_case *cases[];
153
};
154
155
#endif /* _DECODE_H_ */
156
157