mc_opc.h
6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*
* mc_opc.h - Opcode definitions for the MXS compiler and simulator
*
* NOTE: When the opcode numbering below is modified, the
* tables and routines in mc_opc.c should be checked to see
* if they need changes.
*
* Jim Bennett
* 1993, 1994, 1995
*/
/*
* INST - The format of all instructions for MXS
*/
typedef struct
{
int op; /* Opcode */
int r2;
short r1, r3; /* Register operands */
int imm; /* Immediate operand */
} INST;
/*
* Handy macros for checking out the type of instructions
*
* is_branch - Return true if opcode is a branch (=> not a call)
* is_branch_imm - Return true if opcode is a branch to an
* immediate destination
*/
#define is_branch_imm(op) (((op) <= OPBC1TL) && ((op) >= OPJ))
#define is_branch(op) (((op) <= OPJRET) && ((op) >= OPJ))
#define is_call_imm(op) (((op) <= OPBGEZALL) && ((op) >= OPJAL))
#define is_call(op) (((op) <= OPJALR) && ((op) >= OPJAL))
#define is_conditional(op) ((((op) <= OPBGEZALL)&&((op) >= OPBLTZAL)) || \
(((op) <= OPBC1TL) && ((op) >= OPBEQ)) )
#define is_indirect_branch(op) ((((op) <= OPJRET) && ((op) >= OPJR)) || \
((op) == OPJALR) )
#define is_sys(op) ((((op) <= OPBREAK) && ((op) >= OPSYSCALL) || \
((op) == OPCP0) || ((op) == OPBDOOR) || \
((op) == OPLDHACK)) || ((op) == OPSDHACK))
#define is_load(op) ((((op) <= OPLDC1) && ((op) >= OPLB)) || \
((op) == OPLL))
#define is_store(op) ((((op) <= OPSDC1) && ((op) >= OPSB)) || \
((op) == OPSC))
#define is_prefetch(op) ((op) == OPPREF)
#define is_ldst(op) ((((op) <= OPSDC1) && ((op) >= OPLB)) || \
((op) == OPLL) || ((op) == OPSC) || ((op) == OPPREF))
#define is_fp_ctl(op) ((op) == CTL_FPC)
#define is_sc(op) ((op) == OPSC)
#ifdef BRANCH_LIKELY
#define is_likely(op) ((((op) <= OPBC1TL) && ((op) >= OPBEQL)) || \
(((op) <= OPBGEZALL) && ((op) >= OPBLTZALL)) )
#else
#define is_likely(op) (0)
#endif
/*
* Opcode mnemonics
*
* Generally they follow the mnemonics in the Kane book
* (MIPS RISC Architecture).
*/
#define OPILL 0 /* Illegal opcode */
#define OPJ 1 /* is_branch/is_branch_imm */
#define OPBEQ 2 /* group */
#define OPBNE 3
#define OPBLEZ 4
#define OPBGTZ 5
#define OPBLTZ 6
#define OPBGEZ 7
#define OPBC1F 8
#define OPBC1T 9
#define OPBEQL 10
#define OPBNEL 11
#define OPBLEZL 12
#define OPBGTZL 13
#define OPBLTZL 14
#define OPBGEZL 15
#define OPBC1FL 16
#define OPBC1TL 17
#define OPJR 18
#define OPJRET 19 /* Like JR, but used to */
/* indicate subroutine */
/* return */
#define OPJAL 20 /* is_call/is_call_imm */
#define OPBLTZAL 21 /* group */
#define OPBGEZAL 22
#define OPBLTZALL 23
#define OPBGEZALL 24
#define OPJALR 25
#define OPSYSCALL 26 /* is_sys group */
#define OPBREAK 27
#define OPLB 28 /* is_load group */
#define OPLH 29
#define OPLWL 30
#define OPLW 31
#define OPLBU 32
#define OPLHU 33
#define OPLWR 34
#define OPLWC1 35
#define OPLDC1 36
#define OPSB 37 /* is_store group */
#define OPSH 38
#define OPSWL 39
#define OPSW 40
#define OPSWR 41
#define OPSWC1 42
#define OPSDC1 43
#define OPADDI 44 /* ALU operations */
#define OPADDIU 45
#define OPSLTI 46
#define OPSLTIU 47
#define OPANDI 48
#define OPORI 49
#define OPXORI 50
#define OPHCPY 51 /* Specialized OPCPY */
/* for half a reg pair */
#define OPSLL 52
#define OPSRL 53
#define OPSRA 54
#define OPSLLV 55
#define OPSRLV 56
#define OPSRAV 57
#define OPMULT 58
#define OPMULTU 59
#define OPDIV 60
#define OPDIVU 61
#define OPADD 62
#define OPADDU 63
#define OPSUB 64
#define OPSUBU 65
#define OPAND 66
#define OPOR 67
#define OPXOR 68
#define OPNOR 69
#define OPSLT 70
#define OPSLTU 71
#define OPCPY 72
/* Floating point operations */
#define OPCVTSW 73 /* CVT.S.W */
#define OPCVTDW 74 /* CVT.D.W */
#define OPFADDS 75 /* Single */
#define OPFSUBS 76 /* precision */
#define OPFMULS 77 /* floating */
#define OPFDIVS 78 /* point */
#define OPFSQRTS 79 /* operations */
#define OPFABSS 80
#define OPFNEGS 81
#define OPFROUNDS 82
#define OPFTRUNCS 83
#define OPFCEILS 84
#define OPFFLOORS 85
#define OPCVTDS 86
#define OPCVTWS 87
#define OPCFS 88 /* C.F.S */
#define OPCUNS 89 /* C.UN.S */
#define OPCEQS 90 /* etc. */
#define OPCUEQS 91
#define OPCOLTS 92
#define OPCULTS 93
#define OPCOLES 94
#define OPCULES 95
#define OPCSFS 96
#define OPCNGLES 97
#define OPCSEQS 98
#define OPCNGLS 99
#define OPCLTS 100
#define OPCNGES 101
#define OPCLES 102
#define OPCNGTS 103
#define OPFADDD 104 /* Double */
#define OPFSUBD 105 /* precision */
#define OPFMULD 106 /* floating */
#define OPFDIVD 107 /* point */
#define OPFSQRTD 108 /* operations */
#define OPFABSD 109
#define OPFMOVD 110
#define OPFNEGD 111
#define OPFROUNDD 112
#define OPFTRUNCD 113
#define OPFCEILD 114
#define OPFFLOORD 115
#define OPCVTSD 116
#define OPCVTWD 117
#define OPCEQD 118 /* C.EQ.D */
#define OPCUEQD 119
#define OPCOLTD 120
#define OPCULTD 121
#define OPCOLED 122
#define OPCULED 123
#define OPCSEQD 124
#define OPCNGLD 125
#define OPCLTD 126
#define OPCNGED 127
#define OPCLED 128
#define OPCNGTD 129
#define CTL_FPC 130 /* Update of floating */
/* point rounding mode */
#define CTL_CFC 131 /* Read of FP control reg */
#define CTL_DLY 132 /* Branch delay cycle */
#define OPCP0 133
#define OPBDOOR 134
#define OPLL 135
#define OPSC 136
#define OPCPYC1 137 /* Copies to/from cop-1 */
#define OPHCPYC1 138
#define OPCP0_SPEC 139 /* CP0 that can run speculatively */
#define OPPREF 140
#define OPLDHACK 141 /* Hacked LD opcode */
#define OPSDHACK 142 /* Hacked SD opcode */
#define MAX_OP 143
/*
* Global tables and procedures defined in mc_opc.c
*/
extern char *opcode_mnemonics[MAX_OP];
extern int lat_tab [MAX_OP];
extern int immediate_unconditional (INST *ip);