1b8e80941Smrg/*
2b8e80941Smrg * Copyright © 2016 Broadcom
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the next
12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
13b8e80941Smrg * Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21b8e80941Smrg * IN THE SOFTWARE.
22b8e80941Smrg */
23b8e80941Smrg
24b8e80941Smrg/**
25b8e80941Smrg * @file qpu_instr.h
26b8e80941Smrg *
27b8e80941Smrg * Definitions of the unpacked form of QPU instructions.  Assembly and
28b8e80941Smrg * disassembly will use this for talking about instructions, with qpu_encode.c
29b8e80941Smrg * and qpu_decode.c handling the pack and unpack of the actual 64-bit QPU
30b8e80941Smrg * instruction.
31b8e80941Smrg */
32b8e80941Smrg
33b8e80941Smrg#ifndef QPU_INSTR_H
34b8e80941Smrg#define QPU_INSTR_H
35b8e80941Smrg
36b8e80941Smrg#include <stdbool.h>
37b8e80941Smrg#include <stdint.h>
38b8e80941Smrg#include "util/macros.h"
39b8e80941Smrg
40b8e80941Smrgstruct v3d_device_info;
41b8e80941Smrg
42b8e80941Smrgstruct v3d_qpu_sig {
43b8e80941Smrg        bool thrsw:1;
44b8e80941Smrg        bool ldunif:1;
45b8e80941Smrg        bool ldunifa:1;
46b8e80941Smrg        bool ldunifrf:1;
47b8e80941Smrg        bool ldunifarf:1;
48b8e80941Smrg        bool ldtmu:1;
49b8e80941Smrg        bool ldvary:1;
50b8e80941Smrg        bool ldvpm:1;
51b8e80941Smrg        bool ldtlb:1;
52b8e80941Smrg        bool ldtlbu:1;
53b8e80941Smrg        bool small_imm:1;
54b8e80941Smrg        bool ucb:1;
55b8e80941Smrg        bool rotate:1;
56b8e80941Smrg        bool wrtmuc:1;
57b8e80941Smrg};
58b8e80941Smrg
59b8e80941Smrgenum v3d_qpu_cond {
60b8e80941Smrg        V3D_QPU_COND_NONE,
61b8e80941Smrg        V3D_QPU_COND_IFA,
62b8e80941Smrg        V3D_QPU_COND_IFB,
63b8e80941Smrg        V3D_QPU_COND_IFNA,
64b8e80941Smrg        V3D_QPU_COND_IFNB,
65b8e80941Smrg};
66b8e80941Smrg
67b8e80941Smrgenum v3d_qpu_pf {
68b8e80941Smrg        V3D_QPU_PF_NONE,
69b8e80941Smrg        V3D_QPU_PF_PUSHZ,
70b8e80941Smrg        V3D_QPU_PF_PUSHN,
71b8e80941Smrg        V3D_QPU_PF_PUSHC,
72b8e80941Smrg};
73b8e80941Smrg
74b8e80941Smrgenum v3d_qpu_uf {
75b8e80941Smrg        V3D_QPU_UF_NONE,
76b8e80941Smrg        V3D_QPU_UF_ANDZ,
77b8e80941Smrg        V3D_QPU_UF_ANDNZ,
78b8e80941Smrg        V3D_QPU_UF_NORNZ,
79b8e80941Smrg        V3D_QPU_UF_NORZ,
80b8e80941Smrg        V3D_QPU_UF_ANDN,
81b8e80941Smrg        V3D_QPU_UF_ANDNN,
82b8e80941Smrg        V3D_QPU_UF_NORNN,
83b8e80941Smrg        V3D_QPU_UF_NORN,
84b8e80941Smrg        V3D_QPU_UF_ANDC,
85b8e80941Smrg        V3D_QPU_UF_ANDNC,
86b8e80941Smrg        V3D_QPU_UF_NORNC,
87b8e80941Smrg        V3D_QPU_UF_NORC,
88b8e80941Smrg};
89b8e80941Smrg
90b8e80941Smrgenum v3d_qpu_waddr {
91b8e80941Smrg        V3D_QPU_WADDR_R0 = 0,
92b8e80941Smrg        V3D_QPU_WADDR_R1 = 1,
93b8e80941Smrg        V3D_QPU_WADDR_R2 = 2,
94b8e80941Smrg        V3D_QPU_WADDR_R3 = 3,
95b8e80941Smrg        V3D_QPU_WADDR_R4 = 4,
96b8e80941Smrg        V3D_QPU_WADDR_R5 = 5,
97b8e80941Smrg        /* 6 is reserved, but note 3.2.2.8: "Result Writes" */
98b8e80941Smrg        V3D_QPU_WADDR_NOP = 6,
99b8e80941Smrg        V3D_QPU_WADDR_TLB = 7,
100b8e80941Smrg        V3D_QPU_WADDR_TLBU = 8,
101b8e80941Smrg        V3D_QPU_WADDR_TMU = 9,
102b8e80941Smrg        V3D_QPU_WADDR_TMUL = 10,
103b8e80941Smrg        V3D_QPU_WADDR_TMUD = 11,
104b8e80941Smrg        V3D_QPU_WADDR_TMUA = 12,
105b8e80941Smrg        V3D_QPU_WADDR_TMUAU = 13,
106b8e80941Smrg        V3D_QPU_WADDR_VPM = 14,
107b8e80941Smrg        V3D_QPU_WADDR_VPMU = 15,
108b8e80941Smrg        V3D_QPU_WADDR_SYNC = 16,
109b8e80941Smrg        V3D_QPU_WADDR_SYNCU = 17,
110b8e80941Smrg        V3D_QPU_WADDR_SYNCB = 18,
111b8e80941Smrg        V3D_QPU_WADDR_RECIP = 19,
112b8e80941Smrg        V3D_QPU_WADDR_RSQRT = 20,
113b8e80941Smrg        V3D_QPU_WADDR_EXP = 21,
114b8e80941Smrg        V3D_QPU_WADDR_LOG = 22,
115b8e80941Smrg        V3D_QPU_WADDR_SIN = 23,
116b8e80941Smrg        V3D_QPU_WADDR_RSQRT2 = 24,
117b8e80941Smrg        V3D_QPU_WADDR_TMUC = 32,
118b8e80941Smrg        V3D_QPU_WADDR_TMUS = 33,
119b8e80941Smrg        V3D_QPU_WADDR_TMUT = 34,
120b8e80941Smrg        V3D_QPU_WADDR_TMUR = 35,
121b8e80941Smrg        V3D_QPU_WADDR_TMUI = 36,
122b8e80941Smrg        V3D_QPU_WADDR_TMUB = 37,
123b8e80941Smrg        V3D_QPU_WADDR_TMUDREF = 38,
124b8e80941Smrg        V3D_QPU_WADDR_TMUOFF = 39,
125b8e80941Smrg        V3D_QPU_WADDR_TMUSCM = 40,
126b8e80941Smrg        V3D_QPU_WADDR_TMUSF = 41,
127b8e80941Smrg        V3D_QPU_WADDR_TMUSLOD = 42,
128b8e80941Smrg        V3D_QPU_WADDR_TMUHS = 43,
129b8e80941Smrg        V3D_QPU_WADDR_TMUHSCM = 44,
130b8e80941Smrg        V3D_QPU_WADDR_TMUHSF = 45,
131b8e80941Smrg        V3D_QPU_WADDR_TMUHSLOD = 46,
132b8e80941Smrg        V3D_QPU_WADDR_R5REP = 55,
133b8e80941Smrg};
134b8e80941Smrg
135b8e80941Smrgstruct v3d_qpu_flags {
136b8e80941Smrg        enum v3d_qpu_cond ac, mc;
137b8e80941Smrg        enum v3d_qpu_pf apf, mpf;
138b8e80941Smrg        enum v3d_qpu_uf auf, muf;
139b8e80941Smrg};
140b8e80941Smrg
141b8e80941Smrgenum v3d_qpu_add_op {
142b8e80941Smrg        V3D_QPU_A_FADD,
143b8e80941Smrg        V3D_QPU_A_FADDNF,
144b8e80941Smrg        V3D_QPU_A_VFPACK,
145b8e80941Smrg        V3D_QPU_A_ADD,
146b8e80941Smrg        V3D_QPU_A_SUB,
147b8e80941Smrg        V3D_QPU_A_FSUB,
148b8e80941Smrg        V3D_QPU_A_MIN,
149b8e80941Smrg        V3D_QPU_A_MAX,
150b8e80941Smrg        V3D_QPU_A_UMIN,
151b8e80941Smrg        V3D_QPU_A_UMAX,
152b8e80941Smrg        V3D_QPU_A_SHL,
153b8e80941Smrg        V3D_QPU_A_SHR,
154b8e80941Smrg        V3D_QPU_A_ASR,
155b8e80941Smrg        V3D_QPU_A_ROR,
156b8e80941Smrg        V3D_QPU_A_FMIN,
157b8e80941Smrg        V3D_QPU_A_FMAX,
158b8e80941Smrg        V3D_QPU_A_VFMIN,
159b8e80941Smrg        V3D_QPU_A_AND,
160b8e80941Smrg        V3D_QPU_A_OR,
161b8e80941Smrg        V3D_QPU_A_XOR,
162b8e80941Smrg        V3D_QPU_A_VADD,
163b8e80941Smrg        V3D_QPU_A_VSUB,
164b8e80941Smrg        V3D_QPU_A_NOT,
165b8e80941Smrg        V3D_QPU_A_NEG,
166b8e80941Smrg        V3D_QPU_A_FLAPUSH,
167b8e80941Smrg        V3D_QPU_A_FLBPUSH,
168b8e80941Smrg        V3D_QPU_A_FLPOP,
169b8e80941Smrg        V3D_QPU_A_RECIP,
170b8e80941Smrg        V3D_QPU_A_SETMSF,
171b8e80941Smrg        V3D_QPU_A_SETREVF,
172b8e80941Smrg        V3D_QPU_A_NOP,
173b8e80941Smrg        V3D_QPU_A_TIDX,
174b8e80941Smrg        V3D_QPU_A_EIDX,
175b8e80941Smrg        V3D_QPU_A_LR,
176b8e80941Smrg        V3D_QPU_A_VFLA,
177b8e80941Smrg        V3D_QPU_A_VFLNA,
178b8e80941Smrg        V3D_QPU_A_VFLB,
179b8e80941Smrg        V3D_QPU_A_VFLNB,
180b8e80941Smrg        V3D_QPU_A_FXCD,
181b8e80941Smrg        V3D_QPU_A_XCD,
182b8e80941Smrg        V3D_QPU_A_FYCD,
183b8e80941Smrg        V3D_QPU_A_YCD,
184b8e80941Smrg        V3D_QPU_A_MSF,
185b8e80941Smrg        V3D_QPU_A_REVF,
186b8e80941Smrg        V3D_QPU_A_VDWWT,
187b8e80941Smrg        V3D_QPU_A_IID,
188b8e80941Smrg        V3D_QPU_A_SAMPID,
189b8e80941Smrg        V3D_QPU_A_BARRIERID,
190b8e80941Smrg        V3D_QPU_A_TMUWT,
191b8e80941Smrg        V3D_QPU_A_VPMSETUP,
192b8e80941Smrg        V3D_QPU_A_VPMWT,
193b8e80941Smrg        V3D_QPU_A_LDVPMV_IN,
194b8e80941Smrg        V3D_QPU_A_LDVPMV_OUT,
195b8e80941Smrg        V3D_QPU_A_LDVPMD_IN,
196b8e80941Smrg        V3D_QPU_A_LDVPMD_OUT,
197b8e80941Smrg        V3D_QPU_A_LDVPMP,
198b8e80941Smrg        V3D_QPU_A_RSQRT,
199b8e80941Smrg        V3D_QPU_A_EXP,
200b8e80941Smrg        V3D_QPU_A_LOG,
201b8e80941Smrg        V3D_QPU_A_SIN,
202b8e80941Smrg        V3D_QPU_A_RSQRT2,
203b8e80941Smrg        V3D_QPU_A_LDVPMG_IN,
204b8e80941Smrg        V3D_QPU_A_LDVPMG_OUT,
205b8e80941Smrg        V3D_QPU_A_FCMP,
206b8e80941Smrg        V3D_QPU_A_VFMAX,
207b8e80941Smrg        V3D_QPU_A_FROUND,
208b8e80941Smrg        V3D_QPU_A_FTOIN,
209b8e80941Smrg        V3D_QPU_A_FTRUNC,
210b8e80941Smrg        V3D_QPU_A_FTOIZ,
211b8e80941Smrg        V3D_QPU_A_FFLOOR,
212b8e80941Smrg        V3D_QPU_A_FTOUZ,
213b8e80941Smrg        V3D_QPU_A_FCEIL,
214b8e80941Smrg        V3D_QPU_A_FTOC,
215b8e80941Smrg        V3D_QPU_A_FDX,
216b8e80941Smrg        V3D_QPU_A_FDY,
217b8e80941Smrg        V3D_QPU_A_STVPMV,
218b8e80941Smrg        V3D_QPU_A_STVPMD,
219b8e80941Smrg        V3D_QPU_A_STVPMP,
220b8e80941Smrg        V3D_QPU_A_ITOF,
221b8e80941Smrg        V3D_QPU_A_CLZ,
222b8e80941Smrg        V3D_QPU_A_UTOF,
223b8e80941Smrg};
224b8e80941Smrg
225b8e80941Smrgenum v3d_qpu_mul_op {
226b8e80941Smrg        V3D_QPU_M_ADD,
227b8e80941Smrg        V3D_QPU_M_SUB,
228b8e80941Smrg        V3D_QPU_M_UMUL24,
229b8e80941Smrg        V3D_QPU_M_VFMUL,
230b8e80941Smrg        V3D_QPU_M_SMUL24,
231b8e80941Smrg        V3D_QPU_M_MULTOP,
232b8e80941Smrg        V3D_QPU_M_FMOV,
233b8e80941Smrg        V3D_QPU_M_MOV,
234b8e80941Smrg        V3D_QPU_M_NOP,
235b8e80941Smrg        V3D_QPU_M_FMUL,
236b8e80941Smrg};
237b8e80941Smrg
238b8e80941Smrgenum v3d_qpu_output_pack {
239b8e80941Smrg        V3D_QPU_PACK_NONE,
240b8e80941Smrg        /**
241b8e80941Smrg         * Convert to 16-bit float, put in low 16 bits of destination leaving
242b8e80941Smrg         * high unmodified.
243b8e80941Smrg         */
244b8e80941Smrg        V3D_QPU_PACK_L,
245b8e80941Smrg        /**
246b8e80941Smrg         * Convert to 16-bit float, put in high 16 bits of destination leaving
247b8e80941Smrg         * low unmodified.
248b8e80941Smrg         */
249b8e80941Smrg        V3D_QPU_PACK_H,
250b8e80941Smrg};
251b8e80941Smrg
252b8e80941Smrgenum v3d_qpu_input_unpack {
253b8e80941Smrg        /**
254b8e80941Smrg         * No-op input unpacking.  Note that this enum's value doesn't match
255b8e80941Smrg         * the packed QPU instruction value of the field (we use 0 so that the
256b8e80941Smrg         * default on new instruction creation is no-op).
257b8e80941Smrg         */
258b8e80941Smrg        V3D_QPU_UNPACK_NONE,
259b8e80941Smrg        /** Absolute value.  Only available for some operations. */
260b8e80941Smrg        V3D_QPU_UNPACK_ABS,
261b8e80941Smrg        /** Convert low 16 bits from 16-bit float to 32-bit float. */
262b8e80941Smrg        V3D_QPU_UNPACK_L,
263b8e80941Smrg        /** Convert high 16 bits from 16-bit float to 32-bit float. */
264b8e80941Smrg        V3D_QPU_UNPACK_H,
265b8e80941Smrg
266b8e80941Smrg        /** Convert to 16f and replicate it to the high bits. */
267b8e80941Smrg        V3D_QPU_UNPACK_REPLICATE_32F_16,
268b8e80941Smrg
269b8e80941Smrg        /** Replicate low 16 bits to high */
270b8e80941Smrg        V3D_QPU_UNPACK_REPLICATE_L_16,
271b8e80941Smrg
272b8e80941Smrg        /** Replicate high 16 bits to low */
273b8e80941Smrg        V3D_QPU_UNPACK_REPLICATE_H_16,
274b8e80941Smrg
275b8e80941Smrg        /** Swap high and low 16 bits */
276b8e80941Smrg        V3D_QPU_UNPACK_SWAP_16,
277b8e80941Smrg};
278b8e80941Smrg
279b8e80941Smrgenum v3d_qpu_mux {
280b8e80941Smrg        V3D_QPU_MUX_R0,
281b8e80941Smrg        V3D_QPU_MUX_R1,
282b8e80941Smrg        V3D_QPU_MUX_R2,
283b8e80941Smrg        V3D_QPU_MUX_R3,
284b8e80941Smrg        V3D_QPU_MUX_R4,
285b8e80941Smrg        V3D_QPU_MUX_R5,
286b8e80941Smrg        V3D_QPU_MUX_A,
287b8e80941Smrg        V3D_QPU_MUX_B,
288b8e80941Smrg};
289b8e80941Smrg
290b8e80941Smrgstruct v3d_qpu_alu_instr {
291b8e80941Smrg        struct {
292b8e80941Smrg                enum v3d_qpu_add_op op;
293b8e80941Smrg                enum v3d_qpu_mux a, b;
294b8e80941Smrg                uint8_t waddr;
295b8e80941Smrg                bool magic_write;
296b8e80941Smrg                enum v3d_qpu_output_pack output_pack;
297b8e80941Smrg                enum v3d_qpu_input_unpack a_unpack;
298b8e80941Smrg                enum v3d_qpu_input_unpack b_unpack;
299b8e80941Smrg        } add;
300b8e80941Smrg
301b8e80941Smrg        struct {
302b8e80941Smrg                enum v3d_qpu_mul_op op;
303b8e80941Smrg                enum v3d_qpu_mux a, b;
304b8e80941Smrg                uint8_t waddr;
305b8e80941Smrg                bool magic_write;
306b8e80941Smrg                enum v3d_qpu_output_pack output_pack;
307b8e80941Smrg                enum v3d_qpu_input_unpack a_unpack;
308b8e80941Smrg                enum v3d_qpu_input_unpack b_unpack;
309b8e80941Smrg        } mul;
310b8e80941Smrg};
311b8e80941Smrg
312b8e80941Smrgenum v3d_qpu_branch_cond {
313b8e80941Smrg        V3D_QPU_BRANCH_COND_ALWAYS,
314b8e80941Smrg        V3D_QPU_BRANCH_COND_A0,
315b8e80941Smrg        V3D_QPU_BRANCH_COND_NA0,
316b8e80941Smrg        V3D_QPU_BRANCH_COND_ALLA,
317b8e80941Smrg        V3D_QPU_BRANCH_COND_ANYNA,
318b8e80941Smrg        V3D_QPU_BRANCH_COND_ANYA,
319b8e80941Smrg        V3D_QPU_BRANCH_COND_ALLNA,
320b8e80941Smrg};
321b8e80941Smrg
322b8e80941Smrgenum v3d_qpu_msfign {
323b8e80941Smrg        /** Ignore multisample flags when determining branch condition. */
324b8e80941Smrg        V3D_QPU_MSFIGN_NONE,
325b8e80941Smrg        /**
326b8e80941Smrg         * If no multisample flags are set in the lane (a pixel in the FS, a
327b8e80941Smrg         * vertex in the VS), ignore the lane's condition when computing the
328b8e80941Smrg         * branch condition.
329b8e80941Smrg         */
330b8e80941Smrg        V3D_QPU_MSFIGN_P,
331b8e80941Smrg        /**
332b8e80941Smrg         * If no multisample flags are set in a 2x2 quad in the FS, ignore the
333b8e80941Smrg         * quad's a/b conditions.
334b8e80941Smrg         */
335b8e80941Smrg        V3D_QPU_MSFIGN_Q,
336b8e80941Smrg};
337b8e80941Smrg
338b8e80941Smrgenum v3d_qpu_branch_dest {
339b8e80941Smrg        V3D_QPU_BRANCH_DEST_ABS,
340b8e80941Smrg        V3D_QPU_BRANCH_DEST_REL,
341b8e80941Smrg        V3D_QPU_BRANCH_DEST_LINK_REG,
342b8e80941Smrg        V3D_QPU_BRANCH_DEST_REGFILE,
343b8e80941Smrg};
344b8e80941Smrg
345b8e80941Smrgstruct v3d_qpu_branch_instr {
346b8e80941Smrg        enum v3d_qpu_branch_cond cond;
347b8e80941Smrg        enum v3d_qpu_msfign msfign;
348b8e80941Smrg
349b8e80941Smrg        /** Selects how to compute the new IP if the branch is taken. */
350b8e80941Smrg        enum v3d_qpu_branch_dest bdi;
351b8e80941Smrg
352b8e80941Smrg        /**
353b8e80941Smrg         * Selects how to compute the new uniforms pointer if the branch is
354b8e80941Smrg         * taken.  (ABS/REL implicitly load a uniform and use that)
355b8e80941Smrg         */
356b8e80941Smrg        enum v3d_qpu_branch_dest bdu;
357b8e80941Smrg
358b8e80941Smrg        /**
359b8e80941Smrg         * If set, then udest determines how the uniform stream will branch,
360b8e80941Smrg         * otherwise the uniform stream is left as is.
361b8e80941Smrg         */
362b8e80941Smrg        bool ub;
363b8e80941Smrg
364b8e80941Smrg        uint8_t raddr_a;
365b8e80941Smrg
366b8e80941Smrg        uint32_t offset;
367b8e80941Smrg};
368b8e80941Smrg
369b8e80941Smrgenum v3d_qpu_instr_type {
370b8e80941Smrg        V3D_QPU_INSTR_TYPE_ALU,
371b8e80941Smrg        V3D_QPU_INSTR_TYPE_BRANCH,
372b8e80941Smrg};
373b8e80941Smrg
374b8e80941Smrgstruct v3d_qpu_instr {
375b8e80941Smrg        enum v3d_qpu_instr_type type;
376b8e80941Smrg
377b8e80941Smrg        struct v3d_qpu_sig sig;
378b8e80941Smrg        uint8_t sig_addr;
379b8e80941Smrg        bool sig_magic; /* If the signal writes to a magic address */
380b8e80941Smrg        uint8_t raddr_a;
381b8e80941Smrg        uint8_t raddr_b;
382b8e80941Smrg        struct v3d_qpu_flags flags;
383b8e80941Smrg
384b8e80941Smrg        union {
385b8e80941Smrg                struct v3d_qpu_alu_instr alu;
386b8e80941Smrg                struct v3d_qpu_branch_instr branch;
387b8e80941Smrg        };
388b8e80941Smrg};
389b8e80941Smrg
390b8e80941Smrgconst char *v3d_qpu_magic_waddr_name(enum v3d_qpu_waddr waddr);
391b8e80941Smrgconst char *v3d_qpu_add_op_name(enum v3d_qpu_add_op op);
392b8e80941Smrgconst char *v3d_qpu_mul_op_name(enum v3d_qpu_mul_op op);
393b8e80941Smrgconst char *v3d_qpu_cond_name(enum v3d_qpu_cond cond);
394b8e80941Smrgconst char *v3d_qpu_pf_name(enum v3d_qpu_pf pf);
395b8e80941Smrgconst char *v3d_qpu_uf_name(enum v3d_qpu_uf uf);
396b8e80941Smrgconst char *v3d_qpu_pack_name(enum v3d_qpu_output_pack pack);
397b8e80941Smrgconst char *v3d_qpu_unpack_name(enum v3d_qpu_input_unpack unpack);
398b8e80941Smrgconst char *v3d_qpu_branch_cond_name(enum v3d_qpu_branch_cond cond);
399b8e80941Smrgconst char *v3d_qpu_msfign_name(enum v3d_qpu_msfign msfign);
400b8e80941Smrg
401b8e80941Smrgenum v3d_qpu_cond v3d_qpu_cond_invert(enum v3d_qpu_cond cond) ATTRIBUTE_CONST;
402b8e80941Smrg
403b8e80941Smrgbool v3d_qpu_add_op_has_dst(enum v3d_qpu_add_op op);
404b8e80941Smrgbool v3d_qpu_mul_op_has_dst(enum v3d_qpu_mul_op op);
405b8e80941Smrgint v3d_qpu_add_op_num_src(enum v3d_qpu_add_op op);
406b8e80941Smrgint v3d_qpu_mul_op_num_src(enum v3d_qpu_mul_op op);
407b8e80941Smrg
408b8e80941Smrgbool v3d_qpu_sig_pack(const struct v3d_device_info *devinfo,
409b8e80941Smrg                      const struct v3d_qpu_sig *sig,
410b8e80941Smrg                      uint32_t *packed_sig);
411b8e80941Smrgbool v3d_qpu_sig_unpack(const struct v3d_device_info *devinfo,
412b8e80941Smrg                        uint32_t packed_sig,
413b8e80941Smrg                        struct v3d_qpu_sig *sig);
414b8e80941Smrg
415b8e80941Smrgbool
416b8e80941Smrgv3d_qpu_flags_pack(const struct v3d_device_info *devinfo,
417b8e80941Smrg                   const struct v3d_qpu_flags *cond,
418b8e80941Smrg                   uint32_t *packed_cond);
419b8e80941Smrgbool
420b8e80941Smrgv3d_qpu_flags_unpack(const struct v3d_device_info *devinfo,
421b8e80941Smrg                     uint32_t packed_cond,
422b8e80941Smrg                     struct v3d_qpu_flags *cond);
423b8e80941Smrg
424b8e80941Smrgbool
425b8e80941Smrgv3d_qpu_small_imm_pack(const struct v3d_device_info *devinfo,
426b8e80941Smrg                       uint32_t value,
427b8e80941Smrg                       uint32_t *packed_small_immediate);
428b8e80941Smrg
429b8e80941Smrgbool
430b8e80941Smrgv3d_qpu_small_imm_unpack(const struct v3d_device_info *devinfo,
431b8e80941Smrg                         uint32_t packed_small_immediate,
432b8e80941Smrg                         uint32_t *small_immediate);
433b8e80941Smrg
434b8e80941Smrgbool
435b8e80941Smrgv3d_qpu_instr_pack(const struct v3d_device_info *devinfo,
436b8e80941Smrg                   const struct v3d_qpu_instr *instr,
437b8e80941Smrg                   uint64_t *packed_instr);
438b8e80941Smrgbool
439b8e80941Smrgv3d_qpu_instr_unpack(const struct v3d_device_info *devinfo,
440b8e80941Smrg                     uint64_t packed_instr,
441b8e80941Smrg                     struct v3d_qpu_instr *instr);
442b8e80941Smrg
443b8e80941Smrgbool v3d_qpu_magic_waddr_is_sfu(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
444b8e80941Smrgbool v3d_qpu_magic_waddr_is_tmu(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
445b8e80941Smrgbool v3d_qpu_magic_waddr_is_tlb(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
446b8e80941Smrgbool v3d_qpu_magic_waddr_is_vpm(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
447b8e80941Smrgbool v3d_qpu_magic_waddr_is_tsy(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
448b8e80941Smrgbool v3d_qpu_magic_waddr_loads_unif(enum v3d_qpu_waddr waddr) ATTRIBUTE_CONST;
449b8e80941Smrgbool v3d_qpu_uses_tlb(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
450b8e80941Smrgbool v3d_qpu_uses_sfu(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
451b8e80941Smrgbool v3d_qpu_writes_tmu(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
452b8e80941Smrgbool v3d_qpu_writes_r3(const struct v3d_device_info *devinfo,
453b8e80941Smrg                       const struct v3d_qpu_instr *instr) ATTRIBUTE_CONST;
454b8e80941Smrgbool v3d_qpu_writes_r4(const struct v3d_device_info *devinfo,
455b8e80941Smrg                       const struct v3d_qpu_instr *instr) ATTRIBUTE_CONST;
456b8e80941Smrgbool v3d_qpu_writes_r5(const struct v3d_device_info *devinfo,
457b8e80941Smrg                       const struct v3d_qpu_instr *instr) ATTRIBUTE_CONST;
458b8e80941Smrgbool v3d_qpu_waits_on_tmu(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
459b8e80941Smrgbool v3d_qpu_uses_mux(const struct v3d_qpu_instr *inst, enum v3d_qpu_mux mux);
460b8e80941Smrgbool v3d_qpu_uses_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
461b8e80941Smrgbool v3d_qpu_reads_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
462b8e80941Smrgbool v3d_qpu_writes_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
463b8e80941Smrgbool v3d_qpu_reads_flags(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
464b8e80941Smrgbool v3d_qpu_writes_flags(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
465b8e80941Smrgbool v3d_qpu_sig_writes_address(const struct v3d_device_info *devinfo,
466b8e80941Smrg                                const struct v3d_qpu_sig *sig) ATTRIBUTE_CONST;
467b8e80941Smrgbool v3d_qpu_unpacks_f32(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
468b8e80941Smrgbool v3d_qpu_unpacks_f16(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
469b8e80941Smrg
470b8e80941Smrg#endif
471