nir: Add {i2f, u2f, f2i, f2u} helpers
Convenient for bitsize independent lowerings, will be used in the idiv lowering. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8339>
This commit is contained in:

committed by
Marge Bot

parent
6b19711645
commit
e4da24bd24
@@ -1713,4 +1713,32 @@ nir_f2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
|
||||
return nir_convert_to_bit_size(b, src, nir_type_float, bit_size);
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_i2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
|
||||
{
|
||||
return nir_type_convert(b, src, nir_type_int,
|
||||
(nir_alu_type) (nir_type_float | bit_size));
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_u2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
|
||||
{
|
||||
return nir_type_convert(b, src, nir_type_uint,
|
||||
(nir_alu_type) (nir_type_float | bit_size));
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_f2uN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
|
||||
{
|
||||
return nir_type_convert(b, src, nir_type_float,
|
||||
(nir_alu_type) (nir_type_uint | bit_size));
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_f2iN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
|
||||
{
|
||||
return nir_type_convert(b, src, nir_type_float,
|
||||
(nir_alu_type) (nir_type_int | bit_size));
|
||||
}
|
||||
|
||||
#endif /* NIR_BUILDER_H */
|
||||
|
Reference in New Issue
Block a user