| 1 |
/* |
| 2 |
* Copyright 2022 Alyssa Rosenzweig |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#include "compiler/nir/nir_builder.h" |
| 7 |
#include "agx_compiler.h" |
| 8 |
|
| 9 |
/* Local memory instructions require 16-bit offsets, so we add conversions. */ |
| 10 |
static bool |
| 11 |
pass(struct nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) |
| 12 |
{ |
| 13 |
nir_src *offset = nir_get_io_offset_src(intr); |
| 14 |
if (!nir_is_shared_access(intr) || nir_src_bit_size(*offset) == 16) |
| 15 |
return false; |
| 16 |
|
| 17 |
b->cursor = nir_before_instr(&intr->instr); |
| 18 |
nir_src_rewrite(offset, nir_u2u16(b, offset->ssa)); |
| 19 |
return true; |
| 20 |
} |
| 21 |
|
| 22 |
bool |
| 23 |
agx_nir_lower_shared_bitsize(nir_shader *shader) |
| 24 |
{ |
| 25 |
return nir_shader_intrinsics_pass(shader, pass, nir_metadata_control_flow, |
| 26 |
NULL); |
| 27 |
} |