llvmpipe: Remove llvm version guard LLVM_VERSION_MAJOR <=> 4

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17813>
This commit is contained in:
Yonggang Luo 2022-07-30 12:17:27 +08:00 committed by Marge Bot
parent 1ebfa00bc5
commit f47ca35077
3 changed files with 4 additions and 55 deletions

View file

@ -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];

View file

@ -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

View file

@ -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");