On 31 January 2017 at 17:35, Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> wrote:
> Signed-off-by: Bas Nieuwenhuizen <ba...@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 <airl...@redhat.com>

Dave.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to