[Mesa-dev] [PATCH] radeonsi: Set datalayout on the llvm module

Nicolai Hähnle nhaehnle at gmail.com
Fri Dec 16 10:58:38 UTC 2016


On 15.12.2016 19:11, Tom Stellard wrote:
> This prevents LLVM from using sext instructions for local memory offsets
> and allows the backend to fold immediate offsets into the instruction.
>
> This also prevents some incorrect code generation for ptrtoint and
> inttoptr instructions.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

> ---
>  src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
> index 2f38949..b6cb00f 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
> @@ -1231,6 +1231,8 @@ void si_llvm_context_init(struct si_shader_context *ctx,
>  			  const struct tgsi_token *tokens)
>  {
>  	struct lp_type type;
> +	LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
> +	char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
>
>  	/* Initialize the gallivm object:
>  	 * We are only using the module, context, and builder fields of this struct.
> @@ -1248,6 +1250,10 @@ void si_llvm_context_init(struct si_shader_context *ctx,
>  						ctx->gallivm.context);
>  	LLVMSetTarget(ctx->gallivm.module, "amdgcn--");
>
> +	LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
> +	LLVMDisposeTargetData(data_layout);
> +	LLVMDisposeMessage(data_layout_str);
> +
>  	bool unsafe_fpmath = (sscreen->b.debug_flags & DBG_UNSAFE_MATH) != 0;
>  	ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context,
>  						 unsafe_fpmath);
>


More information about the mesa-dev mailing list