annotate-mips.c 1.3 KB

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