[Mesa-dev] [PATCH 1/3] radeon/ac: add emit umsb shared code.
Edward O'Callaghan
funfunctor at folklore1984.net
Thu Feb 16 04:45:01 UTC 2017
This series is,
Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>
On 02/16/2017 02:55 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> Since we shared imsb, makes sense to share umsb.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/amd/common/ac_llvm_build.c | 25 +++++++++++++++++++++++++
> src/amd/common/ac_llvm_build.h | 4 ++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index dda2c0b..ed31a56 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -788,3 +788,28 @@ ac_emit_imsb(struct ac_llvm_context *ctx,
>
> return LLVMBuildSelect(ctx->builder, cond, all_ones, msb, "");
> }
> +
> +LLVMValueRef
> +ac_emit_umsb(struct ac_llvm_context *ctx,
> + LLVMValueRef arg,
> + LLVMTypeRef dst_type)
> +{
> + LLVMValueRef args[2] = {
> + arg,
> + LLVMConstInt(ctx->i32, 1, 0),
> + };
> + LLVMValueRef msb = ac_emit_llvm_intrinsic(ctx, "llvm.ctlz.i32",
> + dst_type, args, ARRAY_SIZE(args),
> + AC_FUNC_ATTR_READNONE);
> +
> + /* The HW returns the last bit index from MSB, but TGSI/NIR wants
> + * the index from LSB. Invert it by doing "31 - msb". */
> + msb = LLVMBuildSub(ctx->builder, LLVMConstInt(ctx->i32, 31, false),
> + msb, "");
> +
> + /* check for zero */
> + return LLVMBuildSelect(ctx->builder,
> + LLVMBuildICmp(ctx->builder, LLVMIntEQ, arg,
> + LLVMConstInt(ctx->i32, 0, 0), ""),
> + LLVMConstInt(ctx->i32, -1, true), msb, "");
> +}
> diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
> index 0ff04e4..3258e5e 100644
> --- a/src/amd/common/ac_llvm_build.h
> +++ b/src/amd/common/ac_llvm_build.h
> @@ -186,6 +186,10 @@ LLVMValueRef ac_emit_imsb(struct ac_llvm_context *ctx,
> LLVMValueRef arg,
> LLVMTypeRef dst_type);
>
> +LLVMValueRef ac_emit_umsb(struct ac_llvm_context *ctx,
> + LLVMValueRef arg,
> + LLVMTypeRef dst_type);
> +
> #ifdef __cplusplus
> }
> #endif
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170216/266785ef/attachment.sig>
More information about the mesa-dev
mailing list