assert(!Operands.empty() && "Unexpect empty operand list!");
// First, try a direct match.
- if (!MatchInstructionImpl(Operands, Inst))
+ if (MatchInstructionImpl(Operands, Inst) == Match_Success)
return false;
// FIXME: Ideally, we would only attempt suffix matches for things which are
// Check for the various suffix matches.
Tmp[Base.size()] = 'b';
- bool MatchB = MatchInstructionImpl(Operands, Inst);
+ bool MatchB = MatchInstructionImpl(Operands, Inst) != Match_Success;
Tmp[Base.size()] = 'w';
- bool MatchW = MatchInstructionImpl(Operands, Inst);
+ bool MatchW = MatchInstructionImpl(Operands, Inst) != Match_Success;
Tmp[Base.size()] = 'l';
- bool MatchL = MatchInstructionImpl(Operands, Inst);
+ bool MatchL = MatchInstructionImpl(Operands, Inst) != Match_Success;
Tmp[Base.size()] = 'q';
- bool MatchQ = MatchInstructionImpl(Operands, Inst);
+ bool MatchQ = MatchInstructionImpl(Operands, Inst) != Match_Success;
// Restore the old token.
Op->setTokenValue(Base);
// Information for the class declaration.
OS << "\n#ifdef GET_ASSEMBLER_HEADER\n";
OS << "#undef GET_ASSEMBLER_HEADER\n";
+ OS << " // This should be included into the middle of the declaration of \n";
+ OS << " // your subclasses implementation of TargetAsmParser.\n";
OS << " unsigned ComputeAvailableFeatures(const " <<
Target.getName() << "Subtarget *Subtarget) const;\n";
- OS << "bool MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>"
+ OS << " enum MatchResultTy {\n";
+ OS << " Match_Success, Match_Fail\n";
+ OS << " };\n";
+ OS << " MatchResultTy MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>"
<< " &Operands, MCInst &Inst);\n\n";
OS << "#endif // GET_ASSEMBLER_HEADER_INFO\n\n";
it != ie; ++it)
MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size());
- OS << "bool " << Target.getName() << ClassName << "::\n"
+ OS << Target.getName() << ClassName << "::MatchResultTy "
+ << Target.getName() << ClassName << "::\n"
<< "MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>"
<< " &Operands,\n";
OS << " MCInst &Inst) {\n";
// Emit code to compute the class list for this operand vector.
OS << " // Eliminate obvious mismatches.\n";
OS << " if (Operands.size() > " << MaxNumOperands << ")\n";
- OS << " return true;\n\n";
+ OS << " return Match_Fail;\n\n";
OS << " // Compute the class list for this operand vector.\n";
OS << " MatchClassKind Classes[" << MaxNumOperands << "];\n";
OS << " // Check for invalid operands before matching.\n";
OS << " if (Classes[i] == InvalidMatchClass)\n";
- OS << " return true;\n";
+ OS << " return Match_Fail;\n";
OS << " }\n\n";
OS << " // Mark unused classes.\n";
if (!InsnCleanupFn.empty())
OS << " " << InsnCleanupFn << "(Inst);\n";
- OS << " return false;\n";
+ OS << " return Match_Success;\n";
OS << " }\n\n";
- OS << " return true;\n";
+ OS << " return Match_Fail;\n";
OS << "}\n\n";
OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n";