summaryrefslogtreecommitdiff
path: root/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
blob: a49525b46e484b98c1d1204a7bc9f983e982156d (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
//===- SparcV9RegisterInfo.cpp - SparcV9 Register Information ---*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the SparcV9 implementation of the MRegisterInfo class.
// It also contains stuff needed to instantiate that class, which would
// ordinarily be provided by TableGen.
//
// This is NOT used by the SparcV9 backend to do register allocation, yet.
//
//===----------------------------------------------------------------------===//
//
// The first section of this file (immediately following) is what
// you would find in SparcV9GenRegisterInfo.inc, if we were using
// TableGen to generate the register file description automatically.
// It consists of register classes and register class instances
// for the SparcV9 target.
//
// FIXME: the alignments listed here are wild guesses.
//
//===----------------------------------------------------------------------===//

#include "SparcV9RegisterInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/ValueTypes.h"
using namespace llvm;

namespace llvm {

namespace {
  // IR Register Class...
  const unsigned IR[] = {
    SparcV9::o0, SparcV9::o1, SparcV9::o2, SparcV9::o3, SparcV9::o4,
    SparcV9::o5, SparcV9::o7, SparcV9::l0, SparcV9::l1, SparcV9::l2,
    SparcV9::l3, SparcV9::l4, SparcV9::l5, SparcV9::l6, SparcV9::l7,
    SparcV9::i0, SparcV9::i1, SparcV9::i2, SparcV9::i3, SparcV9::i4,
    SparcV9::i5, SparcV9::i6, SparcV9::i7, SparcV9::g0, SparcV9::g1,
    SparcV9::g2, SparcV9::g3, SparcV9::g4, SparcV9::g5, SparcV9::g6,
    SparcV9::g7, SparcV9::o6
  };
  const MVT::ValueType IRVTs[] = { MVT::i64, MVT::Other };
  struct IRClass : public TargetRegisterClass {
    IRClass() : TargetRegisterClass(IRVTs, 8, 8, IR, IR + 32) {}
  } IRInstance;


  // FR Register Class...
  const unsigned FR[] = {
    SparcV9::f0, SparcV9::f1, SparcV9::f2, SparcV9::f3, SparcV9::f4,
    SparcV9::f5, SparcV9::f6, SparcV9::f7, SparcV9::f8, SparcV9::f9,
    SparcV9::f10, SparcV9::f11, SparcV9::f12, SparcV9::f13,
    SparcV9::f14, SparcV9::f15, SparcV9::f16, SparcV9::f17,
    SparcV9::f18, SparcV9::f19, SparcV9::f20, SparcV9::f21,
    SparcV9::f22, SparcV9::f23, SparcV9::f24, SparcV9::f25,
    SparcV9::f26, SparcV9::f27, SparcV9::f28, SparcV9::f29,
    SparcV9::f30, SparcV9::f31, SparcV9::f32, SparcV9::f33,
    SparcV9::f34, SparcV9::f35, SparcV9::f36, SparcV9::f37,
    SparcV9::f38, SparcV9::f39, SparcV9::f40, SparcV9::f41,
    SparcV9::f42, SparcV9::f43, SparcV9::f44, SparcV9::f45,
    SparcV9::f46, SparcV9::f47, SparcV9::f48, SparcV9::f49,
    SparcV9::f50, SparcV9::f51, SparcV9::f52, SparcV9::f53,
    SparcV9::f54, SparcV9::f55, SparcV9::f56, SparcV9::f57,
    SparcV9::f58, SparcV9::f59, SparcV9::f60, SparcV9::f61,
    SparcV9::f62, SparcV9::f63
  };
  const MVT::ValueType FRVTs[] = { MVT::f32, MVT::Other };
  // FIXME: The size is correct for the first 32 registers. The
  // latter 32 do not all really exist; you can only access every other
  // one (32, 34, ...), and they must contain double-fp or quad-fp
  // values... see below about the aliasing problems.
  struct FRClass : public TargetRegisterClass {
    FRClass() : TargetRegisterClass(FRVTs, 4, 8, FR, FR + 64) {}
  } FRInstance;


  // ICCR Register Class...
  const unsigned ICCR[] = {
    SparcV9::xcc, SparcV9::icc, SparcV9::ccr
  };
  const MVT::ValueType ICCRVTs[] = { MVT::i1, MVT::Other };
  struct ICCRClass : public TargetRegisterClass {
    ICCRClass() : TargetRegisterClass(ICCRVTs, 1, 8, ICCR, ICCR + 3) {}
  } ICCRInstance;


  // FCCR Register Class...
  const unsigned FCCR[] = {
    SparcV9::fcc0, SparcV9::fcc1, SparcV9::fcc2, SparcV9::fcc3
  };
  const MVT::ValueType FCCRVTs[] = { MVT::i1, MVT::Other };
  struct FCCRClass : public TargetRegisterClass {
    FCCRClass() : TargetRegisterClass(FCCRVTs, 1, 8, FCCR, FCCR + 4) {}
  } FCCRInstance;


  // SR Register Class...
  const unsigned SR[] = {
    SparcV9::fsr
  };
  const MVT::ValueType SRVTs[] = { MVT::i64, MVT::Other };
  struct SRClass : public TargetRegisterClass {
    SRClass() : TargetRegisterClass(SRVTs, 8, 8, SR, SR + 1) {}
  } SRInstance;


  // Register Classes...
  const TargetRegisterClass* const RegisterClasses[] = {
    &IRInstance,
    &FRInstance,
    &ICCRInstance,
    &FCCRInstance,
    &SRInstance
  };


  // Register Alias Sets...
  // FIXME: Note that the SparcV9 backend does not currently abstract
  // very well over the way that double-fp and quad-fp values may alias
  // single-fp values in registers. Therefore those aliases are NOT
  // reflected here.
  const unsigned Empty_AliasSet[] = { 0 };
  const unsigned fcc3_AliasSet[] = { SparcV9::fsr, 0 };
  const unsigned fcc2_AliasSet[] = { SparcV9::fsr, 0 };
  const unsigned fcc1_AliasSet[] = { SparcV9::fsr, 0 };
  const unsigned fcc0_AliasSet[] = { SparcV9::fsr, 0 };
  const unsigned fsr_AliasSet[] = { SparcV9::fcc3, SparcV9::fcc2,
                                    SparcV9::fcc1, SparcV9::fcc0, 0 };
  const unsigned xcc_AliasSet[] = { SparcV9::ccr, 0 };
  const unsigned icc_AliasSet[] = { SparcV9::ccr, 0 };
  const unsigned ccr_AliasSet[] = { SparcV9::xcc, SparcV9::icc, 0 };

const TargetRegisterDesc RegisterDescriptors[] = { // Descriptors
  { "o0", Empty_AliasSet },
  { "o1", Empty_AliasSet },
  { "o2", Empty_AliasSet },
  { "o3", Empty_AliasSet },
  { "o4", Empty_AliasSet },
  { "o5", Empty_AliasSet },
  { "o7", Empty_AliasSet },
  { "l0", Empty_AliasSet },
  { "l1", Empty_AliasSet },
  { "l2", Empty_AliasSet },
  { "l3", Empty_AliasSet },
  { "l4", Empty_AliasSet },
  { "l5", Empty_AliasSet },
  { "l6", Empty_AliasSet },
  { "l7", Empty_AliasSet },
  { "i0", Empty_AliasSet },
  { "i1", Empty_AliasSet },
  { "i2", Empty_AliasSet },
  { "i3", Empty_AliasSet },
  { "i4", Empty_AliasSet },
  { "i5", Empty_AliasSet },
  { "i6", Empty_AliasSet },
  { "i7", Empty_AliasSet },
  { "g0", Empty_AliasSet },
  { "g1", Empty_AliasSet },
  { "g2", Empty_AliasSet },
  { "g3", Empty_AliasSet },
  { "g4", Empty_AliasSet },
  { "g5", Empty_AliasSet },
  { "g6", Empty_AliasSet },
  { "g7", Empty_AliasSet },
  { "o6", Empty_AliasSet },
  { "f0", Empty_AliasSet },
  { "f1", Empty_AliasSet },
  { "f2", Empty_AliasSet },
  { "f3", Empty_AliasSet },
  { "f4", Empty_AliasSet },
  { "f5", Empty_AliasSet },
  { "f6", Empty_AliasSet },
  { "f7", Empty_AliasSet },
  { "f8", Empty_AliasSet },
  { "f9", Empty_AliasSet },
  { "f10", Empty_AliasSet },
  { "f11", Empty_AliasSet },
  { "f12", Empty_AliasSet },
  { "f13", Empty_AliasSet },
  { "f14", Empty_AliasSet },
  { "f15", Empty_AliasSet },
  { "f16", Empty_AliasSet },
  { "f17", Empty_AliasSet },
  { "f18", Empty_AliasSet },
  { "f19", Empty_AliasSet },
  { "f20", Empty_AliasSet },
  { "f21", Empty_AliasSet },
  { "f22", Empty_AliasSet },
  { "f23", Empty_AliasSet },
  { "f24", Empty_AliasSet },
  { "f25", Empty_AliasSet },
  { "f26", Empty_AliasSet },
  { "f27", Empty_AliasSet },
  { "f28", Empty_AliasSet },
  { "f29", Empty_AliasSet },
  { "f30", Empty_AliasSet },
  { "f31", Empty_AliasSet },
  { "f32", Empty_AliasSet },
  { "f33", Empty_AliasSet },
  { "f34", Empty_AliasSet },
  { "f35", Empty_AliasSet },
  { "f36", Empty_AliasSet },
  { "f37", Empty_AliasSet },
  { "f38", Empty_AliasSet },
  { "f39", Empty_AliasSet },
  { "f40", Empty_AliasSet },
  { "f41", Empty_AliasSet },
  { "f42", Empty_AliasSet },
  { "f43", Empty_AliasSet },
  { "f44", Empty_AliasSet },
  { "f45", Empty_AliasSet },
  { "f46", Empty_AliasSet },
  { "f47", Empty_AliasSet },
  { "f48", Empty_AliasSet },
  { "f49", Empty_AliasSet },
  { "f50", Empty_AliasSet },
  { "f51", Empty_AliasSet },
  { "f52", Empty_AliasSet },
  { "f53", Empty_AliasSet },
  { "f54", Empty_AliasSet },
  { "f55", Empty_AliasSet },
  { "f56", Empty_AliasSet },
  { "f57", Empty_AliasSet },
  { "f58", Empty_AliasSet },
  { "f59", Empty_AliasSet },
  { "f60", Empty_AliasSet },
  { "f61", Empty_AliasSet },
  { "f62", Empty_AliasSet },
  { "f63", Empty_AliasSet },
  { "xcc", xcc_AliasSet },
  { "icc", icc_AliasSet },
  { "ccr", ccr_AliasSet },
  { "fcc0", fcc0_AliasSet },
  { "fcc1", fcc1_AliasSet },
  { "fcc2", fcc2_AliasSet },
  { "fcc3", fcc3_AliasSet },
  { "fsr", fsr_AliasSet },
};

} // end anonymous namespace

namespace SparcV9 { // Register classes
  TargetRegisterClass *IRRegisterClass = &IRInstance;
  TargetRegisterClass *FRRegisterClass = &FRInstance;
  TargetRegisterClass *ICCRRegisterClass = &ICCRInstance;
  TargetRegisterClass *FCCRRegisterClass = &FCCRInstance;
  TargetRegisterClass *SRRegisterClass = &SRInstance;
} // end namespace SparcV9

const unsigned *SparcV9RegisterInfo::getCalleeSaveRegs() const {
  // FIXME: This should be verified against the SparcV9 ABI at some point.
  // These are the registers which the SparcV9 backend considers
  // "non-volatile".
  static const unsigned CalleeSaveRegs[] = {
     SparcV9::l0, SparcV9::l1, SparcV9::l2, SparcV9::l3, SparcV9::l4,
     SparcV9::l5, SparcV9::l6, SparcV9::l7, SparcV9::i0, SparcV9::i1,
     SparcV9::i2, SparcV9::i3, SparcV9::i4, SparcV9::i5, SparcV9::i6,
     SparcV9::i7, SparcV9::g0, SparcV9::g1, SparcV9::g2, SparcV9::g3,
     SparcV9::g4, SparcV9::g5, SparcV9::g6, SparcV9::g7, SparcV9::o6,
     0
  };
  return CalleeSaveRegs;
}

} // end namespace llvm

//===----------------------------------------------------------------------===//
//
// The second section of this file (immediately following) contains the
// SparcV9 implementation of the MRegisterInfo class. It currently consists
// entirely of stub functions, because the SparcV9 target does not use the
// same register allocator that the X86 target uses.
//
//===----------------------------------------------------------------------===//

SparcV9RegisterInfo::SparcV9RegisterInfo ()
  : MRegisterInfo (RegisterDescriptors, 104, RegisterClasses,
                   RegisterClasses + 5) {
}

void SparcV9RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
                                         MachineBasicBlock::iterator MI,
                                         unsigned SrcReg, int FrameIndex,
                                         const TargetRegisterClass *RC) const {
  abort ();
}

void SparcV9RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
                                          MachineBasicBlock::iterator MI,
                                          unsigned DestReg, int FrameIndex,
                                          const TargetRegisterClass *RC) const {
  abort ();
}

void SparcV9RegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
                                      MachineBasicBlock::iterator MI,
                                      unsigned DestReg, unsigned SrcReg,
                                      const TargetRegisterClass *RC) const {
  abort ();
}

void SparcV9RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI)
  const {
  abort ();
}

void SparcV9RegisterInfo::emitPrologue(MachineFunction &MF) const {
  abort ();
}

void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
                                       MachineBasicBlock &MBB) const {
  abort ();
}

int SparcV9RegisterInfo::getDwarfRegNum(unsigned RegNum) const {
  abort ();
  return 0;
}

unsigned SparcV9RegisterInfo::getRARegister() const {
  abort ();
  return 0;
}

unsigned SparcV9RegisterInfo::getFrameRegister(MachineFunction &MF) const {
  abort ();
  return 0;
}