summaryrefslogtreecommitdiff
path: root/src/freedreno/isa/ir3-common.xml
blob: 0be7eeb40458057a46d2d8e2aa6fe169071b63b5 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2020 Google, Inc.

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 (including the next
paragraph) 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.
 -->

<isa>

<!--
	Helpers for cat2/cat3 nop encoding, which re-uses the SRC1_R/SRC2_R
	fields to encode a # of nop delay slots following the instruction.
 -->

<expr name="#cat2-cat3-nop-encoding">
	(({SRC1_R} != 0) || ({SRC2_R} != 0)) &amp;&amp; ({REPEAT} == 0)
</expr>

<expr name="#cat2-cat3-nop-value">
	{SRC1_R} | ({SRC2_R} &lt;&lt; 1)
</expr>

<!--
	Source/Dest gpr encoding.  In the gpr case, this handles the special
	cases (p0.x/a0.x)
 -->

<expr name="#reg-gpr-a0">
	{GPR} == 61 /* a0.* */
</expr>

<expr name="#reg-gpr-p0">
	{GPR} == 62 /* p0.x */
</expr>

<bitset name="#reg-gpr" size="8">
	<override expr="#reg-gpr-a0">
		<display>
			a0.{SWIZ}
		</display>
		<assert low="2" high="7">111101</assert>
	</override>
	<override expr="#reg-gpr-p0">
		<display>
			p0.{SWIZ}
		</display>
		<assert low="2" high="7">111110</assert>
	</override>
	<display>
		r{GPR}.{SWIZ}
	</display>
	<field name="SWIZ" low="0" high="1" type="#swiz"/>
	<field name="GPR" low="2"  high="7" type="uint"/>
	<encode type="struct ir3_register *">
		<map name="GPR">src->num >> 2</map>
		<map name="SWIZ">src->num &amp; 0x3</map>
	</encode>
</bitset>

<bitset name="#reg-const" size="11">
	<display>
		c{CONST}.{SWIZ}
	</display>
	<field name="SWIZ" low="0" high="1" type="#swiz"/>
	<field name="CONST" low="2" high="10" type="uint"/>
	<encode type="struct ir3_register *">
		<map name="CONST">src->num >> 2</map>
		<map name="SWIZ">src->num &amp; 0x3</map>
	</encode>
</bitset>

<expr name="#offset-zero">
	{OFFSET} == 0
</expr>

<bitset name="#reg-relative-gpr" size="10">
	<override expr="#offset-zero">
		<display>
			r&lt;a0.x&gt;
		</display>
	</override>
	<display>
		r&lt;a0.x + {OFFSET}&gt;
	</display>
	<field name="OFFSET" low="0" high="9" type="int"/>
	<encode type="struct ir3_register *">
		<map name="OFFSET">src->array.offset</map>
	</encode>
</bitset>

<bitset name="#reg-relative-const" size="10">
	<override expr="#offset-zero">
		<display>
			c&lt;a0.x&gt;
		</display>
	</override>
	<display>
		c&lt;a0.x + {OFFSET}&gt;
	</display>
	<field name="OFFSET" low="0" high="9" type="int"/>
	<encode type="struct ir3_register *">
		<map name="OFFSET">src->array.offset</map>
	</encode>
</bitset>

<!--
	Source Register encoding, used in cat2 and cat4 where a src can be
	either gpr/const/relative
 -->

<bitset name="#multisrc" size="16">
	<doc>
		Encoding for instruction source which can be GPR/CONST/IMMED
		or relative GPR/CONST.
	</doc>
	<encode type="struct ir3_register *" case-prefix="REG_">
		<map name="ABSNEG">extract_ABSNEG(src)</map>
		<map name="SRC">src</map>
	</encode>
</bitset>

<bitset name="#mulitsrc-immed" extends="#multisrc">
	<override expr="#multisrc-half">
		<display>
			{ABSNEG}{SRC_R}h({IMMED})
		</display>
	</override>
	<display>
		{ABSNEG}{SRC_R}{IMMED}
	</display>
	<field name="IMMED" low="0"  high="10" type="int"/>
	<pattern low="11" high="13">100</pattern>
	<field name="ABSNEG" low="14" high="15" type="#absneg"/>
	<encode>
		<map name="IMMED">src->uim_val</map>
	</encode>
</bitset>

<bitset name="#mulitsrc-immed-flut" extends="#multisrc">
	<doc>
		Immediate with int->float lookup table:

			0  -> 0.0
			1  -> 0.5
			2  -> 1.0
			3  -> 2.0
			4  -> e
			5  -> pi
			6  -> 1/pi
			7  -> 1/log2(e)
			8  -> log2(e)
			9  -> 1/log2(10)
			10 -> log2(10)
			11 -> 4.0

	</doc>
	<field name="IMMED" low="0"  high="9" type="#flut"/>
	<pattern low="11" high="13">101</pattern>
	<field name="ABSNEG" low="14" high="15" type="#absneg"/>
	<encode>
		<map name="IMMED">src->uim_val</map>
	</encode>
</bitset>

<bitset name="#multisrc-immed-flut-full" extends="#mulitsrc-immed-flut">
	<display>
		{ABSNEG}{SRC_R}{IMMED}
	</display>
	<pattern pos="10">0</pattern>
</bitset>

<bitset name="#multisrc-immed-flut-half" extends="#mulitsrc-immed-flut">
	<display>
		{ABSNEG}{SRC_R}h{IMMED}
	</display>
	<pattern pos="10">1</pattern>
</bitset>

<expr name="#multisrc-half">
	!{FULL}
</expr>

<bitset name="#multisrc-gpr" extends="#multisrc">
	<display>
		{ABSNEG}{SRC_R}{HALF}{SRC}
	</display>
	<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>
	<field name="SRC" low="0" high="7" type="#reg-gpr"/>
	<pattern low="8" high="13">000000</pattern>
	<field name="ABSNEG" low="14" high="15" type="#absneg"/>
</bitset>

<bitset name="#multisrc-const" extends="#multisrc">
	<display>
		{ABSNEG}{SRC_R}{HALF}{SRC}
	</display>
	<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>
	<field name="SRC" low="0" high="10" type="#reg-const"/>
	<pattern low="11" high="13">x10</pattern>
	<field name="ABSNEG" low="14" high="15" type="#absneg"/>
</bitset>

<bitset name="#multisrc-relative" extends="#multisrc">
	<pattern low="11" high="13">001</pattern>
	<field name="ABSNEG" low="14" high="15" type="#absneg"/>
</bitset>

<bitset name="#multisrc-relative-gpr" extends="#multisrc-relative">
	<display>
		{ABSNEG}{SRC_R}{HALF}{SRC}
	</display>
	<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>
	<field name="SRC" low="0" high="9" type="#reg-relative-gpr"/>
	<pattern pos="10">0</pattern>
</bitset>

<bitset name="#multisrc-relative-const" extends="#multisrc-relative">
	<display>
		{ABSNEG}{SRC_R}{HALF}{SRC}
	</display>
	<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>
	<field name="SRC" low="0" high="9" type="#reg-relative-const"/>
	<pattern pos="10">1</pattern>
</bitset>

<!--
	For cat2/cat4, the dst reg is full precision if {FULL} == {DEST_CONV}
	In addition, for cat2 instructions that can write p0.x (cmps.*, and.b,
	xor.b, etc), p0.x is never half (DEST_CONV is ignored)
 -->
<expr name="#dest-half">
	({FULL} == {DST_CONV}) &amp;&amp; ({DST} &lt;= 0xf7 /* p0.x */)
</expr>

<expr name="#true">
	1
</expr>

<expr name="#false">
	0
</expr>

<!-- These make #true/#false a bit redundant, but I guess keep them for clarity -->
<expr name="#zero">
	0
</expr>
<expr name="#one">
	1
</expr>
<expr name="#two">
	2
</expr>

<!--
	Enums used in various places:
 -->

<enum name="#rptN">
	<value val="0" display=""/>
	<value val="1" display="(rpt1)"/>
	<value val="2" display="(rpt2)"/>
	<value val="3" display="(rpt3)"/>
	<value val="4" display="(rpt4)"/>
	<value val="5" display="(rpt5)"/>
</enum>

<enum name="#cond">
	<value val="0" display="lt"/>
	<value val="1" display="le"/>
	<value val="2" display="gt"/>
	<value val="3" display="ge"/>
	<value val="4" display="eq"/>
	<value val="5" display="ne"/>
</enum>

<enum name="#swiz">
	<value val="0" display="x"/>
	<value val="1" display="y"/>
	<value val="2" display="z"/>
	<value val="3" display="w"/>
</enum>

<enum name="#type">
	<value val="0" display="f16"/>
	<value val="1" display="f32"/>
	<value val="2" display="u16"/>
	<value val="3" display="u32"/>
	<value val="4" display="s16"/>
	<value val="5" display="s32"/>
	<value val="6" display="u8"/>
	<value val="7" display="s8"/>
</enum>

<enum name="#absneg">
	<value val="0" display=""/>
	<value val="1" display="(neg)"/>
	<value val="2" display="(abs)"/>
	<value val="3" display="(absneg)"/>
</enum>

<enum name="#flut">
	<doc>int to float lookup table</doc>
	<value val="0"  display="(0.0)"/>
	<value val="1"  display="(0.5)"/>
	<value val="2"  display="(1.0)"/>
	<value val="3"  display="(2.0)"/>
	<value val="4"  display="(e)"/>
	<value val="5"  display="(pi)"/>
	<value val="6"  display="(1/pi)"/>
	<value val="7"  display="(1/log2(e))"/>
	<value val="8"  display="(log2(e))"/>
	<value val="9"  display="(1/log2(10))"/>
	<value val="10" display="(log2(10))"/>
	<value val="11" display="(4.0)"/>
</enum>

<enum name="#wrmask">
	<value val="0"  display=""/>
	<value val="1"  display="x"/>
	<value val="2"  display="y"/>
	<value val="3"  display="xy"/>
	<value val="4"  display="z"/>
	<value val="5"  display="zx"/>
	<value val="6"  display="zy"/>
	<value val="7"  display="xyz"/>
	<value val="8"  display="w"/>
	<value val="9"  display="xw"/>
	<value val="10" display="yw"/>
	<value val="11" display="xyw"/>
	<value val="12" display="zw"/>
	<value val="13" display="xzw"/>
	<value val="14" display="yzw"/>
	<value val="15" display="xyzw"/>
</enum>

</isa>