diff options
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.h | 3 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 158502ce353..405e508b51e 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -970,10 +970,7 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest, TiedDefIdx = Idx; } } else if (consumeIfPresent(MIToken::lparen)) { - // Generic virtual registers must have a size. - // The "must" part will be verify by the machine verifier, - // because at this point we actually do not know if Reg is - // a generic virtual register. + // Virtual registers may have a size with GlobalISel. if (!TargetRegisterInfo::isVirtualRegister(Reg)) return error("unexpected size on physical register"); unsigned Size; @@ -982,6 +979,11 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest, MachineRegisterInfo &MRI = MF.getRegInfo(); MRI.setSize(Reg, Size); + } else if (PFS.GenericVRegs.count(Reg)) { + // Generic virtual registers must have a size. + // If we end up here this means the size hasn't been specified and + // this is bad! + return error("generic virtual registers must have a size"); } Dest = MachineOperand::CreateReg( Reg, Flags & RegState::Define, Flags & RegState::Implicit, diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.h b/llvm/lib/CodeGen/MIRParser/MIParser.h index ce39805e0c5..3557b9a6d5d 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.h +++ b/llvm/lib/CodeGen/MIRParser/MIParser.h @@ -15,6 +15,7 @@ #define LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallSet.h" namespace llvm { @@ -35,6 +36,8 @@ struct PerFunctionMIParsingState { DenseMap<unsigned, int> StackObjectSlots; DenseMap<unsigned, unsigned> ConstantPoolSlots; DenseMap<unsigned, unsigned> JumpTableSlots; + /// Hold the generic virtual registers. + SmallSet<unsigned, 8> GenericVRegs; }; /// Parse the machine basic block definitions, and skip the machine diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index 69aae373f2e..e977973b1a5 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -365,6 +365,7 @@ bool MIRParserImpl::initializeRegisterInfo(MachineFunction &MF, // This is a generic virtual register. // The size will be set appropriately when we reach the definition. Reg = RegInfo.createGenericVirtualRegister(/*Size*/ 1); + PFS.GenericVRegs.insert(Reg); } else { const auto *RC = getRegClass(MF, VReg.Class.Value); if (RC) { @@ -378,6 +379,7 @@ bool MIRParserImpl::initializeRegisterInfo(MachineFunction &MF, VReg.Class.Value + "'"); Reg = RegInfo.createGenericVirtualRegister(/*Size*/ 1); RegInfo.setRegBank(Reg, *RegBank); + PFS.GenericVRegs.insert(Reg); } } if (!PFS.VirtualRegisterSlots.insert(std::make_pair(VReg.ID.Value, Reg)) |

