const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; \
assert(info->index_map[NIR_INTRINSIC_##flag] > 0); \
instr->const_index[info->index_map[NIR_INTRINSIC_##flag] - 1] = val; \
+} \
+static inline bool \
+nir_intrinsic_has_##name(nir_intrinsic_instr *instr) \
+{ \
+ const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; \
+ return info->index_map[NIR_INTRINSIC_##flag] > 0; \
}
INTRINSIC_IDX_ACCESSORS(write_mask, WRMASK, unsigned)
load->src[1] = nir_src_for_ssa(addr_to_offset(b, addr, addr_format));
}
- if (nir_intrinsic_infos[op].index_map[NIR_INTRINSIC_ACCESS] > 0)
+ if (nir_intrinsic_has_access(load))
nir_intrinsic_set_access(load, nir_intrinsic_access(intrin));
unsigned bit_size = intrin->dest.ssa.bit_size;
nir_intrinsic_set_write_mask(store, write_mask);
- if (nir_intrinsic_infos[op].index_map[NIR_INTRINSIC_ACCESS] > 0)
+ if (nir_intrinsic_has_access(store))
nir_intrinsic_set_access(store, nir_intrinsic_access(intrin));
/* TODO: We should try and provide a better alignment. For OpenCL, we need
/* Global atomics don't have access flags because they assume that the
* address may be non-uniform.
*/
- if (nir_intrinsic_infos[op].index_map[NIR_INTRINSIC_ACCESS] > 0)
+ if (nir_intrinsic_has_access(atomic))
nir_intrinsic_set_access(atomic, nir_intrinsic_access(intrin));
assert(intrin->dest.ssa.num_components == 1);
const int offset_units = value->bit_size / 8;
- if (info->index_map[NIR_INTRINSIC_ALIGN_MUL]) {
- assert(info->index_map[NIR_INTRINSIC_ALIGN_OFFSET]);
+ if (nir_intrinsic_has_align_mul(intr)) {
+ assert(nir_intrinsic_has_align_offset(intr));
unsigned align_mul = nir_intrinsic_align_mul(intr);
unsigned align_off = nir_intrinsic_align_offset(intr);
* instructions
*/
unsigned offset_adj = offset_units * first_component;
- if (info->index_map[NIR_INTRINSIC_BASE]) {
+ if (nir_intrinsic_has_base(intr)) {
nir_intrinsic_set_base(new_intr,
nir_intrinsic_base(intr) + offset_adj);
} else {
continue;
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
/* if no wrmask, then skip it: */
- if (!info->index_map[NIR_INTRINSIC_WRMASK])
+ if (!nir_intrinsic_has_write_mask(intr))
continue;
/* if wrmask is already contiguous, then nothing to do: */
nir_ssa_def *base = entry->info->base_src >= 0 ?
intrin->src[entry->info->base_src].ssa : NULL;
uint64_t offset = 0;
- if (nir_intrinsic_infos[intrin->intrinsic].index_map[NIR_INTRINSIC_BASE])
+ if (nir_intrinsic_has_base(intrin))
offset += nir_intrinsic_base(intrin);
entry->key = create_entry_key_from_offset(entry, base, 1, &offset);
entry->offset = offset;
if (entry->info->resource_src >= 0)
entry->key->resource = intrin->src[entry->info->resource_src].ssa;
- if (nir_intrinsic_infos[intrin->intrinsic].index_map[NIR_INTRINSIC_ACCESS])
+ if (nir_intrinsic_has_access(intrin))
entry->access = nir_intrinsic_access(intrin);
else if (entry->key->var)
entry->access = entry->key->var->data.access;
best_align = gcd(best_align, entry->key->offset_defs_mul[i]);
}
- if (nir_intrinsic_infos[entry->intrin->intrinsic].index_map[NIR_INTRINSIC_ALIGN_MUL])
+ if (nir_intrinsic_has_align_mul(entry->intrin))
best_align = MAX2(best_align, nir_intrinsic_align(entry->intrin));
/* ensure the result is a power of two that fits in a int32_t */
static bool update_align(struct entry *entry)
{
- bool has_align_index =
- nir_intrinsic_infos[entry->intrin->intrinsic].index_map[NIR_INTRINSIC_ALIGN_MUL];
- if (has_align_index) {
+ if (nir_intrinsic_has_align_mul(entry->intrin)) {
unsigned align = get_best_align(entry);
if (align != nir_intrinsic_align(entry->intrin)) {
nir_intrinsic_set_align(entry->intrin, align, 0);
}
/* update base/align */
- bool has_base_index =
- nir_intrinsic_infos[first->intrin->intrinsic].index_map[NIR_INTRINSIC_BASE];
-
- if (first != low && has_base_index)
+ if (first != low && nir_intrinsic_has_base(first->intrin))
nir_intrinsic_set_base(first->intrin, nir_intrinsic_base(low->intrin));
first->key = low->key;
}
/* update base/align */
- bool has_base_index =
- nir_intrinsic_infos[second->intrin->intrinsic].index_map[NIR_INTRINSIC_BASE];
-
- if (second != low && has_base_index)
+ if (second != low && nir_intrinsic_has_base(second->intrin))
nir_intrinsic_set_base(second->intrin, nir_intrinsic_base(low->intrin));
second->key = low->key;