1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef __PERF_UTIL_DISASM_H
3 #define __PERF_UTIL_DISASM_H
5 #include "map_symbol.h"
7 #ifdef HAVE_LIBDW_SUPPORT
11 struct annotation_options
;
22 struct ins
*instructions
;
23 size_t nr_instructions
;
24 size_t nr_instructions_allocated
;
25 struct ins_ops
*(*associate_instruction_ops
)(struct arch
*arch
, const char *name
);
26 bool sorted_instructions
;
28 const char *insn_suffix
;
32 int (*init
)(struct arch
*arch
, char *cpuid
);
33 bool (*ins_is_fused
)(struct arch
*arch
, const char *ins1
,
37 char skip_functions_char
;
42 #ifdef HAVE_LIBDW_SUPPORT
43 void (*update_insn_state
)(struct type_state
*state
,
44 struct data_loc_info
*dloc
, Dwarf_Die
*cu_die
,
45 struct disasm_line
*dl
);
47 /** @e_machine: ELF machine associated with arch. */
48 unsigned int e_machine
;
49 /** @e_flags: Optional ELF flags associated with arch. */
81 struct ins_operands
*ops
;
91 void (*free
)(struct ins_operands
*ops
);
92 int (*parse
)(struct arch
*arch
, struct ins_operands
*ops
, struct map_symbol
*ms
,
93 struct disasm_line
*dl
);
94 int (*scnprintf
)(struct ins
*ins
, char *bf
, size_t size
,
95 struct ins_operands
*ops
, int max_ins_name
);
98 struct annotate_args
{
100 struct map_symbol ms
;
102 struct annotation_options
*options
;
109 struct arch
*arch__find(const char *name
);
110 bool arch__is(struct arch
*arch
, const char *name
);
112 struct ins_ops
*ins__find(struct arch
*arch
, const char *name
, struct disasm_line
*dl
);
113 int ins__scnprintf(struct ins
*ins
, char *bf
, size_t size
,
114 struct ins_operands
*ops
, int max_ins_name
);
116 bool ins__is_call(const struct ins
*ins
);
117 bool ins__is_jump(const struct ins
*ins
);
118 bool ins__is_fused(struct arch
*arch
, const char *ins1
, const char *ins2
);
119 bool ins__is_nop(const struct ins
*ins
);
120 bool ins__is_ret(const struct ins
*ins
);
121 bool ins__is_lock(const struct ins
*ins
);
123 struct disasm_line
*disasm_line__new(struct annotate_args
*args
);
124 void disasm_line__free(struct disasm_line
*dl
);
126 int disasm_line__scnprintf(struct disasm_line
*dl
, char *bf
, size_t size
,
127 bool raw
, int max_ins_name
);
129 int symbol__disassemble(struct symbol
*sym
, struct annotate_args
*args
);
131 #endif /* __PERF_UTIL_DISASM_H */