Mesa (master): radv: setup llvm target data layout

Dave Airlie airlied at kemper.freedesktop.org
Tue Mar 14 00:35:11 UTC 2017


Module: Mesa
Branch: master
Commit: b8ee70384adc3286d18febba7a92047118cc0f0f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8ee70384adc3286d18febba7a92047118cc0f0f

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Mar 14 06:50:59 2017 +1000

radv: setup llvm target data layout

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."

Cc: "13.0 17.0" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Tom Stellard <tstellar at redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied 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 7675ecf..0aba679 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -4793,6 +4793,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);




More information about the mesa-commit mailing list