From f47ca350777c240ba402320e5c05e86fcc3d6996 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 30 Jul 2022 12:17:27 +0800 Subject: [PATCH] llvmpipe: Remove llvm version guard LLVM_VERSION_MAJOR <=> 4 Signed-off-by: Yonggang Luo Reviewed-by: Jose Fonseca Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_intr.c | 39 +------------------ src/gallium/auxiliary/gallivm/lp_bld_intr.h | 6 +-- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 14 ------- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c b/src/gallium/auxiliary/gallivm/lp_bld_intr.c index 99f5c77c4f0..1a78312afff 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c @@ -131,25 +131,6 @@ lp_declare_intrinsic(LLVMModuleRef module, return lp_declare_intrinsic_with_type(module, name, function_type); } - -#if LLVM_VERSION_MAJOR < 4 -static LLVMAttribute lp_attr_to_llvm_attr(enum lp_func_attr attr) -{ - switch (attr) { - case LP_FUNC_ATTR_ALWAYSINLINE: return LLVMAlwaysInlineAttribute; - case LP_FUNC_ATTR_INREG: return LLVMInRegAttribute; - case LP_FUNC_ATTR_NOALIAS: return LLVMNoAliasAttribute; - case LP_FUNC_ATTR_NOUNWIND: return LLVMNoUnwindAttribute; - case LP_FUNC_ATTR_READNONE: return LLVMReadNoneAttribute; - case LP_FUNC_ATTR_READONLY: return LLVMReadOnlyAttribute; - default: - _debug_printf("Unhandled function attribute: %x\n", attr); - return 0; - } -} - -#else - static const char *attr_to_str(enum lp_func_attr attr) { switch (attr) { @@ -168,26 +149,10 @@ static const char *attr_to_str(enum lp_func_attr attr) } } -#endif - void lp_add_function_attr(LLVMValueRef function_or_call, int attr_idx, enum lp_func_attr attr) { - -#if LLVM_VERSION_MAJOR < 4 - LLVMAttribute llvm_attr = lp_attr_to_llvm_attr(attr); - if (LLVMIsAFunction(function_or_call)) { - if (attr_idx == -1) { - LLVMAddFunctionAttr(function_or_call, llvm_attr); - } else { - LLVMAddAttribute(LLVMGetParam(function_or_call, attr_idx - 1), llvm_attr); - } - } else { - LLVMAddInstrAttribute(function_or_call, attr_idx, llvm_attr); - } -#else - LLVMModuleRef module; if (LLVMIsAFunction(function_or_call)) { module = LLVMGetGlobalParent(function_or_call); @@ -207,7 +172,6 @@ lp_add_function_attr(LLVMValueRef function_or_call, LLVMAddAttributeAtIndex(function_or_call, attr_idx, llvm_attr); else LLVMAddCallSiteAttribute(function_or_call, attr_idx, llvm_attr); -#endif } static void @@ -235,8 +199,7 @@ lp_build_intrinsic(LLVMBuilderRef builder, { LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); LLVMValueRef function, call; - bool set_callsite_attrs = LLVM_VERSION_MAJOR >= 4 && - !(attr_mask & LP_FUNC_ATTR_LEGACY); + bool set_callsite_attrs = !(attr_mask & LP_FUNC_ATTR_LEGACY); LLVMTypeRef arg_types[LP_MAX_FUNC_ARGS]; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.h b/src/gallium/auxiliary/gallivm/lp_bld_intr.h index 98dfb0d0cb3..82716eabe31 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.h @@ -54,9 +54,9 @@ enum lp_func_attr { LP_FUNC_ATTR_NOUNWIND = (1 << 4), LP_FUNC_ATTR_READNONE = (1 << 5), LP_FUNC_ATTR_READONLY = (1 << 6), - LP_FUNC_ATTR_WRITEONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 7) : 0, - LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 8) : 0, - LP_FUNC_ATTR_CONVERGENT = LLVM_VERSION_MAJOR >= 4 ? (1 << 9) : 0, + LP_FUNC_ATTR_WRITEONLY = (1 << 7), + LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = (1 << 8), + LP_FUNC_ATTR_CONVERGENT = (1 << 9), /* Legacy intrinsic that needs attributes on function declarations * and they must match the internal LLVM definition exactly, otherwise diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 016a0c78ac5..2c993685b08 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -438,19 +438,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if defined(PIPE_ARCH_PPC) MAttrs.push_back(util_get_cpu_caps()->has_altivec ? "+altivec" : "-altivec"); -#if (LLVM_VERSION_MAJOR < 4) - /* - * Make sure VSX instructions are disabled - * See LLVM bugs: - * https://llvm.org/bugs/show_bug.cgi?id=25503#c7 (fixed in 3.8.1) - * https://llvm.org/bugs/show_bug.cgi?id=26775 (fixed in 3.8.1) - * https://llvm.org/bugs/show_bug.cgi?id=33531 (fixed in 4.0) - * https://llvm.org/bugs/show_bug.cgi?id=34647 (llc performance on certain unusual shader IR; intro'd in 4.0, pending as of 5.0) - */ - if (util_get_cpu_caps()->has_altivec) { - MAttrs.push_back("-vsx"); - } -#else /* * Bug 25503 is fixed, by the same fix that fixed * bug 26775, in versions of LLVM later than 3.8 (starting with 3.8.1). @@ -465,7 +452,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, MAttrs.push_back(util_get_cpu_caps()->has_vsx ? "+vsx" : "-vsx"); } #endif -#endif #if defined(PIPE_ARCH_MIPS64) MAttrs.push_back(util_get_cpu_caps()->has_msa ? "+msa" : "-msa");