Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an...
[deliverable/binutils-gdb.git] / opcodes / mips-formats.h
CommitLineData
ab902481 1/* mips-formats.h
b3adc24a 2 Copyright (C) 2013-2020 Free Software Foundation, Inc.
ab902481
RS
3
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)
7 any later version.
8
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.
13
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/>. */
17
18/* For ARRAY_SIZE. */
19#include "libiberty.h"
20
38bf472a 21#define INT_BIAS(SIZE, LSB, MAX_VAL, BIAS, SHIFT, PRINT_HEX) \
ab902481
RS
22 { \
23 static const struct mips_int_operand op = { \
38bf472a 24 { OP_INT, SIZE, LSB }, MAX_VAL, BIAS, SHIFT, PRINT_HEX \
ab902481
RS
25 }; \
26 return &op.root; \
27 }
28
38bf472a
MR
29#define INT_ADJ(SIZE, LSB, MAX_VAL, SHIFT, PRINT_HEX) \
30 INT_BIAS(SIZE, LSB, MAX_VAL, 0, SHIFT, PRINT_HEX)
31
ab902481
RS
32#define UINT(SIZE, LSB) \
33 INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, FALSE)
34
35#define SINT(SIZE, LSB) \
36 INT_ADJ(SIZE, LSB, (1 << ((SIZE) - 1)) - 1, 0, FALSE)
37
38#define HINT(SIZE, LSB) \
39 INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, TRUE)
40
41#define BIT(SIZE, LSB, BIAS) \
42 { \
43 static const struct mips_int_operand op = { \
44 { OP_INT, SIZE, LSB }, (1 << (SIZE)) - 1, BIAS, 0, TRUE \
45 }; \
46 return &op.root; \
47 }
48
49#define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
50 { \
b56e23fb
RS
51 typedef char ATTRIBUTE_UNUSED \
52 static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
ab902481
RS
53 static const struct mips_mapped_int_operand op = { \
54 { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
55 }; \
56 return &op.root; \
57 }
58
59#define MSB(SIZE, LSB, BIAS, ADD_LSB, OPSIZE) \
60 { \
61 static const struct mips_msb_operand op = { \
62 { OP_MSB, SIZE, LSB }, BIAS, ADD_LSB, OPSIZE \
63 }; \
64 return &op.root; \
65 }
66
67#define REG(SIZE, LSB, BANK) \
68 { \
69 static const struct mips_reg_operand op = { \
70 { OP_REG, SIZE, LSB }, OP_REG_##BANK, 0 \
71 }; \
72 return &op.root; \
73 }
74
0f35dbc4
RS
75#define OPTIONAL_REG(SIZE, LSB, BANK) \
76 { \
77 static const struct mips_reg_operand op = { \
78 { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, 0 \
79 }; \
80 return &op.root; \
81 }
82
ab902481
RS
83#define MAPPED_REG(SIZE, LSB, BANK, MAP) \
84 { \
b56e23fb
RS
85 typedef char ATTRIBUTE_UNUSED \
86 static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
ab902481
RS
87 static const struct mips_reg_operand op = { \
88 { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
89 }; \
90 return &op.root; \
91 }
92
0f35dbc4
RS
93#define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
94 { \
95 typedef char ATTRIBUTE_UNUSED \
96 static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
97 static const struct mips_reg_operand op = { \
98 { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
99 }; \
100 return &op.root; \
101 }
102
ab902481
RS
103#define REG_PAIR(SIZE, LSB, BANK, MAP) \
104 { \
b56e23fb
RS
105 typedef char ATTRIBUTE_UNUSED \
106 static_assert1[(1 << (SIZE)) == ARRAY_SIZE (MAP##1)]; \
107 typedef char ATTRIBUTE_UNUSED \
108 static_assert2[(1 << (SIZE)) == ARRAY_SIZE (MAP##2)]; \
ab902481
RS
109 static const struct mips_reg_pair_operand op = { \
110 { OP_REG_PAIR, SIZE, LSB }, OP_REG_##BANK, MAP##1, MAP##2 \
111 }; \
112 return &op.root; \
113 }
114
3ccad066 115#define PCREL(SIZE, LSB, IS_SIGNED, SHIFT, ALIGN_LOG2, INCLUDE_ISA_BIT, \
ab902481
RS
116 FLIP_ISA_BIT) \
117 { \
118 static const struct mips_pcrel_operand op = { \
3ccad066
RS
119 { { OP_PCREL, SIZE, LSB }, \
120 (1 << ((SIZE) - (IS_SIGNED))) - 1, 0, SHIFT, TRUE }, \
121 ALIGN_LOG2, INCLUDE_ISA_BIT, FLIP_ISA_BIT \
ab902481 122 }; \
3ccad066 123 return &op.root.root; \
ab902481
RS
124 }
125
126#define JUMP(SIZE, LSB, SHIFT) \
3ccad066 127 PCREL (SIZE, LSB, FALSE, SHIFT, SIZE + SHIFT, TRUE, FALSE)
ab902481
RS
128
129#define JALX(SIZE, LSB, SHIFT) \
3ccad066 130 PCREL (SIZE, LSB, FALSE, SHIFT, SIZE + SHIFT, TRUE, TRUE)
ab902481
RS
131
132#define BRANCH(SIZE, LSB, SHIFT) \
3ccad066 133 PCREL (SIZE, LSB, TRUE, SHIFT, 0, TRUE, FALSE)
ab902481
RS
134
135#define SPECIAL(SIZE, LSB, TYPE) \
136 { \
137 static const struct mips_operand op = { OP_##TYPE, SIZE, LSB }; \
138 return &op; \
139 }
7361da2c
AB
140
141#define PREV_CHECK(SIZE, LSB, GT_OK, LT_OK, EQ_OK, ZERO_OK) \
142 { \
143 static const struct mips_check_prev_operand op = { \
144 { OP_CHECK_PREV, SIZE, LSB }, GT_OK, LT_OK, EQ_OK, ZERO_OK \
145 }; \
146 return &op.root; \
147 }
This page took 0.306872 seconds and 4 git commands to generate.