Wrap a few opcodes headers in extern "C" for C++
[deliverable/binutils-gdb.git] / include / opcode / nios2.h
1 /* Nios II opcode list for GAS, the GNU assembler.
2 Copyright (C) 2012-2015 Free Software Foundation, Inc.
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
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
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
38 /* Instruction encoding formats. */
39 enum iw_format_type {
40 /* R1 formats */
41 iw_i_type,
42 iw_r_type,
43 iw_j_type,
44 iw_custom_type
45 };
46
47 /* Identify different overflow situations for error messages. */
48 enum 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:
64 c - a 5-bit control register index
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
70 o - a 16-bit signed program counter relative offset
71 j - a 5-bit unsigned immediate
72 l - a 8-bit custom instruction constant
73 m - a 26-bit unsigned immediate
74 Literal ',', '(', and ')' characters may also appear in the args as
75 delimiters.
76
77 Note that the args describe the semantics and assembly-language syntax
78 of the operands, not their encoding into the instruction word.
79
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
93 struct 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. */
102 unsigned size; /* Size in bytes of the instruction. */
103 enum iw_format_type format; /* Instruction format. */
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
127 #define NIOS2_INSN_OPTARG 0x00000080
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. */
133
134 struct nios2_reg
135 {
136 const char *name;
137 const int index;
138 unsigned long regtype;
139 };
140
141 /* Pull in the instruction field accessors, opcodes, and masks. */
142 #include "nios2r1.h"
143
144 /* These are the data structures used to hold the instruction information. */
145 extern const struct nios2_opcode nios2_r1_opcodes[];
146 extern const int nios2_num_r1_opcodes;
147 extern struct nios2_opcode *nios2_opcodes;
148 extern int nios2_num_opcodes;
149
150 /* These are the data structures used to hold the register information. */
151 extern const struct nios2_reg nios2_builtin_regs[];
152 extern struct nios2_reg *nios2_regs;
153 extern const int nios2_num_builtin_regs;
154 extern int nios2_num_regs;
155
156 /* Return the opcode descriptor for a single instruction. */
157 extern const struct nios2_opcode *
158 nios2_find_opcode_hash (unsigned long, unsigned long);
159
160 #ifdef __cplusplus
161 }
162 #endif
163
164 #endif /* _NIOS2_H */
This page took 0.043183 seconds and 5 git commands to generate.