| 1 | |
| 2 | #include <string.h>
|
| 3 | #include <linux/compiler.h>
|
| 4 | #include <linux/zalloc.h>
|
| 5 | #include "../disasm.h"
|
| 6 |
|
| 7 | static
|
| 8 | const struct ins_ops *mips__associate_ins_ops(struct arch *arch, const char *name)
|
| 9 | {
|
| 10 | const struct ins_ops *ops = NULL;
|
| 11 |
|
| 12 | if (!strncmp(name, "bal", 3) ||
|
| 13 | !strncmp(name, "bgezal", 6) ||
|
| 14 | !strncmp(name, "bltzal", 6) ||
|
| 15 | !strncmp(name, "bgtzal", 6) ||
|
| 16 | !strncmp(name, "blezal", 6) ||
|
| 17 | !strncmp(name, "beqzal", 6) ||
|
| 18 | !strncmp(name, "bnezal", 6) ||
|
| 19 | !strncmp(name, "bgtzl", 5) ||
|
| 20 | !strncmp(name, "bltzl", 5) ||
|
| 21 | !strncmp(name, "bgezl", 5) ||
|
| 22 | !strncmp(name, "blezl", 5) ||
|
| 23 | !strncmp(name, "jialc", 5) ||
|
| 24 | !strncmp(name, "beql", 4) ||
|
| 25 | !strncmp(name, "bnel", 4) ||
|
| 26 | !strncmp(name, "jal", 3))
|
| 27 | ops = &call_ops;
|
| 28 | else if (!strncmp(name, "jr", 2))
|
| 29 | ops = &ret_ops;
|
| 30 | else if (name[0] == 'j' || name[0] == 'b')
|
| 31 | ops = &jump_ops;
|
| 32 | else
|
| 33 | return NULL;
|
| 34 |
|
| 35 | arch__associate_ins_ops(arch, name, ops);
|
| 36 |
|
| 37 | return ops;
|
| 38 | }
|
| 39 |
|
| 40 | const struct arch *arch__new_mips(const struct e_machine_and_e_flags *id,
|
| 41 | const char *cpuid __maybe_unused)
|
| 42 | {
|
| 43 | struct arch *arch = zalloc(sizeof(*arch));
|
| 44 |
|
| 45 | if (!arch)
|
| 46 | return NULL;
|
| 47 |
|
| 48 | arch->name = "mips";
|
| 49 | arch->id = *id;
|
| 50 | arch->objdump.comment_char = '#';
|
| 51 | arch->associate_instruction_ops = mips__associate_ins_ops;
|
| 52 | return arch;
|
| 53 | }
|