diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-14 22:21:20 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-14 22:21:20 +0000 | 
| commit | f29c0b6880c217b65a6a1df18a54e308719e48b3 (patch) | |
| tree | bc7ebf089faab00d1eb5efb4b266c26971c0b256 /llvm/utils | |
| parent | fdf7031a1a896899cf1bb7f0bd812b2ae4467579 (diff) | |
| download | bcm5719-llvm-f29c0b6880c217b65a6a1df18a54e308719e48b3.tar.gz bcm5719-llvm-f29c0b6880c217b65a6a1df18a54e308719e48b3.zip | |
Split the TargetAsmParser "ParseInstruction" interface in half:
the new ParseInstruction method just parses and returns a list of
target operands.  A new MatchInstruction interface is used to
turn the operand list into an MCInst.
This requires new/deleting all the operands, but it also gives 
targets the ability to use polymorphic operands if they want to. 
llvm-svn: 93469
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 22 | 
1 files changed, 13 insertions, 9 deletions
| diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 3eac9d201b7..019908bd599 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -961,8 +961,8 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,    CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "          << "unsigned Opcode,\n" -        << "                            SmallVectorImpl<" -        << Target.getName() << "Operand> &Operands) {\n"; +        << "                      const SmallVectorImpl<MCParsedAsmOperand*" +        << "> &Operands) {\n";    CvtOS << "  Inst.setOpcode(Opcode);\n";    CvtOS << "  switch (Kind) {\n";    CvtOS << "  default:\n"; @@ -972,6 +972,9 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,    OS << "// Unified function for converting operants to MCInst instances.\n\n";    OS << "enum ConversionKind {\n"; +  // TargetOperandClass - This is the target's operand class, like X86Operand. +  std::string TargetOperandClass = Target.getName() + "Operand"; +      for (std::vector<InstructionInfo*>::const_iterator it = Infos.begin(),           ie = Infos.end(); it != ie; ++it) {      InstructionInfo &II = **it; @@ -1050,8 +1053,9 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,        for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex)          CvtOS << "    Inst.addOperand(MCOperand::CreateReg(0));\n"; -      CvtOS << "    Operands[" << MIOperandList[i].second  -         << "]." << Op.Class->RenderMethod  +      CvtOS << "    ((" << TargetOperandClass << "*)Operands[" +         << MIOperandList[i].second  +         << "])->" << Op.Class->RenderMethod            << "(Inst, " << Op.OperandInfo->MINumOperands << ");\n";        CurIndex += Op.OperandInfo->MINumOperands;      } @@ -1111,8 +1115,9 @@ static void EmitMatchClassEnumeration(CodeGenTarget &Target,  static void EmitClassifyOperand(CodeGenTarget &Target,                                  AsmMatcherInfo &Info,                                  raw_ostream &OS) { -  OS << "static MatchClassKind ClassifyOperand(" -     << Target.getName() << "Operand &Operand) {\n"; +  OS << "static MatchClassKind ClassifyOperand(MCParsedAsmOperand *GOp) {\n" +     << "  " << Target.getName() << "Operand &Operand = *(" +     << Target.getName() << "Operand*)GOp;\n";    // Classify tokens.    OS << "  if (Operand.isToken())\n"; @@ -1467,9 +1472,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {      MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size());    OS << "bool " << Target.getName() << ClassName -     << "::MatchInstruction("  -     << "SmallVectorImpl<" << Target.getName() << "Operand> &Operands, " -     << "MCInst &Inst) {\n"; +     << "::\nMatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> " +        "&Operands,\n                 MCInst &Inst) {\n";    // Emit the static match table; unused classes get initalized to 0 which is    // guaranteed to be InvalidMatchClass. | 

