r-b for the series
On Tue, Mar 26, 2019 at 12:36 PM Samuel Pitoiset <samuel.pitoi...@gmail.com> wrote: > > LLVM 9+ now supports 8-bit and 16-bit types. > > This changes requires LLVM r356465. > > Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> > --- > src/amd/common/ac_llvm_build.c | 51 +++++++++++++++++++--------------- > 1 file changed, 28 insertions(+), 23 deletions(-) > > diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c > index a816327ce95..88df82dcc54 100644 > --- a/src/amd/common/ac_llvm_build.c > +++ b/src/amd/common/ac_llvm_build.c > @@ -1136,6 +1136,7 @@ ac_build_llvm8_buffer_store_common(struct > ac_llvm_context *ctx, > LLVMValueRef voffset, > LLVMValueRef soffset, > unsigned num_channels, > + LLVMTypeRef base_type, > bool glc, > bool slc, > bool writeonly_memory, > @@ -1151,21 +1152,22 @@ ac_build_llvm8_buffer_store_common(struct > ac_llvm_context *ctx, > args[idx++] = voffset ? voffset : ctx->i32_0; > args[idx++] = soffset ? soffset : ctx->i32_0; > args[idx++] = LLVMConstInt(ctx->i32, (glc ? 1 : 0) + (slc ? 2 : 0), > 0); > - unsigned func = CLAMP(num_channels, 1, 4) - 1; > + unsigned func = CLAMP(num_channels, 1, 4); > + const char *indexing_kind = structurized ? "struct" : "raw"; > + char name[256], type_name[8]; > > - if (HAVE_LLVM == 0x800 && func == 2) > - func = 3; /* Only LLVM 9+ supports vec3 */ > + if (HAVE_LLVM == 0x800 && func == 3) > + func = 4; /* Only LLVM 9+ supports vec3 */ > > - const char *type_names[] = {"f32", "v2f32", "v3f32", "v4f32"}; > - const char *indexing_kind = structurized ? "struct" : "raw"; > - char name[256]; > + LLVMTypeRef type = func > 1 ? LLVMVectorType(base_type, func) : > base_type; > + ac_build_type_name_for_intr(type, type_name, sizeof(type_name)); > > if (use_format) { > snprintf(name, sizeof(name), > "llvm.amdgcn.%s.buffer.store.format.%s", > - indexing_kind, type_names[func]); > + indexing_kind, type_name); > } else { > snprintf(name, sizeof(name), "llvm.amdgcn.%s.buffer.store.%s", > - indexing_kind, type_names[func]); > + indexing_kind, type_name); > } > > ac_build_intrinsic(ctx, name, ctx->voidt, args, idx, > @@ -1185,8 +1187,8 @@ ac_build_buffer_store_format(struct ac_llvm_context > *ctx, > if (HAVE_LLVM >= 0x800) { > ac_build_llvm8_buffer_store_common(ctx, rsrc, data, vindex, > voffset, NULL, > num_channels, > - glc, false, > writeonly_memory, > - true, true); > + ctx->f32, glc, false, > + writeonly_memory, true, > true); > } else { > ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset, > num_channels, glc, false, > @@ -1249,6 +1251,7 @@ ac_build_buffer_store_dword(struct ac_llvm_context *ctx, > ctx->i32_0, > voffset, offset, > num_channels, > + ctx->f32, > glc, slc, > writeonly_memory, > false, false); > @@ -1324,6 +1327,7 @@ ac_build_llvm8_buffer_load_common(struct > ac_llvm_context *ctx, > LLVMValueRef voffset, > LLVMValueRef soffset, > unsigned num_channels, > + LLVMTypeRef base_type, > bool glc, > bool slc, > bool can_speculate, > @@ -1338,26 +1342,26 @@ ac_build_llvm8_buffer_load_common(struct > ac_llvm_context *ctx, > args[idx++] = voffset ? voffset : ctx->i32_0; > args[idx++] = soffset ? soffset : ctx->i32_0; > args[idx++] = LLVMConstInt(ctx->i32, (glc ? 1 : 0) + (slc ? 2 : 0), > 0); > - unsigned func = CLAMP(num_channels, 1, 4) - 1; > + unsigned func = CLAMP(num_channels, 1, 4); > > - if (HAVE_LLVM == 0x800 && func == 2) > - func = 3; /* Only LLVM 9+ supports vec3 */ > + if (HAVE_LLVM == 0x800 && func == 3) > + func = 4; /* Only LLVM 9+ supports vec3 */ > > - LLVMTypeRef types[] = {ctx->f32, ctx->v2f32, ctx->v3f32, ctx->v4f32}; > - const char *type_names[] = {"f32", "v2f32", "v3f32", "v4f32"}; > + LLVMTypeRef type = func > 1 ? LLVMVectorType(base_type, func) : > base_type; > const char *indexing_kind = structurized ? "struct" : "raw"; > - char name[256]; > + char name[256], type_name[8]; > + > + ac_build_type_name_for_intr(type, type_name, sizeof(type_name)); > > if (use_format) { > snprintf(name, sizeof(name), > "llvm.amdgcn.%s.buffer.load.format.%s", > - indexing_kind, type_names[func]); > + indexing_kind, type_name); > } else { > snprintf(name, sizeof(name), "llvm.amdgcn.%s.buffer.load.%s", > - indexing_kind, type_names[func]); > + indexing_kind, type_name); > } > > - return ac_build_intrinsic(ctx, name, types[func], args, > - idx, > + return ac_build_intrinsic(ctx, name, type, args, idx, > ac_get_load_intr_attribs(can_speculate)); > } > > @@ -1416,7 +1420,8 @@ ac_build_buffer_load(struct ac_llvm_context *ctx, > if (HAVE_LLVM >= 0x0800) { > return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex, > offset, ctx->i32_0, > - num_channels, glc, > slc, > + num_channels, > ctx->f32, > + glc, slc, > can_speculate, false, > false); > } > @@ -1436,7 +1441,7 @@ LLVMValueRef ac_build_buffer_load_format(struct > ac_llvm_context *ctx, > { > if (HAVE_LLVM >= 0x800) { > return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex, > voffset, ctx->i32_0, > - num_channels, glc, > false, > + num_channels, > ctx->f32, glc, false, > can_speculate, true, > true); > } > return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset, > @@ -1454,7 +1459,7 @@ LLVMValueRef > ac_build_buffer_load_format_gfx9_safe(struct ac_llvm_context *ctx, > { > if (HAVE_LLVM >= 0x800) { > return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex, > voffset, ctx->i32_0, > - num_channels, glc, > false, > + num_channels, > ctx->f32, glc, false, > can_speculate, true, > true); > } > > -- > 2.21.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev