[11/11] ac: use new LLVM 8 intrinsics in ac_build_buffer_store_dword()

Submitted by Samuel Pitoiset on March 12, 2019, 4:19 p.m.

Details

Message ID 20190312161947.24880-12-samuel.pitoiset@gmail.com
State New
Headers show
Series "ac: use LLVM 8 buffer intrinsics everywhere" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset March 12, 2019, 4:19 p.m.
New buffer intrinsics have a separate soffset parameter.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/common/ac_llvm_build.c | 66 ++++++++++++++--------------------
 1 file changed, 26 insertions(+), 40 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index ce6639d49bf..8ed5199da55 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1227,59 +1227,45 @@  ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
 	if (!swizzle_enable_hint) {
 		LLVMValueRef offset = soffset;
 
-		static const char *types[] = {"f32", "v2f32", "v4f32"};
-
 		if (inst_offset)
 			offset = LLVMBuildAdd(ctx->builder, offset,
 					      LLVMConstInt(ctx->i32, inst_offset, 0), "");
-		if (voffset)
-			offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
-
-		LLVMValueRef args[] = {
-			ac_to_float(ctx, vdata),
-			LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
-			ctx->i32_0,
-			offset,
-			LLVMConstInt(ctx->i1, glc, 0),
-			LLVMConstInt(ctx->i1, slc, 0),
-		};
-
-		char name[256];
-		snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",
-			 types[CLAMP(num_channels, 1, 3) - 1]);
 
-		ac_build_intrinsic(ctx, name, ctx->voidt,
-				   args, ARRAY_SIZE(args),
-				   ac_get_store_intr_attribs(writeonly_memory));
+		if (HAVE_LLVM >= 0x800) {
+			ac_build_llvm8_buffer_store_common(ctx, rsrc,
+							   ac_to_float(ctx, vdata),
+							   ctx->i32_0,
+							   voffset, offset,
+							   num_channels,
+							   glc, slc,
+							   writeonly_memory,
+							   false, true);
+		} else {
+			if (voffset)
+				offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
+
+			ac_build_buffer_store_common(ctx, rsrc,
+						     ac_to_float(ctx, vdata),
+						     ctx->i32_0, offset,
+						     num_channels, glc, slc,
+						     writeonly_memory, false);
+		}
 		return;
 	}
 
-	static const unsigned dfmt[] = {
+	static const unsigned dfmts[] = {
 		V_008F0C_BUF_DATA_FORMAT_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32_32_32
 	};
-	static const char *types[] = {"i32", "v2i32", "v4i32"};
-	LLVMValueRef args[] = {
-		vdata,
-		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
-		ctx->i32_0,
-		voffset ? voffset : ctx->i32_0,
-		soffset,
-		LLVMConstInt(ctx->i32, inst_offset, 0),
-		LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
-		LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
-		LLVMConstInt(ctx->i1, glc, 0),
-		LLVMConstInt(ctx->i1, slc, 0),
-	};
-	char name[256];
-	snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s",
-		 types[CLAMP(num_channels, 1, 3) - 1]);
+	unsigned dfmt = dfmts[num_channels - 1];
+	unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
+	LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
 
-	ac_build_intrinsic(ctx, name, ctx->voidt,
-			   args, ARRAY_SIZE(args),
-			   ac_get_store_intr_attribs(writeonly_memory));
+	ac_build_tbuffer_store(ctx, rsrc, vdata, ctx->i32_0, voffset, soffset,
+			       immoffset, num_channels, dfmt, nfmt, glc, slc,
+			       writeonly_memory);
 }
 
 static LLVMValueRef

Comments

This one causes 2000+ piglit tests to fail on radeonsi. For example:

./bin/shader_runner 
generated_tests/spec/arb_gpu_shader_fp64/execution/conversion/geom-conversion-explicit-bool-double.shader_test 
-auto -fbo

On 13/3/19 3:19 am, Samuel Pitoiset wrote:
> New buffer intrinsics have a separate soffset parameter.
> 
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
> ---
>   src/amd/common/ac_llvm_build.c | 66 ++++++++++++++--------------------
>   1 file changed, 26 insertions(+), 40 deletions(-)
> 
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index ce6639d49bf..8ed5199da55 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -1227,59 +1227,45 @@ ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
>   	if (!swizzle_enable_hint) {
>   		LLVMValueRef offset = soffset;
>   
> -		static const char *types[] = {"f32", "v2f32", "v4f32"};
> -
>   		if (inst_offset)
>   			offset = LLVMBuildAdd(ctx->builder, offset,
>   					      LLVMConstInt(ctx->i32, inst_offset, 0), "");
> -		if (voffset)
> -			offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
> -
> -		LLVMValueRef args[] = {
> -			ac_to_float(ctx, vdata),
> -			LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
> -			ctx->i32_0,
> -			offset,
> -			LLVMConstInt(ctx->i1, glc, 0),
> -			LLVMConstInt(ctx->i1, slc, 0),
> -		};
> -
> -		char name[256];
> -		snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",
> -			 types[CLAMP(num_channels, 1, 3) - 1]);
>   
> -		ac_build_intrinsic(ctx, name, ctx->voidt,
> -				   args, ARRAY_SIZE(args),
> -				   ac_get_store_intr_attribs(writeonly_memory));
> +		if (HAVE_LLVM >= 0x800) {
> +			ac_build_llvm8_buffer_store_common(ctx, rsrc,
> +							   ac_to_float(ctx, vdata),
> +							   ctx->i32_0,
> +							   voffset, offset,
> +							   num_channels,
> +							   glc, slc,
> +							   writeonly_memory,
> +							   false, true);
> +		} else {
> +			if (voffset)
> +				offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
> +
> +			ac_build_buffer_store_common(ctx, rsrc,
> +						     ac_to_float(ctx, vdata),
> +						     ctx->i32_0, offset,
> +						     num_channels, glc, slc,
> +						     writeonly_memory, false);
> +		}
>   		return;
>   	}
>   
> -	static const unsigned dfmt[] = {
> +	static const unsigned dfmts[] = {
>   		V_008F0C_BUF_DATA_FORMAT_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32_32_32
>   	};
> -	static const char *types[] = {"i32", "v2i32", "v4i32"};
> -	LLVMValueRef args[] = {
> -		vdata,
> -		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
> -		ctx->i32_0,
> -		voffset ? voffset : ctx->i32_0,
> -		soffset,
> -		LLVMConstInt(ctx->i32, inst_offset, 0),
> -		LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
> -		LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
> -		LLVMConstInt(ctx->i1, glc, 0),
> -		LLVMConstInt(ctx->i1, slc, 0),
> -	};
> -	char name[256];
> -	snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s",
> -		 types[CLAMP(num_channels, 1, 3) - 1]);
> +	unsigned dfmt = dfmts[num_channels - 1];
> +	unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
> +	LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
>   
> -	ac_build_intrinsic(ctx, name, ctx->voidt,
> -			   args, ARRAY_SIZE(args),
> -			   ac_get_store_intr_attribs(writeonly_memory));
> +	ac_build_tbuffer_store(ctx, rsrc, vdata, ctx->i32_0, voffset, soffset,
> +			       immoffset, num_channels, dfmt, nfmt, glc, slc,
> +			       writeonly_memory);
>   }
>   
>   static LLVMValueRef
>
On 3/13/19 1:26 AM, Timothy Arceri wrote:
> This one causes 2000+ piglit tests to fail on radeonsi. For example:
>
> ./bin/shader_runner 
> generated_tests/spec/arb_gpu_shader_fp64/execution/conversion/geom-conversion-explicit-bool-double.shader_test 
> -auto -fbo
What chip? what LLVM?
>
> On 13/3/19 3:19 am, Samuel Pitoiset wrote:
>> New buffer intrinsics have a separate soffset parameter.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
>> ---
>>   src/amd/common/ac_llvm_build.c | 66 ++++++++++++++--------------------
>>   1 file changed, 26 insertions(+), 40 deletions(-)
>>
>> diff --git a/src/amd/common/ac_llvm_build.c 
>> b/src/amd/common/ac_llvm_build.c
>> index ce6639d49bf..8ed5199da55 100644
>> --- a/src/amd/common/ac_llvm_build.c
>> +++ b/src/amd/common/ac_llvm_build.c
>> @@ -1227,59 +1227,45 @@ ac_build_buffer_store_dword(struct 
>> ac_llvm_context *ctx,
>>       if (!swizzle_enable_hint) {
>>           LLVMValueRef offset = soffset;
>>   -        static const char *types[] = {"f32", "v2f32", "v4f32"};
>> -
>>           if (inst_offset)
>>               offset = LLVMBuildAdd(ctx->builder, offset,
>>                             LLVMConstInt(ctx->i32, inst_offset, 0), "");
>> -        if (voffset)
>> -            offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
>> -
>> -        LLVMValueRef args[] = {
>> -            ac_to_float(ctx, vdata),
>> -            LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>> -            ctx->i32_0,
>> -            offset,
>> -            LLVMConstInt(ctx->i1, glc, 0),
>> -            LLVMConstInt(ctx->i1, slc, 0),
>> -        };
>> -
>> -        char name[256];
>> -        snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",
>> -             types[CLAMP(num_channels, 1, 3) - 1]);
>>   -        ac_build_intrinsic(ctx, name, ctx->voidt,
>> -                   args, ARRAY_SIZE(args),
>> - ac_get_store_intr_attribs(writeonly_memory));
>> +        if (HAVE_LLVM >= 0x800) {
>> +            ac_build_llvm8_buffer_store_common(ctx, rsrc,
>> +                               ac_to_float(ctx, vdata),
>> +                               ctx->i32_0,
>> +                               voffset, offset,
>> +                               num_channels,
>> +                               glc, slc,
>> +                               writeonly_memory,
>> +                               false, true);
>> +        } else {
>> +            if (voffset)
>> +                offset = LLVMBuildAdd(ctx->builder, offset, voffset, 
>> "");
>> +
>> +            ac_build_buffer_store_common(ctx, rsrc,
>> +                             ac_to_float(ctx, vdata),
>> +                             ctx->i32_0, offset,
>> +                             num_channels, glc, slc,
>> +                             writeonly_memory, false);
>> +        }
>>           return;
>>       }
>>   -    static const unsigned dfmt[] = {
>> +    static const unsigned dfmts[] = {
>>           V_008F0C_BUF_DATA_FORMAT_32,
>>           V_008F0C_BUF_DATA_FORMAT_32_32,
>>           V_008F0C_BUF_DATA_FORMAT_32_32_32,
>>           V_008F0C_BUF_DATA_FORMAT_32_32_32_32
>>       };
>> -    static const char *types[] = {"i32", "v2i32", "v4i32"};
>> -    LLVMValueRef args[] = {
>> -        vdata,
>> -        LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>> -        ctx->i32_0,
>> -        voffset ? voffset : ctx->i32_0,
>> -        soffset,
>> -        LLVMConstInt(ctx->i32, inst_offset, 0),
>> -        LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
>> -        LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
>> -        LLVMConstInt(ctx->i1, glc, 0),
>> -        LLVMConstInt(ctx->i1, slc, 0),
>> -    };
>> -    char name[256];
>> -    snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s",
>> -         types[CLAMP(num_channels, 1, 3) - 1]);
>> +    unsigned dfmt = dfmts[num_channels - 1];
>> +    unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
>> +    LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
>>   -    ac_build_intrinsic(ctx, name, ctx->voidt,
>> -               args, ARRAY_SIZE(args),
>> -               ac_get_store_intr_attribs(writeonly_memory));
>> +    ac_build_tbuffer_store(ctx, rsrc, vdata, ctx->i32_0, voffset, 
>> soffset,
>> +                   immoffset, num_channels, dfmt, nfmt, glc, slc,
>> +                   writeonly_memory);
>>   }
>>     static LLVMValueRef
>>
On 3/13/19 9:01 AM, Samuel Pitoiset wrote:
>
> On 3/13/19 1:26 AM, Timothy Arceri wrote:
>> This one causes 2000+ piglit tests to fail on radeonsi. For example:
>>
>> ./bin/shader_runner 
>> generated_tests/spec/arb_gpu_shader_fp64/execution/conversion/geom-conversion-explicit-bool-double.shader_test 
>> -auto -fbo
> What chip? what LLVM?
GFX9 I assume.
>>
>> On 13/3/19 3:19 am, Samuel Pitoiset wrote:
>>> New buffer intrinsics have a separate soffset parameter.
>>>
>>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
>>> ---
>>>   src/amd/common/ac_llvm_build.c | 66 
>>> ++++++++++++++--------------------
>>>   1 file changed, 26 insertions(+), 40 deletions(-)
>>>
>>> diff --git a/src/amd/common/ac_llvm_build.c 
>>> b/src/amd/common/ac_llvm_build.c
>>> index ce6639d49bf..8ed5199da55 100644
>>> --- a/src/amd/common/ac_llvm_build.c
>>> +++ b/src/amd/common/ac_llvm_build.c
>>> @@ -1227,59 +1227,45 @@ ac_build_buffer_store_dword(struct 
>>> ac_llvm_context *ctx,
>>>       if (!swizzle_enable_hint) {
>>>           LLVMValueRef offset = soffset;
>>>   -        static const char *types[] = {"f32", "v2f32", "v4f32"};
>>> -
>>>           if (inst_offset)
>>>               offset = LLVMBuildAdd(ctx->builder, offset,
>>>                             LLVMConstInt(ctx->i32, inst_offset, 0), 
>>> "");
>>> -        if (voffset)
>>> -            offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
>>> -
>>> -        LLVMValueRef args[] = {
>>> -            ac_to_float(ctx, vdata),
>>> -            LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>>> -            ctx->i32_0,
>>> -            offset,
>>> -            LLVMConstInt(ctx->i1, glc, 0),
>>> -            LLVMConstInt(ctx->i1, slc, 0),
>>> -        };
>>> -
>>> -        char name[256];
>>> -        snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",
>>> -             types[CLAMP(num_channels, 1, 3) - 1]);
>>>   -        ac_build_intrinsic(ctx, name, ctx->voidt,
>>> -                   args, ARRAY_SIZE(args),
>>> - ac_get_store_intr_attribs(writeonly_memory));
>>> +        if (HAVE_LLVM >= 0x800) {
>>> +            ac_build_llvm8_buffer_store_common(ctx, rsrc,
>>> +                               ac_to_float(ctx, vdata),
>>> +                               ctx->i32_0,
>>> +                               voffset, offset,
>>> +                               num_channels,
>>> +                               glc, slc,
>>> +                               writeonly_memory,
>>> +                               false, true);
>>> +        } else {
>>> +            if (voffset)
>>> +                offset = LLVMBuildAdd(ctx->builder, offset, 
>>> voffset, "");
>>> +
>>> +            ac_build_buffer_store_common(ctx, rsrc,
>>> +                             ac_to_float(ctx, vdata),
>>> +                             ctx->i32_0, offset,
>>> +                             num_channels, glc, slc,
>>> +                             writeonly_memory, false);
>>> +        }
>>>           return;
>>>       }
>>>   -    static const unsigned dfmt[] = {
>>> +    static const unsigned dfmts[] = {
>>>           V_008F0C_BUF_DATA_FORMAT_32,
>>>           V_008F0C_BUF_DATA_FORMAT_32_32,
>>>           V_008F0C_BUF_DATA_FORMAT_32_32_32,
>>>           V_008F0C_BUF_DATA_FORMAT_32_32_32_32
>>>       };
>>> -    static const char *types[] = {"i32", "v2i32", "v4i32"};
>>> -    LLVMValueRef args[] = {
>>> -        vdata,
>>> -        LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>>> -        ctx->i32_0,
>>> -        voffset ? voffset : ctx->i32_0,
>>> -        soffset,
>>> -        LLVMConstInt(ctx->i32, inst_offset, 0),
>>> -        LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
>>> -        LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
>>> -        LLVMConstInt(ctx->i1, glc, 0),
>>> -        LLVMConstInt(ctx->i1, slc, 0),
>>> -    };
>>> -    char name[256];
>>> -    snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s",
>>> -         types[CLAMP(num_channels, 1, 3) - 1]);
>>> +    unsigned dfmt = dfmts[num_channels - 1];
>>> +    unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
>>> +    LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
>>>   -    ac_build_intrinsic(ctx, name, ctx->voidt,
>>> -               args, ARRAY_SIZE(args),
>>> -               ac_get_store_intr_attribs(writeonly_memory));
>>> +    ac_build_tbuffer_store(ctx, rsrc, vdata, ctx->i32_0, voffset, 
>>> soffset,
>>> +                   immoffset, num_channels, dfmt, nfmt, glc, slc,
>>> +                   writeonly_memory);
>>>   }
>>>     static LLVMValueRef
>>>
On 13/3/19 7:07 pm, Samuel Pitoiset wrote:
> 
> On 3/13/19 9:01 AM, Samuel Pitoiset wrote:
>>
>> On 3/13/19 1:26 AM, Timothy Arceri wrote:
>>> This one causes 2000+ piglit tests to fail on radeonsi. For example:
>>>
>>> ./bin/shader_runner 
>>> generated_tests/spec/arb_gpu_shader_fp64/execution/conversion/geom-conversion-explicit-bool-double.shader_test 
>>> -auto -fbo
>> What chip? what LLVM?
> GFX9 I assume.

VEGA64 llvm 9

>>>
>>> On 13/3/19 3:19 am, Samuel Pitoiset wrote:
>>>> New buffer intrinsics have a separate soffset parameter.
>>>>
>>>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
>>>> ---
>>>>   src/amd/common/ac_llvm_build.c | 66 
>>>> ++++++++++++++--------------------
>>>>   1 file changed, 26 insertions(+), 40 deletions(-)
>>>>
>>>> diff --git a/src/amd/common/ac_llvm_build.c 
>>>> b/src/amd/common/ac_llvm_build.c
>>>> index ce6639d49bf..8ed5199da55 100644
>>>> --- a/src/amd/common/ac_llvm_build.c
>>>> +++ b/src/amd/common/ac_llvm_build.c
>>>> @@ -1227,59 +1227,45 @@ ac_build_buffer_store_dword(struct 
>>>> ac_llvm_context *ctx,
>>>>       if (!swizzle_enable_hint) {
>>>>           LLVMValueRef offset = soffset;
>>>>   -        static const char *types[] = {"f32", "v2f32", "v4f32"};
>>>> -
>>>>           if (inst_offset)
>>>>               offset = LLVMBuildAdd(ctx->builder, offset,
>>>>                             LLVMConstInt(ctx->i32, inst_offset, 0), 
>>>> "");
>>>> -        if (voffset)
>>>> -            offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
>>>> -
>>>> -        LLVMValueRef args[] = {
>>>> -            ac_to_float(ctx, vdata),
>>>> -            LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>>>> -            ctx->i32_0,
>>>> -            offset,
>>>> -            LLVMConstInt(ctx->i1, glc, 0),
>>>> -            LLVMConstInt(ctx->i1, slc, 0),
>>>> -        };
>>>> -
>>>> -        char name[256];
>>>> -        snprintf(name, sizeof(name), "llvm.amdgcn.buffer.store.%s",
>>>> -             types[CLAMP(num_channels, 1, 3) - 1]);
>>>>   -        ac_build_intrinsic(ctx, name, ctx->voidt,
>>>> -                   args, ARRAY_SIZE(args),
>>>> - ac_get_store_intr_attribs(writeonly_memory));
>>>> +        if (HAVE_LLVM >= 0x800) {
>>>> +            ac_build_llvm8_buffer_store_common(ctx, rsrc,
>>>> +                               ac_to_float(ctx, vdata),
>>>> +                               ctx->i32_0,
>>>> +                               voffset, offset,
>>>> +                               num_channels,
>>>> +                               glc, slc,
>>>> +                               writeonly_memory,
>>>> +                               false, true);
>>>> +        } else {
>>>> +            if (voffset)
>>>> +                offset = LLVMBuildAdd(ctx->builder, offset, 
>>>> voffset, "");
>>>> +
>>>> +            ac_build_buffer_store_common(ctx, rsrc,
>>>> +                             ac_to_float(ctx, vdata),
>>>> +                             ctx->i32_0, offset,
>>>> +                             num_channels, glc, slc,
>>>> +                             writeonly_memory, false);
>>>> +        }
>>>>           return;
>>>>       }
>>>>   -    static const unsigned dfmt[] = {
>>>> +    static const unsigned dfmts[] = {
>>>>           V_008F0C_BUF_DATA_FORMAT_32,
>>>>           V_008F0C_BUF_DATA_FORMAT_32_32,
>>>>           V_008F0C_BUF_DATA_FORMAT_32_32_32,
>>>>           V_008F0C_BUF_DATA_FORMAT_32_32_32_32
>>>>       };
>>>> -    static const char *types[] = {"i32", "v2i32", "v4i32"};
>>>> -    LLVMValueRef args[] = {
>>>> -        vdata,
>>>> -        LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>>>> -        ctx->i32_0,
>>>> -        voffset ? voffset : ctx->i32_0,
>>>> -        soffset,
>>>> -        LLVMConstInt(ctx->i32, inst_offset, 0),
>>>> -        LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
>>>> -        LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
>>>> -        LLVMConstInt(ctx->i1, glc, 0),
>>>> -        LLVMConstInt(ctx->i1, slc, 0),
>>>> -    };
>>>> -    char name[256];
>>>> -    snprintf(name, sizeof(name), "llvm.amdgcn.tbuffer.store.%s",
>>>> -         types[CLAMP(num_channels, 1, 3) - 1]);
>>>> +    unsigned dfmt = dfmts[num_channels - 1];
>>>> +    unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
>>>> +    LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
>>>>   -    ac_build_intrinsic(ctx, name, ctx->voidt,
>>>> -               args, ARRAY_SIZE(args),
>>>> -               ac_get_store_intr_attribs(writeonly_memory));
>>>> +    ac_build_tbuffer_store(ctx, rsrc, vdata, ctx->i32_0, voffset, 
>>>> soffset,
>>>> +                   immoffset, num_channels, dfmt, nfmt, glc, slc,
>>>> +                   writeonly_memory);
>>>>   }
>>>>     static LLVMValueRef
>>>>