[llvm] r262893 - [MIR] Teach the parser/printer that generic virtual registers do not need a register class.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 17:17:03 PST 2016
Author: qcolombet
Date: Mon Mar 7 19:17:03 2016
New Revision: 262893
URL: http://llvm.org/viewvc/llvm-project?rev=262893&view=rev
Log:
[MIR] Teach the parser/printer that generic virtual registers do not need a register class.
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/trunk/lib/CodeGen/MIRPrinter.cpp
llvm/trunk/test/CodeGen/MIR/X86/generic-virtual-registers.mir
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=262893&r1=262892&r2=262893&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Mon Mar 7 19:17:03 2016
@@ -347,12 +347,19 @@ bool MIRParserImpl::initializeRegisterIn
SMDiagnostic Error;
// Parse the virtual register information.
for (const auto &VReg : YamlMF.VirtualRegisters) {
- const auto *RC = getRegClass(MF, VReg.Class.Value);
- if (!RC)
- return error(VReg.Class.SourceRange.Start,
- Twine("use of undefined register class '") +
- VReg.Class.Value + "'");
- unsigned Reg = RegInfo.createVirtualRegister(RC);
+ unsigned Reg;
+ if (StringRef(VReg.Class.Value).equals("_")) {
+ // This is a generic virtual register.
+ // The size will be set appropriately when we reach the definition.
+ Reg = RegInfo.createGenericVirtualRegister(/*Size*/ 1);
+ } else {
+ const auto *RC = getRegClass(MF, VReg.Class.Value);
+ if (!RC)
+ return error(VReg.Class.SourceRange.Start,
+ Twine("use of undefined register class '") +
+ VReg.Class.Value + "'");
+ Reg = RegInfo.createVirtualRegister(RC);
+ }
if (!PFS.VirtualRegisterSlots.insert(std::make_pair(VReg.ID.Value, Reg))
.second)
return error(VReg.ID.SourceRange.Start,
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=262893&r1=262892&r2=262893&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Mon Mar 7 19:17:03 2016
@@ -207,8 +207,13 @@ void MIRPrinter::convert(yaml::MachineFu
unsigned Reg = TargetRegisterInfo::index2VirtReg(I);
yaml::VirtualRegisterDefinition VReg;
VReg.ID = I;
- VReg.Class =
- StringRef(TRI->getRegClassName(RegInfo.getRegClass(Reg))).lower();
+ if (RegInfo.getRegClass(Reg))
+ VReg.Class =
+ StringRef(TRI->getRegClassName(RegInfo.getRegClass(Reg))).lower();
+ else {
+ VReg.Class = std::string("_");
+ assert(RegInfo.getSize(Reg) && "Generic registers must have a size");
+ }
unsigned PreferredReg = RegInfo.getSimpleHint(Reg);
if (PreferredReg)
printReg(PreferredReg, VReg.PreferredRegister, TRI);
Modified: llvm/trunk/test/CodeGen/MIR/X86/generic-virtual-registers.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/generic-virtual-registers.mir?rev=262893&r1=262892&r2=262893&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/generic-virtual-registers.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/generic-virtual-registers.mir Mon Mar 7 19:17:03 2016
@@ -19,14 +19,17 @@
name: bar
isSSA: true
# CHECK: registers:
-# CHECK-NEXT: - { id: 0, class: gr32 }
-# CHECK-NEXT: - { id: 1, class: gr64 }
+# CHECK-NEXT: - { id: 0, class: _ }
+# CHECK-NEXT: - { id: 1, class: _ }
+# CHECK-NEXT: - { id: 2, class: _ }
+# CHECK-NEXT: - { id: 3, class: _ }
+# CHECK-NEXT: - { id: 4, class: _ }
registers:
- - { id: 0, class: gr32 }
- - { id: 1, class: gr64 }
- - { id: 2, class: gr64 }
- - { id: 3, class: gr64 }
- - { id: 4, class: gr64 }
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+ - { id: 3, class: _ }
+ - { id: 4, class: _ }
body: |
bb.0.entry:
liveins: %edi
More information about the llvm-commits
mailing list