diff options
| author | Tim Northover <tnorthover@apple.com> | 2016-09-09 11:46:34 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2016-09-09 11:46:34 +0000 |
| commit | 0f140c769a75779991d0bb31c2e34907621d2386 (patch) | |
| tree | ee9ab7880246083d7fe91bd95f29a59a98e2e09f /llvm/lib/CodeGen/MIRParser/MIParser.cpp | |
| parent | a3afe44d6c1499e7b11968ed502f3d5193479076 (diff) | |
| download | bcm5719-llvm-0f140c769a75779991d0bb31c2e34907621d2386.tar.gz bcm5719-llvm-0f140c769a75779991d0bb31c2e34907621d2386.zip | |
GlobalISel: move type information to MachineRegisterInfo.
We want each register to have a canonical type, which means the best place to
store this is in MachineRegisterInfo rather than on every MachineInstr that
happens to use or define that register.
Most changes following from this are pretty simple (you need an MRI anyway if
you're going to be doing any transformations, so just check the type there).
But legalization doesn't really want to check redundant operands (when, for
example, a G_ADD only ever has one type) so I've made use of MCInstrDesc's
operand type field to encode these constraints and limit legalization's work.
As an added bonus, more validation is possible, both in MachineVerifier and
MachineIRBuilder (coming soon).
llvm-svn: 281035
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIParser.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 91943ea36ac..4dc964e1d80 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -599,25 +599,6 @@ bool MIParser::parse(MachineInstr *&MI) { if (Token.isError() || parseInstruction(OpCode, Flags)) return true; - SmallVector<LLT, 1> Tys; - if (isPreISelGenericOpcode(OpCode)) { - // For generic opcode, at least one type is mandatory. - auto Loc = Token.location(); - bool ManyTypes = Token.is(MIToken::lbrace); - if (ManyTypes) - lex(); - - // Now actually parse the type(s). - do { - Tys.resize(Tys.size() + 1); - if (parseLowLevelType(Loc, Tys[Tys.size() - 1])) - return true; - } while (ManyTypes && consumeIfPresent(MIToken::comma)); - - if (ManyTypes) - expectAndConsume(MIToken::rbrace); - } - // Parse the remaining machine operands. while (!Token.isNewlineOrEOF() && Token.isNot(MIToken::kw_debug_location) && Token.isNot(MIToken::coloncolon) && Token.isNot(MIToken::lbrace)) { @@ -673,10 +654,6 @@ bool MIParser::parse(MachineInstr *&MI) { // TODO: Check for extraneous machine operands. MI = MF.CreateMachineInstr(MCID, DebugLocation, /*NoImplicit=*/true); MI->setFlags(Flags); - if (Tys.size() > 0) { - for (unsigned i = 0; i < Tys.size(); ++i) - MI->setType(Tys[i], i); - } for (const auto &Operand : Operands) MI->addOperand(MF, Operand.Operand); if (assignRegisterTies(*MI, Operands)) @@ -996,11 +973,14 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest, if (MRI.getRegClassOrRegBank(Reg).is<const TargetRegisterClass *>()) return error("unexpected size on non-generic virtual register"); - unsigned Size; - if (parseSize(Size)) + LLT Ty; + if (parseLowLevelType(Token.location(), Ty)) + return true; + + if (expectAndConsume(MIToken::rparen)) return true; - MRI.setSize(Reg, Size); + MRI.setType(Reg, Ty); } 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 |

