17e102996Smaya/*
27e102996Smaya * Copyright (C) 2017-2018 Rob Clark <robclark@freedesktop.org>
37e102996Smaya *
47e102996Smaya * Permission is hereby granted, free of charge, to any person obtaining a
57e102996Smaya * copy of this software and associated documentation files (the "Software"),
67e102996Smaya * to deal in the Software without restriction, including without limitation
77e102996Smaya * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87e102996Smaya * and/or sell copies of the Software, and to permit persons to whom the
97e102996Smaya * Software is furnished to do so, subject to the following conditions:
107e102996Smaya *
117e102996Smaya * The above copyright notice and this permission notice (including the next
127e102996Smaya * paragraph) shall be included in all copies or substantial portions of the
137e102996Smaya * Software.
147e102996Smaya *
157e102996Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167e102996Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177e102996Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
187e102996Smaya * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
197e102996Smaya * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
207e102996Smaya * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
217e102996Smaya * SOFTWARE.
227e102996Smaya *
237e102996Smaya * Authors:
247e102996Smaya *    Rob Clark <robclark@freedesktop.org>
257e102996Smaya */
267e102996Smaya
277ec681f3Smrg/* 500 gets us LDIB but doesn't change any other a4xx instructions */
287ec681f3Smrg#define GPU 500
297e102996Smaya
307e102996Smaya#include "ir3_context.h"
317e102996Smaya#include "ir3_image.h"
327e102996Smaya
337e102996Smaya/*
347e102996Smaya * Handlers for instructions changed/added in a4xx:
357e102996Smaya */
367e102996Smaya
377e102996Smaya/* src[] = { buffer_index, offset }. No const_index */
387e102996Smayastatic void
397e102996Smayaemit_intrinsic_load_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr,
407ec681f3Smrg                         struct ir3_instruction **dst)
417e102996Smaya{
427ec681f3Smrg   struct ir3_block *b = ctx->block;
437ec681f3Smrg   struct ir3_instruction *ldgb, *src0, *src1, *byte_offset, *offset;
447ec681f3Smrg
457ec681f3Smrg   struct ir3_instruction *ssbo = ir3_ssbo_to_ibo(ctx, intr->src[0]);
467ec681f3Smrg
477ec681f3Smrg   byte_offset = ir3_get_src(ctx, &intr->src[1])[0];
487ec681f3Smrg   offset = ir3_get_src(ctx, &intr->src[2])[0];
497ec681f3Smrg
507ec681f3Smrg   /* src0 is uvec2(offset*4, 0), src1 is offset.. nir already *= 4: */
517ec681f3Smrg   src0 = ir3_collect(b, byte_offset, create_immed(b, 0));
527ec681f3Smrg   src1 = offset;
537ec681f3Smrg
547ec681f3Smrg   ldgb = ir3_LDGB(b, ssbo, 0, src0, 0, src1, 0);
557ec681f3Smrg   ldgb->dsts[0]->wrmask = MASK(intr->num_components);
567ec681f3Smrg   ldgb->cat6.iim_val = intr->num_components;
577ec681f3Smrg   ldgb->cat6.d = 4;
587ec681f3Smrg   ldgb->cat6.type = TYPE_U32;
597ec681f3Smrg   ldgb->barrier_class = IR3_BARRIER_BUFFER_R;
607ec681f3Smrg   ldgb->barrier_conflict = IR3_BARRIER_BUFFER_W;
617ec681f3Smrg
627ec681f3Smrg   ir3_split_dest(b, dst, ldgb, 0, intr->num_components);
637e102996Smaya}
647e102996Smaya
657e102996Smaya/* src[] = { value, block_index, offset }. const_index[] = { write_mask } */
667e102996Smayastatic void
677e102996Smayaemit_intrinsic_store_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
687e102996Smaya{
697ec681f3Smrg   struct ir3_block *b = ctx->block;
707ec681f3Smrg   struct ir3_instruction *stgb, *src0, *src1, *src2, *byte_offset, *offset;
717ec681f3Smrg   unsigned wrmask = nir_intrinsic_write_mask(intr);
727ec681f3Smrg   unsigned ncomp = ffs(~wrmask) - 1;
737ec681f3Smrg
747ec681f3Smrg   assert(wrmask == BITFIELD_MASK(intr->num_components));
757ec681f3Smrg
767ec681f3Smrg   struct ir3_instruction *ssbo = ir3_ssbo_to_ibo(ctx, intr->src[1]);
777ec681f3Smrg
787ec681f3Smrg   byte_offset = ir3_get_src(ctx, &intr->src[2])[0];
797ec681f3Smrg   offset = ir3_get_src(ctx, &intr->src[3])[0];
807ec681f3Smrg
817ec681f3Smrg   /* src0 is value, src1 is offset, src2 is uvec2(offset*4, 0)..
827ec681f3Smrg    * nir already *= 4:
837ec681f3Smrg    */
847ec681f3Smrg   src0 = ir3_create_collect(b, ir3_get_src(ctx, &intr->src[0]), ncomp);
857ec681f3Smrg   src1 = offset;
867ec681f3Smrg   src2 = ir3_collect(b, byte_offset, create_immed(b, 0));
877ec681f3Smrg
887ec681f3Smrg   stgb = ir3_STGB(b, ssbo, 0, src0, 0, src1, 0, src2, 0);
897ec681f3Smrg   stgb->cat6.iim_val = ncomp;
907ec681f3Smrg   stgb->cat6.d = 4;
917ec681f3Smrg   stgb->cat6.type = TYPE_U32;
927ec681f3Smrg   stgb->barrier_class = IR3_BARRIER_BUFFER_W;
937ec681f3Smrg   stgb->barrier_conflict = IR3_BARRIER_BUFFER_R | IR3_BARRIER_BUFFER_W;
947ec681f3Smrg
957ec681f3Smrg   array_insert(b, b->keeps, stgb);
967e102996Smaya}
977e102996Smaya
987e102996Smaya/*
997e102996Smaya * SSBO atomic intrinsics
1007e102996Smaya *
1017e102996Smaya * All of the SSBO atomic memory operations read a value from memory,
1027e102996Smaya * compute a new value using one of the operations below, write the new
1037e102996Smaya * value to memory, and return the original value read.
1047e102996Smaya *
1057e102996Smaya * All operations take 3 sources except CompSwap that takes 4. These
1067e102996Smaya * sources represent:
1077e102996Smaya *
1087e102996Smaya * 0: The SSBO buffer index.
1097ec681f3Smrg * 1: The byte offset into the SSBO buffer of the variable that the atomic
1107e102996Smaya *    operation will operate on.
1117e102996Smaya * 2: The data parameter to the atomic function (i.e. the value to add
1127e102996Smaya *    in ssbo_atomic_add, etc).
1137ec681f3Smrg * 3: CompSwap: the second data parameter.
1147ec681f3Smrg *    Non-CompSwap: The dword offset into the SSBO buffer variable.
1157ec681f3Smrg * 4: CompSwap: The dword offset into the SSBO buffer variable.
1167ec681f3Smrg *
1177ec681f3Smrg * We use custom ssbo_*_ir3 intrinsics generated by ir3_nir_lower_io_offsets()
1187ec681f3Smrg * so we can have the dword offset generated in NIR.
1197e102996Smaya */
1207e102996Smayastatic struct ir3_instruction *
1217e102996Smayaemit_intrinsic_atomic_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
1227e102996Smaya{
1237ec681f3Smrg   struct ir3_block *b = ctx->block;
1247ec681f3Smrg   struct ir3_instruction *atomic;
1257ec681f3Smrg   type_t type = TYPE_U32;
1267ec681f3Smrg
1277ec681f3Smrg   struct ir3_instruction *ssbo = ir3_ssbo_to_ibo(ctx, intr->src[0]);
1287ec681f3Smrg
1297ec681f3Smrg   struct ir3_instruction *data = ir3_get_src(ctx, &intr->src[2])[0];
1307ec681f3Smrg   /* 64b byte offset */
1317ec681f3Smrg   struct ir3_instruction *byte_offset =
1327ec681f3Smrg      ir3_collect(b, ir3_get_src(ctx, &intr->src[1])[0], create_immed(b, 0));
1337ec681f3Smrg   /* dword offset for everything but comp_swap */
1347ec681f3Smrg   struct ir3_instruction *src3 = ir3_get_src(ctx, &intr->src[3])[0];
1357ec681f3Smrg
1367ec681f3Smrg   switch (intr->intrinsic) {
1377ec681f3Smrg   case nir_intrinsic_ssbo_atomic_add_ir3:
1387ec681f3Smrg      atomic = ir3_ATOMIC_ADD_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1397ec681f3Smrg      break;
1407ec681f3Smrg   case nir_intrinsic_ssbo_atomic_imin_ir3:
1417ec681f3Smrg      atomic = ir3_ATOMIC_MIN_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1427ec681f3Smrg      type = TYPE_S32;
1437ec681f3Smrg      break;
1447ec681f3Smrg   case nir_intrinsic_ssbo_atomic_umin_ir3:
1457ec681f3Smrg      atomic = ir3_ATOMIC_MIN_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1467ec681f3Smrg      break;
1477ec681f3Smrg   case nir_intrinsic_ssbo_atomic_imax_ir3:
1487ec681f3Smrg      atomic = ir3_ATOMIC_MAX_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1497ec681f3Smrg      type = TYPE_S32;
1507ec681f3Smrg      break;
1517ec681f3Smrg   case nir_intrinsic_ssbo_atomic_umax_ir3:
1527ec681f3Smrg      atomic = ir3_ATOMIC_MAX_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1537ec681f3Smrg      break;
1547ec681f3Smrg   case nir_intrinsic_ssbo_atomic_and_ir3:
1557ec681f3Smrg      atomic = ir3_ATOMIC_AND_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1567ec681f3Smrg      break;
1577ec681f3Smrg   case nir_intrinsic_ssbo_atomic_or_ir3:
1587ec681f3Smrg      atomic = ir3_ATOMIC_OR_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1597ec681f3Smrg      break;
1607ec681f3Smrg   case nir_intrinsic_ssbo_atomic_xor_ir3:
1617ec681f3Smrg      atomic = ir3_ATOMIC_XOR_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1627ec681f3Smrg      break;
1637ec681f3Smrg   case nir_intrinsic_ssbo_atomic_exchange_ir3:
1647ec681f3Smrg      atomic = ir3_ATOMIC_XCHG_G(b, ssbo, 0, data, 0, src3, 0, byte_offset, 0);
1657ec681f3Smrg      break;
1667ec681f3Smrg   case nir_intrinsic_ssbo_atomic_comp_swap_ir3:
1677ec681f3Smrg      /* for cmpxchg, src0 is [ui]vec2(data, compare): */
1687ec681f3Smrg      data = ir3_collect(b, src3, data);
1697ec681f3Smrg      struct ir3_instruction *dword_offset = ir3_get_src(ctx, &intr->src[4])[0];
1707ec681f3Smrg      atomic = ir3_ATOMIC_CMPXCHG_G(b, ssbo, 0, data, 0, dword_offset, 0,
1717ec681f3Smrg                                    byte_offset, 0);
1727ec681f3Smrg      break;
1737ec681f3Smrg   default:
1747ec681f3Smrg      unreachable("boo");
1757ec681f3Smrg   }
1767ec681f3Smrg
1777ec681f3Smrg   atomic->cat6.iim_val = 1;
1787ec681f3Smrg   atomic->cat6.d = 4;
1797ec681f3Smrg   atomic->cat6.type = type;
1807ec681f3Smrg   atomic->barrier_class = IR3_BARRIER_BUFFER_W;
1817ec681f3Smrg   atomic->barrier_conflict = IR3_BARRIER_BUFFER_R | IR3_BARRIER_BUFFER_W;
1827ec681f3Smrg
1837ec681f3Smrg   /* even if nothing consume the result, we can't DCE the instruction: */
1847ec681f3Smrg   array_insert(b, b->keeps, atomic);
1857ec681f3Smrg
1867ec681f3Smrg   return atomic;
1877e102996Smaya}
1887e102996Smaya
1897e102996Smayastatic struct ir3_instruction *
1907ec681f3Smrgget_image_offset(struct ir3_context *ctx, const nir_intrinsic_instr *instr,
1917ec681f3Smrg                 struct ir3_instruction *const *coords, bool byteoff)
1927ec681f3Smrg{
1937ec681f3Smrg   struct ir3_block *b = ctx->block;
1947ec681f3Smrg   struct ir3_instruction *offset;
1957ec681f3Smrg   unsigned index = nir_src_as_uint(instr->src[0]);
1967ec681f3Smrg   unsigned ncoords = ir3_get_image_coords(instr, NULL);
1977ec681f3Smrg
1987ec681f3Smrg   /* to calculate the byte offset (yes, uggg) we need (up to) three
1997ec681f3Smrg    * const values to know the bytes per pixel, and y and z stride:
2007ec681f3Smrg    */
2017ec681f3Smrg   const struct ir3_const_state *const_state = ir3_const_state(ctx->so);
2027ec681f3Smrg   unsigned cb = regid(const_state->offsets.image_dims, 0) +
2037ec681f3Smrg                 const_state->image_dims.off[index];
2047ec681f3Smrg
2057ec681f3Smrg   debug_assert(const_state->image_dims.mask & (1 << index));
2067ec681f3Smrg
2077ec681f3Smrg   /* offset = coords.x * bytes_per_pixel: */
2087ec681f3Smrg   offset = ir3_MUL_S24(b, coords[0], 0, create_uniform(b, cb + 0), 0);
2097ec681f3Smrg   if (ncoords > 1) {
2107ec681f3Smrg      /* offset += coords.y * y_pitch: */
2117ec681f3Smrg      offset =
2127ec681f3Smrg         ir3_MAD_S24(b, create_uniform(b, cb + 1), 0, coords[1], 0, offset, 0);
2137ec681f3Smrg   }
2147ec681f3Smrg   if (ncoords > 2) {
2157ec681f3Smrg      /* offset += coords.z * z_pitch: */
2167ec681f3Smrg      offset =
2177ec681f3Smrg         ir3_MAD_S24(b, create_uniform(b, cb + 2), 0, coords[2], 0, offset, 0);
2187ec681f3Smrg   }
2197ec681f3Smrg
2207ec681f3Smrg   if (!byteoff) {
2217ec681f3Smrg      /* Some cases, like atomics, seem to use dword offset instead
2227ec681f3Smrg       * of byte offsets.. blob just puts an extra shr.b in there
2237ec681f3Smrg       * in those cases:
2247ec681f3Smrg       */
2257ec681f3Smrg      offset = ir3_SHR_B(b, offset, 0, create_immed(b, 2), 0);
2267ec681f3Smrg   }
2277ec681f3Smrg
2287ec681f3Smrg   return ir3_collect(b, offset, create_immed(b, 0));
2297ec681f3Smrg}
2307ec681f3Smrg
2317ec681f3Smrg/* src[] = { deref, coord, sample_index }. const_index[] = {} */
2327ec681f3Smrgstatic void
2337ec681f3Smrgemit_intrinsic_load_image(struct ir3_context *ctx, nir_intrinsic_instr *intr,
2347ec681f3Smrg                          struct ir3_instruction **dst)
2357e102996Smaya{
2367ec681f3Smrg   struct ir3_block *b = ctx->block;
2377ec681f3Smrg   struct ir3_instruction *const *coords = ir3_get_src(ctx, &intr->src[1]);
2387ec681f3Smrg   struct ir3_instruction *ibo = ir3_image_to_ibo(ctx, intr->src[0]);
2397ec681f3Smrg   struct ir3_instruction *offset = get_image_offset(ctx, intr, coords, true);
2407ec681f3Smrg   unsigned ncoords = ir3_get_image_coords(intr, NULL);
2417ec681f3Smrg   unsigned ncomp =
2427ec681f3Smrg      ir3_get_num_components_for_image_format(nir_intrinsic_format(intr));
2437ec681f3Smrg
2447ec681f3Smrg   struct ir3_instruction *ldib = ir3_LDIB(
2457ec681f3Smrg      b, ibo, 0, offset, 0, ir3_create_collect(b, coords, ncoords), 0);
2467ec681f3Smrg   ldib->dsts[0]->wrmask = MASK(intr->num_components);
2477ec681f3Smrg   ldib->cat6.iim_val = ncomp;
2487ec681f3Smrg   ldib->cat6.d = ncoords;
2497ec681f3Smrg   ldib->cat6.type = ir3_get_type_for_image_intrinsic(intr);
2507ec681f3Smrg   ldib->cat6.typed = true;
2517ec681f3Smrg   ldib->barrier_class = IR3_BARRIER_IMAGE_R;
2527ec681f3Smrg   ldib->barrier_conflict = IR3_BARRIER_IMAGE_W;
2537ec681f3Smrg
2547ec681f3Smrg   ir3_split_dest(b, dst, ldib, 0, intr->num_components);
2557e102996Smaya}
2567e102996Smaya
2577ec681f3Smrg/* src[] = { index, coord, sample_index, value }. const_index[] = {} */
2587e102996Smayastatic void
2597e102996Smayaemit_intrinsic_store_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
2607e102996Smaya{
2617ec681f3Smrg   struct ir3_block *b = ctx->block;
2627ec681f3Smrg   struct ir3_instruction *stib, *offset;
2637ec681f3Smrg   struct ir3_instruction *const *value = ir3_get_src(ctx, &intr->src[3]);
2647ec681f3Smrg   struct ir3_instruction *const *coords = ir3_get_src(ctx, &intr->src[1]);
2657ec681f3Smrg   struct ir3_instruction *ibo = ir3_image_to_ibo(ctx, intr->src[0]);
2667ec681f3Smrg   unsigned ncoords = ir3_get_image_coords(intr, NULL);
2677ec681f3Smrg   unsigned ncomp =
2687ec681f3Smrg      ir3_get_num_components_for_image_format(nir_intrinsic_format(intr));
2697ec681f3Smrg
2707ec681f3Smrg   /* src0 is value
2717ec681f3Smrg    * src1 is coords
2727ec681f3Smrg    * src2 is 64b byte offset
2737ec681f3Smrg    */
2747ec681f3Smrg
2757ec681f3Smrg   offset = get_image_offset(ctx, intr, coords, true);
2767ec681f3Smrg
2777ec681f3Smrg   /* NOTE: stib seems to take byte offset, but stgb.typed can be used
2787ec681f3Smrg    * too and takes a dword offset.. not quite sure yet why blob uses
2797ec681f3Smrg    * one over the other in various cases.
2807ec681f3Smrg    */
2817ec681f3Smrg
2827ec681f3Smrg   stib = ir3_STIB(b, ibo, 0, ir3_create_collect(b, value, ncomp), 0,
2837ec681f3Smrg                   ir3_create_collect(b, coords, ncoords), 0, offset, 0);
2847ec681f3Smrg   stib->cat6.iim_val = ncomp;
2857ec681f3Smrg   stib->cat6.d = ncoords;
2867ec681f3Smrg   stib->cat6.type = ir3_get_type_for_image_intrinsic(intr);
2877ec681f3Smrg   stib->cat6.typed = true;
2887ec681f3Smrg   stib->barrier_class = IR3_BARRIER_IMAGE_W;
2897ec681f3Smrg   stib->barrier_conflict = IR3_BARRIER_IMAGE_R | IR3_BARRIER_IMAGE_W;
2907ec681f3Smrg
2917ec681f3Smrg   array_insert(b, b->keeps, stib);
2927e102996Smaya}
2937e102996Smaya
2947e102996Smaya/* src[] = { deref, coord, sample_index, value, compare }. const_index[] = {} */
2957e102996Smayastatic struct ir3_instruction *
2967e102996Smayaemit_intrinsic_atomic_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
2977e102996Smaya{
2987ec681f3Smrg   struct ir3_block *b = ctx->block;
2997ec681f3Smrg   struct ir3_instruction *atomic, *src0, *src1, *src2;
3007ec681f3Smrg   struct ir3_instruction *const *coords = ir3_get_src(ctx, &intr->src[1]);
3017ec681f3Smrg   struct ir3_instruction *image = ir3_image_to_ibo(ctx, intr->src[0]);
3027ec681f3Smrg   unsigned ncoords = ir3_get_image_coords(intr, NULL);
3037ec681f3Smrg
3047ec681f3Smrg   /* src0 is value (or uvec2(value, compare))
3057ec681f3Smrg    * src1 is coords
3067ec681f3Smrg    * src2 is 64b byte offset
3077ec681f3Smrg    */
3087ec681f3Smrg   src0 = ir3_get_src(ctx, &intr->src[3])[0];
3097ec681f3Smrg   src1 = ir3_create_collect(b, coords, ncoords);
3107ec681f3Smrg   src2 = get_image_offset(ctx, intr, coords, false);
3117ec681f3Smrg
3127ec681f3Smrg   switch (intr->intrinsic) {
3137ec681f3Smrg   case nir_intrinsic_image_atomic_add:
3147ec681f3Smrg      atomic = ir3_ATOMIC_ADD_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3157ec681f3Smrg      break;
3167ec681f3Smrg   case nir_intrinsic_image_atomic_imin:
3177ec681f3Smrg   case nir_intrinsic_image_atomic_umin:
3187ec681f3Smrg      atomic = ir3_ATOMIC_MIN_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3197ec681f3Smrg      break;
3207ec681f3Smrg   case nir_intrinsic_image_atomic_imax:
3217ec681f3Smrg   case nir_intrinsic_image_atomic_umax:
3227ec681f3Smrg      atomic = ir3_ATOMIC_MAX_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3237ec681f3Smrg      break;
3247ec681f3Smrg   case nir_intrinsic_image_atomic_and:
3257ec681f3Smrg      atomic = ir3_ATOMIC_AND_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3267ec681f3Smrg      break;
3277ec681f3Smrg   case nir_intrinsic_image_atomic_or:
3287ec681f3Smrg      atomic = ir3_ATOMIC_OR_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3297ec681f3Smrg      break;
3307ec681f3Smrg   case nir_intrinsic_image_atomic_xor:
3317ec681f3Smrg      atomic = ir3_ATOMIC_XOR_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3327ec681f3Smrg      break;
3337ec681f3Smrg   case nir_intrinsic_image_atomic_exchange:
3347ec681f3Smrg      atomic = ir3_ATOMIC_XCHG_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3357ec681f3Smrg      break;
3367ec681f3Smrg   case nir_intrinsic_image_atomic_comp_swap:
3377ec681f3Smrg      /* for cmpxchg, src0 is [ui]vec2(data, compare): */
3387ec681f3Smrg      src0 = ir3_collect(b, ir3_get_src(ctx, &intr->src[4])[0], src0);
3397ec681f3Smrg      atomic = ir3_ATOMIC_CMPXCHG_G(b, image, 0, src0, 0, src1, 0, src2, 0);
3407ec681f3Smrg      break;
3417ec681f3Smrg   default:
3427ec681f3Smrg      unreachable("boo");
3437ec681f3Smrg   }
3447ec681f3Smrg
3457ec681f3Smrg   atomic->cat6.iim_val = 1;
3467ec681f3Smrg   atomic->cat6.d = ncoords;
3477ec681f3Smrg   atomic->cat6.type = ir3_get_type_for_image_intrinsic(intr);
3487ec681f3Smrg   atomic->cat6.typed = true;
3497ec681f3Smrg   atomic->barrier_class = IR3_BARRIER_IMAGE_W;
3507ec681f3Smrg   atomic->barrier_conflict = IR3_BARRIER_IMAGE_R | IR3_BARRIER_IMAGE_W;
3517ec681f3Smrg
3527ec681f3Smrg   /* even if nothing consume the result, we can't DCE the instruction: */
3537ec681f3Smrg   array_insert(b, b->keeps, atomic);
3547ec681f3Smrg
3557ec681f3Smrg   return atomic;
3567e102996Smaya}
3577e102996Smaya
3587e102996Smayaconst struct ir3_context_funcs ir3_a4xx_funcs = {
3597ec681f3Smrg   .emit_intrinsic_load_ssbo = emit_intrinsic_load_ssbo,
3607ec681f3Smrg   .emit_intrinsic_store_ssbo = emit_intrinsic_store_ssbo,
3617ec681f3Smrg   .emit_intrinsic_atomic_ssbo = emit_intrinsic_atomic_ssbo,
3627ec681f3Smrg   .emit_intrinsic_load_image = emit_intrinsic_load_image,
3637ec681f3Smrg   .emit_intrinsic_store_image = emit_intrinsic_store_image,
3647ec681f3Smrg   .emit_intrinsic_atomic_image = emit_intrinsic_atomic_image,
3657ec681f3Smrg   .emit_intrinsic_image_size = emit_intrinsic_image_size_tex,
3667ec681f3Smrg   .emit_intrinsic_load_global_ir3 = NULL,
3677ec681f3Smrg   .emit_intrinsic_store_global_ir3 = NULL,
3687e102996Smaya};
369