[Mesa-dev] [PATCH] radv: setup llvm target data layout

Tom Stellard tom at stellard.net
Mon Mar 13 22:32:50 UTC 2017


On Tue, Mar 14, 2017 at 06:52:19AM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> Ported from radeonsi, pointed out by Tom.
> 
> "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."
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Reviewed-by: Tom Stellard <tstellar at redhat.com>
> ---
>  src/amd/common/ac_nir_to_llvm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 47091a2..417b34e 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -4911,6 +4911,13 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
>  	memset(shader_info, 0, sizeof(*shader_info));
>  
>  	LLVMSetTarget(ctx.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--");
> +
> +	LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
> +	char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
> +	LLVMSetDataLayout(ctx.module, data_layout_str);
> +	LLVMDisposeTargetData(data_layout);
> +	LLVMDisposeMessage(data_layout_str);
> +
>  	setup_types(&ctx);
>  
>  	ctx.builder = LLVMCreateBuilderInContext(ctx.context);
> -- 
> 2.9.3
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list