diff options
author | Samuel Pitoiset <[email protected]> | 2019-03-26 12:24:52 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2019-04-17 22:10:28 +0200 |
commit | 26ea50623550dd84c19e4f2132a355509b1b0c41 (patch) | |
tree | 100c43fda55e025d4625234b3ee1153269eee419 /src/amd/common/ac_llvm_build.c | |
parent | 6fd5e39b60804e1c0d1eab23c22cb79995aa367f (diff) |
ac: use struct/raw load intrinsics for 8-bit/16-bit int with LLVM 9+
This changes requires LLVM r356465.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd/common/ac_llvm_build.c')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index c7100e52295..55ad3534ae2 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1603,15 +1603,28 @@ ac_build_tbuffer_load_short(struct ac_llvm_context *ctx, LLVMValueRef immoffset, bool glc) { - unsigned dfmt = V_008F0C_BUF_DATA_FORMAT_16; - unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT; LLVMValueRef res; - res = ac_build_raw_tbuffer_load(ctx, rsrc, voffset, soffset, - immoffset, 1, dfmt, nfmt, glc, false, - false); + if (HAVE_LLVM >= 0x900) { + voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, ""); + + /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */ + res = ac_build_llvm8_buffer_load_common(ctx, rsrc, NULL, + voffset, soffset, + 1, ctx->i16, glc, false, + false, false, false); + } else { + unsigned dfmt = V_008F0C_BUF_DATA_FORMAT_16; + unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT; - return LLVMBuildTrunc(ctx->builder, res, ctx->i16, ""); + res = ac_build_raw_tbuffer_load(ctx, rsrc, voffset, soffset, + immoffset, 1, dfmt, nfmt, glc, false, + false); + + res = LLVMBuildTrunc(ctx->builder, res, ctx->i16, ""); + } + + return res; } LLVMValueRef @@ -1622,15 +1635,28 @@ ac_build_tbuffer_load_byte(struct ac_llvm_context *ctx, LLVMValueRef immoffset, bool glc) { - unsigned dfmt = V_008F0C_BUF_DATA_FORMAT_8; - unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT; LLVMValueRef res; - res = ac_build_raw_tbuffer_load(ctx, rsrc, voffset, soffset, - immoffset, 1, dfmt, nfmt, glc, false, - false); + if (HAVE_LLVM >= 0x900) { + voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, ""); + + /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */ + res = ac_build_llvm8_buffer_load_common(ctx, rsrc, NULL, + voffset, soffset, + 1, ctx->i8, glc, false, + false, false, false); + } else { + unsigned dfmt = V_008F0C_BUF_DATA_FORMAT_8; + unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT; - return LLVMBuildTrunc(ctx->builder, res, ctx->i8, ""); + res = ac_build_raw_tbuffer_load(ctx, rsrc, voffset, soffset, + immoffset, 1, dfmt, nfmt, glc, false, + false); + + res = LLVMBuildTrunc(ctx->builder, res, ctx->i8, ""); + } + + return res; } static void ac_build_llvm8_tbuffer_store(struct ac_llvm_context *ctx, |