summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2016-12-15 15:25:49 +0000
committerTom Stellard <thomas.stellard@amd.com>2017-01-31 20:39:30 +0000
commite0cc0a614c96011958bc3a1b84da9168e0e1ccbb (patch)
tree3d0320f93e7918ed276a8ac1106e3f435fff12a2 /src
parent11e9ebbf15ecf49d7ef02c2ec6c2d9d3ff0f1b6e (diff)
radeonsi: Set datalayout on the llvm module
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@amd.com>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 4f355e5849..205686a771 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1256,6 +1256,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.
@@ -1273,6 +1275,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);