1 //===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This tablegen backend is responsible for emitting a description of a target
11 // register file for a code generator. It uses instances of the Register,
12 // RegisterAliases, and RegisterClass classes to gather this information.
14 //===----------------------------------------------------------------------===//
16 #include "RegisterInfoEmitter.h"
17 #include "CodeGenTarget.h"
18 #include "CodeGenRegisters.h"
20 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/Support/Streams.h"
26 // runEnums - Print out enum values for all of the registers.
27 void RegisterInfoEmitter::runEnums(std::ostream &OS) {
29 const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
31 std::string Namespace = Registers[0].TheDef->getValueAsString("Namespace");
33 EmitSourceFileHeader("Target Register Enum Values", OS);
34 OS << "namespace llvm {\n\n";
36 if (!Namespace.empty())
37 OS << "namespace " << Namespace << " {\n";
38 OS << " enum {\n NoRegister,\n";
40 for (unsigned i = 0, e = Registers.size(); i != e; ++i)
41 OS << " " << Registers[i].getName() << ", \t// " << i+1 << "\n";
42 OS << " NUM_TARGET_REGS \t// " << Registers.size()+1 << "\n";
44 if (!Namespace.empty())
46 OS << "} // End llvm namespace \n";
49 void RegisterInfoEmitter::runHeader(std::ostream &OS) {
50 EmitSourceFileHeader("Register Information Header Fragment", OS);
52 const std::string &TargetName = Target.getName();
53 std::string ClassName = TargetName + "GenRegisterInfo";
55 OS << "#include \"llvm/Target/MRegisterInfo.h\"\n";
56 OS << "#include <string>\n\n";
58 OS << "namespace llvm {\n\n";
60 OS << "struct " << ClassName << " : public MRegisterInfo {\n"
62 << "(int CallFrameSetupOpcode = -1, int CallFrameDestroyOpcode = -1);\n"
63 << " virtual int getDwarfRegNumFull(unsigned RegNum, "
64 << "unsigned Flavour) const;\n"
65 << " virtual int getDwarfRegNum(unsigned RegNum) const = 0;\n"
66 << " unsigned getSubReg(unsigned RegNo, unsigned Index) const;\n"
69 const std::vector<CodeGenRegisterClass> &RegisterClasses =
70 Target.getRegisterClasses();
72 if (!RegisterClasses.empty()) {
73 OS << "namespace " << RegisterClasses[0].Namespace
74 << " { // Register classes\n";
77 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
79 OS << " " << RegisterClasses[i].getName() << "RegClassID";
84 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
85 const std::string &Name = RegisterClasses[i].getName();
87 // Output the register class definition.
88 OS << " struct " << Name << "Class : public TargetRegisterClass {\n"
89 << " " << Name << "Class();\n"
90 << RegisterClasses[i].MethodProtos << " };\n";
92 // Output the extern for the instance.
93 OS << " extern " << Name << "Class\t" << Name << "RegClass;\n";
94 // Output the extern for the pointer to the instance (should remove).
95 OS << " static TargetRegisterClass * const "<< Name <<"RegisterClass = &"
96 << Name << "RegClass;\n";
98 OS << "} // end of namespace " << TargetName << "\n\n";
100 OS << "} // End llvm namespace \n";
103 bool isSubRegisterClass(const CodeGenRegisterClass &RC,
104 std::set<Record*> &RegSet) {
105 for (unsigned i = 0, e = RC.Elements.size(); i != e; ++i) {
106 Record *Reg = RC.Elements[i];
107 if (!RegSet.count(Reg))
113 static void addSuperReg(Record *R, Record *S,
114 std::map<Record*, std::set<Record*> > &SubRegs,
115 std::map<Record*, std::set<Record*> > &SuperRegs,
116 std::map<Record*, std::set<Record*> > &Aliases,
117 RegisterInfoEmitter &RIE) {
119 cerr << "Error: recursive sub-register relationship between"
120 << " register " << RIE.getQualifiedName(R)
121 << " and its sub-registers?\n";
124 if (!SuperRegs[R].insert(S).second)
126 SubRegs[S].insert(R);
127 Aliases[R].insert(S);
128 Aliases[S].insert(R);
129 if (SuperRegs.count(S))
130 for (std::set<Record*>::iterator I = SuperRegs[S].begin(),
131 E = SuperRegs[S].end(); I != E; ++I)
132 addSuperReg(R, *I, SubRegs, SuperRegs, Aliases, RIE);
135 static void addSubSuperReg(Record *R, Record *S,
136 std::map<Record*, std::set<Record*> > &SubRegs,
137 std::map<Record*, std::set<Record*> > &SuperRegs,
138 std::map<Record*, std::set<Record*> > &Aliases,
139 RegisterInfoEmitter &RIE) {
141 cerr << "Error: recursive sub-register relationship between"
142 << " register " << RIE.getQualifiedName(R)
143 << " and its sub-registers?\n";
147 if (!SubRegs[R].insert(S).second)
149 addSuperReg(S, R, SubRegs, SuperRegs, Aliases, RIE);
150 Aliases[R].insert(S);
151 Aliases[S].insert(R);
152 if (SubRegs.count(S))
153 for (std::set<Record*>::iterator I = SubRegs[S].begin(),
154 E = SubRegs[S].end(); I != E; ++I)
155 addSubSuperReg(R, *I, SubRegs, SuperRegs, Aliases, RIE);
158 // RegisterInfoEmitter::run - Main register file description emitter.
160 void RegisterInfoEmitter::run(std::ostream &OS) {
161 CodeGenTarget Target;
162 EmitSourceFileHeader("Register Information Source Fragment", OS);
164 OS << "namespace llvm {\n\n";
166 // Start out by emitting each of the register classes... to do this, we build
167 // a set of registers which belong to a register class, this is to ensure that
168 // each register is only in a single register class.
170 const std::vector<CodeGenRegisterClass> &RegisterClasses =
171 Target.getRegisterClasses();
173 // Loop over all of the register classes... emitting each one.
174 OS << "namespace { // Register classes...\n";
176 // RegClassesBelongedTo - Keep track of which register classes each reg
178 std::multimap<Record*, const CodeGenRegisterClass*> RegClassesBelongedTo;
180 // Emit the register enum value arrays for each RegisterClass
181 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
182 const CodeGenRegisterClass &RC = RegisterClasses[rc];
184 // Give the register class a legal C name if it's anonymous.
185 std::string Name = RC.TheDef->getName();
187 // Emit the register list now.
188 OS << " // " << Name << " Register Class...\n"
189 << " static const unsigned " << Name
191 for (unsigned i = 0, e = RC.Elements.size(); i != e; ++i) {
192 Record *Reg = RC.Elements[i];
193 OS << getQualifiedName(Reg) << ", ";
195 // Keep track of which regclasses this register is in.
196 RegClassesBelongedTo.insert(std::make_pair(Reg, &RC));
201 // Emit the ValueType arrays for each RegisterClass
202 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
203 const CodeGenRegisterClass &RC = RegisterClasses[rc];
205 // Give the register class a legal C name if it's anonymous.
206 std::string Name = RC.TheDef->getName() + "VTs";
208 // Emit the register list now.
210 << " Register Class Value Types...\n"
211 << " static const MVT::ValueType " << Name
213 for (unsigned i = 0, e = RC.VTs.size(); i != e; ++i)
214 OS << getEnumName(RC.VTs[i]) << ", ";
215 OS << "MVT::Other\n };\n\n";
217 OS << "} // end anonymous namespace\n\n";
219 // Now that all of the structs have been emitted, emit the instances.
220 if (!RegisterClasses.empty()) {
221 OS << "namespace " << RegisterClasses[0].Namespace
222 << " { // Register class instances\n";
223 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i)
224 OS << " " << RegisterClasses[i].getName() << "Class\t"
225 << RegisterClasses[i].getName() << "RegClass;\n";
227 std::map<unsigned, std::set<unsigned> > SuperClassMap;
228 std::map<unsigned, std::set<unsigned> > SuperRegClassMap;
231 // Emit the sub-register classes for each RegisterClass
232 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
233 const CodeGenRegisterClass &RC = RegisterClasses[rc];
235 // Give the register class a legal C name if it's anonymous.
236 std::string Name = RC.TheDef->getName();
239 << " Sub-register Classess...\n"
240 << " static const TargetRegisterClass* const "
241 << Name << "SubRegClasses [] = {\n ";
245 for (unsigned subrc = 0, subrcMax = RC.SubRegClasses.size();
246 subrc != subrcMax; ++subrc) {
247 unsigned rc2 = 0, e2 = RegisterClasses.size();
248 for (; rc2 != e2; ++rc2) {
249 const CodeGenRegisterClass &RC2 = RegisterClasses[rc2];
250 if (RC.SubRegClasses[subrc]->getName() == RC2.getName()) {
253 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
256 std::map<unsigned, std::set<unsigned> >::iterator SCMI =
257 SuperRegClassMap.find(rc2);
258 if (SCMI == SuperRegClassMap.end()) {
259 SuperRegClassMap.insert(std::make_pair(rc2, std::set<unsigned>()));
260 SCMI = SuperRegClassMap.find(rc2);
262 SCMI->second.insert(rc);
267 throw "Register Class member '" +
268 RC.SubRegClasses[subrc]->getName() +
269 "' is not a valid RegisterClass!";
272 OS << (!Empty ? ", " : "") << "NULL";
276 // Emit the super-register classes for each RegisterClass
277 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
278 const CodeGenRegisterClass &RC = RegisterClasses[rc];
280 // Give the register class a legal C name if it's anonymous.
281 std::string Name = RC.TheDef->getName();
284 << " Super-register Classess...\n"
285 << " static const TargetRegisterClass* const "
286 << Name << "SuperRegClasses [] = {\n ";
289 std::map<unsigned, std::set<unsigned> >::iterator I =
290 SuperRegClassMap.find(rc);
291 if (I != SuperRegClassMap.end()) {
292 for (std::set<unsigned>::iterator II = I->second.begin(),
293 EE = I->second.end(); II != EE; ++II) {
294 const CodeGenRegisterClass &RC2 = RegisterClasses[*II];
297 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
302 OS << (!Empty ? ", " : "") << "NULL";
306 // Emit the sub-classes array for each RegisterClass
307 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
308 const CodeGenRegisterClass &RC = RegisterClasses[rc];
310 // Give the register class a legal C name if it's anonymous.
311 std::string Name = RC.TheDef->getName();
313 std::set<Record*> RegSet;
314 for (unsigned i = 0, e = RC.Elements.size(); i != e; ++i) {
315 Record *Reg = RC.Elements[i];
320 << " Register Class sub-classes...\n"
321 << " static const TargetRegisterClass* const "
322 << Name << "Subclasses [] = {\n ";
325 for (unsigned rc2 = 0, e2 = RegisterClasses.size(); rc2 != e2; ++rc2) {
326 const CodeGenRegisterClass &RC2 = RegisterClasses[rc2];
327 if (rc == rc2 || RC2.Elements.size() > RC.Elements.size() ||
328 RC.SpillSize != RC2.SpillSize || !isSubRegisterClass(RC2, RegSet))
331 if (!Empty) OS << ", ";
332 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
335 std::map<unsigned, std::set<unsigned> >::iterator SCMI =
336 SuperClassMap.find(rc2);
337 if (SCMI == SuperClassMap.end()) {
338 SuperClassMap.insert(std::make_pair(rc2, std::set<unsigned>()));
339 SCMI = SuperClassMap.find(rc2);
341 SCMI->second.insert(rc);
344 OS << (!Empty ? ", " : "") << "NULL";
348 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
349 const CodeGenRegisterClass &RC = RegisterClasses[rc];
351 // Give the register class a legal C name if it's anonymous.
352 std::string Name = RC.TheDef->getName();
355 << " Register Class super-classes...\n"
356 << " static const TargetRegisterClass* const "
357 << Name << "Superclasses [] = {\n ";
360 std::map<unsigned, std::set<unsigned> >::iterator I =
361 SuperClassMap.find(rc);
362 if (I != SuperClassMap.end()) {
363 for (std::set<unsigned>::iterator II = I->second.begin(),
364 EE = I->second.end(); II != EE; ++II) {
365 const CodeGenRegisterClass &RC2 = RegisterClasses[*II];
366 if (!Empty) OS << ", ";
367 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
372 OS << (!Empty ? ", " : "") << "NULL";
377 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
378 const CodeGenRegisterClass &RC = RegisterClasses[i];
379 OS << RC.MethodBodies << "\n";
380 OS << RC.getName() << "Class::" << RC.getName()
381 << "Class() : TargetRegisterClass("
382 << RC.getName() + "RegClassID" << ", "
383 << RC.getName() + "VTs" << ", "
384 << RC.getName() + "Subclasses" << ", "
385 << RC.getName() + "Superclasses" << ", "
386 << RC.getName() + "SubRegClasses" << ", "
387 << RC.getName() + "SuperRegClasses" << ", "
388 << RC.SpillSize/8 << ", "
389 << RC.SpillAlignment/8 << ", "
390 << RC.CopyCost << ", "
391 << RC.getName() << ", " << RC.getName() << " + " << RC.Elements.size()
398 OS << "\nnamespace {\n";
399 OS << " const TargetRegisterClass* const RegisterClasses[] = {\n";
400 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i)
401 OS << " &" << getQualifiedName(RegisterClasses[i].TheDef)
405 // Emit register sub-registers / super-registers, aliases...
406 std::map<Record*, std::set<Record*> > RegisterImmSubRegs;
407 std::map<Record*, std::set<Record*> > RegisterSubRegs;
408 std::map<Record*, std::set<Record*> > RegisterSuperRegs;
409 std::map<Record*, std::set<Record*> > RegisterAliases;
410 std::map<Record*, std::vector<std::pair<int, Record*> > > SubRegVectors;
411 std::map<Record*, std::vector<int> > DwarfRegNums;
413 const std::vector<CodeGenRegister> &Regs = Target.getRegisters();
415 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
416 Record *R = Regs[i].TheDef;
417 std::vector<Record*> LI = Regs[i].TheDef->getValueAsListOfDefs("Aliases");
418 // Add information that R aliases all of the elements in the list... and
419 // that everything in the list aliases R.
420 for (unsigned j = 0, e = LI.size(); j != e; ++j) {
422 if (RegisterAliases[R].count(Reg))
423 cerr << "Warning: register alias between " << getQualifiedName(R)
424 << " and " << getQualifiedName(Reg)
425 << " specified multiple times!\n";
426 RegisterAliases[R].insert(Reg);
428 if (RegisterAliases[Reg].count(R))
429 cerr << "Warning: register alias between " << getQualifiedName(R)
430 << " and " << getQualifiedName(Reg)
431 << " specified multiple times!\n";
432 RegisterAliases[Reg].insert(R);
436 // Process sub-register sets.
437 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
438 Record *R = Regs[i].TheDef;
439 std::vector<Record*> LI = Regs[i].TheDef->getValueAsListOfDefs("SubRegs");
440 // Process sub-register set and add aliases information.
441 for (unsigned j = 0, e = LI.size(); j != e; ++j) {
442 Record *SubReg = LI[j];
443 if (RegisterSubRegs[R].count(SubReg))
444 cerr << "Warning: register " << getQualifiedName(SubReg)
445 << " specified as a sub-register of " << getQualifiedName(R)
446 << " multiple times!\n";
447 RegisterImmSubRegs[R].insert(SubReg);
448 addSubSuperReg(R, SubReg, RegisterSubRegs, RegisterSuperRegs,
449 RegisterAliases, *this);
453 if (!RegisterAliases.empty())
454 OS << "\n\n // Register Alias Sets...\n";
456 // Emit the empty alias list
457 OS << " const unsigned Empty_AliasSet[] = { 0 };\n";
458 // Loop over all of the registers which have aliases, emitting the alias list
460 for (std::map<Record*, std::set<Record*> >::iterator
461 I = RegisterAliases.begin(), E = RegisterAliases.end(); I != E; ++I) {
462 OS << " const unsigned " << I->first->getName() << "_AliasSet[] = { ";
463 for (std::set<Record*>::iterator ASI = I->second.begin(),
464 E = I->second.end(); ASI != E; ++ASI)
465 OS << getQualifiedName(*ASI) << ", ";
469 if (!RegisterSubRegs.empty())
470 OS << "\n\n // Register Sub-registers Sets...\n";
472 // Emit the empty sub-registers list
473 OS << " const unsigned Empty_SubRegsSet[] = { 0 };\n";
474 // Loop over all of the registers which have sub-registers, emitting the
475 // sub-registers list to memory.
476 for (std::map<Record*, std::set<Record*> >::iterator
477 I = RegisterSubRegs.begin(), E = RegisterSubRegs.end(); I != E; ++I) {
478 OS << " const unsigned " << I->first->getName() << "_SubRegsSet[] = { ";
479 for (std::set<Record*>::iterator ASI = I->second.begin(),
480 E = I->second.end(); ASI != E; ++ASI)
481 OS << getQualifiedName(*ASI) << ", ";
485 if (!RegisterImmSubRegs.empty())
486 OS << "\n\n // Register Immediate Sub-registers Sets...\n";
488 // Loop over all of the registers which have sub-registers, emitting the
489 // sub-registers list to memory.
490 for (std::map<Record*, std::set<Record*> >::iterator
491 I = RegisterImmSubRegs.begin(), E = RegisterImmSubRegs.end();
493 OS << " const unsigned " << I->first->getName() << "_ImmSubRegsSet[] = { ";
494 for (std::set<Record*>::iterator ASI = I->second.begin(),
495 E = I->second.end(); ASI != E; ++ASI)
496 OS << getQualifiedName(*ASI) << ", ";
500 if (!RegisterSuperRegs.empty())
501 OS << "\n\n // Register Super-registers Sets...\n";
503 // Emit the empty super-registers list
504 OS << " const unsigned Empty_SuperRegsSet[] = { 0 };\n";
505 // Loop over all of the registers which have super-registers, emitting the
506 // super-registers list to memory.
507 for (std::map<Record*, std::set<Record*> >::iterator
508 I = RegisterSuperRegs.begin(), E = RegisterSuperRegs.end(); I != E; ++I) {
509 OS << " const unsigned " << I->first->getName() << "_SuperRegsSet[] = { ";
510 for (std::set<Record*>::iterator ASI = I->second.begin(),
511 E = I->second.end(); ASI != E; ++ASI)
512 OS << getQualifiedName(*ASI) << ", ";
516 OS<<"\n const TargetRegisterDesc RegisterDescriptors[] = { // Descriptors\n";
517 OS << " { \"NOREG\",\t0,\t0,\t0,\t0 },\n";
519 // Now that register alias and sub-registers sets have been emitted, emit the
520 // register descriptors now.
521 const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
522 for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
523 const CodeGenRegister &Reg = Registers[i];
525 if (!Reg.TheDef->getValueAsString("Name").empty())
526 OS << Reg.TheDef->getValueAsString("Name");
530 if (RegisterAliases.count(Reg.TheDef))
531 OS << Reg.getName() << "_AliasSet,\t";
533 OS << "Empty_AliasSet,\t";
534 if (RegisterSubRegs.count(Reg.TheDef))
535 OS << Reg.getName() << "_SubRegsSet,\t";
537 OS << "Empty_SubRegsSet,\t";
538 if (RegisterImmSubRegs.count(Reg.TheDef))
539 OS << Reg.getName() << "_ImmSubRegsSet,\t";
541 OS << "Empty_SubRegsSet,\t";
542 if (RegisterSuperRegs.count(Reg.TheDef))
543 OS << Reg.getName() << "_SuperRegsSet },\n";
545 OS << "Empty_SuperRegsSet },\n";
547 OS << " };\n"; // End of register descriptors...
548 OS << "}\n\n"; // End of anonymous namespace...
550 std::string ClassName = Target.getName() + "GenRegisterInfo";
552 // Calculate the mapping of subregister+index pairs to physical registers.
553 std::vector<Record*> SubRegs = Records.getAllDerivedDefinitions("SubRegSet");
554 for (unsigned i = 0, e = SubRegs.size(); i != e; ++i) {
555 int subRegIndex = SubRegs[i]->getValueAsInt("index");
556 std::vector<Record*> From = SubRegs[i]->getValueAsListOfDefs("From");
557 std::vector<Record*> To = SubRegs[i]->getValueAsListOfDefs("To");
559 if (From.size() != To.size()) {
560 cerr << "Error: register list and sub-register list not of equal length"
561 << " in SubRegSet\n";
565 // For each entry in from/to vectors, insert the to register at index
566 for (unsigned ii = 0, ee = From.size(); ii != ee; ++ii)
567 SubRegVectors[From[ii]].push_back(std::make_pair(subRegIndex, To[ii]));
570 // Emit the subregister + index mapping function based on the information
572 OS << "unsigned " << ClassName
573 << "::getSubReg(unsigned RegNo, unsigned Index) const {\n"
574 << " switch (RegNo) {\n"
575 << " default: abort(); break;\n";
576 for (std::map<Record*, std::vector<std::pair<int, Record*> > >::iterator
577 I = SubRegVectors.begin(), E = SubRegVectors.end(); I != E; ++I) {
578 OS << " case " << getQualifiedName(I->first) << ":\n";
579 OS << " switch (Index) {\n";
580 OS << " default: abort(); break;\n";
581 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
582 OS << " case " << (I->second)[i].first << ": return "
583 << getQualifiedName((I->second)[i].second) << ";\n";
584 OS << " }; break;\n";
587 OS << " return 0;\n";
590 // Emit the constructor of the class...
591 OS << ClassName << "::" << ClassName
592 << "(int CallFrameSetupOpcode, int CallFrameDestroyOpcode)\n"
593 << " : MRegisterInfo(RegisterDescriptors, " << Registers.size()+1
594 << ", RegisterClasses, RegisterClasses+" << RegisterClasses.size() <<",\n "
595 << " CallFrameSetupOpcode, CallFrameDestroyOpcode) {}\n\n";
597 // Collect all information about dwarf register numbers
599 // First, just pull all provided information to the map
600 unsigned maxLength = 0;
601 for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
602 Record *Reg = Registers[i].TheDef;
603 std::vector<int> RegNums = Reg->getValueAsListOfInts("DwarfNumbers");
604 maxLength = std::max(maxLength, RegNums.size());
605 if (DwarfRegNums.count(Reg))
606 cerr << "Warning: DWARF numbers for register " << getQualifiedName(Reg)
607 << "specified multiple times\n";
608 DwarfRegNums[Reg] = RegNums;
611 // Now we know maximal length of number list. Append -1's, where needed
612 for (std::map<Record*, std::vector<int> >::iterator
613 I = DwarfRegNums.begin(), E = DwarfRegNums.end(); I != E; ++I)
614 for (unsigned i = I->second.size(), e = maxLength; i != e; ++i)
615 I->second.push_back(-1);
617 // Emit information about the dwarf register numbers.
618 OS << "int " << ClassName << "::getDwarfRegNumFull(unsigned RegNum, "
619 << "unsigned Flavour) const {\n"
620 << " switch (Flavour) {\n"
622 << " assert(0 && \"Unknown DWARF flavour\");\n"
625 for (unsigned i = 0, e = maxLength; i != e; ++i) {
626 OS << " case " << i << ":\n"
627 << " switch (RegNum) {\n"
629 << " assert(0 && \"Invalid RegNum\");\n"
632 for (std::map<Record*, std::vector<int> >::iterator
633 I = DwarfRegNums.begin(), E = DwarfRegNums.end(); I != E; ++I) {
634 int RegNo = I->second[i];
636 OS << " case " << getQualifiedName(I->first) << ":\n"
637 << " return " << RegNo << ";\n";
639 OS << " case " << getQualifiedName(I->first) << ":\n"
640 << " assert(0 && \"Invalid register for this mode\");\n"
648 OS << "} // End llvm namespace \n";