From 5e349757d5d9ebad3825ee826ce66cfb04e2a054 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Thu, 30 Mar 2017 14:10:44 +0200 Subject: ac: add ac_get_exec_mask helper function TODO: this needs an optimization barrier to prevent hoisting / speculating --- src/amd/common/ac_llvm_build.c | 14 ++++++++++++++ src/amd/common/ac_llvm_build.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 1ae2b9dd17..a3afcb3586 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1121,6 +1121,20 @@ ac_get_thread_id(struct ac_llvm_context *ctx) return tid; } +LLVMValueRef +ac_get_exec_mask(struct ac_llvm_context *ctx) +{ + LLVMContextRef context = ctx->context; + LLVMValueRef md_exec; + LLVMValueRef args[1]; + + md_exec = LLVMMDStringInContext(context, "exec", 4); + args[0] = LLVMMDNodeInContext(context, &md_exec, 1); + + return ac_build_intrinsic(ctx, "llvm.read_register.i64", ctx->i64, + args, 1, AC_FUNC_ATTR_READONLY); +} + /* * SI implements derivatives using the local data store (LDS) * All writes to the LDS happen in all executing threads at diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 6adcc11448..bfbbe1b8d7 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -245,6 +245,9 @@ LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef ac_get_thread_id(struct ac_llvm_context *ctx); +LLVMValueRef +ac_get_exec_mask(struct ac_llvm_context *ctx); + #define AC_TID_MASK_TOP_LEFT 0xfffffffc #define AC_TID_MASK_TOP 0xfffffffd #define AC_TID_MASK_LEFT 0xfffffffe -- cgit v1.2.3