1 /* Altera Nios II opcode list.
2 Copyright (C) 2012, 2013 Free Software Foundation, Inc.
3 Contributed by Nigel Gray (ngray@altera.com).
4 Contributed by Mentor Graphics, Inc.
6 This file is part of the GNU opcodes library.
8 This library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 It is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this file; see the file COPYING. If not, write to the
20 Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 #include "opcode/nios2.h"
27 /* Register string table */
29 const struct nios2_reg nios2_builtin_regs[] = {
30 /* Standard register names. */
32 {"at", 1}, /* assembler temporary */
57 {"gp", 26}, /* global pointer */
58 {"sp", 27}, /* stack pointer */
59 {"fp", 28}, /* frame pointer */
60 {"ea", 29}, /* exception return address */
61 {"ba", 30}, /* breakpoint return address */
62 {"ra", 31}, /* return address */
64 /* Alternative names for special registers. */
76 /* Control register names. */
110 /* Alternative names for special control registers. */
127 /* Coprocessor register names. */
162 #define NIOS2_NUM_REGS \
163 ((sizeof nios2_builtin_regs) / (sizeof (nios2_builtin_regs[0])))
164 const int nios2_num_builtin_regs = NIOS2_NUM_REGS;
166 /* This is not const in order to allow for dynamic extensions to the
167 built-in instruction set. */
168 struct nios2_reg *nios2_regs = (struct nios2_reg *) nios2_builtin_regs;
169 int nios2_num_regs = NIOS2_NUM_REGS;
170 #undef NIOS2_NUM_REGS
172 /* This is the opcode table used by the Nios II GNU as, disassembler
174 const struct nios2_opcode nios2_builtin_opcodes[] =
176 /* { name, args, args_test, num_args,
177 match, mask, pinfo, overflow_msg } */
178 {"add", "d,s,t", "d,s,t,E", 3,
179 OP_MATCH_ADD, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
180 {"addi", "t,s,i", "t,s,i,E", 3,
181 OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_ADDI, signed_immed16_overflow},
182 {"subi", "t,s,i", "t,s,i,E", 3,
183 OP_MATCH_ADDI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow},
184 {"and", "d,s,t", "d,s,t,E", 3,
185 OP_MATCH_AND, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
186 {"andhi", "t,s,u", "t,s,u,E", 3,
187 OP_MATCH_ANDHI, OP_MASK_IOP, 0, unsigned_immed16_overflow},
188 {"andi", "t,s,u", "t,s,u,E", 3,
189 OP_MATCH_ANDI, OP_MASK_IOP, NIOS2_INSN_ANDI, unsigned_immed16_overflow},
190 {"beq", "s,t,o", "s,t,o,E", 3,
191 OP_MATCH_BEQ, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
192 {"bge", "s,t,o", "s,t,o,E", 3,
193 OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
194 {"bgeu", "s,t,o", "s,t,o,E", 3,
195 OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
196 {"bgt", "s,t,o", "s,t,o,E", 3,
197 OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH,
198 branch_target_overflow},
199 {"bgtu", "s,t,o", "s,t,o,E", 3,
200 OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH,
201 branch_target_overflow},
202 {"ble", "s,t,o", "s,t,o,E", 3,
203 OP_MATCH_BGE, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH,
204 branch_target_overflow},
205 {"bleu", "s,t,o", "s,t,o,E", 3,
206 OP_MATCH_BGEU, OP_MASK_IOP, NIOS2_INSN_MACRO|NIOS2_INSN_CBRANCH,
207 branch_target_overflow},
208 {"blt", "s,t,o", "s,t,o,E", 3,
209 OP_MATCH_BLT, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
210 {"bltu", "s,t,o", "s,t,o,E", 3,
211 OP_MATCH_BLTU, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
212 {"bne", "s,t,o", "s,t,o,E", 3,
213 OP_MATCH_BNE, OP_MASK_IOP, NIOS2_INSN_CBRANCH, branch_target_overflow},
214 {"br", "o", "o,E", 1,
215 OP_MATCH_BR, OP_MASK_IOP, NIOS2_INSN_UBRANCH, branch_target_overflow},
216 {"break", "b", "b,E", 1,
217 OP_MATCH_BREAK, OP_MASK_BREAK, 0, no_overflow},
219 OP_MATCH_BRET, OP_MASK, 0, no_overflow},
220 {"flushd", "i(s)", "i(s)E", 2,
221 OP_MATCH_FLUSHD, OP_MASK_IOP, 0, signed_immed16_overflow},
222 {"flushda", "i(s)", "i(s)E", 2,
223 OP_MATCH_FLUSHDA, OP_MASK_IOP, 0, signed_immed16_overflow},
224 {"flushi", "s", "s,E", 1,
225 OP_MATCH_FLUSHI, OP_MASK_FLUSHI, 0, no_overflow},
226 {"flushp", "", "E", 0,
227 OP_MATCH_FLUSHP, OP_MASK, 0, no_overflow},
228 {"initd", "i(s)", "i(s)E", 2,
229 OP_MATCH_INITD, OP_MASK_IOP, 0, signed_immed16_overflow},
230 {"initda", "i(s)", "i(s)E", 2,
231 OP_MATCH_INITDA, OP_MASK_IOP, 0, signed_immed16_overflow},
232 {"initi", "s", "s,E", 1,
233 OP_MATCH_INITI, OP_MASK_INITI, 0, no_overflow},
234 {"call", "m", "m,E", 1,
235 OP_MATCH_CALL, OP_MASK_IOP, NIOS2_INSN_CALL, call_target_overflow},
236 {"callr", "s", "s,E", 1,
237 OP_MATCH_CALLR, OP_MASK_CALLR, 0, no_overflow},
238 {"cmpeq", "d,s,t", "d,s,t,E", 3,
239 OP_MATCH_CMPEQ, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
240 {"cmpeqi", "t,s,i", "t,s,i,E", 3,
241 OP_MATCH_CMPEQI, OP_MASK_IOP, 0, signed_immed16_overflow},
242 {"cmpge", "d,s,t", "d,s,t,E", 3,
243 OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
244 {"cmpgei", "t,s,i", "t,s,i,E", 3,
245 OP_MATCH_CMPGEI, OP_MASK_IOP, 0, signed_immed16_overflow},
246 {"cmpgeu", "d,s,t", "d,s,t,E", 3,
247 OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
248 {"cmpgeui", "t,s,u", "t,s,u,E", 3,
249 OP_MATCH_CMPGEUI, OP_MASK_IOP, 0, unsigned_immed16_overflow},
250 {"cmpgt", "d,s,t", "d,s,t,E", 3,
251 OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow},
252 {"cmpgti", "t,s,i", "t,s,i,E", 3,
253 OP_MATCH_CMPGEI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow},
254 {"cmpgtu", "d,s,t", "d,s,t,E", 3,
255 OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow},
256 {"cmpgtui", "t,s,u", "t,s,u,E", 3,
257 OP_MATCH_CMPGEUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow},
258 {"cmple", "d,s,t", "d,s,t,E", 3,
259 OP_MATCH_CMPGE, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow},
260 {"cmplei", "t,s,i", "t,s,i,E", 3,
261 OP_MATCH_CMPLTI, OP_MASK_IOP, NIOS2_INSN_MACRO, signed_immed16_overflow},
262 {"cmpleu", "d,s,t", "d,s,t,E", 3,
263 OP_MATCH_CMPGEU, OP_MASK_ROPX | OP_MASK_ROP, NIOS2_INSN_MACRO, no_overflow},
264 {"cmpleui", "t,s,u", "t,s,u,E", 3,
265 OP_MATCH_CMPLTUI, OP_MASK_IOP, NIOS2_INSN_MACRO, unsigned_immed16_overflow},
266 {"cmplt", "d,s,t", "d,s,t,E", 3,
267 OP_MATCH_CMPLT, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
268 {"cmplti", "t,s,i", "t,s,i,E", 3,
269 OP_MATCH_CMPLTI, OP_MASK_IOP, 0, signed_immed16_overflow},
270 {"cmpltu", "d,s,t", "d,s,t,E", 3,
271 OP_MATCH_CMPLTU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
272 {"cmpltui", "t,s,u", "t,s,u,E", 3,
273 OP_MATCH_CMPLTUI, OP_MASK_IOP, 0, unsigned_immed16_overflow},
274 {"cmpne", "d,s,t", "d,s,t,E", 3,
275 OP_MATCH_CMPNE, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
276 {"cmpnei", "t,s,i", "t,s,i,E", 3,
277 OP_MATCH_CMPNEI, OP_MASK_IOP, 0, signed_immed16_overflow},
278 {"div", "d,s,t", "d,s,t,E", 3,
279 OP_MATCH_DIV, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
280 {"divu", "d,s,t", "d,s,t,E", 3,
281 OP_MATCH_DIVU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
282 {"jmp", "s", "s,E", 1,
283 OP_MATCH_JMP, OP_MASK_JMP, 0, no_overflow},
284 {"jmpi", "m", "m,E", 1,
285 OP_MATCH_JMPI, OP_MASK_IOP, 0, no_overflow},
286 {"ldb", "t,i(s)", "t,i(s)E", 3,
287 OP_MATCH_LDB, OP_MASK_IOP, 0, address_offset_overflow},
288 {"ldbio", "t,i(s)", "t,i(s)E", 3,
289 OP_MATCH_LDBIO, OP_MASK_IOP, 0, address_offset_overflow},
290 {"ldbu", "t,i(s)", "t,i(s)E", 3,
291 OP_MATCH_LDBU, OP_MASK_IOP, 0, address_offset_overflow},
292 {"ldbuio", "t,i(s)", "t,i(s)E", 3,
293 OP_MATCH_LDBUIO, OP_MASK_IOP, 0, address_offset_overflow},
294 {"ldh", "t,i(s)", "t,i(s)E", 3,
295 OP_MATCH_LDH, OP_MASK_IOP, 0, address_offset_overflow},
296 {"ldhio", "t,i(s)", "t,i(s)E", 3,
297 OP_MATCH_LDHIO, OP_MASK_IOP, 0, address_offset_overflow},
298 {"ldhu", "t,i(s)", "t,i(s)E", 3,
299 OP_MATCH_LDHU, OP_MASK_IOP, 0, address_offset_overflow},
300 {"ldhuio", "t,i(s)", "t,i(s)E", 3,
301 OP_MATCH_LDHUIO, OP_MASK_IOP, 0, address_offset_overflow},
302 {"ldl", "t,i(s)", "t,i(s)E", 3,
303 OP_MATCH_LDL, OP_MASK_IOP, 0, address_offset_overflow},
304 {"ldw", "t,i(s)", "t,i(s)E", 3,
305 OP_MATCH_LDW, OP_MASK_IOP, 0, address_offset_overflow},
306 {"ldwio", "t,i(s)", "t,i(s)E", 3,
307 OP_MATCH_LDWIO, OP_MASK_IOP, 0, address_offset_overflow},
308 {"mov", "d,s", "d,s,E", 2,
309 OP_MATCH_ADD, OP_MASK_RRT|OP_MASK_ROPX|OP_MASK_ROP, NIOS2_INSN_MACRO_MOV,
311 {"movhi", "t,u", "t,u,E", 2,
312 OP_MATCH_ORHI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI,
313 unsigned_immed16_overflow},
314 {"movui", "t,u", "t,u,E", 2,
315 OP_MATCH_ORI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI,
316 unsigned_immed16_overflow},
317 {"movi", "t,i", "t,i,E", 2,
318 OP_MATCH_ADDI, OP_MASK_IRS|OP_MASK_IOP, NIOS2_INSN_MACRO_MOVI,
319 signed_immed16_overflow},
320 /* movia expands to two instructions so there is no mask or match */
321 {"movia", "t,o", "t,o,E", 2,
322 OP_MATCH_ORHI, OP_MASK_IOP, NIOS2_INSN_MACRO_MOVIA, no_overflow},
323 {"mul", "d,s,t", "d,s,t,E", 3,
324 OP_MATCH_MUL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
325 {"muli", "t,s,i", "t,s,i,E", 3,
326 OP_MATCH_MULI, OP_MASK_IOP, 0, signed_immed16_overflow},
327 {"mulxss", "d,s,t", "d,s,t,E", 3,
328 OP_MATCH_MULXSS, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
329 {"mulxsu", "d,s,t", "d,s,t,E", 3,
330 OP_MATCH_MULXSU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
331 {"mulxuu", "d,s,t", "d,s,t,E", 3,
332 OP_MATCH_MULXUU, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
333 {"nextpc", "d", "d,E", 1,
334 OP_MATCH_NEXTPC, OP_MASK_NEXTPC, 0, no_overflow},
336 OP_MATCH_ADD, OP_MASK, NIOS2_INSN_MACRO_MOV, no_overflow},
337 {"nor", "d,s,t", "d,s,t,E", 3,
338 OP_MATCH_NOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
339 {"or", "d,s,t", "d,s,t,E", 3,
340 OP_MATCH_OR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
341 {"orhi", "t,s,u", "t,s,u,E", 3,
342 OP_MATCH_ORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow},
343 {"ori", "t,s,u", "t,s,u,E", 3,
344 OP_MATCH_ORI, OP_MASK_IOP, NIOS2_INSN_ORI, unsigned_immed16_overflow},
345 {"rdctl", "d,c", "d,c,E", 2,
346 OP_MATCH_RDCTL, OP_MASK_RDCTL, 0, no_overflow},
348 OP_MATCH_RET, OP_MASK, 0, no_overflow},
349 {"rol", "d,s,t", "d,s,t,E", 3,
350 OP_MATCH_ROL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
351 {"roli", "d,s,j", "d,s,j,E", 3,
352 OP_MATCH_ROLI, OP_MASK_ROLI, 0, unsigned_immed5_overflow},
353 {"ror", "d,s,t", "d,s,t,E", 3,
354 OP_MATCH_ROR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
355 {"sll", "d,s,t", "d,s,t,E", 3,
356 OP_MATCH_SLL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
357 {"slli", "d,s,j", "d,s,j,E", 3,
358 OP_MATCH_SLLI, OP_MASK_SLLI, 0, unsigned_immed5_overflow},
359 {"sra", "d,s,t", "d,s,t,E", 3,
360 OP_MATCH_SRA, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
361 {"srai", "d,s,j", "d,s,j,E", 3,
362 OP_MATCH_SRAI, OP_MASK_SRAI, 0, unsigned_immed5_overflow},
363 {"srl", "d,s,t", "d,s,t,E", 3,
364 OP_MATCH_SRL, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
365 {"srli", "d,s,j", "d,s,j,E", 3,
366 OP_MATCH_SRLI, OP_MASK_SRLI, 0, unsigned_immed5_overflow},
367 {"stb", "t,i(s)", "t,i(s)E", 3,
368 OP_MATCH_STB, OP_MASK_IOP, 0, address_offset_overflow},
369 {"stbio", "t,i(s)", "t,i(s)E", 3,
370 OP_MATCH_STBIO, OP_MASK_IOP, 0, address_offset_overflow},
371 {"stc", "t,i(s)", "t,i(s)E", 3,
372 OP_MATCH_STC, OP_MASK_IOP, 0, address_offset_overflow},
373 {"sth", "t,i(s)", "t,i(s)E", 3,
374 OP_MATCH_STH, OP_MASK_IOP, 0, address_offset_overflow},
375 {"sthio", "t,i(s)", "t,i(s)E", 3,
376 OP_MATCH_STHIO, OP_MASK_IOP, 0, address_offset_overflow},
377 {"stw", "t,i(s)", "t,i(s)E", 3,
378 OP_MATCH_STW, OP_MASK_IOP, 0, address_offset_overflow},
379 {"stwio", "t,i(s)", "t,i(s)E", 3,
380 OP_MATCH_STWIO, OP_MASK_IOP, 0, address_offset_overflow},
381 {"sub", "d,s,t", "d,s,t,E", 3,
382 OP_MATCH_SUB, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
384 OP_MATCH_SYNC, OP_MASK_SYNC, 0, no_overflow},
386 OP_MATCH_TRAP, OP_MASK_TRAP, 0, no_overflow},
388 OP_MATCH_ERET, OP_MASK, 0, no_overflow},
389 {"custom", "l,d,s,t", "l,d,s,t,E", 4,
390 OP_MATCH_CUSTOM, OP_MASK_ROP, 0, custom_opcode_overflow},
391 {"wrctl", "c,s", "c,s,E", 2,
392 OP_MATCH_WRCTL, OP_MASK_WRCTL, 0, no_overflow},
393 {"xor", "d,s,t", "d,s,t,E", 3,
394 OP_MATCH_XOR, OP_MASK_ROPX | OP_MASK_ROP, 0, no_overflow},
395 {"xorhi", "t,s,u", "t,s,u,E", 3,
396 OP_MATCH_XORHI, OP_MASK_IOP, 0, unsigned_immed16_overflow},
397 {"xori", "t,s,u", "t,s,u,E", 3,
398 OP_MATCH_XORI, OP_MASK_IOP, NIOS2_INSN_XORI, unsigned_immed16_overflow}
401 #define NIOS2_NUM_OPCODES \
402 ((sizeof nios2_builtin_opcodes) / (sizeof (nios2_builtin_opcodes[0])))
403 const int bfd_nios2_num_builtin_opcodes = NIOS2_NUM_OPCODES;
405 /* This is not const to allow for dynamic extensions to the
406 built-in instruction set. */
407 struct nios2_opcode *nios2_opcodes =
408 (struct nios2_opcode *) nios2_builtin_opcodes;
409 int bfd_nios2_num_opcodes = NIOS2_NUM_OPCODES;
410 #undef NIOS2_NUM_OPCODES