ac: replace SI.export with amdgcn.exp.*
authorMarek Olšák <marek.olsak@amd.com>
Thu, 23 Feb 2017 01:15:54 +0000 (02:15 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 3 Mar 2017 14:29:30 +0000 (15:29 +0100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_llvm_build.c
src/gallium/drivers/radeonsi/si_shader.c

index fae551055ed07b3d6dcd3370f4ab56026d4fc7dc..bd1b63d40fae25571e7b97206db04ad3e595fa14 100644 (file)
@@ -891,6 +891,37 @@ void ac_emit_export(struct ac_llvm_context *ctx, struct ac_export_args *a)
 {
        LLVMValueRef args[9];
 
+       if (HAVE_LLVM >= 0x0500) {
+               args[0] = LLVMConstInt(ctx->i32, a->target, 0);
+               args[1] = LLVMConstInt(ctx->i32, a->enabled_channels, 0);
+
+               if (a->compr) {
+                       LLVMTypeRef i16 = LLVMInt16TypeInContext(ctx->context);
+                       LLVMTypeRef v2i16 = LLVMVectorType(i16, 2);
+
+                       args[2] = LLVMBuildBitCast(ctx->builder, a->out[0],
+                                                  v2i16, "");
+                       args[3] = LLVMBuildBitCast(ctx->builder, a->out[1],
+                                                  v2i16, "");
+                       args[4] = LLVMConstInt(ctx->i1, a->done, 0);
+                       args[5] = LLVMConstInt(ctx->i1, a->valid_mask, 0);
+
+                       ac_emit_llvm_intrinsic(ctx, "llvm.amdgcn.exp.compr.v2i16",
+                                              ctx->voidt, args, 6, 0);
+               } else {
+                       args[2] = a->out[0];
+                       args[3] = a->out[1];
+                       args[4] = a->out[2];
+                       args[5] = a->out[3];
+                       args[6] = LLVMConstInt(ctx->i1, a->done, 0);
+                       args[7] = LLVMConstInt(ctx->i1, a->valid_mask, 0);
+
+                       ac_emit_llvm_intrinsic(ctx, "llvm.amdgcn.exp.f32",
+                                              ctx->voidt, args, 8, 0);
+               }
+               return;
+       }
+
        args[0] = LLVMConstInt(ctx->i32, a->enabled_channels, 0);
        args[1] = LLVMConstInt(ctx->i32, a->valid_mask, 0);
        args[2] = LLVMConstInt(ctx->i32, a->done, 0);
index 055c8f7daed52e3c2735ef84989d98236620d680..7bc977b6ed7795da6f1cf2ab76159a01e5a75522 100644 (file)
@@ -6490,7 +6490,7 @@ static bool si_eliminate_const_output(struct si_shader_context *ctx,
 
        for (i = 0; i < 4; i++) {
                LLVMBool loses_info;
-               LLVMValueRef p = LLVMGetOperand(inst, 5 + i);
+               LLVMValueRef p = LLVMGetOperand(inst, (HAVE_LLVM >= 0x0500 ? 2 : 5) + i);
 
                /* It's a constant expression. Undef outputs are eliminated too. */
                if (LLVMIsUndef(p)) {
@@ -6574,10 +6574,12 @@ static void si_eliminate_const_vs_outputs(struct si_shader_context *ctx)
                        unsigned num_args = LLVMCountParams(callee);
 
                        /* Check if this is an export instruction. */
-                       if (num_args != 9 || strcmp(name, "llvm.SI.export"))
+                       if ((num_args != 9 && num_args != 8) ||
+                           (strcmp(name, "llvm.SI.export") &&
+                            strcmp(name, "llvm.amdgcn.exp.")))
                                continue;
 
-                       LLVMValueRef arg = LLVMGetOperand(cur, 3);
+                       LLVMValueRef arg = LLVMGetOperand(cur, HAVE_LLVM >= 0x0500 ? 0 : 3);
                        unsigned target = LLVMConstIntGetZExtValue(arg);
 
                        if (target < V_008DFC_SQ_EXP_PARAM)