Ejemplo n.º 1
0
unsigned r600_llvm_compile(
	LLVMModuleRef mod,
	unsigned char ** inst_bytes,
	unsigned * inst_byte_count,
	enum radeon_family family,
	unsigned dump)
{
	const char * gpu_family = r600_llvm_gpu_string(family);
	return radeon_llvm_compile(mod, inst_bytes, inst_byte_count,
							gpu_family, dump);
}
unsigned r600_llvm_compile(
	LLVMModuleRef mod,
	enum radeon_family family,
	struct r600_bytecode *bc,
	boolean *use_kill,
	unsigned dump)
{
	unsigned r;
	struct radeon_llvm_binary binary;
	const char * gpu_family = r600_llvm_gpu_string(family);
	unsigned i;

	memset(&binary, 0, sizeof(struct radeon_llvm_binary));
	r = radeon_llvm_compile(mod, &binary, gpu_family, dump);

	assert(binary.code_size % 4 == 0);
	bc->bytecode = CALLOC(1, binary.code_size);
	memcpy(bc->bytecode, binary.code, binary.code_size);
	bc->ndw = binary.code_size / 4;

	for (i = 0; i < binary.config_size; i+= 8) {
		unsigned reg =
			util_le32_to_cpu(*(uint32_t*)(binary.config + i));
		unsigned value =
			util_le32_to_cpu(*(uint32_t*)(binary.config + i + 4));
		switch (reg) {
		/* R600 / R700 */
		case R_028850_SQ_PGM_RESOURCES_PS:
		case R_028868_SQ_PGM_RESOURCES_VS:
		/* Evergreen / Northern Islands */
		case R_028844_SQ_PGM_RESOURCES_PS:
		case R_028860_SQ_PGM_RESOURCES_VS:
		case R_0288D4_SQ_PGM_RESOURCES_LS:
			bc->ngpr = G_028844_NUM_GPRS(value);
			bc->nstack = G_028844_STACK_SIZE(value);
			break;
		case R_02880C_DB_SHADER_CONTROL:
			*use_kill = G_02880C_KILL_ENABLE(value);
			break;
		case CM_R_0288E8_SQ_LDS_ALLOC:
			bc->nlds_dw = value;
			break;
		}
	}

	FREE(binary.code);
	FREE(binary.config);

	return r;
}
unsigned r600_llvm_compile(
	LLVMModuleRef mod,
	enum radeon_family family,
	struct r600_bytecode *bc,
	boolean *use_kill,
	unsigned dump)
{
	unsigned r;
	struct radeon_shader_binary binary;
	const char * gpu_family = r600_get_llvm_processor_name(family);

	memset(&binary, 0, sizeof(struct radeon_shader_binary));
	r = radeon_llvm_compile(mod, &binary, gpu_family, dump, dump, NULL);

	r = r600_create_shader(bc, &binary, use_kill);

	FREE(binary.code);
	FREE(binary.config);
	FREE(binary.rodata);
	FREE(binary.global_symbol_offsets);

	return r;
}
Ejemplo n.º 4
0
unsigned r600_llvm_compile(
	LLVMModuleRef mod,
	enum radeon_family family,
	struct r600_bytecode *bc,
	boolean *use_kill,
	unsigned dump,
	struct pipe_debug_callback *debug)
{
	unsigned r;
	struct radeon_shader_binary binary;
	const char * gpu_family = r600_get_llvm_processor_name(family);

	radeon_shader_binary_init(&binary);
	if (dump)
		LLVMDumpModule(mod);
	r = radeon_llvm_compile(mod, &binary, gpu_family, NULL, debug);

	r = r600_create_shader(bc, &binary, use_kill);

	radeon_shader_binary_clean(&binary);

	return r;
}