mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
nir/search: Constify instruction parameter to search helpers
The search helps must *never* modify the instruction passed in, so let the compiler enforce this. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9378>
This commit is contained in:
parent
0f437e49c6
commit
c393ae9d84
2 changed files with 32 additions and 29 deletions
|
|
@ -95,8 +95,8 @@ typedef struct {
|
|||
* variables to require, for example, power-of-two in order for the search
|
||||
* to match.
|
||||
*/
|
||||
bool (*cond)(struct hash_table *range_ht, nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components, const uint8_t *swizzle);
|
||||
bool (*cond)(struct hash_table *range_ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components, const uint8_t *swizzle);
|
||||
|
||||
/** Swizzle (for replace only) */
|
||||
uint8_t swizzle[NIR_MAX_VEC_COMPONENTS];
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <math.h>
|
||||
|
||||
static inline bool
|
||||
is_pos_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
||||
is_pos_power_of_two(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
|
|
@ -65,7 +65,7 @@ is_pos_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_neg_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
||||
is_neg_power_of_two(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
|
|
@ -92,7 +92,8 @@ is_neg_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
|||
|
||||
#define MULTIPLE(test) \
|
||||
static inline bool \
|
||||
is_unsigned_multiple_of_ ## test(UNUSED struct hash_table *ht, nir_alu_instr *instr, \
|
||||
is_unsigned_multiple_of_ ## test(UNUSED struct hash_table *ht, \
|
||||
const nir_alu_instr *instr, \
|
||||
unsigned src, unsigned num_components, \
|
||||
const uint8_t *swizzle) \
|
||||
{ \
|
||||
|
|
@ -117,8 +118,8 @@ MULTIPLE(32)
|
|||
MULTIPLE(64)
|
||||
|
||||
static inline bool
|
||||
is_zero_to_one(UNUSED struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components,
|
||||
is_zero_to_one(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
/* only constant srcs: */
|
||||
|
|
@ -148,7 +149,7 @@ is_zero_to_one(UNUSED struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
* 1 while this function tests 0 < src < 1.
|
||||
*/
|
||||
static inline bool
|
||||
is_gt_0_and_lt_1(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
||||
is_gt_0_and_lt_1(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
|
|
@ -173,7 +174,7 @@ is_gt_0_and_lt_1(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_not_const_zero(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
||||
is_not_const_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
|
|
@ -202,15 +203,15 @@ is_not_const_zero(UNUSED struct hash_table *ht, nir_alu_instr *instr,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_not_const(UNUSED struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components,
|
||||
is_not_const(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, UNUSED unsigned num_components,
|
||||
UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
return !nir_src_is_const(instr->src[src].src);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_not_fmul(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_not_fmul(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
nir_alu_instr *src_alu =
|
||||
|
|
@ -226,7 +227,7 @@ is_not_fmul(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_fmul(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_fmul(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
nir_alu_instr *src_alu =
|
||||
|
|
@ -242,7 +243,7 @@ is_fmul(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_fsign(nir_alu_instr *instr, unsigned src,
|
||||
is_fsign(const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
nir_alu_instr *src_alu =
|
||||
|
|
@ -258,8 +259,9 @@ is_fsign(nir_alu_instr *instr, unsigned src,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_not_const_and_not_fsign(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components, const uint8_t *swizzle)
|
||||
is_not_const_and_not_fsign(struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
return is_not_const(ht, instr, src, num_components, swizzle) &&
|
||||
!is_fsign(instr, src, num_components, swizzle);
|
||||
|
|
@ -355,9 +357,9 @@ only_lower_16_bits_used(nir_alu_instr *instr)
|
|||
* of all its components is zero.
|
||||
*/
|
||||
static inline bool
|
||||
is_upper_half_zero(UNUSED struct hash_table *ht,
|
||||
nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components, const uint8_t *swizzle)
|
||||
is_upper_half_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
if (nir_src_as_const_value(instr->src[src].src) == NULL)
|
||||
return false;
|
||||
|
|
@ -380,9 +382,9 @@ is_upper_half_zero(UNUSED struct hash_table *ht,
|
|||
* of all its components is zero.
|
||||
*/
|
||||
static inline bool
|
||||
is_lower_half_zero(UNUSED struct hash_table *ht,
|
||||
nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components, const uint8_t *swizzle)
|
||||
is_lower_half_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components,
|
||||
const uint8_t *swizzle)
|
||||
{
|
||||
if (nir_src_as_const_value(instr->src[src].src) == NULL)
|
||||
return false;
|
||||
|
|
@ -410,7 +412,7 @@ no_unsigned_wrap(nir_alu_instr *instr)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_integral(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_integral(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
const struct ssa_result_range r = nir_analyze_range(ht, instr, src);
|
||||
|
|
@ -425,7 +427,7 @@ is_integral(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
* constant that is finite.
|
||||
*/
|
||||
static inline bool
|
||||
is_finite(UNUSED struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_finite(UNUSED struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
unsigned num_components, const uint8_t *swizzle)
|
||||
{
|
||||
if (nir_src_as_const_value(instr->src[src].src) == NULL)
|
||||
|
|
@ -454,8 +456,9 @@ is_finite(UNUSED struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
|
||||
#define RELATION(r) \
|
||||
static inline bool \
|
||||
is_ ## r (struct hash_table *ht, nir_alu_instr *instr, unsigned src, \
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle) \
|
||||
is_ ## r (struct hash_table *ht, const nir_alu_instr *instr, \
|
||||
unsigned src, UNUSED unsigned num_components, \
|
||||
UNUSED const uint8_t *swizzle) \
|
||||
{ \
|
||||
const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \
|
||||
return v.range == r; \
|
||||
|
|
@ -468,7 +471,7 @@ RELATION(ge_zero)
|
|||
RELATION(ne_zero)
|
||||
|
||||
static inline bool
|
||||
is_not_negative(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_not_negative(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||
|
|
@ -476,7 +479,7 @@ is_not_negative(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_not_positive(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_not_positive(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||
|
|
@ -484,7 +487,7 @@ is_not_positive(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_not_zero(struct hash_table *ht, nir_alu_instr *instr, unsigned src,
|
||||
is_not_zero(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||
{
|
||||
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue