Including bpf instruction macros and register alias.
Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
---
tools/perf/util/bpf-loader.h | 188 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 188 insertions(+)
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index baa4404..840f96d 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -70,4 +70,192 @@ struct bpf_obj {
} elf;
};
#define obj_elf_valid(o) ((o)->elf.fd >= 0)
+
+/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
+
+#define BPF_ALU64_REG(OP, DST, SRC) \
+ ((struct bpf_insn) { \
+ .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \
+ .dst_reg = DST, \
+ .src_reg = SRC, \
+ .off = 0, \
+ .imm = 0 })