inst.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Format of an instruction in memory.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1996, 2000 by Ralf Baechle
  9. * Copyright (C) 2006 by Thiemo Seufer
  10. */
  11. #ifndef _ASM_INST_H
  12. #define _ASM_INST_H
  13. #include <uapi/asm/inst.h>
  14. /* HACHACHAHCAHC ... */
  15. /* In case some other massaging is needed, keep MIPSInst as wrapper */
  16. #define MIPSInst(x) x
  17. #define I_OPCODE_SFT 26
  18. #define MIPSInst_OPCODE(x) (MIPSInst(x) >> I_OPCODE_SFT)
  19. #define I_JTARGET_SFT 0
  20. #define MIPSInst_JTARGET(x) (MIPSInst(x) & 0x03ffffff)
  21. #define I_RS_SFT 21
  22. #define MIPSInst_RS(x) ((MIPSInst(x) & 0x03e00000) >> I_RS_SFT)
  23. #define I_RT_SFT 16
  24. #define MIPSInst_RT(x) ((MIPSInst(x) & 0x001f0000) >> I_RT_SFT)
  25. #define I_IMM_SFT 0
  26. #define MIPSInst_SIMM(x) ((int)((short)(MIPSInst(x) & 0xffff)))
  27. #define MIPSInst_UIMM(x) (MIPSInst(x) & 0xffff)
  28. #define I_CACHEOP_SFT 18
  29. #define MIPSInst_CACHEOP(x) ((MIPSInst(x) & 0x001c0000) >> I_CACHEOP_SFT)
  30. #define I_CACHESEL_SFT 16
  31. #define MIPSInst_CACHESEL(x) ((MIPSInst(x) & 0x00030000) >> I_CACHESEL_SFT)
  32. #define I_RD_SFT 11
  33. #define MIPSInst_RD(x) ((MIPSInst(x) & 0x0000f800) >> I_RD_SFT)
  34. #define I_RE_SFT 6
  35. #define MIPSInst_RE(x) ((MIPSInst(x) & 0x000007c0) >> I_RE_SFT)
  36. #define I_FUNC_SFT 0
  37. #define MIPSInst_FUNC(x) (MIPSInst(x) & 0x0000003f)
  38. #define I_FFMT_SFT 21
  39. #define MIPSInst_FFMT(x) ((MIPSInst(x) & 0x01e00000) >> I_FFMT_SFT)
  40. #define I_FT_SFT 16
  41. #define MIPSInst_FT(x) ((MIPSInst(x) & 0x001f0000) >> I_FT_SFT)
  42. #define I_FS_SFT 11
  43. #define MIPSInst_FS(x) ((MIPSInst(x) & 0x0000f800) >> I_FS_SFT)
  44. #define I_FD_SFT 6
  45. #define MIPSInst_FD(x) ((MIPSInst(x) & 0x000007c0) >> I_FD_SFT)
  46. #define I_FR_SFT 21
  47. #define MIPSInst_FR(x) ((MIPSInst(x) & 0x03e00000) >> I_FR_SFT)
  48. #define I_FMA_FUNC_SFT 2
  49. #define MIPSInst_FMA_FUNC(x) ((MIPSInst(x) & 0x0000003c) >> I_FMA_FUNC_SFT)
  50. #define I_FMA_FFMT_SFT 0
  51. #define MIPSInst_FMA_FFMT(x) (MIPSInst(x) & 0x00000003)
  52. typedef unsigned int mips_instruction;
  53. /* microMIPS instruction decode structure. Do NOT export!!! */
  54. struct mm_decoded_insn {
  55. mips_instruction insn;
  56. mips_instruction next_insn;
  57. int pc_inc;
  58. int next_pc_inc;
  59. int micro_mips_mode;
  60. };
  61. /* Recode table from 16-bit register notation to 32-bit GPR. Do NOT export!!! */
  62. extern const int reg16to32[];
  63. #endif /* _ASM_INST_H */