2 Copyright 2013 Free Software Foundation, Inc.
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 It is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
12 License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING3. If not,
16 see <http://www.gnu.org/licenses/>. */
19 #include "libiberty.h"
21 #define INT_ADJ(SIZE, LSB, MAX_VAL, SHIFT, PRINT_HEX) \
23 static const struct mips_int_operand op = { \
24 { OP_INT, SIZE, LSB }, MAX_VAL, 0, SHIFT, PRINT_HEX \
29 #define UINT(SIZE, LSB) \
30 INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, FALSE)
32 #define SINT(SIZE, LSB) \
33 INT_ADJ(SIZE, LSB, (1 << ((SIZE) - 1)) - 1, 0, FALSE)
35 #define HINT(SIZE, LSB) \
36 INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, TRUE)
38 #define BIT(SIZE, LSB, BIAS) \
40 static const struct mips_int_operand op = { \
41 { OP_INT, SIZE, LSB }, (1 << (SIZE)) - 1, BIAS, 0, TRUE \
46 #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
48 typedef char ATTRIBUTE_UNUSED \
49 static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
50 static const struct mips_mapped_int_operand op = { \
51 { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
56 #define MSB(SIZE, LSB, BIAS, ADD_LSB, OPSIZE) \
58 static const struct mips_msb_operand op = { \
59 { OP_MSB, SIZE, LSB }, BIAS, ADD_LSB, OPSIZE \
64 #define REG(SIZE, LSB, BANK) \
66 static const struct mips_reg_operand op = { \
67 { OP_REG, SIZE, LSB }, OP_REG_##BANK, 0 \
72 #define MAPPED_REG(SIZE, LSB, BANK, MAP) \
74 typedef char ATTRIBUTE_UNUSED \
75 static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
76 static const struct mips_reg_operand op = { \
77 { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
82 #define REG_PAIR(SIZE, LSB, BANK, MAP) \
84 typedef char ATTRIBUTE_UNUSED \
85 static_assert1[(1 << (SIZE)) == ARRAY_SIZE (MAP##1)]; \
86 typedef char ATTRIBUTE_UNUSED \
87 static_assert2[(1 << (SIZE)) == ARRAY_SIZE (MAP##2)]; \
88 static const struct mips_reg_pair_operand op = { \
89 { OP_REG_PAIR, SIZE, LSB }, OP_REG_##BANK, MAP##1, MAP##2 \
94 #define PCREL(SIZE, LSB, ALIGN_LOG2, SHIFT, IS_SIGNED, INCLUDE_ISA_BIT, \
97 static const struct mips_pcrel_operand op = { \
98 { OP_PCREL, SIZE, LSB }, ALIGN_LOG2, SHIFT, IS_SIGNED, \
99 INCLUDE_ISA_BIT, FLIP_ISA_BIT \
104 #define JUMP(SIZE, LSB, SHIFT) \
105 PCREL (SIZE, LSB, SIZE + SHIFT, SHIFT, FALSE, TRUE, FALSE)
107 #define JALX(SIZE, LSB, SHIFT) \
108 PCREL (SIZE, LSB, SIZE + SHIFT, SHIFT, FALSE, TRUE, TRUE)
110 #define BRANCH(SIZE, LSB, SHIFT) \
111 PCREL (SIZE, LSB, 0, SHIFT, TRUE, TRUE, FALSE)
113 #define SPECIAL(SIZE, LSB, TYPE) \
115 static const struct mips_operand op = { OP_##TYPE, SIZE, LSB }; \