Path: blob/master/tools/perf/arch/arm/annotate/instructions.c
49693 views
// SPDX-License-Identifier: GPL-2.01#include <linux/compiler.h>2#include <linux/zalloc.h>3#include <errno.h>4#include <sys/types.h>5#include <regex.h>6#include <stdlib.h>78struct arm_annotate {9regex_t call_insn,10jump_insn;11};1213static struct ins_ops *arm__associate_instruction_ops(struct arch *arch, const char *name)14{15struct arm_annotate *arm = arch->priv;16struct ins_ops *ops;17regmatch_t match[2];1819if (!regexec(&arm->call_insn, name, 2, match, 0))20ops = &call_ops;21else if (!regexec(&arm->jump_insn, name, 2, match, 0))22ops = &jump_ops;23else24return NULL;2526arch__associate_ins_ops(arch, name, ops);27return ops;28}2930static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)31{32struct arm_annotate *arm;33int err;3435if (arch->initialized)36return 0;3738arm = zalloc(sizeof(*arm));39if (!arm)40return ENOMEM;4142#define ARM_CONDS "(cc|cs|eq|ge|gt|hi|le|ls|lt|mi|ne|pl|vc|vs)"43err = regcomp(&arm->call_insn, "^blx?" ARM_CONDS "?$", REG_EXTENDED);44if (err)45goto out_free_arm;46err = regcomp(&arm->jump_insn, "^bx?" ARM_CONDS "?$", REG_EXTENDED);47if (err)48goto out_free_call;49#undef ARM_CONDS5051arch->initialized = true;52arch->priv = arm;53arch->associate_instruction_ops = arm__associate_instruction_ops;54arch->objdump.comment_char = ';';55arch->objdump.skip_functions_char = '+';56arch->e_machine = EM_ARM;57arch->e_flags = 0;58return 0;5960out_free_call:61regfree(&arm->call_insn);62out_free_arm:63free(arm);64return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP;65}666768