diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2013-07-14 13:28:56 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2013-07-14 13:28:56 +0000 |
commit | ab90248154ba05dc800c480712c3cb03eb33b135 (patch) | |
tree | 111a36595f3d3ad10b07a5fc1b7c6a443ac757a0 /opcodes/mips-opc.c | |
parent | 2f8b73cc2b2dd77e0f4cc772262c9ae0092d4e14 (diff) | |
download | gdb-ab90248154ba05dc800c480712c3cb03eb33b135.zip gdb-ab90248154ba05dc800c480712c3cb03eb33b135.tar.gz gdb-ab90248154ba05dc800c480712c3cb03eb33b135.tar.bz2 |
include/opcode/
* mips.h (mips_operand_type, mips_reg_operand_type): New enums.
(mips_operand, mips_int_operand, mips_mapped_int_operand)
(mips_msb_operand, mips_reg_operand, mips_reg_pair_operand)
(mips_pcrel_operand): New structures.
(mips_insert_operand, mips_extract_operand, mips_signed_operand)
(mips_decode_int_operand, mips_decode_pcrel_operand): New functions.
(decode_mips_operand, decode_micromips_operand): Declare.
opcodes/
* mips-formats.h: New file.
* mips-opc.c: Include mips-formats.h.
(reg_0_map): New static array.
(decode_mips_operand): New function.
* micromips-opc.c: Remove <stdio.h> include. Include mips-formats.h.
(reg_0_map, reg_28_map, reg_29_map, reg_31_map, reg_m16_map)
(reg_mn_map, reg_q_map, reg_h_map1, reg_h_map2, int_b_map)
(int_c_map): New static arrays.
(decode_micromips_operand): New function.
* mips-dis.c (micromips_to_32_reg_b_map, micromips_to_32_reg_c_map)
(micromips_to_32_reg_d_map, micromips_to_32_reg_e_map)
(micromips_to_32_reg_f_map, micromips_to_32_reg_g_map)
(micromips_to_32_reg_h_map1, micromips_to_32_reg_h_map2)
(micromips_to_32_reg_l_map, micromips_to_32_reg_m_map)
(micromips_to_32_reg_n_map, micromips_to_32_reg_q_map)
(micromips_imm_b_map, micromips_imm_c_map): Delete.
(print_reg): New function.
(mips_print_arg_state): New structure.
(init_print_arg_state, print_insn_arg): New functions.
(print_insn_args): Change interface and use mips_operand structures.
Delete GET_OP_S. Move GET_OP definition to...
(print_insn_mips): ...here. Update the call to print_insn_args.
(print_insn_micromips): Use print_insn_args.
gas/
* config/tc-mips.c (validate_mips_insn): Move further up file.
Add insn_bits and decode_operand arguments. Use the mips_operand
fields to work out which bits an operand occupies. Detect double
definitions.
(validate_micromips_insn): Move further up file. Call into
validate_mips_insn.
Diffstat (limited to 'opcodes/mips-opc.c')
-rw-r--r-- | opcodes/mips-opc.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/opcodes/mips-opc.c b/opcodes/mips-opc.c index e6833f7..702016b 100644 --- a/opcodes/mips-opc.c +++ b/opcodes/mips-opc.c @@ -28,6 +28,123 @@ #include "sysdep.h" #include <stdio.h> #include "opcode/mips.h" +#include "mips-formats.h" + +static unsigned char reg_0_map[] = { 0 }; + +/* Return the mips_operand structure for the operand at the beginning of P. */ + +const struct mips_operand * +decode_mips_operand (const char *p) +{ + switch (p[0]) + { + case '+': + switch (p[1]) + { + case '1': HINT (5, 6); + case '2': HINT (10, 6); + case '3': HINT (15, 6); + case '4': HINT (20, 6); + + case 'A': BIT (5, 6, 0); /* (0 .. 31) */ + case 'B': MSB (5, 11, 1, TRUE, 32); /* (1 .. 32), 32-bit op */ + case 'C': MSB (5, 11, 1, FALSE, 32); /* (1 .. 32), 32-bit op */ + case 'E': BIT (5, 6, 32); /* (32 .. 63) */ + case 'F': MSB (5, 11, 33, TRUE, 64); /* (33 .. 64), 64-bit op */ + case 'G': MSB (5, 11, 33, FALSE, 64); /* (33 .. 64), 64-bit op */ + case 'H': MSB (5, 11, 1, FALSE, 64); /* (1 .. 32), 64-bit op */ + case 'J': HINT (10, 11); + case 'P': BIT (5, 6, 32); /* (32 .. 63) */ + case 'Q': SINT (10, 6); + case 'S': MSB (5, 11, 0, FALSE, 63); /* (0 .. 31), 64-bit op */ + case 'X': BIT (5, 16, 32); /* (32 .. 63) */ + case 'Z': REG (5, 0, FP); + + case 'a': SINT (8, 6); + case 'b': SINT (8, 3); + case 'c': INT_ADJ (9, 6, 255, 4, FALSE); /* (-256 .. 255) << 4 */ + case 'i': JALX (26, 0, 2); + case 'j': SINT (9, 7); + case 'p': BIT (5, 6, 0); /* (0 .. 31), 32-bit op */ + case 's': MSB (5, 11, 0, FALSE, 31); /* (0 .. 31) */ + case 't': REG (5, 16, COPRO); + case 'x': BIT (5, 16, 0); /* (0 .. 31) */ + case 'z': REG (5, 0, GP); + } + break; + + case '<': BIT (5, 6, 0); /* (0 .. 31) */ + case '>': BIT (5, 6, 32); /* (32 .. 63) */ + case '%': UINT (3, 21); + case ':': SINT (7, 19); + case '\'': HINT (6, 16); + case '@': SINT (10, 16); + case '!': UINT (1, 5); + case '$': UINT (1, 4); + case '*': REG (2, 18, ACC); + case '&': REG (2, 13, ACC); + case '~': SINT (12, 0); + case '\\': BIT (3, 12, 0); /* (0 .. 7) */ + + case '0': SINT (6, 20); + case '1': HINT (5, 6); + case '2': HINT (2, 11); + case '3': HINT (3, 21); + case '4': HINT (4, 21); + case '5': HINT (8, 16); + case '6': HINT (5, 21); + case '7': REG (2, 11, ACC); + case '8': HINT (6, 11); + case '9': REG (2, 21, ACC); + + case 'B': HINT (20, 6); + case 'C': HINT (25, 0); + case 'D': REG (5, 6, FP); + case 'E': REG (5, 16, COPRO); + case 'G': REG (5, 11, COPRO); + case 'H': UINT (3, 0); + case 'J': HINT (19, 6); + case 'K': REG (5, 11, HW); + case 'M': REG (3, 8, CCC); + case 'N': REG (3, 18, CCC); + case 'O': UINT (3, 21); + case 'P': SPECIAL (5, 1, PERF_REG); + case 'Q': SPECIAL (10, 16, MDMX_IMM_REG); + case 'R': REG (5, 21, FP); + case 'S': REG (5, 11, FP); + case 'T': REG (5, 16, FP); + case 'U': SPECIAL (10, 11, CLO_CLZ_DEST); + case 'V': REG (5, 11, FP); + case 'W': REG (5, 16, FP); + case 'X': REG (5, 6, VEC); + case 'Y': REG (5, 11, VEC); + case 'Z': REG (5, 16, VEC); + + case 'a': JUMP (26, 0, 2); + case 'b': REG (5, 21, GP); + case 'c': HINT (10, 16); + case 'd': REG (5, 11, GP); + case 'e': UINT (3, 22) + case 'g': REG (5, 11, COPRO); + case 'h': HINT (5, 11); + case 'i': HINT (16, 0); + case 'j': SINT (16, 0); + case 'k': HINT (5, 16); + case 'o': SINT (16, 0); + case 'p': BRANCH (16, 0, 2); + case 'q': HINT (10, 6); + case 'r': REG (5, 21, GP); + case 's': REG (5, 21, GP); + case 't': REG (5, 16, GP); + case 'u': HINT (16, 0); + case 'v': REG (5, 21, GP); + case 'w': REG (5, 16, GP); + case 'x': REG (0, 0, GP); + case 'z': MAPPED_REG (0, 0, GP, reg_0_map); + } + return 0; +} /* Short hand so the lines aren't too long. */ |