1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (c) 2017 Lima Project
3bf215546Sopenharmony_ci * Copyright (c) 2013 Ben Brewer (ben.brewer@codethink.co.uk)
4bf215546Sopenharmony_ci * Copyright (c) 2013 Connor Abbott (connor@abbott.cx)
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
14bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
15bf215546Sopenharmony_ci * of the Software.
16bf215546Sopenharmony_ci *
17bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
24bf215546Sopenharmony_ci *
25bf215546Sopenharmony_ci */
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#ifndef LIMA_IR_PP_CODEGEN_H
28bf215546Sopenharmony_ci#define LIMA_IR_PP_CODEGEN_H
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include <stdint.h>
31bf215546Sopenharmony_ci#include <stdbool.h>
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci/* Control */
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_citypedef union __attribute__((__packed__)) {
36bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
37bf215546Sopenharmony_ci      unsigned count      :  5;
38bf215546Sopenharmony_ci      bool     stop       :  1;
39bf215546Sopenharmony_ci      bool     sync       :  1;
40bf215546Sopenharmony_ci      unsigned fields     : 12;
41bf215546Sopenharmony_ci      unsigned next_count :  6;
42bf215546Sopenharmony_ci      bool     prefetch   :  1;
43bf215546Sopenharmony_ci      unsigned unknown    :  6;
44bf215546Sopenharmony_ci   };
45bf215546Sopenharmony_ci   uint32_t mask;
46bf215546Sopenharmony_ci} ppir_codegen_ctrl;
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_citypedef enum {
49bf215546Sopenharmony_ci   ppir_codegen_field_shift_varying      =  0,
50bf215546Sopenharmony_ci   ppir_codegen_field_shift_sampler      =  1,
51bf215546Sopenharmony_ci   ppir_codegen_field_shift_uniform      =  2,
52bf215546Sopenharmony_ci   ppir_codegen_field_shift_vec4_mul     =  3,
53bf215546Sopenharmony_ci   ppir_codegen_field_shift_float_mul    =  4,
54bf215546Sopenharmony_ci   ppir_codegen_field_shift_vec4_acc     =  5,
55bf215546Sopenharmony_ci   ppir_codegen_field_shift_float_acc    =  6,
56bf215546Sopenharmony_ci   ppir_codegen_field_shift_combine      =  7,
57bf215546Sopenharmony_ci   ppir_codegen_field_shift_temp_write   =  8,
58bf215546Sopenharmony_ci   ppir_codegen_field_shift_branch       =  9,
59bf215546Sopenharmony_ci   ppir_codegen_field_shift_vec4_const_0 = 10,
60bf215546Sopenharmony_ci   ppir_codegen_field_shift_vec4_const_1 = 11,
61bf215546Sopenharmony_ci   ppir_codegen_field_shift_count        = 12,
62bf215546Sopenharmony_ci} ppir_codegen_field_shift;
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_ci/* Data Inputs */
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_citypedef enum {
67bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_frag_color =  0,
68bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_constant0  = 12,
69bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_constant1  = 13,
70bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_texture    = 14,
71bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_uniform    = 15,
72bf215546Sopenharmony_ci   ppir_codegen_vec4_reg_discard    = 15,
73bf215546Sopenharmony_ci} ppir_codegen_vec4_reg;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_citypedef union __attribute__((__packed__)) {
76bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
77bf215546Sopenharmony_ci      unsigned              perspective   :  2;
78bf215546Sopenharmony_ci      unsigned              source_type   :  2;
79bf215546Sopenharmony_ci      unsigned              unknown_0     :  1; /* = 0 */
80bf215546Sopenharmony_ci      unsigned              alignment     :  2;
81bf215546Sopenharmony_ci      unsigned              unknown_1     :  3; /* = 00 0 */
82bf215546Sopenharmony_ci      unsigned              offset_vector :  4;
83bf215546Sopenharmony_ci      unsigned              unknown_2     :  2; /* = 00 */
84bf215546Sopenharmony_ci      unsigned              offset_scalar :  2;
85bf215546Sopenharmony_ci      unsigned              index         :  6;
86bf215546Sopenharmony_ci      ppir_codegen_vec4_reg dest          :  4;
87bf215546Sopenharmony_ci      unsigned              mask          :  4;
88bf215546Sopenharmony_ci      unsigned              unknown_3     :  2; /* = 00 */
89bf215546Sopenharmony_ci   } imm;
90bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
91bf215546Sopenharmony_ci      unsigned              perspective :  2;
92bf215546Sopenharmony_ci      unsigned              source_type :  2; /* = 01 */
93bf215546Sopenharmony_ci      unsigned              unknown_0   :  2; /* = 00 */
94bf215546Sopenharmony_ci      bool                  normalize   :  1;
95bf215546Sopenharmony_ci      unsigned              unknown_1   :  3;
96bf215546Sopenharmony_ci      ppir_codegen_vec4_reg source      :  4;
97bf215546Sopenharmony_ci      bool                  negate      :  1;
98bf215546Sopenharmony_ci      bool                  absolute    :  1;
99bf215546Sopenharmony_ci      unsigned              swizzle     :  8;
100bf215546Sopenharmony_ci      ppir_codegen_vec4_reg dest        :  4;
101bf215546Sopenharmony_ci      unsigned              mask        :  4;
102bf215546Sopenharmony_ci      unsigned              unknown_2   :  2; /* = 00 */
103bf215546Sopenharmony_ci   } reg;
104bf215546Sopenharmony_ci} ppir_codegen_field_varying;
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_citypedef enum {
107bf215546Sopenharmony_ci   ppir_codegen_sampler_type_generic = 0x00,
108bf215546Sopenharmony_ci   ppir_codegen_sampler_type_cube    = 0x1F,
109bf215546Sopenharmony_ci} ppir_codegen_sampler_type;
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
112bf215546Sopenharmony_ci   unsigned                  lod_bias     :  6;
113bf215546Sopenharmony_ci   unsigned                  index_offset :  6;
114bf215546Sopenharmony_ci   unsigned                  unknown_0    :  5; /* = 00000 */
115bf215546Sopenharmony_ci   bool                      explicit_lod :  1;
116bf215546Sopenharmony_ci   bool                      lod_bias_en  :  1;
117bf215546Sopenharmony_ci   unsigned                  unknown_1    :  5; /* = 00000 */
118bf215546Sopenharmony_ci   ppir_codegen_sampler_type type         :  5;
119bf215546Sopenharmony_ci   bool                      offset_en    :  1;
120bf215546Sopenharmony_ci   unsigned                  index        : 12;
121bf215546Sopenharmony_ci   unsigned                  unknown_2    : 20; /* = 0011 1001 0000 0000 0001 */
122bf215546Sopenharmony_ci} ppir_codegen_field_sampler;
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_citypedef enum {
125bf215546Sopenharmony_ci   ppir_codegen_uniform_src_uniform   = 0,
126bf215546Sopenharmony_ci   ppir_codegen_uniform_src_temporary = 3,
127bf215546Sopenharmony_ci} ppir_codegen_uniform_src;
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
130bf215546Sopenharmony_ci   ppir_codegen_uniform_src source     :  2;
131bf215546Sopenharmony_ci   unsigned                 unknown_0  :  8; /* = 00 0000 00 */
132bf215546Sopenharmony_ci   unsigned                 alignment  :  2; /* 00: float, 01: vec2, 10: vec4 */
133bf215546Sopenharmony_ci   unsigned                 unknown_1  :  6; /* = 00 0000 */
134bf215546Sopenharmony_ci   unsigned                 offset_reg :  6;
135bf215546Sopenharmony_ci   bool                     offset_en  :  1;
136bf215546Sopenharmony_ci   unsigned                 index      : 16;
137bf215546Sopenharmony_ci} ppir_codegen_field_uniform;
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci/* Vector Pipe */
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_citypedef enum {
142bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_not = 0x08, /* Logical Not */
143bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_and = 0x09, /* Logical AND */
144bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_or  = 0x0A, /* Logical OR */
145bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_xor = 0x0B, /* Logical XOR */
146bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_ne  = 0x0C, /* Not Equal */
147bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_gt  = 0x0D, /* Great Than */
148bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_ge  = 0x0E, /* Great than or Equal */
149bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_eq  = 0x0F, /* Equal */
150bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_min = 0x10, /* Minimum */
151bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_max = 0x11, /* Maximum */
152bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op_mov = 0x1F, /* Passthrough, result = arg1 */
153bf215546Sopenharmony_ci} ppir_codegen_vec4_mul_op;
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_citypedef enum {
156bf215546Sopenharmony_ci   ppir_codegen_outmod_none           = 0,
157bf215546Sopenharmony_ci   ppir_codegen_outmod_clamp_fraction = 1,
158bf215546Sopenharmony_ci   ppir_codegen_outmod_clamp_positive = 2,
159bf215546Sopenharmony_ci   ppir_codegen_outmod_round          = 3,
160bf215546Sopenharmony_ci} ppir_codegen_outmod;
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
163bf215546Sopenharmony_ci   ppir_codegen_vec4_reg    arg0_source   : 4;
164bf215546Sopenharmony_ci   unsigned                 arg0_swizzle  : 8;
165bf215546Sopenharmony_ci   bool                     arg0_absolute : 1;
166bf215546Sopenharmony_ci   bool                     arg0_negate   : 1;
167bf215546Sopenharmony_ci   ppir_codegen_vec4_reg    arg1_source   : 4;
168bf215546Sopenharmony_ci   unsigned                 arg1_swizzle  : 8;
169bf215546Sopenharmony_ci   bool                     arg1_absolute : 1;
170bf215546Sopenharmony_ci   bool                     arg1_negate   : 1;
171bf215546Sopenharmony_ci   unsigned                 dest          : 4;
172bf215546Sopenharmony_ci   unsigned                 mask          : 4;
173bf215546Sopenharmony_ci   ppir_codegen_outmod      dest_modifier : 2;
174bf215546Sopenharmony_ci   ppir_codegen_vec4_mul_op op            : 5;
175bf215546Sopenharmony_ci} ppir_codegen_field_vec4_mul;
176bf215546Sopenharmony_ci
177bf215546Sopenharmony_citypedef enum {
178bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_add   = 0x00,
179bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_fract = 0x04, /* Fract? */
180bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_ne    = 0x08, /* Not Equal */
181bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_gt    = 0x09, /* Great-Than */
182bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_ge    = 0x0A, /* Great-than or Equal */
183bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_eq    = 0x0B, /* Equal */
184bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_floor = 0x0C,
185bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_ceil  = 0x0D,
186bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_min   = 0x0E,
187bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_max   = 0x0F,
188bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_sum3  = 0x10, /* dest.xyzw = (arg0.x + arg0.y + arg0.z) */
189bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_sum4  = 0x11, /* dest.xyzw = (arg0.x + arg0.y + arg0.z + arg0.w) */
190bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_dFdx  = 0x14,
191bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_dFdy  = 0x15,
192bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_sel   = 0x17, /* result = (^fmul ? arg0 : arg1) */
193bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op_mov   = 0x1F, /* Passthrough, result = arg0 */
194bf215546Sopenharmony_ci} ppir_codegen_vec4_acc_op;
195bf215546Sopenharmony_ci
196bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
197bf215546Sopenharmony_ci   ppir_codegen_vec4_reg    arg0_source   : 4;
198bf215546Sopenharmony_ci   unsigned                 arg0_swizzle  : 8;
199bf215546Sopenharmony_ci   bool                     arg0_absolute : 1;
200bf215546Sopenharmony_ci   bool                     arg0_negate   : 1;
201bf215546Sopenharmony_ci   ppir_codegen_vec4_reg    arg1_source   : 4;
202bf215546Sopenharmony_ci   unsigned                 arg1_swizzle  : 8;
203bf215546Sopenharmony_ci   bool                     arg1_absolute : 1;
204bf215546Sopenharmony_ci   bool                     arg1_negate   : 1;
205bf215546Sopenharmony_ci   unsigned                 dest          : 4;
206bf215546Sopenharmony_ci   unsigned                 mask          : 4;
207bf215546Sopenharmony_ci   ppir_codegen_outmod      dest_modifier : 2;
208bf215546Sopenharmony_ci   ppir_codegen_vec4_acc_op op            : 5;
209bf215546Sopenharmony_ci   bool                     mul_in        : 1; /* whether to get arg0 from multiply unit below */
210bf215546Sopenharmony_ci} ppir_codegen_field_vec4_acc;
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci/* Float (Scalar) Pipe */
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_citypedef enum {
215bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_not = 0x08, /* Logical Not */
216bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_and = 0x09, /* Logical AND */
217bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_or  = 0x0A, /* Logical OR */
218bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_xor = 0x0B, /* Logical XOR */
219bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_ne  = 0x0C, /* Not Equal */
220bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_gt  = 0x0D, /* Great Than */
221bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_ge  = 0x0E, /* great than or Equal */
222bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_eq  = 0x0F, /* Equal */
223bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_min = 0x10, /* Minimum */
224bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_max = 0x11, /* Maximum */
225bf215546Sopenharmony_ci   ppir_codegen_float_mul_op_mov = 0x1F, /* Passthrough, result = arg1 */
226bf215546Sopenharmony_ci} ppir_codegen_float_mul_op;
227bf215546Sopenharmony_ci
228bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
229bf215546Sopenharmony_ci   unsigned                  arg0_source   : 6;
230bf215546Sopenharmony_ci   bool                      arg0_absolute : 1;
231bf215546Sopenharmony_ci   bool                      arg0_negate   : 1;
232bf215546Sopenharmony_ci   unsigned                  arg1_source   : 6;
233bf215546Sopenharmony_ci   bool                      arg1_absolute : 1;
234bf215546Sopenharmony_ci   bool                      arg1_negate   : 1;
235bf215546Sopenharmony_ci   unsigned                  dest          : 6;
236bf215546Sopenharmony_ci   bool                      output_en     : 1; /* Set to 0 when outputting directly to float_acc below. */
237bf215546Sopenharmony_ci   ppir_codegen_outmod       dest_modifier : 2;
238bf215546Sopenharmony_ci   ppir_codegen_float_mul_op op            : 5;
239bf215546Sopenharmony_ci} ppir_codegen_field_float_mul;
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_citypedef enum {
242bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_add   = 0x00,
243bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_fract = 0x04,
244bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_ne    = 0x08, /* Not Equal */
245bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_gt    = 0x09, /* Great-Than */
246bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_ge    = 0x0A, /* Great-than or Equal */
247bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_eq    = 0x0B, /* Equal */
248bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_floor = 0x0C,
249bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_ceil  = 0x0D,
250bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_min   = 0x0E,
251bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_max   = 0x0F,
252bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_dFdx  = 0x14,
253bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_dFdy  = 0x15,
254bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_sel   = 0x17, /* result = (^fmul ? arg0 : arg1) */
255bf215546Sopenharmony_ci   ppir_codegen_float_acc_op_mov   = 0x1F, /* Passthrough, result = arg1 */
256bf215546Sopenharmony_ci} ppir_codegen_float_acc_op;
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_citypedef struct __attribute__((__packed__)) {
259bf215546Sopenharmony_ci   unsigned                  arg0_source   : 6;
260bf215546Sopenharmony_ci   bool                      arg0_absolute : 1;
261bf215546Sopenharmony_ci   bool                      arg0_negate   : 1;
262bf215546Sopenharmony_ci   unsigned                  arg1_source   : 6;
263bf215546Sopenharmony_ci   bool                      arg1_absolute : 1;
264bf215546Sopenharmony_ci   bool                      arg1_negate   : 1;
265bf215546Sopenharmony_ci   unsigned                  dest          : 6;
266bf215546Sopenharmony_ci   bool                      output_en     : 1; /* Always true */
267bf215546Sopenharmony_ci   ppir_codegen_outmod       dest_modifier : 2;
268bf215546Sopenharmony_ci   ppir_codegen_float_acc_op op            : 5;
269bf215546Sopenharmony_ci   bool                      mul_in        : 1; /* Get arg1 from float_mul above. */
270bf215546Sopenharmony_ci} ppir_codegen_field_float_acc;
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci/* Temporary Write / Framebuffer Read */
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_citypedef union __attribute__((__packed__)) {
275bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
276bf215546Sopenharmony_ci      unsigned dest       :  2; /* = 11 */
277bf215546Sopenharmony_ci      unsigned unknown_0  :  2; /* = 00 */
278bf215546Sopenharmony_ci      unsigned source     :  6;
279bf215546Sopenharmony_ci      unsigned alignment  :  2; /* 0: float, 1:vec2, 2: vec4 */
280bf215546Sopenharmony_ci      unsigned unknown_1  :  6; /* = 00 0000 */
281bf215546Sopenharmony_ci      unsigned offset_reg :  6;
282bf215546Sopenharmony_ci      bool     offset_en  :  1;
283bf215546Sopenharmony_ci      unsigned index      : 16;
284bf215546Sopenharmony_ci   } temp_write;
285bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
286bf215546Sopenharmony_ci      bool     source    :  1; /* 0 = fb_depth, 1 = fb_color */
287bf215546Sopenharmony_ci      unsigned unknown_0 :  5; /* = 00 111 */
288bf215546Sopenharmony_ci      unsigned dest      :  4;
289bf215546Sopenharmony_ci      unsigned unknown_1 : 31; /* = 0 0000 ... 10 */
290bf215546Sopenharmony_ci   } fb_read;
291bf215546Sopenharmony_ci} ppir_codegen_field_temp_write;
292bf215546Sopenharmony_ci
293bf215546Sopenharmony_ci/* Result combiner */
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_citypedef enum {
296bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_rcp   = 0, /* Reciprocal */
297bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_mov   = 1, /* No Operation */
298bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_sqrt  = 2, /* Square-Root */
299bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_rsqrt = 3, /* Inverse Square-Root */
300bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_exp2  = 4, /* Binary Exponent */
301bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_log2  = 5, /* Binary Logarithm */
302bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_sin   = 6, /* Sine   (Scaled LUT) */
303bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_cos   = 7, /* Cosine (Scaled LUT) */
304bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_atan  = 8, /* Arc Tangent Part 1 */
305bf215546Sopenharmony_ci   ppir_codegen_combine_scalar_op_atan2 = 9, /* Arc Tangent 2 Part 1 */
306bf215546Sopenharmony_ci} ppir_codegen_combine_scalar_op;
307bf215546Sopenharmony_ci
308bf215546Sopenharmony_citypedef union __attribute__((__packed__)) {
309bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
310bf215546Sopenharmony_ci      bool                           dest_vec      : 1;
311bf215546Sopenharmony_ci      bool                           arg1_en       : 1;
312bf215546Sopenharmony_ci      ppir_codegen_combine_scalar_op op            : 4;
313bf215546Sopenharmony_ci      bool                           arg1_absolute : 1;
314bf215546Sopenharmony_ci      bool                           arg1_negate   : 1;
315bf215546Sopenharmony_ci      unsigned                       arg1_src      : 6;
316bf215546Sopenharmony_ci      bool                           arg0_absolute : 1;
317bf215546Sopenharmony_ci      bool                           arg0_negate   : 1;
318bf215546Sopenharmony_ci      unsigned                       arg0_src      : 6;
319bf215546Sopenharmony_ci      ppir_codegen_outmod            dest_modifier : 2;
320bf215546Sopenharmony_ci      unsigned                       dest          : 6;
321bf215546Sopenharmony_ci   } scalar;
322bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
323bf215546Sopenharmony_ci      bool     dest_vec     : 1;
324bf215546Sopenharmony_ci      bool     arg1_en      : 1;
325bf215546Sopenharmony_ci      unsigned arg1_swizzle : 8;
326bf215546Sopenharmony_ci      unsigned arg1_source  : 4;
327bf215546Sopenharmony_ci      unsigned padding_0    : 8;
328bf215546Sopenharmony_ci      unsigned mask         : 4;
329bf215546Sopenharmony_ci      unsigned dest         : 4;
330bf215546Sopenharmony_ci   } vector;
331bf215546Sopenharmony_ci} ppir_codegen_field_combine;
332bf215546Sopenharmony_ci
333bf215546Sopenharmony_ci/* Branch/Control Flow */
334bf215546Sopenharmony_ci
335bf215546Sopenharmony_ci#define PPIR_CODEGEN_DISCARD_WORD0 0x007F0003
336bf215546Sopenharmony_ci#define PPIR_CODEGEN_DISCARD_WORD1 0x00000000
337bf215546Sopenharmony_ci#define PPIR_CODEGEN_DISCARD_WORD2 0x000
338bf215546Sopenharmony_ci
339bf215546Sopenharmony_citypedef union __attribute__((__packed__)) {
340bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
341bf215546Sopenharmony_ci      unsigned unknown_0   :  4; /* = 0000 */
342bf215546Sopenharmony_ci      unsigned arg1_source :  6;
343bf215546Sopenharmony_ci      unsigned arg0_source :  6;
344bf215546Sopenharmony_ci      bool     cond_gt     :  1;
345bf215546Sopenharmony_ci      bool     cond_eq     :  1;
346bf215546Sopenharmony_ci      bool     cond_lt     :  1;
347bf215546Sopenharmony_ci      unsigned unknown_1   : 22; /* = 0 0000 0000 0000 0000 0000 0 */
348bf215546Sopenharmony_ci      signed   target      : 27;
349bf215546Sopenharmony_ci      unsigned next_count  :  5;
350bf215546Sopenharmony_ci   } branch;
351bf215546Sopenharmony_ci   struct __attribute__((__packed__)) {
352bf215546Sopenharmony_ci      unsigned word0 : 32;
353bf215546Sopenharmony_ci      unsigned word1 : 32;
354bf215546Sopenharmony_ci      unsigned word2 : 9;
355bf215546Sopenharmony_ci   } discard;
356bf215546Sopenharmony_ci} ppir_codegen_field_branch;
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_civoid ppir_disassemble_instr(uint32_t *instr, unsigned offset, FILE *fp);
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_ci#endif
361