04df2d87c291bae0474e676a6eabc00169bd3981
[deliverable/binutils-gdb.git] / include / opcode / sparc.h
1 /* Definitions for opcode table for the sparc.
2 Copyright (C) 1989, 1991, 1992, 1995, 1996 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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* The SPARC opcode table (and other related data) is defined in
23 the opcodes library in sparc-opc.c. If you change anything here, make
24 sure you fix up that file, and vice versa. */
25
26 /* FIXME-someday: perhaps the ,a's and such should be embedded in the
27 instruction's name rather than the args. This would make gas faster, pinsn
28 slower, but would mess up some macros a bit. xoxorich. */
29
30 #define sparc_architecture bfd_sparc_architecture
31 #define architecture_pname bfd_sparc_architecture_pname
32 #define sparc_opcode bfd_sparc_opcode
33 #define sparc_opcodes bfd_sparc_opcodes
34
35 /*
36 * Structure of an opcode table entry.
37 * This enumerator must parallel the architecture_pname array
38 * in opcodes/sparc-opc.c.
39 */
40 enum sparc_architecture {
41 v6 = 0,
42 v7,
43 v8,
44 sparclite,
45 v9,
46 v9a /* v9 with ultrasparc additions */
47 };
48
49 extern const char *architecture_pname[];
50
51 /* Sparclite and v9 are both supersets of v8; we can't bump between them. */
52
53 #define ARCHITECTURES_CONFLICT_P(ARCH1, ARCH2) \
54 ((ARCH1) == sparclite && ((ARCH2) == v9 || (ARCH2) == v9a))
55
56 struct sparc_opcode {
57 const char *name;
58 unsigned long match; /* Bits that must be set. */
59 unsigned long lose; /* Bits that must not be set. */
60 const char *args;
61 /* This was called "delayed" in versions before the flags. */
62 char flags;
63 enum sparc_architecture architecture;
64 };
65
66 #define F_DELAYED 1 /* Delayed branch */
67 #define F_ALIAS 2 /* Alias for a "real" instruction */
68 #define F_UNBR 4 /* Unconditional branch */
69 #define F_CONDBR 8 /* Conditional branch */
70 #define F_JSR 16 /* Subroutine call */
71 /* ??? One can argue this shouldn't be here and the architecture
72 field should be used instead. */
73 #define F_NOTV9 32 /* Doesn't exist in v9 */
74 /* FIXME: Add F_ANACHRONISTIC flag for v9. */
75
76 /*
77
78 All sparc opcodes are 32 bits, except for the `set' instruction (really a
79 macro), which is 64 bits. It is handled as a special case.
80
81 The match component is a mask saying which bits must match a particular
82 opcode in order for an instruction to be an instance of that opcode.
83
84 The args component is a string containing one character for each operand of the
85 instruction.
86
87 Kinds of operands:
88 # Number used by optimizer. It is ignored.
89 1 rs1 register.
90 2 rs2 register.
91 d rd register.
92 e frs1 floating point register.
93 v frs1 floating point register (double/even).
94 V frs1 floating point register (quad/multiple of 4).
95 f frs2 floating point register.
96 B frs2 floating point register (double/even).
97 R frs2 floating point register (quad/multiple of 4).
98 g frsd floating point register.
99 H frsd floating point register (double/even).
100 J frsd floating point register (quad/multiple of 4).
101 b crs1 coprocessor register
102 c crs2 coprocessor register
103 D crsd coprocessor register
104 m alternate space register (asr) in rd
105 M alternate space register (asr) in rs1
106 h 22 high bits.
107 K MEMBAR mask (7 bits). (v9)
108 j 10 bit Immediate. (v9)
109 I 11 bit Immediate. (v9)
110 i 13 bit Immediate.
111 n 22 bit immediate.
112 k 2+14 bit PC relative immediate. (v9)
113 G 19 bit PC relative immediate. (v9)
114 l 22 bit PC relative immediate.
115 L 30 bit PC relative immediate.
116 a Annul. The annul bit is set.
117 A Alternate address space. Stored as 8 bits.
118 C Coprocessor state register.
119 F floating point state register.
120 p Processor state register.
121 N Branch predict clear ",pn" (v9)
122 T Branch predict set ",pt" (v9)
123 z %icc. (v9)
124 Z %xcc. (v9)
125 q Floating point queue.
126 r Single register that is both rs1 and rsd.
127 Q Coprocessor queue.
128 S Special case.
129 t Trap base register.
130 w Window invalid mask register.
131 y Y register.
132 E %ccr. (v9)
133 s %fprs. (v9)
134 P %pc. (v9)
135 W %tick. (v9)
136 o %asi. (v9)
137 6 %fcc0. (v9)
138 7 %fcc1. (v9)
139 8 %fcc2. (v9)
140 9 %fcc3. (v9)
141 ! Privileged Register in rd (v9)
142 ? Privileged Register in rs1 (v9)
143 * Prefetch function constant. (v9)
144 x OPF field (v9 impdep).
145
146 The following chars are unused: (note: ,[] are used as punctuation)
147 [uOUXY3450]
148
149 */
150
151 #define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */
152 #define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */
153 #define OP(x) ((unsigned)((x)&0x3) << 30) /* op field of all insns */
154 #define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */
155 #define OPF_LOW5(x) OPF((x)&0x1f) /* v9 */
156 #define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */
157 #define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */
158 #define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */
159 #define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */
160 #define F1(x) (OP(x))
161 #define DISP30(x) ((x)&0x3fffffff)
162 #define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */
163 #define RS2(x) ((x)&0x1f) /* rs2 field */
164 #define SIMM13(x) ((x)&0x1fff) /* simm13 field */
165 #define RD(x) (((x)&0x1f) << 25) /* destination register field */
166 #define RS1(x) (((x)&0x1f) << 14) /* rs1 field */
167 #define ASI_RS2(x) (SIMM13(x))
168 #define MEMBAR(x) ((x)&0x7f)
169
170 #define ANNUL (1<<29)
171 #define BPRED (1<<19) /* v9 */
172 #define IMMED F3I(1)
173 #define RD_G0 RD(~0)
174 #define RS1_G0 RS1(~0)
175 #define RS2_G0 RS2(~0)
176
177 extern struct sparc_opcode sparc_opcodes[];
178 extern const int bfd_sparc_num_opcodes;
179
180 #define NUMOPCODES bfd_sparc_num_opcodes
181
182 int sparc_encode_asi ();
183 char *sparc_decode_asi ();
184 int sparc_encode_membar ();
185 char *sparc_decode_membar ();
186 int sparc_encode_prefetch ();
187 char *sparc_decode_prefetch ();
188
189 /*
190 * Local Variables:
191 * fill-column: 131
192 * comment-column: 0
193 * End:
194 */
195
196 /* end of sparc.h */
This page took 0.034718 seconds and 4 git commands to generate.