ac,radeonsi: fix compilations issues with LLVM 11

Latest LLVM replaced LLVMVectorTypeKind.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2826
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4755>
This commit is contained in:
Samuel Pitoiset
2020-04-27 11:01:24 +02:00
committed by Marge Bot
parent 52aa730d07
commit 42b1696ef6
5 changed files with 19 additions and 15 deletions

View File

@@ -144,7 +144,7 @@ int
ac_get_llvm_num_components(LLVMValueRef value) ac_get_llvm_num_components(LLVMValueRef value)
{ {
LLVMTypeRef type = LLVMTypeOf(value); LLVMTypeRef type = LLVMTypeOf(value);
unsigned num_components = LLVMGetTypeKind(type) == LLVMVectorTypeKind unsigned num_components = LLVMGetTypeKind(type) == LLVMFixedVectorTypeKind
? LLVMGetVectorSize(type) ? LLVMGetVectorSize(type)
: 1; : 1;
return num_components; return num_components;
@@ -155,7 +155,7 @@ ac_llvm_extract_elem(struct ac_llvm_context *ac,
LLVMValueRef value, LLVMValueRef value,
int index) int index)
{ {
if (LLVMGetTypeKind(LLVMTypeOf(value)) != LLVMVectorTypeKind) { if (LLVMGetTypeKind(LLVMTypeOf(value)) != LLVMFixedVectorTypeKind) {
assert(index == 0); assert(index == 0);
return value; return value;
} }
@@ -167,7 +167,7 @@ ac_llvm_extract_elem(struct ac_llvm_context *ac,
int int
ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type) ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type)
{ {
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) if (LLVMGetTypeKind(type) == LLVMFixedVectorTypeKind)
type = LLVMGetElementType(type); type = LLVMGetElementType(type);
if (LLVMGetTypeKind(type) == LLVMIntegerTypeKind) if (LLVMGetTypeKind(type) == LLVMIntegerTypeKind)
@@ -206,7 +206,7 @@ ac_get_type_size(LLVMTypeRef type)
if (LLVMGetPointerAddressSpace(type) == AC_ADDR_SPACE_CONST_32BIT) if (LLVMGetPointerAddressSpace(type) == AC_ADDR_SPACE_CONST_32BIT)
return 4; return 4;
return 8; return 8;
case LLVMVectorTypeKind: case LLVMFixedVectorTypeKind:
return LLVMGetVectorSize(type) * return LLVMGetVectorSize(type) *
ac_get_type_size(LLVMGetElementType(type)); ac_get_type_size(LLVMGetElementType(type));
case LLVMArrayTypeKind: case LLVMArrayTypeKind:
@@ -235,7 +235,7 @@ static LLVMTypeRef to_integer_type_scalar(struct ac_llvm_context *ctx, LLVMTypeR
LLVMTypeRef LLVMTypeRef
ac_to_integer_type(struct ac_llvm_context *ctx, LLVMTypeRef t) ac_to_integer_type(struct ac_llvm_context *ctx, LLVMTypeRef t)
{ {
if (LLVMGetTypeKind(t) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(t) == LLVMFixedVectorTypeKind) {
LLVMTypeRef elem_type = LLVMGetElementType(t); LLVMTypeRef elem_type = LLVMGetElementType(t);
return LLVMVectorType(to_integer_type_scalar(ctx, elem_type), return LLVMVectorType(to_integer_type_scalar(ctx, elem_type),
LLVMGetVectorSize(t)); LLVMGetVectorSize(t));
@@ -290,7 +290,7 @@ static LLVMTypeRef to_float_type_scalar(struct ac_llvm_context *ctx, LLVMTypeRef
LLVMTypeRef LLVMTypeRef
ac_to_float_type(struct ac_llvm_context *ctx, LLVMTypeRef t) ac_to_float_type(struct ac_llvm_context *ctx, LLVMTypeRef t)
{ {
if (LLVMGetTypeKind(t) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(t) == LLVMFixedVectorTypeKind) {
LLVMTypeRef elem_type = LLVMGetElementType(t); LLVMTypeRef elem_type = LLVMGetElementType(t);
return LLVMVectorType(to_float_type_scalar(ctx, elem_type), return LLVMVectorType(to_float_type_scalar(ctx, elem_type),
LLVMGetVectorSize(t)); LLVMGetVectorSize(t));
@@ -352,7 +352,7 @@ void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize)
assert(bufsize >= 8); assert(bufsize >= 8);
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(type) == LLVMFixedVectorTypeKind) {
int ret = snprintf(buf, bufsize, "v%u", int ret = snprintf(buf, bufsize, "v%u",
LLVMGetVectorSize(type)); LLVMGetVectorSize(type));
if (ret < 0) { if (ret < 0) {
@@ -627,7 +627,7 @@ ac_build_expand(struct ac_llvm_context *ctx,
LLVMTypeRef elemtype; LLVMTypeRef elemtype;
LLVMValueRef chan[dst_channels]; LLVMValueRef chan[dst_channels];
if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMFixedVectorTypeKind) {
unsigned vec_size = LLVMGetVectorSize(LLVMTypeOf(value)); unsigned vec_size = LLVMGetVectorSize(LLVMTypeOf(value));
if (src_channels == dst_channels && vec_size == dst_channels) if (src_channels == dst_channels && vec_size == dst_channels)

View File

@@ -36,6 +36,10 @@
extern "C" { extern "C" {
#endif #endif
#if LLVM_VERSION_MAJOR < 11
#define LLVMFixedVectorTypeKind LLVMVectorTypeKind
#endif
struct ac_compiler_passes; struct ac_compiler_passes;
enum ac_func_attr { enum ac_func_attr {

View File

@@ -245,7 +245,7 @@ static LLVMValueRef emit_bcsel(struct ac_llvm_context *ctx,
LLVMTypeRef src1_type = LLVMTypeOf(src1); LLVMTypeRef src1_type = LLVMTypeOf(src1);
LLVMTypeRef src2_type = LLVMTypeOf(src2); LLVMTypeRef src2_type = LLVMTypeOf(src2);
assert(LLVMGetTypeKind(LLVMTypeOf(src0)) != LLVMVectorTypeKind); assert(LLVMGetTypeKind(LLVMTypeOf(src0)) != LLVMFixedVectorTypeKind);
if (LLVMGetTypeKind(src1_type) == LLVMPointerTypeKind && if (LLVMGetTypeKind(src1_type) == LLVMPointerTypeKind &&
LLVMGetTypeKind(src2_type) != LLVMPointerTypeKind) { LLVMGetTypeKind(src2_type) != LLVMPointerTypeKind) {
@@ -2193,7 +2193,7 @@ static LLVMValueRef load_tess_varyings(struct ac_nir_context *ctx,
LLVMTypeRef dest_type = get_def_type(ctx, &instr->dest.ssa); LLVMTypeRef dest_type = get_def_type(ctx, &instr->dest.ssa);
LLVMTypeRef src_component_type; LLVMTypeRef src_component_type;
if (LLVMGetTypeKind(dest_type) == LLVMVectorTypeKind) if (LLVMGetTypeKind(dest_type) == LLVMFixedVectorTypeKind)
src_component_type = LLVMGetElementType(dest_type); src_component_type = LLVMGetElementType(dest_type);
else else
src_component_type = dest_type; src_component_type = dest_type;
@@ -2353,7 +2353,7 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
bool split_loads = ctx->ac.chip_class == GFX6 && elem_size_bytes < 4; bool split_loads = ctx->ac.chip_class == GFX6 && elem_size_bytes < 4;
if (stride != natural_stride || split_loads) { if (stride != natural_stride || split_loads) {
if (LLVMGetTypeKind(result_type) == LLVMVectorTypeKind) if (LLVMGetTypeKind(result_type) == LLVMFixedVectorTypeKind)
result_type = LLVMGetElementType(result_type); result_type = LLVMGetElementType(result_type);
LLVMTypeRef ptr_type = LLVMPointerType(result_type, LLVMTypeRef ptr_type = LLVMPointerType(result_type,
@@ -2529,7 +2529,7 @@ visit_store_var(struct ac_nir_context *ctx,
LLVMBuildStore(ctx->ac.builder, val, address); LLVMBuildStore(ctx->ac.builder, val, address);
} else { } else {
LLVMTypeRef val_type = LLVMTypeOf(val); LLVMTypeRef val_type = LLVMTypeOf(val);
if (LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind) if (LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMFixedVectorTypeKind)
val_type = LLVMGetElementType(val_type); val_type = LLVMGetElementType(val_type);
LLVMTypeRef ptr_type = LLVMPointerType(val_type, LLVMTypeRef ptr_type = LLVMPointerType(val_type,
@@ -4957,7 +4957,7 @@ static void visit_deref(struct ac_nir_context *ctx,
LLVMTypeRef type = LLVMPointerType(pointee_type, address_space); LLVMTypeRef type = LLVMPointerType(pointee_type, address_space);
if (LLVMTypeOf(result) != type) { if (LLVMTypeOf(result) != type) {
if (LLVMGetTypeKind(LLVMTypeOf(result)) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(LLVMTypeOf(result)) == LLVMFixedVectorTypeKind) {
result = LLVMBuildBitCast(ctx->ac.builder, result, result = LLVMBuildBitCast(ctx->ac.builder, result,
type, ""); type, "");
} else { } else {

View File

@@ -1173,7 +1173,7 @@ radv_fixup_vertex_input_fetches(struct radv_shader_context *ctx,
LLVMValueRef one = is_float ? ctx->ac.f32_1 : ctx->ac.i32_1; LLVMValueRef one = is_float ? ctx->ac.f32_1 : ctx->ac.i32_1;
LLVMValueRef chan[4]; LLVMValueRef chan[4];
if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMFixedVectorTypeKind) {
unsigned vec_size = LLVMGetVectorSize(LLVMTypeOf(value)); unsigned vec_size = LLVMGetVectorSize(LLVMTypeOf(value));
if (num_channels == 4 && num_channels == vec_size) if (num_channels == 4 && num_channels == vec_size)

View File

@@ -526,7 +526,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part
if (LLVMGetTypeKind(type) == LLVMPointerTypeKind) { if (LLVMGetTypeKind(type) == LLVMPointerTypeKind) {
type = LLVMGetElementType(type); type = LLVMGetElementType(type);
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) { if (LLVMGetTypeKind(type) == LLVMFixedVectorTypeKind) {
if (LLVMGetVectorSize(type) == 4) if (LLVMGetVectorSize(type) == 4)
arg_type = AC_ARG_CONST_DESC_PTR; arg_type = AC_ARG_CONST_DESC_PTR;
else if (LLVMGetVectorSize(type) == 8) else if (LLVMGetVectorSize(type) == 8)