llvm.org GIT mirror llvm / 8102703
Sort sub-registers and super-registers lists according to super-sub register relations. e.g. X86::RAX sub-register list is EAX, AX, AL, AH (order of last two are not guaranteed). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49714 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
2 changed file(s) with 33 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
352352 return get(RegNo).AliasSet;
353353 }
354354
355 /// getSubRegisters - Return the set of registers that are sub-registers of
355 /// getSubRegisters - Return the list of registers that are sub-registers of
356356 /// the specified register, or a null list of there are none. The list
357 /// returned is zero terminated.
357 /// returned is zero terminated and sorted according to super-sub register
358 /// relations. e.g. X86::RAX's sub-register list is EAX, AX, AL, AH.
358359 ///
359360 const unsigned *getSubRegisters(unsigned RegNo) const {
360361 return get(RegNo).SubRegs;
368369 return get(RegNo).ImmSubRegs;
369370 }
370371
371 /// getSuperRegisters - Return the set of registers that are super-registers
372 /// getSuperRegisters - Return the list of registers that are super-registers
372373 /// of the specified register, or a null list of there are none. The list
373 /// returned is zero terminated.
374 /// returned is zero terminated and sorted according to super-sub register
375 /// relations. e.g. X86::AL's super-register list is RAX, EAX, AX.
374376 ///
375377 const unsigned *getSuperRegisters(unsigned RegNo) const {
376378 return get(RegNo).SuperRegs;
151151 E = SubRegs[S].end(); I != E; ++I)
152152 addSubSuperReg(R, *I, SubRegs, SuperRegs, Aliases);
153153 }
154
155 class RegisterSorter {
156 private:
157 std::map > &RegisterSubRegs;
158
159 public:
160 RegisterSorter(std::map > &RS)
161 : RegisterSubRegs(RS) {};
162
163 bool operator()(Record *RegA, Record *RegB) {
164 // B is sub-register of A.
165 return RegisterSubRegs.count(RegA) && RegisterSubRegs[RegA].count(RegB);
166 }
167 };
154168
155169 // RegisterInfoEmitter::run - Main register file description emitter.
156170 //
473487 for (std::map >::iterator
474488 I = RegisterSubRegs.begin(), E = RegisterSubRegs.end(); I != E; ++I) {
475489 OS << " const unsigned " << I->first->getName() << "_SubRegsSet[] = { ";
490 std::vector SubRegsVector;
476491 for (std::set::iterator ASI = I->second.begin(),
477492 E = I->second.end(); ASI != E; ++ASI)
478 OS << getQualifiedName(*ASI) << ", ";
493 SubRegsVector.push_back(*ASI);
494 RegisterSorter RS(RegisterSubRegs);
495 std::stable_sort(SubRegsVector.begin(), SubRegsVector.end(), RS);
496 for (unsigned i = 0, e = SubRegsVector.size(); i != e; ++i)
497 OS << getQualifiedName(SubRegsVector[i]) << ", ";
479498 OS << "0 };\n";
480499 }
481500
504523 for (std::map >::iterator
505524 I = RegisterSuperRegs.begin(), E = RegisterSuperRegs.end(); I != E; ++I) {
506525 OS << " const unsigned " << I->first->getName() << "_SuperRegsSet[] = { ";
526
527 std::vector SuperRegsVector;
507528 for (std::set::iterator ASI = I->second.begin(),
508529 E = I->second.end(); ASI != E; ++ASI)
509 OS << getQualifiedName(*ASI) << ", ";
530 SuperRegsVector.push_back(*ASI);
531 RegisterSorter RS(RegisterSubRegs);
532 std::stable_sort(SuperRegsVector.begin(), SuperRegsVector.end(), RS);
533 for (unsigned i = 0, e = SuperRegsVector.size(); i != e; ++i)
534 OS << getQualifiedName(SuperRegsVector[i]) << ", ";
510535 OS << "0 };\n";
511536 }
512537