<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><a class="enum highlight" href="http://code.woboq.org/llvm/llvm/include/llvm/MC/MCParser/MCAsmLexer.h.html#llvm::AsmToken::TokenKind::EndOfStatement" data-ref="llvm::AsmToken::TokenKind::EndOfStatement" id="llvm::AsmToken::TokenKind::EndOfStatement"></a>Would
getLexer().isNot(AsmToken::EndOfStatement) in that condition do the trick? The lexer is already splitting the input at spaces.<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF748460"><font color="#000000" face="Tahoma" size="2"><b>From:</b> llvm-dev [llvm-dev-bounces@lists.llvm.org] on behalf of Sky Flyer via llvm-dev [llvm-dev@lists.llvm.org]<br>
<b>Sent:</b> 28 September 2015 14:41<br>
<b>To:</b> Pierre-Andre Saulais<br>
<b>Cc:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] Parse Instruction<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div>Hi Pierre-Andre<br>
<br>
Thanks for your prompt reply.<br>
What I mean, is located at line 4192 <a href="UrlBlockedError.aspx" target="_blank">
(http://code.woboq.org/llvm/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp.html#4192</a>).<br>
It, first, has to parse the instruction, and based on the number of operands it uses a pattern in MatchAndEmit.<br>
My problem is, what would be a suitable substitute if operands in the assembly code are not comma-separated, instead space-separated. (as you know, space is automatically removed so I cannot simply switch AsmToken::Comma to AsmToken::Space.)<br>
<br>
</div>
Thanks a lot. :-)<br>
<div><br>
<br>
<br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 28, 2015 at 3:32 PM, Pierre-Andre Saulais <span dir="ltr">
<<a href="mailto:pierre-andre@codeplay.com" target="_blank">pierre-andre@codeplay.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div bgcolor="#FFFFFF">Hi ES,<br>
<br>
>From what I understand instruction parsing is divided into two parts:<br>
<br>
- Parsing an operand list (XXXAsmParser::ParseInstruction)<br>
- Turning the operand list into an actual instruction (XXXAsmParser::MatchAndEmitInstruction)<br>
<br>
The second part does the validation (e.g. how many operands, what kind, etc) while the first part only does the parsing. That's why I think in the first part you have to handle all possible operand combinations (i.e. parse the first operand, and keep parsing
operands as long as you see spaces). LLVM will reject instructions with too many operands (as defined in the .td files).<br>
<br>
Is this something that would work with your assembly syntax?<br>
<br>
Cheers,<br>
Pierre-Andre
<div>
<div class="h5"><br>
<br>
<div>On 28/09/15 14:21, Sky Flyer via llvm-dev wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">
<div>practically I cannot use a function namly <b>getMnemonicAcceptInfo</b> (mnemonic as input, and number of possible outputs as output), because there are mnemonics that accepts different number of operands! :-/<br>
<br>
</div>
Any help is highly appreciated.<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 28, 2015 at 10:53 AM, Sky Flyer <span dir="ltr">
<<a href="mailto:skylake007@googlemail.com" target="_blank">skylake007@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">Hi all,<br>
<br>
in most of the architectures, assembly operands are comma-separated.<br>
I would like to parse an assembly code that is space-separated and I am having a bit of problem.<br>
In <b>ParseInstruction</b> function, I don't know what is the easiest way to figure out how many operands a mnemonic expected to have.<br>
In comma-separated assembly code, it just consuming commas (while (getLexer().is(AsmToken::Comma))) and adds operands, but it's not the case for space...<br>
<br>
I have a dirty hack, that I manually provide such information (number of operands) in a function called for example getMnemonicAcceptInfo and with a for loop I parse the operand!!<br>
<br>
What would you suggest for parsing space-separated assembly codes when it comes to figuring out if a mnemonic has two operands or one?<br>
<br>
Cheers,<br>
ES</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset target="_blank"></fieldset> <br>
</div>
</div>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>