Mesa (master): radeonsi: Use llvm.amdgcn.mbcnt.* intrinsics instead of llvm.SI.tid

Tom Stellard tstellar at kemper.freedesktop.org
Sat Apr 23 01:07:04 UTC 2016


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

Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Fri Apr 15 22:53:38 2016 +0000

radeonsi: Use llvm.amdgcn.mbcnt.* intrinsics instead of llvm.SI.tid

We're trying to move to more of the new style intrinsics with include
the correct target name, and map directly to ISA instructions.

v2:
  - Only do this with LLVM 3.8 and newer.

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/gallium/drivers/radeonsi/si_shader.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index cd6725e..9b3f591 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1141,8 +1141,23 @@ static void set_range_metadata(LLVMValueRef value, unsigned lo, unsigned hi)
 static LLVMValueRef get_thread_id(struct si_shader_context *ctx)
 {
 	struct gallivm_state *gallivm = &ctx->radeon_bld.gallivm;
-	LLVMValueRef tid = lp_build_intrinsic(gallivm->builder, "llvm.SI.tid",
+	LLVMValueRef tid;
+
+	if (HAVE_LLVM < 0x0308) {
+		tid = lp_build_intrinsic(gallivm->builder, "llvm.SI.tid",
 				ctx->i32,   NULL, 0, LLVMReadNoneAttribute);
+	} else {
+		LLVMValueRef tid_args[2];
+		tid_args[0] = lp_build_const_int32(gallivm, 0xffffffff);
+		tid_args[1] = lp_build_const_int32(gallivm, 0);
+		tid_args[1] = lp_build_intrinsic(gallivm->builder,
+					"llvm.amdgcn.mbcnt.lo", ctx->i32,
+					tid_args, 2, LLVMReadNoneAttribute);
+
+		tid = lp_build_intrinsic(gallivm->builder,
+					"llvm.amdgcn.mbcnt.hi", ctx->i32,
+					tid_args, 2, LLVMReadNoneAttribute);
+	}
 	set_range_metadata(tid, 0, 64);
 	return tid;
 }




More information about the mesa-commit mailing list