1 //===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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/TargetRegisterInfo.h\"\n";
56 OS << "#include <string>\n\n";
58 OS << "namespace llvm {\n\n";
60 OS << "struct " << ClassName << " : public TargetRegisterInfo {\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, bool isEH) 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) {
118 cerr << "Error: recursive sub-register relationship between"
119 << " register " << getQualifiedName(R)
120 << " and its sub-registers?\n";
123 if (!SuperRegs[R].insert(S).second)
125 SubRegs[S].insert(R);
126 Aliases[R].insert(S);
127 Aliases[S].insert(R);
128 if (SuperRegs.count(S))
129 for (std::set<Record*>::iterator I = SuperRegs[S].begin(),
130 E = SuperRegs[S].end(); I != E; ++I)
131 addSuperReg(R, *I, SubRegs, SuperRegs, Aliases);
134 static void addSubSuperReg(Record *R, Record *S,
135 std::map<Record*, std::set<Record*> > &SubRegs,
136 std::map<Record*, std::set<Record*> > &SuperRegs,
137 std::map<Record*, std::set<Record*> > &Aliases) {
139 cerr << "Error: recursive sub-register relationship between"
140 << " register " << getQualifiedName(R)
141 << " and its sub-registers?\n";
145 if (!SubRegs[R].insert(S).second)
147 addSuperReg(S, R, SubRegs, SuperRegs, Aliases);
148 Aliases[R].insert(S);
149 Aliases[S].insert(R);
150 if (SubRegs.count(S))
151 for (std::set<Record*>::iterator I = SubRegs[S].begin(),
152 E = SubRegs[S].end(); I != E; ++I)
153 addSubSuperReg(R, *I, SubRegs, SuperRegs, Aliases);
156 // RegisterInfoEmitter::run - Main register file description emitter.
158 void RegisterInfoEmitter::run(std::ostream &OS) {
159 CodeGenTarget Target;
160 EmitSourceFileHeader("Register Information Source Fragment", OS);
162 OS << "namespace llvm {\n\n";
164 // Start out by emitting each of the register classes... to do this, we build
165 // a set of registers which belong to a register class, this is to ensure that
166 // each register is only in a single register class.
168 const std::vector<CodeGenRegisterClass> &RegisterClasses =
169 Target.getRegisterClasses();
171 // Loop over all of the register classes... emitting each one.
172 OS << "namespace { // Register classes...\n";
174 // RegClassesBelongedTo - Keep track of which register classes each reg
176 std::multimap<Record*, const CodeGenRegisterClass*> RegClassesBelongedTo;
178 // Emit the register enum value arrays for each RegisterClass
179 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
180 const CodeGenRegisterClass &RC = RegisterClasses[rc];
182 // Give the register class a legal C name if it's anonymous.
183 std::string Name = RC.TheDef->getName();
185 // Emit the register list now.
186 OS << " // " << Name << " Register Class...\n"
187 << " static const unsigned " << Name
189 for (unsigned i = 0, e = RC.Elements.size(); i != e; ++i) {
190 Record *Reg = RC.Elements[i];
191 OS << getQualifiedName(Reg) << ", ";
193 // Keep track of which regclasses this register is in.
194 RegClassesBelongedTo.insert(std::make_pair(Reg, &RC));
199 // Emit the ValueType arrays for each RegisterClass
200 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
201 const CodeGenRegisterClass &RC = RegisterClasses[rc];
203 // Give the register class a legal C name if it's anonymous.
204 std::string Name = RC.TheDef->getName() + "VTs";
206 // Emit the register list now.
208 << " Register Class Value Types...\n"
209 << " static const MVT::ValueType " << Name
211 for (unsigned i = 0, e = RC.VTs.size(); i != e; ++i)
212 OS << getEnumName(RC.VTs[i]) << ", ";
213 OS << "MVT::Other\n };\n\n";
215 OS << "} // end anonymous namespace\n\n";
217 // Now that all of the structs have been emitted, emit the instances.
218 if (!RegisterClasses.empty()) {
219 OS << "namespace " << RegisterClasses[0].Namespace
220 << " { // Register class instances\n";
221 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i)
222 OS << " " << RegisterClasses[i].getName() << "Class\t"
223 << RegisterClasses[i].getName() << "RegClass;\n";
225 std::map<unsigned, std::set<unsigned> > SuperClassMap;
226 std::map<unsigned, std::set<unsigned> > SuperRegClassMap;
229 // Emit the sub-register classes for each RegisterClass
230 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
231 const CodeGenRegisterClass &RC = RegisterClasses[rc];
233 // Give the register class a legal C name if it's anonymous.
234 std::string Name = RC.TheDef->getName();
237 << " Sub-register Classess...\n"
238 << " static const TargetRegisterClass* const "
239 << Name << "SubRegClasses [] = {\n ";
243 for (unsigned subrc = 0, subrcMax = RC.SubRegClasses.size();
244 subrc != subrcMax; ++subrc) {
245 unsigned rc2 = 0, e2 = RegisterClasses.size();
246 for (; rc2 != e2; ++rc2) {
247 const CodeGenRegisterClass &RC2 = RegisterClasses[rc2];
248 if (RC.SubRegClasses[subrc]->getName() == RC2.getName()) {
251 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
254 std::map<unsigned, std::set<unsigned> >::iterator SCMI =
255 SuperRegClassMap.find(rc2);
256 if (SCMI == SuperRegClassMap.end()) {
257 SuperRegClassMap.insert(std::make_pair(rc2, std::set<unsigned>()));
258 SCMI = SuperRegClassMap.find(rc2);
260 SCMI->second.insert(rc);
265 throw "Register Class member '" +
266 RC.SubRegClasses[subrc]->getName() +
267 "' is not a valid RegisterClass!";
270 OS << (!Empty ? ", " : "") << "NULL";
274 // Emit the super-register classes for each RegisterClass
275 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
276 const CodeGenRegisterClass &RC = RegisterClasses[rc];
278 // Give the register class a legal C name if it's anonymous.
279 std::string Name = RC.TheDef->getName();
282 << " Super-register Classess...\n"
283 << " static const TargetRegisterClass* const "
284 << Name << "SuperRegClasses [] = {\n ";
287 std::map<unsigned, std::set<unsigned> >::iterator I =
288 SuperRegClassMap.find(rc);
289 if (I != SuperRegClassMap.end()) {
290 for (std::set<unsigned>::iterator II = I->second.begin(),
291 EE = I->second.end(); II != EE; ++II) {
292 const CodeGenRegisterClass &RC2 = RegisterClasses[*II];
295 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
300 OS << (!Empty ? ", " : "") << "NULL";
304 // Emit the sub-classes array for each RegisterClass
305 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
306 const CodeGenRegisterClass &RC = RegisterClasses[rc];
308 // Give the register class a legal C name if it's anonymous.
309 std::string Name = RC.TheDef->getName();
311 std::set<Record*> RegSet;
312 for (unsigned i = 0, e = RC.Elements.size(); i != e; ++i) {
313 Record *Reg = RC.Elements[i];
318 << " Register Class sub-classes...\n"
319 << " static const TargetRegisterClass* const "
320 << Name << "Subclasses [] = {\n ";
323 for (unsigned rc2 = 0, e2 = RegisterClasses.size(); rc2 != e2; ++rc2) {
324 const CodeGenRegisterClass &RC2 = RegisterClasses[rc2];
325 if (rc == rc2 || RC2.Elements.size() > RC.Elements.size() ||
326 RC.SpillSize != RC2.SpillSize || !isSubRegisterClass(RC2, RegSet))
329 if (!Empty) OS << ", ";
330 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
333 std::map<unsigned, std::set<unsigned> >::iterator SCMI =
334 SuperClassMap.find(rc2);
335 if (SCMI == SuperClassMap.end()) {
336 SuperClassMap.insert(std::make_pair(rc2, std::set<unsigned>()));
337 SCMI = SuperClassMap.find(rc2);
339 SCMI->second.insert(rc);
342 OS << (!Empty ? ", " : "") << "NULL";
346 for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
347 const CodeGenRegisterClass &RC = RegisterClasses[rc];
349 // Give the register class a legal C name if it's anonymous.
350 std::string Name = RC.TheDef->getName();
353 << " Register Class super-classes...\n"
354 << " static const TargetRegisterClass* const "
355 << Name << "Superclasses [] = {\n ";
358 std::map<unsigned, std::set<unsigned> >::iterator I =
359 SuperClassMap.find(rc);
360 if (I != SuperClassMap.end()) {
361 for (std::set<unsigned>::iterator II = I->second.begin(),
362 EE = I->second.end(); II != EE; ++II) {
363 const CodeGenRegisterClass &RC2 = RegisterClasses[*II];
364 if (!Empty) OS << ", ";
365 OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
370 OS << (!Empty ? ", " : "") << "NULL";
375 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
376 const CodeGenRegisterClass &RC = RegisterClasses[i];
377 OS << RC.MethodBodies << "\n";
378 OS << RC.getName() << "Class::" << RC.getName()
379 << "Class() : TargetRegisterClass("
380 << RC.getName() + "RegClassID" << ", "
381 << RC.getName() + "VTs" << ", "
382 << RC.getName() + "Subclasses" << ", "
383 << RC.getName() + "Superclasses" << ", "
384 << RC.getName() + "SubRegClasses" << ", "
385 << RC.getName() + "SuperRegClasses" << ", "
386 << RC.SpillSize/8 << ", "
387 << RC.SpillAlignment/8 << ", "
388 << RC.CopyCost << ", "
389 << RC.getName() << ", " << RC.getName() << " + " << RC.Elements.size()
396 OS << "\nnamespace {\n";
397 OS << " const TargetRegisterClass* const RegisterClasses[] = {\n";
398 for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i)
399 OS << " &" << getQualifiedName(RegisterClasses[i].TheDef)
403 // Emit register sub-registers / super-registers, aliases...
404 std::map<Record*, std::set<Record*> > RegisterImmSubRegs;
405 std::map<Record*, std::set<Record*> > RegisterSubRegs;
406 std::map<Record*, std::set<Record*> > RegisterSuperRegs;
407 std::map<Record*, std::set<Record*> > RegisterAliases;
408 std::map<Record*, std::vector<std::pair<int, Record*> > > SubRegVectors;
409 std::map<Record*, std::vector<int> > DwarfRegNums;
411 const std::vector<CodeGenRegister> &Regs = Target.getRegisters();
413 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
414 Record *R = Regs[i].TheDef;
415 std::vector<Record*> LI = Regs[i].TheDef->getValueAsListOfDefs("Aliases");
416 // Add information that R aliases all of the elements in the list... and
417 // that everything in the list aliases R.
418 for (unsigned j = 0, e = LI.size(); j != e; ++j) {
420 if (RegisterAliases[R].count(Reg))
421 cerr << "Warning: register alias between " << getQualifiedName(R)
422 << " and " << getQualifiedName(Reg)
423 << " specified multiple times!\n";
424 RegisterAliases[R].insert(Reg);
426 if (RegisterAliases[Reg].count(R))
427 cerr << "Warning: register alias between " << getQualifiedName(R)
428 << " and " << getQualifiedName(Reg)
429 << " specified multiple times!\n";
430 RegisterAliases[Reg].insert(R);
434 // Process sub-register sets.
435 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
436 Record *R = Regs[i].TheDef;
437 std::vector<Record*> LI = Regs[i].TheDef->getValueAsListOfDefs("SubRegs");
438 // Process sub-register set and add aliases information.
439 for (unsigned j = 0, e = LI.size(); j != e; ++j) {
440 Record *SubReg = LI[j];
441 if (RegisterSubRegs[R].count(SubReg))
442 cerr << "Warning: register " << getQualifiedName(SubReg)
443 << " specified as a sub-register of " << getQualifiedName(R)
444 << " multiple times!\n";
445 RegisterImmSubRegs[R].insert(SubReg);
446 addSubSuperReg(R, SubReg, RegisterSubRegs, RegisterSuperRegs,
451 if (!RegisterAliases.empty())
452 OS << "\n\n // Register Alias Sets...\n";
454 // Emit the empty alias list
455 OS << " const unsigned Empty_AliasSet[] = { 0 };\n";
456 // Loop over all of the registers which have aliases, emitting the alias list
458 for (std::map<Record*, std::set<Record*> >::iterator
459 I = RegisterAliases.begin(), E = RegisterAliases.end(); I != E; ++I) {
460 OS << " const unsigned " << I->first->getName() << "_AliasSet[] = { ";
461 for (std::set<Record*>::iterator ASI = I->second.begin(),
462 E = I->second.end(); ASI != E; ++ASI)
463 OS << getQualifiedName(*ASI) << ", ";
467 if (!RegisterSubRegs.empty())
468 OS << "\n\n // Register Sub-registers Sets...\n";
470 // Emit the empty sub-registers list
471 OS << " const unsigned Empty_SubRegsSet[] = { 0 };\n";
472 // Loop over all of the registers which have sub-registers, emitting the
473 // sub-registers list to memory.
474 for (std::map<Record*, std::set<Record*> >::iterator
475 I = RegisterSubRegs.begin(), E = RegisterSubRegs.end(); I != E; ++I) {
476 OS << " const unsigned " << I->first->getName() << "_SubRegsSet[] = { ";
477 for (std::set<Record*>::iterator ASI = I->second.begin(),
478 E = I->second.end(); ASI != E; ++ASI)
479 OS << getQualifiedName(*ASI) << ", ";
483 if (!RegisterImmSubRegs.empty())
484 OS << "\n\n // Register Immediate Sub-registers Sets...\n";
486 // Loop over all of the registers which have sub-registers, emitting the
487 // sub-registers list to memory.
488 for (std::map<Record*, std::set<Record*> >::iterator
489 I = RegisterImmSubRegs.begin(), E = RegisterImmSubRegs.end();
491 OS << " const unsigned " << I->first->getName() << "_ImmSubRegsSet[] = { ";
492 for (std::set<Record*>::iterator ASI = I->second.begin(),
493 E = I->second.end(); ASI != E; ++ASI)
494 OS << getQualifiedName(*ASI) << ", ";
498 if (!RegisterSuperRegs.empty())
499 OS << "\n\n // Register Super-registers Sets...\n";
501 // Emit the empty super-registers list
502 OS << " const unsigned Empty_SuperRegsSet[] = { 0 };\n";
503 // Loop over all of the registers which have super-registers, emitting the
504 // super-registers list to memory.
505 for (std::map<Record*, std::set<Record*> >::iterator
506 I = RegisterSuperRegs.begin(), E = RegisterSuperRegs.end(); I != E; ++I) {
507 OS << " const unsigned " << I->first->getName() << "_SuperRegsSet[] = { ";
508 for (std::set<Record*>::iterator ASI = I->second.begin(),
509 E = I->second.end(); ASI != E; ++ASI)
510 OS << getQualifiedName(*ASI) << ", ";
514 OS<<"\n const TargetRegisterDesc RegisterDescriptors[] = { // Descriptors\n";
515 OS << " { \"NOREG\",\t\"NOREG\",\t0,\t0,\t0,\t0 },\n";
517 // Now that register alias and sub-registers sets have been emitted, emit the
518 // register descriptors now.
519 const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
520 for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
521 const CodeGenRegister &Reg = Registers[i];
523 if (!Reg.TheDef->getValueAsString("AsmName").empty())
524 OS << Reg.TheDef->getValueAsString("AsmName");
528 if (!Reg.TheDef->getValueAsString("Name").empty()) {
529 OS << Reg.TheDef->getValueAsString("Name");
531 // Default to "name".
532 if (!Reg.TheDef->getValueAsString("AsmName").empty())
533 OS << Reg.TheDef->getValueAsString("AsmName");
538 if (RegisterAliases.count(Reg.TheDef))
539 OS << Reg.getName() << "_AliasSet,\t";
541 OS << "Empty_AliasSet,\t";
542 if (RegisterSubRegs.count(Reg.TheDef))
543 OS << Reg.getName() << "_SubRegsSet,\t";
545 OS << "Empty_SubRegsSet,\t";
546 if (RegisterImmSubRegs.count(Reg.TheDef))
547 OS << Reg.getName() << "_ImmSubRegsSet,\t";
549 OS << "Empty_SubRegsSet,\t";
550 if (RegisterSuperRegs.count(Reg.TheDef))
551 OS << Reg.getName() << "_SuperRegsSet },\n";
553 OS << "Empty_SuperRegsSet },\n";
555 OS << " };\n"; // End of register descriptors...
556 OS << "}\n\n"; // End of anonymous namespace...
558 std::string ClassName = Target.getName() + "GenRegisterInfo";
560 // Calculate the mapping of subregister+index pairs to physical registers.
561 std::vector<Record*> SubRegs = Records.getAllDerivedDefinitions("SubRegSet");
562 for (unsigned i = 0, e = SubRegs.size(); i != e; ++i) {
563 int subRegIndex = SubRegs[i]->getValueAsInt("index");
564 std::vector<Record*> From = SubRegs[i]->getValueAsListOfDefs("From");
565 std::vector<Record*> To = SubRegs[i]->getValueAsListOfDefs("To");
567 if (From.size() != To.size()) {
568 cerr << "Error: register list and sub-register list not of equal length"
569 << " in SubRegSet\n";
573 // For each entry in from/to vectors, insert the to register at index
574 for (unsigned ii = 0, ee = From.size(); ii != ee; ++ii)
575 SubRegVectors[From[ii]].push_back(std::make_pair(subRegIndex, To[ii]));
578 // Emit the subregister + index mapping function based on the information
580 OS << "unsigned " << ClassName
581 << "::getSubReg(unsigned RegNo, unsigned Index) const {\n"
582 << " switch (RegNo) {\n"
583 << " default: abort(); break;\n";
584 for (std::map<Record*, std::vector<std::pair<int, Record*> > >::iterator
585 I = SubRegVectors.begin(), E = SubRegVectors.end(); I != E; ++I) {
586 OS << " case " << getQualifiedName(I->first) << ":\n";
587 OS << " switch (Index) {\n";
588 OS << " default: abort(); break;\n";
589 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
590 OS << " case " << (I->second)[i].first << ": return "
591 << getQualifiedName((I->second)[i].second) << ";\n";
592 OS << " }; break;\n";
595 OS << " return 0;\n";
598 // Emit the constructor of the class...
599 OS << ClassName << "::" << ClassName
600 << "(int CallFrameSetupOpcode, int CallFrameDestroyOpcode)\n"
601 << " : TargetRegisterInfo(RegisterDescriptors, " << Registers.size()+1
602 << ", RegisterClasses, RegisterClasses+" << RegisterClasses.size() <<",\n "
603 << " CallFrameSetupOpcode, CallFrameDestroyOpcode) {}\n\n";
605 // Collect all information about dwarf register numbers
607 // First, just pull all provided information to the map
608 unsigned maxLength = 0;
609 for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
610 Record *Reg = Registers[i].TheDef;
611 std::vector<int> RegNums = Reg->getValueAsListOfInts("DwarfNumbers");
612 maxLength = std::max((size_t)maxLength, RegNums.size());
613 if (DwarfRegNums.count(Reg))
614 cerr << "Warning: DWARF numbers for register " << getQualifiedName(Reg)
615 << "specified multiple times\n";
616 DwarfRegNums[Reg] = RegNums;
619 // Now we know maximal length of number list. Append -1's, where needed
620 for (std::map<Record*, std::vector<int> >::iterator
621 I = DwarfRegNums.begin(), E = DwarfRegNums.end(); I != E; ++I)
622 for (unsigned i = I->second.size(), e = maxLength; i != e; ++i)
623 I->second.push_back(-1);
625 // Emit information about the dwarf register numbers.
626 OS << "int " << ClassName << "::getDwarfRegNumFull(unsigned RegNum, "
627 << "unsigned Flavour) const {\n"
628 << " switch (Flavour) {\n"
630 << " assert(0 && \"Unknown DWARF flavour\");\n"
633 for (unsigned i = 0, e = maxLength; i != e; ++i) {
634 OS << " case " << i << ":\n"
635 << " switch (RegNum) {\n"
637 << " assert(0 && \"Invalid RegNum\");\n"
640 for (std::map<Record*, std::vector<int> >::iterator
641 I = DwarfRegNums.begin(), E = DwarfRegNums.end(); I != E; ++I) {
642 int RegNo = I->second[i];
644 OS << " case " << getQualifiedName(I->first) << ":\n"
645 << " return " << RegNo << ";\n";
647 OS << " case " << getQualifiedName(I->first) << ":\n"
648 << " assert(0 && \"Invalid register for this mode\");\n"
656 OS << "} // End llvm namespace \n";