9f0ea32a618283fd80bc9695a859ef321c3422f3
[external/binutils.git] / include / opcode / arc-func.h
1 /* Replace functions for the ARC relocs.
2    Copyright (C) 2015-2016 Free Software Foundation, Inc.
3
4    This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
5    the GNU Binutils.
6
7    GAS/GDB is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3, or (at your option)
10    any later version.
11
12    GAS/GDB is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GAS or GDB; see the file COPYING3.  If not, write to
19    the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
20    MA 02110-1301, USA.  */
21
22 /* mask  = 00000000000000000000000000000000.  */
23 #ifndef REPLACE_none
24 #define REPLACE_none
25 ATTRIBUTE_UNUSED static unsigned
26 replace_none (unsigned insn, int value ATTRIBUTE_UNUSED)
27 {
28
29   return insn;
30 }
31
32 #endif /* REPLACE_none */
33
34 /* mask  = 11111111.  */
35 #ifndef REPLACE_bits8
36 #define REPLACE_bits8
37 ATTRIBUTE_UNUSED static unsigned
38 replace_bits8 (unsigned insn, int value ATTRIBUTE_UNUSED)
39 {
40   insn |= ((value >> 0) & 0x00ff) << 0;
41
42   return insn;
43 }
44
45 #endif /* REPLACE_bits8 */
46
47 /* mask  = 1111111111111111.  */
48 #ifndef REPLACE_bits16
49 #define REPLACE_bits16
50 ATTRIBUTE_UNUSED static unsigned
51 replace_bits16 (unsigned insn, int value ATTRIBUTE_UNUSED)
52 {
53   insn |= ((value >> 0) & 0xffff) << 0;
54
55   return insn;
56 }
57
58 #endif /* REPLACE_bits16 */
59
60 /* mask  = 111111111111111111111111.  */
61 #ifndef REPLACE_bits24
62 #define REPLACE_bits24
63 ATTRIBUTE_UNUSED static unsigned
64 replace_bits24 (unsigned insn, int value ATTRIBUTE_UNUSED)
65 {
66   insn |= ((value >> 0) & 0xffffff) << 0;
67
68   return insn;
69 }
70
71 #endif /* REPLACE_bits24 */
72
73 /* mask  = 11111111111111111111111111111111.  */
74 #ifndef REPLACE_word32
75 #define REPLACE_word32
76 ATTRIBUTE_UNUSED static unsigned
77 replace_word32 (unsigned insn, int value ATTRIBUTE_UNUSED)
78 {
79   insn |= ((value >> 0) & 0xffffffff) << 0;
80
81   return insn;
82 }
83
84 #endif /* REPLACE_word32 */
85
86 /* mask  = 0000000000000000000000000000000011111111111111111111111111111111.  */
87 #ifndef REPLACE_limm
88 #define REPLACE_limm
89 ATTRIBUTE_UNUSED static unsigned
90 replace_limm (unsigned insn, int value ATTRIBUTE_UNUSED)
91 {
92   insn |= ((value >> 0) & 0xffffffff) << 0;
93
94   return insn;
95 }
96
97 #endif /* REPLACE_limm */
98
99 /* mask  = 000000000000000011111111111111111111111111111111.  */
100 #ifndef REPLACE_limms
101 #define REPLACE_limms
102 ATTRIBUTE_UNUSED static unsigned
103 replace_limms (unsigned insn, int value ATTRIBUTE_UNUSED)
104 {
105   insn |= ((value >> 0) & 0xffffffff) << 0;
106
107   return insn;
108 }
109
110 #endif /* REPLACE_limms */
111
112 /* mask  = 00000111111111102222222222000000.  */
113 #ifndef REPLACE_disp21h
114 #define REPLACE_disp21h
115 ATTRIBUTE_UNUSED static unsigned
116 replace_disp21h (unsigned insn, int value ATTRIBUTE_UNUSED)
117 {
118   insn |= ((value >> 0) & 0x03ff) << 17;
119   insn |= ((value >> 10) & 0x03ff) << 6;
120
121   return insn;
122 }
123
124 #endif /* REPLACE_disp21h */
125
126 /* mask  = 00000111111111002222222222000000.  */
127 #ifndef REPLACE_disp21w
128 #define REPLACE_disp21w
129 ATTRIBUTE_UNUSED static unsigned
130 replace_disp21w (unsigned insn, int value ATTRIBUTE_UNUSED)
131 {
132   insn |= ((value >> 0) & 0x01ff) << 18;
133   insn |= ((value >> 9) & 0x03ff) << 6;
134
135   return insn;
136 }
137
138 #endif /* REPLACE_disp21w */
139
140 /* mask  = 00000111111111102222222222003333.  */
141 #ifndef REPLACE_disp25h
142 #define REPLACE_disp25h
143 ATTRIBUTE_UNUSED static unsigned
144 replace_disp25h (unsigned insn, int value ATTRIBUTE_UNUSED)
145 {
146   insn |= ((value >> 0) & 0x03ff) << 17;
147   insn |= ((value >> 10) & 0x03ff) << 6;
148   insn |= ((value >> 20) & 0x000f) << 0;
149
150   return insn;
151 }
152
153 #endif /* REPLACE_disp25h */
154
155 /* mask  = 00000111111111002222222222003333.  */
156 #ifndef REPLACE_disp25w
157 #define REPLACE_disp25w
158 ATTRIBUTE_UNUSED static unsigned
159 replace_disp25w (unsigned insn, int value ATTRIBUTE_UNUSED)
160 {
161   insn |= ((value >> 0) & 0x01ff) << 18;
162   insn |= ((value >> 9) & 0x03ff) << 6;
163   insn |= ((value >> 19) & 0x000f) << 0;
164
165   return insn;
166 }
167
168 #endif /* REPLACE_disp25w */
169
170 /* mask  = 00000000000000000000000111111111.  */
171 #ifndef REPLACE_disp9
172 #define REPLACE_disp9
173 ATTRIBUTE_UNUSED static unsigned
174 replace_disp9 (unsigned insn, int value ATTRIBUTE_UNUSED)
175 {
176   insn |= ((value >> 0) & 0x01ff) << 0;
177
178   return insn;
179 }
180
181 #endif /* REPLACE_disp9 */
182
183 /* mask  = 00000000111111112000000000000000.  */
184 #ifndef REPLACE_disp9ls
185 #define REPLACE_disp9ls
186 ATTRIBUTE_UNUSED static unsigned
187 replace_disp9ls (unsigned insn, int value ATTRIBUTE_UNUSED)
188 {
189   insn |= ((value >> 0) & 0x00ff) << 16;
190   insn |= ((value >> 8) & 0x0001) << 15;
191
192   return insn;
193 }
194
195 #endif /* REPLACE_disp9ls */
196
197 /* mask  = 0000000111111111.  */
198 #ifndef REPLACE_disp9s
199 #define REPLACE_disp9s
200 ATTRIBUTE_UNUSED static unsigned
201 replace_disp9s (unsigned insn, int value ATTRIBUTE_UNUSED)
202 {
203   insn |= ((value >> 0) & 0x01ff) << 0;
204
205   return insn;
206 }
207
208 #endif /* REPLACE_disp9s */
209
210 /* mask  = 0000011111111111.  */
211 #ifndef REPLACE_disp13s
212 #define REPLACE_disp13s
213 ATTRIBUTE_UNUSED static unsigned
214 replace_disp13s (unsigned insn, int value ATTRIBUTE_UNUSED)
215 {
216   insn |= ((value >> 0) & 0x07ff) << 0;
217
218   return insn;
219 }
220
221 #endif /* REPLACE_disp13s */
222
223 /* mask  = 0000022222200111.  */
224 #ifndef REPLACE_disp9s1
225 #define REPLACE_disp9s1
226 ATTRIBUTE_UNUSED static unsigned
227 replace_disp9s1 (unsigned insn, int value ATTRIBUTE_UNUSED)
228 {
229   insn |= ((value >> 0) & 0x0007) << 0;
230   insn |= ((value >> 3) & 0x003f) << 5;
231
232   return insn;
233 }
234
235 #endif /* REPLACE_disp9s1 */