ac/nir: implement 16-bit pack/unpack opcodes
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 6 Dec 2018 14:40:23 +0000 (14:40 +0000)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 22 Mar 2019 11:50:16 +0000 (12:50 +0100)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_nir_to_llvm.c

index 37ef50fabaf3905b9a684217b04a4bf91ec81d0b..675623cbfeb7356498c153c05fdcaaeb0af8abe9 100644 (file)
@@ -1034,6 +1034,30 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
                break;
        }
 
+       case nir_op_pack_32_2x16_split: {
+               LLVMValueRef tmp = ac_build_gather_values(&ctx->ac, src, 2);
+               result = LLVMBuildBitCast(ctx->ac.builder, tmp, ctx->ac.i32, "");
+               break;
+       }
+
+       case nir_op_unpack_32_2x16_split_x: {
+               LLVMValueRef tmp = LLVMBuildBitCast(ctx->ac.builder, src[0],
+                                                   ctx->ac.v2i16,
+                                                   "");
+               result = LLVMBuildExtractElement(ctx->ac.builder, tmp,
+                                                ctx->ac.i32_0, "");
+               break;
+       }
+
+       case nir_op_unpack_32_2x16_split_y: {
+               LLVMValueRef tmp = LLVMBuildBitCast(ctx->ac.builder, src[0],
+                                                   ctx->ac.v2i16,
+                                                   "");
+               result = LLVMBuildExtractElement(ctx->ac.builder, tmp,
+                                                ctx->ac.i32_1, "");
+               break;
+       }
+
        case nir_op_cube_face_coord: {
                src[0] = ac_to_float(&ctx->ac, src[0]);
                LLVMValueRef results[2];