aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/Sparc.h
blob: 3eab4048cfe8f2f706771909eb59d3058bac98ed (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
// $Id$ -*-c++-*-
//***************************************************************************
// File:
//	Sparc.cpp
// 
// Purpose:
//	
// History:
//	7/15/01	 -  Vikram Adve  -  Created
//**************************************************************************/

#ifndef LLVM_CODEGEN_SPARC_H
#define LLVM_CODEGEN_SPARC_H

#include "llvm/CodeGen/TargetMachine.h"

// OpCodeMask definitions for the Sparc V9
// 
const OpCodeMask	Immed		= 0x00002000; // immed or reg operand?
const OpCodeMask	Annul		= 0x20000000; // annul delay instr?
const OpCodeMask	PredictTaken	= 0x00080000; // predict branch taken?


//---------------------------------------------------------------------------
// class UltraSparcMachine 
// 
// Purpose:
//   Machine description.
// 
//---------------------------------------------------------------------------

class UltraSparc: public TargetMachine {
public:
  /*ctor*/		UltraSparc	();
  /*dtor*/ virtual	~UltraSparc	() {}
};


//---------------------------------------------------------------------------
// enum SparcMachineOpCode. 
// const MachineInstrInfo SparcMachineInstrInfo[].
// 
// Purpose:
//   Description of UltraSparc machine instructions.
// 
//---------------------------------------------------------------------------


enum SparcMachineOpCode {

  NOP,
  
  // Synthetic SPARC assembly opcodes for setting a register to a constant
  SETSW,
  SETUW,
  
  // Add or add with carry.
  // Immed bit specifies if second operand is immediate(1) or register(0)
  ADD,
  ADDcc,
  ADDC,
  ADDCcc,

  // Subtract or subtract with carry.
  // Immed bit specifies if second operand is immediate(1) or register(0)
  SUB,
  SUBcc,
  SUBC,
  SUBCcc,
  
  // Integer multiply, signed divide, unsigned divide.
  // Note that the deprecated 32-bit multiply and multiply-step are not used.
  MULX,
  SDIVX,
  UDIVX,
  
  // Floating point add, subtract, compare
  FADDS,
  FADDD,
  FADDQ,
  FSUBS,
  FSUBD,
  FSUBQ,
  FCMPS,
  FCMPD,
  FCMPQ,
  // NOTE: FCMPE{S,D,Q}: FP Compare With Exception are currently unused!
  
  // Floating point multiply or divide.
  FMULS,
  FMULD,
  FMULQ,
  FSMULD,
  FDMULQ,
  FDIVS,
  FDIVD,
  FDIVQ,
  
  // Logical operations
  AND,
  ANDcc,
  ANDN,
  ANDNcc,
  OR,
  ORcc,
  ORN,
  ORNcc,
  XOR,
  XORcc,
  XNOR,
  XNORcc,
  
  // Shift operations
  SLL,
  SRL,
  SRA,
  SLLX,
  SRLX,
  SRAX,
  
  // Convert from floating point to floating point formats
  FSTOD,
  FSTOQ,
  FDTOS,
  FDTOQ,
  FQTOS,
  FQTOD,
  
  // Convert from floating point to integer formats
  FSTOX,
  FDTOX,
  FQTOX,
  FSTOI,
  FDTOI,
  FQTOI,
  
  // Convert from integer to floating point formats
  FXTOS,
  FXTOD,
  FXTOQ,
  FITOS,
  FITOD,
  FITOQ,
  
  // Branch on integer comparison with zero.
  // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
  // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
  BRZ,
  BRLEZ,
  BRLZ,
  BRNZ,
  BRGZ,
  BRGEZ,

  // Branch on integer condition code.
  // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
  // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
  BA,
  BN,
  BNE,
  BE,
  BG,
  BLE,
  BGE,
  BL,
  BGU,
  BLEU,
  BCC,
  BCS,
  BPOS,
  BNEG,
  BVC,
  BVS,

  // Branch on floating point condition code.
  // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
  // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
  FBA,
  FBN,
  FBU,
  FBG,
  FBUG,
  FBL,
  FBUL,
  FBLG,
  FBNE,
  FBE,
  FBUE,
  FBGE,
  FBUGE,
  FBLE,
  FBULE,
  FBO,

  // Load integer instructions
  LDSB,
  LDSH,
  LDSW,
  LDUB,
  LDUH,
  LDUW,
  LDX,
  
  // Load floating-point instructions
  LD,
  LDD,			// use of this for integers is deprecated for Sparc V9
  LDQ,
  
  // Store integer instructions
  STB,
  STH,
  STW,
  STX,
  
  // Store floating-point instructions
  ST,
  STD,
  
  // Call, Return, and "Jump and link"
  // Immed bit specifies if second operand is immediate(1) or register(0)
  CALL,
  JMPL,
  RETURN,

  // End-of-array marker
  INVALID_OPCODE
};

const MachineInstrInfo SparcMachineInstrInfo[] = {
  
  { "NOP",	0,  -1,  0,  false },
  
  // Synthetic SPARC assembly opcodes for setting a register to a constant
  { "SETSW",	2,  1,  0, true },	// max immediate constant is ignored
  { "SETUW",	2,  1,  0, false },	// max immediate constant is ignored
  
  // Add or add with carry.
  { "ADD",	3,  2,  (1 << 12) - 1,  true },
  { "ADDcc",	3,  2,  (1 << 12) - 1,  true },
  { "ADDC",	3,  2,  (1 << 12) - 1,  true },
  { "ADDCcc",	3,  2,  (1 << 12) - 1,  true },

  // Sub tract or subtract with carry.
  { "SUB",	3,  2,  (1 << 12) - 1,  true },
  { "SUBcc",	3,  2,  (1 << 12) - 1,  true },
  { "SUBC",	3,  2,  (1 << 12) - 1,  true },
  { "SUBCcc",	3,  2,  (1 << 12) - 1,  true },

  // Integer multiply, signed divide, unsigned divide.
  // Note that the deprecated 32-bit multiply and multiply-step are not used.
  { "MULX",	3,  2,  (1 << 12) - 1,  true },
  { "SDIVX",	3,  2,  (1 << 12) - 1,  true },
  { "UDIVX",	3,  2,  (1 << 12) - 1,  true },
  
  // Floating point add, subtract, compare
  { "FADDS",	3,  2,  0,  false },
  { "FADDD",	3,  2,  0,  false },
  { "FADDQ",	3,  2,  0,  false },
  { "FSUBS",	3,  2,  0,  false },
  { "FSUBD",	3,  2,  0,  false },
  { "FSUBQ",	3,  2,  0,  false },
  { "FCMPS",	3,  2,  0,  false },
  { "FCMPD",	3,  2,  0,  false },
  { "FCMPQ",	3,  2,  0,  false },
  // NOTE: FCMPE{S,D,Q}: FP Compare With Exception are currently unused!
  
  // Floating point multiply or divide.
  { "FMULS",	3,  2,  0,  false },
  { "FMULD",	3,  2,  0,  false },
  { "FMULQ",	3,  2,  0,  false },
  { "FSMULD",	3,  2,  0,  false },
  { "FDMULQ",	3,  2,  0,  false },
  { "FDIVS",	3,  2,  0,  false },
  { "FDIVD",	3,  2,  0,  false },
  { "FDIVQ",	3,  2,  0,  false },
  
  // Logical operations
  { "AND",	3,  2,  (1 << 12) - 1,  true },
  { "ANDcc",	3,  2,  (1 << 12) - 1,  true },
  { "ANDN",	3,  2,  (1 << 12) - 1,  true },
  { "ANDNcc",	3,  2,  (1 << 12) - 1,  true },
  { "OR",	3,  2,  (1 << 12) - 1,  true },
  { "ORcc",	3,  2,  (1 << 12) - 1,  true },
  { "ORN",	3,  2,  (1 << 12) - 1,  true },
  { "ORNcc",	3,  2,  (1 << 12) - 1,  true },
  { "XOR",	3,  2,  (1 << 12) - 1,  true },
  { "XORcc",	3,  2,  (1 << 12) - 1,  true },
  { "XNOR",	3,  2,  (1 << 12) - 1,  true },
  { "XNORcc",	3,  2,  (1 << 12) - 1,  true },
  
  // Shift operations
  { "SLL",	3,  2,  (1 << 5) - 1,  true },
  { "SRL",	3,  2,  (1 << 5) - 1,  true },
  { "SRA",	3,  2,  (1 << 5) - 1,  true },
  { "SLLX",	3,  2,  (1 << 6) - 1,  true },
  { "SRLX",	3,  2,  (1 << 6) - 1,  true },
  { "SRAX",	3,  2,  (1 << 6) - 1,  true },
  
  // Convert from floating point to floating point formats
  { "FSTOD",	2,  1,  0,  false },
  { "FSTOQ",	2,  1,  0,  false },
  { "FDTOS",	2,  1,  0,  false },
  { "FDTOQ",	2,  1,  0,  false },
  { "FQTOS",	2,  1,  0,  false },
  { "FQTOD",	2,  1,  0,  false },
  
  // Convert from floating point to integer formats
  { "FSTOX",	2,  1,  0,  false },
  { "FDTOX",	2,  1,  0,  false },
  { "FQTOX",	2,  1,  0,  false },
  { "FSTOI",	2,  1,  0,  false },
  { "FDTOI",	2,  1,  0,  false },
  { "FQTOI",	2,  1,  0,  false },
  
  // Convert from integer to floating point formats
  { "FXTOS",	2,  1,  0,  false },
  { "FXTOD",	2,  1,  0,  false },
  { "FXTOQ",	2,  1,  0,  false },
  { "FITOS",	2,  1,  0,  false },
  { "FITOD",	2,  1,  0,  false },
  { "FITOQ",	2,  1,  0,  false },
  
  // Branch on integer comparison with zero.
  { "BRZ",	2,  -1,  (1 << 15) - 1,  true },
  { "BRLEZ",	2,  -1,  (1 << 15) - 1,  true },
  { "BRLZ",	2,  -1,  (1 << 15) - 1,  true },
  { "BRNZ",	2,  -1,  (1 << 15) - 1,  true },
  { "BRGZ",	2,  -1,  (1 << 15) - 1,  true },
  { "BRGEZ",	2,  -1,  (1 << 15) - 1,  true },

  // Branch on condition code.
  { "BA",	1,  -1,  (1 << 21) - 1,  true },
  { "BN",	1,  -1,  (1 << 21) - 1,  true },
  { "BNE",	1,  -1,  (1 << 21) - 1,  true },
  { "BE",	1,  -1,  (1 << 21) - 1,  true },
  { "BG",	1,  -1,  (1 << 21) - 1,  true },
  { "BLE",	1,  -1,  (1 << 21) - 1,  true },
  { "BGE",	1,  -1,  (1 << 21) - 1,  true },
  { "BL",	1,  -1,  (1 << 21) - 1,  true },
  { "BGU",	1,  -1,  (1 << 21) - 1,  true },
  { "BLEU",	1,  -1,  (1 << 21) - 1,  true },
  { "BCC",	1,  -1,  (1 << 21) - 1,  true },
  { "BCS",	1,  -1,  (1 << 21) - 1,  true },
  { "BPOS",	1,  -1,  (1 << 21) - 1,  true },
  { "BNEG",	1,  -1,  (1 << 21) - 1,  true },
  { "BVC",	1,  -1,  (1 << 21) - 1,  true },
  { "BVS",	1,  -1,  (1 << 21) - 1,  true },

  // Branch on floating point condition code.
  // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
  // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
  // The first argument is the FCCn register (0 <= n <= 3).
  { "FBA",	2,  -1,  (1 << 18) - 1,  true },
  { "FBN",	2,  -1,  (1 << 18) - 1,  true },
  { "FBU",	2,  -1,  (1 << 18) - 1,  true },
  { "FBG",	2,  -1,  (1 << 18) - 1,  true },
  { "FBUG",	2,  -1,  (1 << 18) - 1,  true },
  { "FBL",	2,  -1,  (1 << 18) - 1,  true },
  { "FBUL",	2,  -1,  (1 << 18) - 1,  true },
  { "FBLG",	2,  -1,  (1 << 18) - 1,  true },
  { "FBNE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBUE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBGE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBUGE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBLE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBULE",	2,  -1,  (1 << 18) - 1,  true },
  { "FBO",	2,  -1,  (1 << 18) - 1,  true },

  // Load integer instructions
  { "LDSB",	3,  2,  (1 << 12) - 1,  true },
  { "LDSH",	3,  2,  (1 << 12) - 1,  true },
  { "LDSW",	3,  2,  (1 << 12) - 1,  true },
  { "LDUB",	3,  2,  (1 << 12) - 1,  true },
  { "LDUH",	3,  2,  (1 << 12) - 1,  true },
  { "LDUW",	3,  2,  (1 << 12) - 1,  true },
  { "LDX",	3,  2,  (1 << 12) - 1,  true },
  
  // Load floating-point instructions
  { "LD",	3,  2,  (1 << 12) - 1,  true },
  { "LDD",	3,  2,  (1 << 12) - 1,  true },
  { "LDQ",	3,  2,  (1 << 12) - 1,  true },
  
  // Store integer instructions
  { "STB",	3,  -1,  (1 << 12) - 1,  true },
  { "STH",	3,  -1,  (1 << 12) - 1,  true },
  { "STW",	3,  -1,  (1 << 12) - 1,  true },
  { "STX",	3,  -1,  (1 << 12) - 1,  true },
  
  // Store floating-point instructions
  { "ST",	3,  -1,  (1 << 12) - 1,  true },
  { "STD",	3,  -1,  (1 << 12) - 1,  true },
  
  // Call, Return and "Jump and link"
  { "CALL",	1,  -1,  (1 << 29) - 1,  true },
  { "JMPL",	3,  -1,  (1 << 12) - 1,  true },	
  { "RETURN",	2,  -1,  0,  false },
  
  // End-of-array marker
  { "INVALID_SPARC_OPCODE",	0,  -1,  0,  false }
};


/***************************************************************************/

#endif