mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
ac/llvm: simplify how function attributes are set
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20146>
This commit is contained in:
parent
9b4142ae9f
commit
2b5edf96ff
4 changed files with 7 additions and 27 deletions
|
|
@ -4629,10 +4629,10 @@ struct ac_llvm_pointer ac_build_main(const struct ac_shader_args *args, struct a
|
|||
if (args->args[i].file != AC_ARG_SGPR)
|
||||
continue;
|
||||
|
||||
ac_add_function_attr(ctx->context, main_function, i + 1, AC_FUNC_ATTR_INREG);
|
||||
ac_add_function_attr(ctx->context, main_function, i + 1, "inreg");
|
||||
|
||||
if (LLVMGetTypeKind(LLVMTypeOf(P)) == LLVMPointerTypeKind) {
|
||||
ac_add_function_attr(ctx->context, main_function, i + 1, AC_FUNC_ATTR_NOALIAS);
|
||||
ac_add_function_attr(ctx->context, main_function, i + 1, "noalias");
|
||||
ac_add_attr_dereferenceable(P, UINT64_MAX);
|
||||
ac_add_attr_alignment(P, 4);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,31 +248,16 @@ static LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_libr
|
|||
return passmgr;
|
||||
}
|
||||
|
||||
static const char *attr_to_str(enum ac_func_attr attr)
|
||||
{
|
||||
switch (attr) {
|
||||
case AC_FUNC_ATTR_ALWAYSINLINE:
|
||||
return "alwaysinline";
|
||||
case AC_FUNC_ATTR_INREG:
|
||||
return "inreg";
|
||||
case AC_FUNC_ATTR_NOALIAS:
|
||||
return "noalias";
|
||||
default:
|
||||
fprintf(stderr, "Unhandled function attribute: %x\n", attr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
LLVMAttributeRef ac_get_llvm_attribute(LLVMContextRef ctx, const char *str)
|
||||
{
|
||||
return LLVMCreateEnumAttribute(ctx, LLVMGetEnumAttributeKindForName(str, strlen(str)), 0);
|
||||
}
|
||||
|
||||
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function, int attr_idx,
|
||||
enum ac_func_attr attr)
|
||||
const char *attr)
|
||||
{
|
||||
assert(LLVMIsAFunction(function));
|
||||
LLVMAddAttributeAtIndex(function, attr_idx, ac_get_llvm_attribute(ctx, attr_to_str(attr)));
|
||||
LLVMAddAttributeAtIndex(function, attr_idx, ac_get_llvm_attribute(ctx, attr));
|
||||
}
|
||||
|
||||
void ac_dump_module(LLVMModuleRef module)
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ struct ac_llvm_context;
|
|||
|
||||
enum ac_func_attr
|
||||
{
|
||||
/* Function and parameter attributes. */
|
||||
AC_FUNC_ATTR_ALWAYSINLINE = (1 << 0),
|
||||
AC_FUNC_ATTR_INREG = (1 << 1),
|
||||
AC_FUNC_ATTR_NOALIAS = (1 << 2),
|
||||
|
||||
/* Call attributes. */
|
||||
AC_FUNC_ATTR_READNONE = (1 << 3),
|
||||
AC_FUNC_ATTR_CONVERGENT = (1 << 4),
|
||||
|
|
@ -91,7 +86,7 @@ void ac_add_attr_alignment(LLVMValueRef val, uint64_t bytes);
|
|||
bool ac_is_sgpr_param(LLVMValueRef param);
|
||||
LLVMAttributeRef ac_get_llvm_attribute(LLVMContextRef ctx, const char *str);
|
||||
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function, int attr_idx,
|
||||
enum ac_func_attr attr);
|
||||
const char *attr);
|
||||
void ac_dump_module(LLVMModuleRef module);
|
||||
LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx);
|
||||
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx, enum ac_float_mode float_mode);
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, struct ac_llvm_poi
|
|||
memset(ctx->args, 0, sizeof(*ctx->args));
|
||||
|
||||
for (unsigned i = 0; i < num_parts; ++i) {
|
||||
ac_add_function_attr(ctx->ac.context, parts[i].value, -1, AC_FUNC_ATTR_ALWAYSINLINE);
|
||||
ac_add_function_attr(ctx->ac.context, parts[i].value, -1, "alwaysinline");
|
||||
LLVMSetLinkage(parts[i].value, LLVMPrivateLinkage);
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, struct ac_llvm_poi
|
|||
is_sgpr = ac_is_sgpr_param(param);
|
||||
|
||||
if (is_sgpr) {
|
||||
ac_add_function_attr(ctx->ac.context, parts[part].value, param_idx + 1, AC_FUNC_ATTR_INREG);
|
||||
ac_add_function_attr(ctx->ac.context, parts[part].value, param_idx + 1, "inreg");
|
||||
} else if (out_idx < num_out_sgpr) {
|
||||
/* Skip returned SGPRs the current part doesn't
|
||||
* declare on the input. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue