mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Introduce TargetRegisterInfo::getOverlaps(Reg), returning a list of all
registers that alias Reg, including itself. This is almost the same as the existing getAliasSet() method, except for the inclusion of Reg. The name matches the reflexive TRI::regsOverlap(x, y) relation. It is very common to do stuff to a register and all its aliases: stuff(Reg) for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) stuff(*Alias); That can now be written as the simpler: for (const unsigned *Alias = TRI->getOverlaps(Reg); *Alias; ++Alias) stuff(*Alias); This change requires a bit more constant space for the alias lists because Reg is included and because the empty alias list cannot be shared any longer. If the getAliasSet method is eventually removed, this space can be reclaimed by sharing overlap lists. For instance, %rax and %eax have identical overlap sets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121800 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -32,19 +32,18 @@ template<class T> class SmallVectorImpl;
|
|||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
/// TargetRegisterDesc - This record contains all of the information known about
|
/// TargetRegisterDesc - This record contains all of the information known about
|
||||||
/// a particular register. The AliasSet field (if not null) contains a pointer
|
/// a particular register. The Overlaps field contains a pointer to a zero
|
||||||
/// to a Zero terminated array of registers that this register aliases. This is
|
/// terminated array of registers that this register aliases, starting with
|
||||||
/// needed for architectures like X86 which have AL alias AX alias EAX.
|
/// itself. This is needed for architectures like X86 which have AL alias AX
|
||||||
/// Registers that this does not apply to simply should set this to null.
|
/// alias EAX. The SubRegs field is a zero terminated array of registers that
|
||||||
/// The SubRegs field is a zero terminated array of registers that are
|
/// are sub-registers of the specific register, e.g. AL, AH are sub-registers of
|
||||||
/// sub-registers of the specific register, e.g. AL, AH are sub-registers of AX.
|
/// AX. The SuperRegs field is a zero terminated array of registers that are
|
||||||
/// The SuperRegs field is a zero terminated array of registers that are
|
|
||||||
/// super-registers of the specific register, e.g. RAX, EAX, are super-registers
|
/// super-registers of the specific register, e.g. RAX, EAX, are super-registers
|
||||||
/// of AX.
|
/// of AX.
|
||||||
///
|
///
|
||||||
struct TargetRegisterDesc {
|
struct TargetRegisterDesc {
|
||||||
const char *Name; // Printable name for the reg (for debugging)
|
const char *Name; // Printable name for the reg (for debugging)
|
||||||
const unsigned *AliasSet; // Register Alias Set, described above
|
const unsigned *Overlaps; // Overlapping registers, described above
|
||||||
const unsigned *SubRegs; // Sub-register set, described above
|
const unsigned *SubRegs; // Sub-register set, described above
|
||||||
const unsigned *SuperRegs; // Super-register set, described above
|
const unsigned *SuperRegs; // Super-register set, described above
|
||||||
};
|
};
|
||||||
@@ -355,7 +354,17 @@ public:
|
|||||||
/// terminated.
|
/// terminated.
|
||||||
///
|
///
|
||||||
const unsigned *getAliasSet(unsigned RegNo) const {
|
const unsigned *getAliasSet(unsigned RegNo) const {
|
||||||
return get(RegNo).AliasSet;
|
// The Overlaps set always begins with Reg itself.
|
||||||
|
return get(RegNo).Overlaps + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getOverlaps - Return a list of registers that overlap Reg, including
|
||||||
|
/// itself. This is the same as the alias set except Reg is included in the
|
||||||
|
/// list.
|
||||||
|
/// These are exactly the registers in { x | regsOverlap(x, Reg) }.
|
||||||
|
///
|
||||||
|
const unsigned *getOverlaps(unsigned RegNo) const {
|
||||||
|
return get(RegNo).Overlaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSubRegisters - Return the list of registers that are sub-registers of
|
/// getSubRegisters - Return the list of registers that are sub-registers of
|
||||||
|
@@ -777,17 +777,13 @@ void RegisterInfoEmitter::run(raw_ostream &OS) {
|
|||||||
delete [] AliasesHashTable;
|
delete [] AliasesHashTable;
|
||||||
|
|
||||||
if (!RegisterAliases.empty())
|
if (!RegisterAliases.empty())
|
||||||
OS << "\n\n // Register Alias Sets...\n";
|
OS << "\n\n // Register Overlap Lists...\n";
|
||||||
|
|
||||||
// Emit the empty alias list
|
// Emit an overlap list for all registers.
|
||||||
OS << " const unsigned Empty_AliasSet[] = { 0 };\n";
|
|
||||||
// Loop over all of the registers which have aliases, emitting the alias list
|
|
||||||
// to memory.
|
|
||||||
for (std::map<Record*, std::set<Record*>, LessRecord >::iterator
|
for (std::map<Record*, std::set<Record*>, LessRecord >::iterator
|
||||||
I = RegisterAliases.begin(), E = RegisterAliases.end(); I != E; ++I) {
|
I = RegisterAliases.begin(), E = RegisterAliases.end(); I != E; ++I) {
|
||||||
if (I->second.empty())
|
OS << " const unsigned " << I->first->getName() << "_Overlaps[] = { "
|
||||||
continue;
|
<< getQualifiedName(I->first) << ", ";
|
||||||
OS << " const unsigned " << I->first->getName() << "_AliasSet[] = { ";
|
|
||||||
for (std::set<Record*>::iterator ASI = I->second.begin(),
|
for (std::set<Record*>::iterator ASI = I->second.begin(),
|
||||||
E = I->second.end(); ASI != E; ++ASI)
|
E = I->second.end(); ASI != E; ++ASI)
|
||||||
OS << getQualifiedName(*ASI) << ", ";
|
OS << getQualifiedName(*ASI) << ", ";
|
||||||
@@ -849,11 +845,7 @@ void RegisterInfoEmitter::run(raw_ostream &OS) {
|
|||||||
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
|
||||||
const CodeGenRegister &Reg = Regs[i];
|
const CodeGenRegister &Reg = Regs[i];
|
||||||
OS << " { \"";
|
OS << " { \"";
|
||||||
OS << Reg.getName() << "\",\t";
|
OS << Reg.getName() << "\",\t" << Reg.getName() << "_Overlaps,\t";
|
||||||
if (!RegisterAliases[Reg.TheDef].empty())
|
|
||||||
OS << Reg.getName() << "_AliasSet,\t";
|
|
||||||
else
|
|
||||||
OS << "Empty_AliasSet,\t";
|
|
||||||
if (!RegisterSubRegs[Reg.TheDef].empty())
|
if (!RegisterSubRegs[Reg.TheDef].empty())
|
||||||
OS << Reg.getName() << "_SubRegsSet,\t";
|
OS << Reg.getName() << "_SubRegsSet,\t";
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user