nir: Add nir_alu_src_as_uint helper

We have a few ALU instructions that take a constant source. Technically, they
have a swizzle so you can't just nir_src_as_uint them, even though a bunch of
backends do. To help backends do the right thing, add a helper that's just as
easy to use that will chase the swizzle properly.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22695>
This commit is contained in:
Alyssa Rosenzweig
2023-04-25 14:39:23 -04:00
parent 7381405095
commit 0eb5f8e765
+7
View File
@@ -2725,6 +2725,13 @@ nir_ssa_scalar_resolved(nir_ssa_def *def, unsigned channel)
return nir_ssa_scalar_chase_movs(nir_get_ssa_scalar(def, channel));
}
static inline uint64_t
nir_alu_src_as_uint(nir_alu_src src)
{
assert(src.src.is_ssa && "precondition");
nir_ssa_scalar scalar = nir_get_ssa_scalar(src.src.ssa, src.swizzle[0]);
return nir_ssa_scalar_as_uint(scalar);
}
typedef struct {
bool success;