ac/nir: support vector types in the type suffix of overloaded intrinsics
authorMarek Olšák <marek.olsak@amd.com>
Mon, 4 May 2020 11:01:04 +0000 (07:01 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 2 Jun 2020 20:29:25 +0000 (16:29 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5003>

src/amd/llvm/ac_llvm_build.c
src/amd/llvm/ac_nir_to_llvm.c

index bafc884362ca2426b5b2ea2160d7600771258bbe..6b8e2a98b5889ab777215815adf3d2e4f62721ad 100644 (file)
@@ -2192,8 +2192,10 @@ ac_build_umsb(struct ac_llvm_context *ctx,
 LLVMValueRef ac_build_fmin(struct ac_llvm_context *ctx, LLVMValueRef a,
                           LLVMValueRef b)
 {
-       char name[64];
-       snprintf(name, sizeof(name), "llvm.minnum.f%d", ac_get_elem_bits(ctx, LLVMTypeOf(a)));
+       char name[64], type[64];
+
+       ac_build_type_name_for_intr(LLVMTypeOf(a), type, sizeof(type));
+       snprintf(name, sizeof(name), "llvm.minnum.%s", type);
        LLVMValueRef args[2] = {a, b};
        return ac_build_intrinsic(ctx, name, LLVMTypeOf(a), args, 2,
                                  AC_FUNC_ATTR_READNONE);
@@ -2202,8 +2204,10 @@ LLVMValueRef ac_build_fmin(struct ac_llvm_context *ctx, LLVMValueRef a,
 LLVMValueRef ac_build_fmax(struct ac_llvm_context *ctx, LLVMValueRef a,
                           LLVMValueRef b)
 {
-       char name[64];
-       snprintf(name, sizeof(name), "llvm.maxnum.f%d", ac_get_elem_bits(ctx, LLVMTypeOf(a)));
+       char name[64], type[64];
+
+       ac_build_type_name_for_intr(LLVMTypeOf(a), type, sizeof(type));
+       snprintf(name, sizeof(name), "llvm.maxnum.%s", type);
        LLVMValueRef args[2] = {a, b};
        return ac_build_intrinsic(ctx, name, LLVMTypeOf(a), args, 2,
                                  AC_FUNC_ATTR_READNONE);
index f150dca22cd62ba5f872ecaa1fe0604742ec416f..e0728822800d0fd66493792091519c9e3acc0c9f 100644 (file)
@@ -194,13 +194,13 @@ static LLVMValueRef emit_intrin_1f_param(struct ac_llvm_context *ctx,
                                         LLVMTypeRef result_type,
                                         LLVMValueRef src0)
 {
-       char name[64];
+       char name[64], type[64];
        LLVMValueRef params[] = {
                ac_to_float(ctx, src0),
        };
 
-       ASSERTED const int length = snprintf(name, sizeof(name), "%s.f%d", intrin,
-                                                ac_get_elem_bits(ctx, result_type));
+       ac_build_type_name_for_intr(LLVMTypeOf(params[0]), type, sizeof(type));
+       ASSERTED const int length = snprintf(name, sizeof(name), "%s.%s", intrin, type);
        assert(length < sizeof(name));
        return ac_build_intrinsic(ctx, name, result_type, params, 1, AC_FUNC_ATTR_READNONE);
 }
@@ -210,14 +210,14 @@ static LLVMValueRef emit_intrin_2f_param(struct ac_llvm_context *ctx,
                                       LLVMTypeRef result_type,
                                       LLVMValueRef src0, LLVMValueRef src1)
 {
-       char name[64];
+       char name[64], type[64];
        LLVMValueRef params[] = {
                ac_to_float(ctx, src0),
                ac_to_float(ctx, src1),
        };
 
-       ASSERTED const int length = snprintf(name, sizeof(name), "%s.f%d", intrin,
-                                                ac_get_elem_bits(ctx, result_type));
+       ac_build_type_name_for_intr(LLVMTypeOf(params[0]), type, sizeof(type));
+       ASSERTED const int length = snprintf(name, sizeof(name), "%s.%s", intrin, type);
        assert(length < sizeof(name));
        return ac_build_intrinsic(ctx, name, result_type, params, 2, AC_FUNC_ATTR_READNONE);
 }
@@ -227,15 +227,15 @@ static LLVMValueRef emit_intrin_3f_param(struct ac_llvm_context *ctx,
                                         LLVMTypeRef result_type,
                                         LLVMValueRef src0, LLVMValueRef src1, LLVMValueRef src2)
 {
-       char name[64];
+       char name[64], type[64];
        LLVMValueRef params[] = {
                ac_to_float(ctx, src0),
                ac_to_float(ctx, src1),
                ac_to_float(ctx, src2),
        };
 
-       ASSERTED const int length = snprintf(name, sizeof(name), "%s.f%d", intrin,
-                                                ac_get_elem_bits(ctx, result_type));
+       ac_build_type_name_for_intr(LLVMTypeOf(params[0]), type, sizeof(type));
+       ASSERTED const int length = snprintf(name, sizeof(name), "%s.%s", intrin, type);
        assert(length < sizeof(name));
        return ac_build_intrinsic(ctx, name, result_type, params, 3, AC_FUNC_ATTR_READNONE);
 }