gallivm: add LLVMAttribute parameter to lp_build_intrinsic
authorMarek Olšák <marek.olsak@amd.com>
Sat, 25 Jul 2015 09:17:48 +0000 (11:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 31 Jul 2015 14:49:16 +0000 (16:49 +0200)
This will help remove some duplicated code from radeon.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_intr.c
src/gallium/auxiliary/gallivm/lp_bld_intr.h
src/gallium/auxiliary/gallivm/lp_bld_logic.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
src/gallium/drivers/r600/r600_llvm.c
src/gallium/drivers/radeonsi/si_shader.c

index 1d327ce48a9850e8f67fd1b4ad34673759effb9c..50ae192325b719b6b12ce10a63ef615e784b3c63 100644 (file)
@@ -1717,7 +1717,7 @@ lp_build_round_sse41(struct lp_build_context *bld,
       args[2] = LLVMConstInt(i32t, mode, 0);
 
       res = lp_build_intrinsic(builder, intrinsic,
-                               vec_type, args, Elements(args));
+                               vec_type, args, Elements(args), 0);
 
       res = LLVMBuildExtractElement(builder, res, index0, "");
    }
@@ -3547,7 +3547,7 @@ lp_build_fpstate_get(struct gallivm_state *gallivm)
       lp_build_intrinsic(builder,
                          "llvm.x86.sse.stmxcsr",
                          LLVMVoidTypeInContext(gallivm->context),
-                         &mxcsr_ptr8, 1);
+                         &mxcsr_ptr8, 1, 0);
       return mxcsr_ptr;
    }
    return 0;
@@ -3594,6 +3594,6 @@ lp_build_fpstate_set(struct gallivm_state *gallivm,
       lp_build_intrinsic(builder,
                          "llvm.x86.sse.ldmxcsr",
                          LLVMVoidTypeInContext(gallivm->context),
-                         &mxcsr_ptr, 1);
+                         &mxcsr_ptr, 1, 0);
    }
 }
index 2bf1211bcd7073b028bff405a336d7cef8baee19..30f4863ec443f8cc9c650de299008b1a7dd87ca2 100644 (file)
@@ -81,7 +81,8 @@ lp_build_intrinsic(LLVMBuilderRef builder,
                    const char *name,
                    LLVMTypeRef ret_type,
                    LLVMValueRef *args,
-                   unsigned num_args)
+                   unsigned num_args,
+                   LLVMAttribute attr)
 {
    LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
    LLVMValueRef function;
@@ -99,6 +100,9 @@ lp_build_intrinsic(LLVMBuilderRef builder,
       }
 
       function = lp_declare_intrinsic(module, name, ret_type, arg_types, num_args);
+
+      if (attr)
+          LLVMAddFunctionAttr(function, attr);
    }
 
    return LLVMBuildCall(builder, function, args, num_args, "");
@@ -111,7 +115,7 @@ lp_build_intrinsic_unary(LLVMBuilderRef builder,
                          LLVMTypeRef ret_type,
                          LLVMValueRef a)
 {
-   return lp_build_intrinsic(builder, name, ret_type, &a, 1);
+   return lp_build_intrinsic(builder, name, ret_type, &a, 1, 0);
 }
 
 
@@ -127,7 +131,7 @@ lp_build_intrinsic_binary(LLVMBuilderRef builder,
    args[0] = a;
    args[1] = b;
 
-   return lp_build_intrinsic(builder, name, ret_type, args, 2);
+   return lp_build_intrinsic(builder, name, ret_type, args, 2, 0);
 }
 
 
@@ -242,7 +246,7 @@ lp_build_intrinsic_map(struct gallivm_state *gallivm,
       LLVMValueRef res_elem;
       for(j = 0; j < num_args; ++j)
          arg_elems[j] = LLVMBuildExtractElement(builder, args[j], index, "");
-      res_elem = lp_build_intrinsic(builder, name, ret_elem_type, arg_elems, num_args);
+      res_elem = lp_build_intrinsic(builder, name, ret_elem_type, arg_elems, num_args, 0);
       res = LLVMBuildInsertElement(builder, res, res_elem, index, "");
    }
 
index 38c5c29c980ba61568e0904cce92169ec813b5a8..a54b367961afecaad8d91a2c05e9cc5ee155e642 100644 (file)
@@ -59,7 +59,8 @@ lp_build_intrinsic(LLVMBuilderRef builder,
                    const char *name,
                    LLVMTypeRef ret_type,
                    LLVMValueRef *args,
-                   unsigned num_args);
+                   unsigned num_args,
+                   LLVMAttribute attr);
 
 
 LLVMValueRef
index 80b53e5c3f896c517d63c5635aa373d4bde317eb..19d30d0d63c845f900923409e2f45a394046c513 100644 (file)
@@ -395,7 +395,7 @@ lp_build_select(struct lp_build_context *bld,
       args[2] = mask;
 
       res = lp_build_intrinsic(builder, intrinsic,
-                               arg_type, args, Elements(args));
+                               arg_type, args, Elements(args), 0);
 
       if (arg_type != bld->vec_type) {
          res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
index 1887956d1c40e5ed3fa2abeb33c8e7d3526ddd2b..c4ae30461cbbbfb2670cc1292eed3828a3111dc4 100644 (file)
@@ -104,7 +104,7 @@ lp_build_tgsi_intrinsic(
    struct lp_build_context * base = &bld_base->base;
    emit_data->output[emit_data->chan] = lp_build_intrinsic(
                base->gallivm->builder, action->intr_name,
-               emit_data->dst_type, emit_data->args, emit_data->arg_count);
+               emit_data->dst_type, emit_data->args, emit_data->arg_count, 0);
 }
 
 LLVMValueRef
index 72e2dc42f7ebdb65b983dc9cf7a74dd83a76c353..15fc2566fb06dfc428e72c28a9b6e27073dee174 100644 (file)
@@ -332,7 +332,7 @@ static void llvm_emit_epilogue(struct lp_build_tgsi_context * bld_base)
                        args[2] = lp_build_const_int32(base->gallivm, so->output[i].output_buffer);
                        args[3] = lp_build_const_int32(base->gallivm, ((1 << num_components) - 1) << start_component);
                        lp_build_intrinsic(base->gallivm->builder, "llvm.R600.store.stream.output",
-                               LLVMVoidTypeInContext(base->gallivm->context), args, 4);
+                               LLVMVoidTypeInContext(base->gallivm->context), args, 4, 0);
                }
        }
 
index d8bab875adb6c643b8c75e3ed23083543b122b54..10fc52d3c298e618d088ddb5c88a23ef0d2a5180 100644 (file)
@@ -1528,7 +1528,7 @@ static void build_tbuffer_store(struct si_shader_context *shader,
 
        lp_build_intrinsic(gallivm->builder, name,
                           LLVMVoidTypeInContext(gallivm->context),
-                          args, Elements(args));
+                          args, Elements(args), 0);
 }
 
 static void build_tbuffer_store_dwords(struct si_shader_context *shader,
@@ -1757,7 +1757,7 @@ handle_semantic:
                        lp_build_intrinsic(base->gallivm->builder,
                                           "llvm.SI.export",
                                           LLVMVoidTypeInContext(base->gallivm->context),
-                                          args, 9);
+                                          args, 9, 0);
                }
 
                if (semantic_name == TGSI_SEMANTIC_CLIPDIST) {
@@ -1845,7 +1845,7 @@ handle_semantic:
                lp_build_intrinsic(base->gallivm->builder,
                                   "llvm.SI.export",
                                   LLVMVoidTypeInContext(base->gallivm->context),
-                                  pos_args[i], 9);
+                                  pos_args[i], 9, 0);
        }
 }
 
@@ -2122,7 +2122,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
                                lp_build_intrinsic(base->gallivm->builder,
                                                   "llvm.SI.export",
                                                   LLVMVoidTypeInContext(base->gallivm->context),
-                                                  last_args, 9);
+                                                  last_args, 9, 0);
                        }
 
                        /* This instruction will be emitted at the end of the shader. */
@@ -2139,14 +2139,14 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
                                        lp_build_intrinsic(base->gallivm->builder,
                                                           "llvm.SI.export",
                                                           LLVMVoidTypeInContext(base->gallivm->context),
-                                                          args, 9);
+                                                          args, 9, 0);
                                }
                        }
                } else {
                        lp_build_intrinsic(base->gallivm->builder,
                                           "llvm.SI.export",
                                           LLVMVoidTypeInContext(base->gallivm->context),
-                                          args, 9);
+                                          args, 9, 0);
                }
        }
 
@@ -2208,7 +2208,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
                        lp_build_intrinsic(base->gallivm->builder,
                                           "llvm.SI.export",
                                           LLVMVoidTypeInContext(base->gallivm->context),
-                                          args, 9);
+                                          args, 9, 0);
                else
                        memcpy(last_args, args, sizeof(args));
        }
@@ -2239,7 +2239,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
        lp_build_intrinsic(base->gallivm->builder,
                           "llvm.SI.export",
                           LLVMVoidTypeInContext(base->gallivm->context),
-                          last_args, 9);
+                          last_args, 9, 0);
 }
 
 static void build_tex_intrinsic(const struct lp_build_tgsi_action * action,