For now, generic virtual registers will not have a register class. We may want
to change that. For instance, if we want to use all the methods from
TargetRegisterInfo with generic virtual registers, we need to either have some
sort of generic register classes that do what we want, or teach those methods
how to deal with nullptr register class.
Although the latter seems easy enough to do, we may still want to differenciate
generic register classes from nullptr to catch cases where nullptr gets
introduced by a bug of some sort.
Anyway, I will file a PR to keep track of that.
llvm-svn: 260474
/// Get the size of \p VReg or 0 if VReg is not a generic
/// (target independent) virtual register.
unsigned getSize(unsigned VReg) const;
+
+ /// Create and return a new generic virtual register with a size of \p Size.
+ /// \pre Size > 0.
+ unsigned createGenericVirtualRegister(unsigned Size);
#endif
/// getNumVirtRegs - Return the number of virtual registers created.
}
for (unsigned i = 0; i != VirtRegs.size(); ++i) {
const TargetRegisterClass *RC = MRI->getRegClass(VirtRegs[i]);
+#ifdef LLVM_BUILD_GLOBAL_ISEL
+ // Generic virtual registers do not have register classes.
+ if (!RC)
+ continue;
+#endif
OS << " " << TRI->getRegClassName(RC)
<< ':' << PrintReg(VirtRegs[i]);
for (unsigned j = i+1; j != VirtRegs.size();) {
VRegToSize.find(VReg);
return SizeIt != VRegToSize.end()? SizeIt->second: 0;
}
+
+unsigned
+MachineRegisterInfo::createGenericVirtualRegister(unsigned Size) {
+ assert(Size && "Cannot create empty virtual register");
+
+ // New virtual register number.
+ unsigned Reg = TargetRegisterInfo::index2VirtReg(getNumVirtRegs());
+ VRegInfo.grow(Reg);
+ // FIXME: Should we use a dummy register class?
+ VRegInfo[Reg].first = nullptr;
+ VRegToSize[Reg] = Size;
+ RegAllocHints.grow(Reg);
+ if (TheDelegate)
+ TheDelegate->MRI_NoteNewVirtualRegister(Reg);
+ return Reg;
+}
#endif // LLVM_BUILD_GLOBAL_ISEL
/// clearVirtRegs - Remove all virtual registers (after physreg assignment).