Relocations for Nios II R2
[deliverable/binutils-gdb.git] / include / opcode / nios2.h
CommitLineData
36591ba1 1/* Nios II opcode list for GAS, the GNU assembler.
b90efa5b 2 Copyright (C) 2012-2015 Free Software Foundation, Inc.
36591ba1
SL
3 Contributed by Nigel Gray (ngray@altera.com).
4 Contributed by Mentor Graphics, Inc.
5
6 This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler.
7
8 GAS/GDB 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)
11 any later version.
12
13 GAS/GDB is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GAS or GDB; see the file COPYING3. If not, write to
20 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23#ifndef _NIOS2_H_
24#define _NIOS2_H_
25
26#include "bfd.h"
27
f63c1776
PA
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36591ba1
SL
32/****************************************************************************
33 * This file contains structures, bit masks and shift counts used
34 * by the GNU toolchain to define the Nios II instruction set and
35 * access various opcode fields.
36 ****************************************************************************/
37
96ba4233
SL
38/* Instruction encoding formats. */
39enum iw_format_type {
40 /* R1 formats */
41 iw_i_type,
42 iw_r_type,
43 iw_j_type,
44 iw_custom_type
45};
46
36591ba1
SL
47/* Identify different overflow situations for error messages. */
48enum overflow_type
49{
50 call_target_overflow = 0,
51 branch_target_overflow,
52 address_offset_overflow,
53 signed_immed16_overflow,
54 unsigned_immed16_overflow,
55 unsigned_immed5_overflow,
56 custom_opcode_overflow,
57 no_overflow
58};
59
60/* This structure holds information for a particular instruction.
61
62 The args field is a string describing the operands. The following
63 letters can appear in the args:
531a94fd 64 c - a 5-bit control register index
36591ba1
SL
65 d - a 5-bit destination register index
66 s - a 5-bit left source register index
67 t - a 5-bit right source register index
68 i - a 16-bit signed immediate
69 u - a 16-bit unsigned immediate
531a94fd 70 o - a 16-bit signed program counter relative offset
36591ba1 71 j - a 5-bit unsigned immediate
531a94fd 72 l - a 8-bit custom instruction constant
36591ba1
SL
73 m - a 26-bit unsigned immediate
74 Literal ',', '(', and ')' characters may also appear in the args as
75 delimiters.
76
96ba4233
SL
77 Note that the args describe the semantics and assembly-language syntax
78 of the operands, not their encoding into the instruction word.
79
36591ba1
SL
80 The pinfo field is INSN_MACRO for a macro. Otherwise, it is a collection
81 of bits describing the instruction, notably any relevant hazard
82 information.
83
84 When assembling, the match field contains the opcode template, which
85 is modified by the arguments to produce the actual opcode
86 that is emitted. If pinfo is INSN_MACRO, then this is 0.
87
88 If pinfo is INSN_MACRO, the mask field stores the macro identifier.
89 Otherwise this is a bit mask for the relevant portions of the opcode
90 when disassembling. If the actual opcode anded with the match field
91 equals the opcode field, then we have found the correct instruction. */
92
93struct nios2_opcode
94{
95 const char *name; /* The name of the instruction. */
96 const char *args; /* A string describing the arguments for this
97 instruction. */
98 const char *args_test; /* Like args, but with an extra argument for
99 the expected opcode. */
100 unsigned long num_args; /* The number of arguments the instruction
101 takes. */
96ba4233
SL
102 unsigned size; /* Size in bytes of the instruction. */
103 enum iw_format_type format; /* Instruction format. */
36591ba1
SL
104 unsigned long match; /* The basic opcode for the instruction. */
105 unsigned long mask; /* Mask for the opcode field of the
106 instruction. */
107 unsigned long pinfo; /* Is this a real instruction or instruction
108 macro? */
109 enum overflow_type overflow_msg; /* Used to generate informative
110 message when fixup overflows. */
111};
112
113/* This value is used in the nios2_opcode.pinfo field to indicate that the
114 instruction is a macro or pseudo-op. This requires special treatment by
115 the assembler, and is used by the disassembler to determine whether to
116 check for a nop. */
117#define NIOS2_INSN_MACRO 0x80000000
118#define NIOS2_INSN_MACRO_MOV 0x80000001
119#define NIOS2_INSN_MACRO_MOVI 0x80000002
120#define NIOS2_INSN_MACRO_MOVIA 0x80000004
121
122#define NIOS2_INSN_RELAXABLE 0x40000000
123#define NIOS2_INSN_UBRANCH 0x00000010
124#define NIOS2_INSN_CBRANCH 0x00000020
125#define NIOS2_INSN_CALL 0x00000040
126
d306ce58 127#define NIOS2_INSN_OPTARG 0x00000080
96ba4233
SL
128
129/* Register attributes. */
130#define REG_NORMAL (1<<0) /* Normal registers. */
131#define REG_CONTROL (1<<1) /* Control registers. */
132#define REG_COPROCESSOR (1<<2) /* For custom instructions. */
36591ba1 133
36591ba1
SL
134struct nios2_reg
135{
136 const char *name;
137 const int index;
96ba4233 138 unsigned long regtype;
36591ba1
SL
139};
140
96ba4233
SL
141/* Pull in the instruction field accessors, opcodes, and masks. */
142#include "nios2r1.h"
36591ba1 143
96ba4233
SL
144/* These are the data structures used to hold the instruction information. */
145extern const struct nios2_opcode nios2_r1_opcodes[];
146extern const int nios2_num_r1_opcodes;
36591ba1 147extern struct nios2_opcode *nios2_opcodes;
96ba4233 148extern int nios2_num_opcodes;
36591ba1
SL
149
150/* These are the data structures used to hold the register information. */
151extern const struct nios2_reg nios2_builtin_regs[];
152extern struct nios2_reg *nios2_regs;
153extern const int nios2_num_builtin_regs;
154extern int nios2_num_regs;
155
b4714c7c
SL
156/* Return the opcode descriptor for a single instruction. */
157extern const struct nios2_opcode *
158nios2_find_opcode_hash (unsigned long, unsigned long);
36591ba1 159
f63c1776
PA
160#ifdef __cplusplus
161}
162#endif
163
36591ba1 164#endif /* _NIOS2_H */
This page took 0.122315 seconds and 4 git commands to generate.