Commit 10adbf77 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf annotate: Add and use ins__is_nop()

Likewise, add ins__is_nop() to check if the current instruction is NOP.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Tested-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240329215812.537846-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ad399baa
...@@ -757,6 +757,11 @@ static struct ins_ops ret_ops = { ...@@ -757,6 +757,11 @@ static struct ins_ops ret_ops = {
.scnprintf = ins__raw_scnprintf, .scnprintf = ins__raw_scnprintf,
}; };
bool ins__is_nop(const struct ins *ins)
{
return ins->ops == &nop_ops;
}
bool ins__is_ret(const struct ins *ins) bool ins__is_ret(const struct ins *ins)
{ {
return ins->ops == &ret_ops; return ins->ops == &ret_ops;
...@@ -1785,7 +1790,7 @@ static void delete_last_nop(struct symbol *sym) ...@@ -1785,7 +1790,7 @@ static void delete_last_nop(struct symbol *sym)
dl = list_entry(list->prev, struct disasm_line, al.node); dl = list_entry(list->prev, struct disasm_line, al.node);
if (dl->ins.ops) { if (dl->ins.ops) {
if (dl->ins.ops != &nop_ops) if (!ins__is_nop(&dl->ins))
return; return;
} else { } else {
if (!strstr(dl->al.line, " nop ") && if (!strstr(dl->al.line, " nop ") &&
......
...@@ -74,6 +74,7 @@ struct ins_ops { ...@@ -74,6 +74,7 @@ struct ins_ops {
bool ins__is_jump(const struct ins *ins); bool ins__is_jump(const struct ins *ins);
bool ins__is_call(const struct ins *ins); bool ins__is_call(const struct ins *ins);
bool ins__is_nop(const struct ins *ins);
bool ins__is_ret(const struct ins *ins); bool ins__is_ret(const struct ins *ins);
bool ins__is_lock(const struct ins *ins); bool ins__is_lock(const struct ins *ins);
int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name); int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment