diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-06-30 23:38:38 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-06-30 23:38:38 +0000 |
| commit | d0a08e0430a8e233b690c2c9e152c130fd8da3ba (patch) | |
| tree | f575cd954d5efff8c2be835c994f83011979dfc0 /llvm/tools/llvm-mc/MC-X86Specific.cpp | |
| parent | d6ea0300e48305f635ee168e7a02c50a560dfdf4 (diff) | |
| download | bcm5719-llvm-d0a08e0430a8e233b690c2c9e152c130fd8da3ba.tar.gz bcm5719-llvm-d0a08e0430a8e233b690c2c9e152c130fd8da3ba.zip | |
llvm-mc: Introduce method to match a parsed x86 instruction into an MCInst.
llvm-svn: 74573
Diffstat (limited to 'llvm/tools/llvm-mc/MC-X86Specific.cpp')
| -rw-r--r-- | llvm/tools/llvm-mc/MC-X86Specific.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/llvm/tools/llvm-mc/MC-X86Specific.cpp b/llvm/tools/llvm-mc/MC-X86Specific.cpp index 806ec4429ce..be0a1281b76 100644 --- a/llvm/tools/llvm-mc/MC-X86Specific.cpp +++ b/llvm/tools/llvm-mc/MC-X86Specific.cpp @@ -65,10 +65,6 @@ struct AsmParser::X86Operand { Res.Mem.ScaleReg = ScaleReg; return Res; } - - void AddToMCInst(MCInst &I) { - // FIXME: Add in x86 order here. - } }; bool AsmParser::ParseX86Operand(X86Operand &Op) { @@ -195,27 +191,34 @@ bool AsmParser::ParseX86MemOperand(X86Operand &Op) { return false; } +/// MatchX86Inst - Convert a parsed instruction name and operand list into a +/// concrete instruction. +static bool MatchX86Inst(const char *Name, + llvm::SmallVector<AsmParser::X86Operand, 3> &Operands, + MCInst &Inst) { + return false; +} + /// ParseX86InstOperands - Parse the operands of an X86 instruction and return /// them as the operands of an MCInst. -bool AsmParser::ParseX86InstOperands(MCInst &Inst) { - // If no operands are present, just return. - if (Lexer.is(asmtok::EndOfStatement)) - return false; +bool AsmParser::ParseX86InstOperands(const char *InstName, MCInst &Inst) { + llvm::SmallVector<X86Operand, 3> Operands; - // Read the first operand. - X86Operand Op; - if (ParseX86Operand(Op)) - return true; - Op.AddToMCInst(Inst); - - while (Lexer.is(asmtok::Comma)) { - Lexer.Lex(); // Eat the comma. - - // Parse and remember the operand. - Op = X86Operand(); - if (ParseX86Operand(Op)) + if (Lexer.isNot(asmtok::EndOfStatement)) { + // Read the first operand. + Operands.push_back(X86Operand()); + if (ParseX86Operand(Operands.back())) return true; - Op.AddToMCInst(Inst); + + while (Lexer.is(asmtok::Comma)) { + Lexer.Lex(); // Eat the comma. + + // Parse and remember the operand. + Operands.push_back(X86Operand()); + if (ParseX86Operand(Operands.back())) + return true; + } } - return false; + + return MatchX86Inst(InstName, Operands, Inst); } |

