[Mesa-dev] [PATCH 2/4] radeonsi: use ac_get_llvm_processor_name

Marek Olšák maraeo at gmail.com
Tue Nov 7 03:12:31 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/amd/common/ac_llvm_util.c                 |  2 +-
 src/amd/common/ac_llvm_util.h                 |  2 ++
 src/gallium/drivers/radeon/r600_pipe_common.c | 37 ++-------------------------
 src/gallium/drivers/radeon/r600_pipe_common.h |  1 -
 src/gallium/drivers/radeonsi/si_pipe.c        |  4 +--
 5 files changed, 7 insertions(+), 39 deletions(-)

diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c
index 675926e..fb2bc11 100644
--- a/src/amd/common/ac_llvm_util.c
+++ b/src/amd/common/ac_llvm_util.c
@@ -67,21 +67,21 @@ LLVMTargetRef ac_get_llvm_target(const char *triple)
 		fprintf(stderr, "Cannot find target for triple %s ", triple);
 		if (err_message) {
 			fprintf(stderr, "%s\n", err_message);
 		}
 		LLVMDisposeMessage(err_message);
 		return NULL;
 	}
 	return target;
 }
 
-static const char *ac_get_llvm_processor_name(enum radeon_family family)
+const char *ac_get_llvm_processor_name(enum radeon_family family)
 {
 	switch (family) {
 	case CHIP_TAHITI:
 		return "tahiti";
 	case CHIP_PITCAIRN:
 		return "pitcairn";
 	case CHIP_VERDE:
 		return "verde";
 	case CHIP_OLAND:
 		return "oland";
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
index cc4fe3b..d4b3915 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -51,20 +51,22 @@ enum ac_func_attr {
 	 * and they must match the internal LLVM definition exactly, otherwise
 	 * intrinsic selection fails.
 	 */
 	AC_FUNC_ATTR_LEGACY       = (1u << 31),
 };
 
 enum ac_target_machine_options {
 	AC_TM_SUPPORTS_SPILL = (1 << 0),
 	AC_TM_SISCHED = (1 << 1),
 };
+
+const char *ac_get_llvm_processor_name(enum radeon_family family);
 LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options);
 
 LLVMTargetRef ac_get_llvm_target(const char *triple);
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
 bool ac_is_sgpr_param(LLVMValueRef param);
 void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
                           int attr_idx, enum ac_func_attr attr);
 void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
 			    unsigned attrib_mask);
 void ac_dump_module(LLVMModuleRef module);
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 478f626..aa72187 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -26,20 +26,21 @@
 #include "tgsi/tgsi_parse.h"
 #include "util/list.h"
 #include "util/u_draw_quad.h"
 #include "util/u_memory.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_upload_mgr.h"
 #include "os/os_time.h"
 #include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 #include "radeon/radeon_video.h"
+#include "amd/common/ac_llvm_util.h"
 #include "amd/common/sid.h"
 #include <inttypes.h>
 #include <sys/utsname.h>
 #include <libsync.h>
 
 #include <llvm-c/TargetMachine.h>
 
 
 struct r600_multi_fence {
 	struct pipe_reference reference;
@@ -989,54 +990,20 @@ static int r600_get_video_param(struct pipe_screen *screen,
 		return false;
 	case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE:
 		return true;
 	case PIPE_VIDEO_CAP_MAX_LEVEL:
 		return vl_level_supported(screen, profile);
 	default:
 		return 0;
 	}
 }
 
-const char *si_get_llvm_processor_name(enum radeon_family family)
-{
-	switch (family) {
-	case CHIP_TAHITI: return "tahiti";
-	case CHIP_PITCAIRN: return "pitcairn";
-	case CHIP_VERDE: return "verde";
-	case CHIP_OLAND: return "oland";
-	case CHIP_HAINAN: return "hainan";
-	case CHIP_BONAIRE: return "bonaire";
-	case CHIP_KABINI: return "kabini";
-	case CHIP_KAVERI: return "kaveri";
-	case CHIP_HAWAII: return "hawaii";
-	case CHIP_MULLINS:
-		return "mullins";
-	case CHIP_TONGA: return "tonga";
-	case CHIP_ICELAND: return "iceland";
-	case CHIP_CARRIZO: return "carrizo";
-	case CHIP_FIJI:
-		return "fiji";
-	case CHIP_STONEY:
-		return "stoney";
-	case CHIP_POLARIS10:
-		return "polaris10";
-	case CHIP_POLARIS11:
-	case CHIP_POLARIS12: /* same as polaris11 */
-		return "polaris11";
-	case CHIP_VEGA10:
-	case CHIP_RAVEN:
-		return "gfx900";
-	default:
-		return "";
-	}
-}
-
 static unsigned get_max_threads_per_block(struct r600_common_screen *screen,
 					  enum pipe_shader_ir ir_type)
 {
 	if (ir_type != PIPE_SHADER_IR_TGSI)
 		return 256;
 
 	/* Only 16 waves per thread-group on gfx9. */
 	if (screen->chip_class >= GFX9)
 		return 1024;
 
@@ -1057,21 +1024,21 @@ static int r600_get_compute_param(struct pipe_screen *screen,
 	switch (param) {
 	case PIPE_COMPUTE_CAP_IR_TARGET: {
 		const char *gpu;
 		const char *triple;
 
 		if (HAVE_LLVM < 0x0400)
 			triple = "amdgcn--";
 		else
 			triple = "amdgcn-mesa-mesa3d";
 
-		gpu = si_get_llvm_processor_name(rscreen->family);
+		gpu = ac_get_llvm_processor_name(rscreen->family);
 		if (ret) {
 			sprintf(ret, "%s-%s", gpu, triple);
 		}
 		/* +2 for dash and terminating NIL byte */
 		return (strlen(triple) + strlen(gpu) + 2) * sizeof(char);
 	}
 	case PIPE_COMPUTE_CAP_GRID_DIMENSION:
 		if (ret) {
 			uint64_t *grid_dimension = ret;
 			grid_dimension[0] = 3;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index a7fec37..f803ee4 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -710,21 +710,20 @@ bool si_common_context_init(struct r600_common_context *rctx,
 			    unsigned context_flags);
 void si_common_context_cleanup(struct r600_common_context *rctx);
 bool si_can_dump_shader(struct r600_common_screen *rscreen,
 			unsigned processor);
 bool si_extra_shader_checks(struct r600_common_screen *rscreen,
 			    unsigned processor);
 void si_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst,
 			    uint64_t offset, uint64_t size, unsigned value);
 struct pipe_resource *si_resource_create_common(struct pipe_screen *screen,
 						const struct pipe_resource *templ);
-const char *si_get_llvm_processor_name(enum radeon_family family);
 void si_need_dma_space(struct r600_common_context *ctx, unsigned num_dw,
 		       struct r600_resource *dst, struct r600_resource *src);
 void si_save_cs(struct radeon_winsys *ws, struct radeon_winsys_cs *cs,
 		struct radeon_saved_cs *saved, bool get_buffer_list);
 void si_clear_saved_cs(struct radeon_saved_cs *saved);
 bool si_check_device_reset(struct r600_common_context *rctx);
 
 /* r600_gpu_load.c */
 void si_gpu_load_kill_thread(struct r600_common_screen *rscreen);
 uint64_t si_begin_counter(struct r600_common_screen *rscreen, unsigned type);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 649a72e..e96380c 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -148,21 +148,21 @@ si_create_llvm_target_machine(struct si_screen *sscreen)
 	const char *triple = "amdgcn--";
 	char features[256];
 
 	snprintf(features, sizeof(features),
 		 "+DumpCode,+vgpr-spilling,-fp32-denormals,+fp64-denormals%s%s%s",
 		 sscreen->b.chip_class >= GFX9 ? ",+xnack" : ",-xnack",
 		 sscreen->llvm_has_working_vgpr_indexing ? "" : ",-promote-alloca",
 		 sscreen->b.debug_flags & DBG(SI_SCHED) ? ",+si-scheduler" : "");
 
 	return LLVMCreateTargetMachine(ac_get_llvm_target(triple), triple,
-				       si_get_llvm_processor_name(sscreen->b.family),
+				       ac_get_llvm_processor_name(sscreen->b.family),
 				       features,
 				       LLVMCodeGenLevelDefault,
 				       LLVMRelocDefault,
 				       LLVMCodeModelDefault);
 }
 
 static void si_set_log_context(struct pipe_context *ctx,
 			       struct u_log_context *log)
 {
 	struct si_context *sctx = (struct si_context *)ctx;
@@ -900,21 +900,21 @@ static bool si_init_gs_info(struct si_screen *sscreen)
 
 static void si_handle_env_var_force_family(struct si_screen *sscreen)
 {
 	const char *family = debug_get_option("SI_FORCE_FAMILY", NULL);
 	unsigned i;
 
 	if (!family)
 		return;
 
 	for (i = CHIP_TAHITI; i < CHIP_LAST; i++) {
-		if (!strcmp(family, si_get_llvm_processor_name(i))) {
+		if (!strcmp(family, ac_get_llvm_processor_name(i))) {
 			/* Override family and chip_class. */
 			sscreen->b.family = sscreen->b.info.family = i;
 
 			if (i >= CHIP_VEGA10)
 				sscreen->b.chip_class = sscreen->b.info.chip_class = GFX9;
 			else if (i >= CHIP_TONGA)
 				sscreen->b.chip_class = sscreen->b.info.chip_class = VI;
 			else if (i >= CHIP_BONAIRE)
 				sscreen->b.chip_class = sscreen->b.info.chip_class = CIK;
 			else
-- 
2.7.4



More information about the mesa-dev mailing list