[Mesa-dev] [PATCH 1/6] ac/nir: Add core Float64 support.

Dave Airlie airlied at gmail.com
Tue Jan 31 23:14:33 UTC 2017


On 31 January 2017 at 17:35, Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl> wrote:
> Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
> ---
>  src/amd/common/ac_nir_to_llvm.c | 173 ++++++++++++++++++++++++++++++----------
>  1 file changed, 129 insertions(+), 44 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index c22529741fa..1b23a065633 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -119,6 +119,7 @@ struct nir_to_llvm_context {
>         LLVMTypeRef v3i32;
>         LLVMTypeRef v4i32;
>         LLVMTypeRef v8i32;
> +       LLVMTypeRef f64;
>         LLVMTypeRef f32;
>         LLVMTypeRef f16;
>         LLVMTypeRef v2f32;
> @@ -313,34 +314,78 @@ static LLVMValueRef get_shared_memory_ptr(struct nir_to_llvm_context *ctx,
>         return ptr;
>  }
>
> +static LLVMTypeRef to_integer_type_scalar(struct nir_to_llvm_context *ctx, LLVMTypeRef t)
> +{
> +       if (t == ctx->f16 || t == ctx->i16)
> +               return ctx->i16;
> +       else if (t == ctx->f32 || t == ctx->i32)
> +               return ctx->i32;
> +       else if (t == ctx->f64 || t == ctx->i64)
> +               return ctx->i64;
> +       else
> +               unreachable("Unhandled integer size");
> +}
> +
> +static LLVMTypeRef to_integer_type(struct nir_to_llvm_context *ctx, LLVMTypeRef t)
> +{
> +       if (LLVMGetTypeKind(t) == LLVMVectorTypeKind) {
> +               LLVMTypeRef elem_type = LLVMGetElementType(t);
> +               return LLVMVectorType(to_integer_type_scalar(ctx, elem_type),
> +                                     LLVMGetVectorSize(t));
> +       }
> +       return to_integer_type_scalar(ctx, t);
> +}
> +
>  static LLVMValueRef to_integer(struct nir_to_llvm_context *ctx, LLVMValueRef v)
>  {
>         LLVMTypeRef type = LLVMTypeOf(v);
> -       if (type == ctx->f32) {
> -               return LLVMBuildBitCast(ctx->builder, v, ctx->i32, "");
> -       } else if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) {
> -               LLVMTypeRef elem_type = LLVMGetElementType(type);
> -               if (elem_type == ctx->f32) {
> -                       LLVMTypeRef nt = LLVMVectorType(ctx->i32, LLVMGetVectorSize(type));
> -                       return LLVMBuildBitCast(ctx->builder, v, nt, "");
> -               }
> +       return LLVMBuildBitCast(ctx->builder, v, to_integer_type(ctx, type), "");
> +}
> +
> +static LLVMTypeRef to_float_type_scalar(struct nir_to_llvm_context *ctx, LLVMTypeRef t)
> +{
> +       if (t == ctx->i16 || t == ctx->f16)
> +               return ctx->f16;
> +       else if (t == ctx->i32 || t == ctx->f32)
> +               return ctx->f32;
> +       else if(t == ctx->i64 || t == ctx->f64)

^ missing space after the if

Otherwise I've read over all 6 and they look good,

Reviewed-by: Dave Airlie <airlied at redhat.com>

Dave.


More information about the mesa-dev mailing list