<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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<br>
<br>
<div class="moz-cite-prefix">On 28/09/15 14:21, Sky Flyer via
llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CAKEa+G6rXMpgpRXuou09Af0c5PMBoAN9QC8TqZ8TC1j0UqfU-A@mail.gmail.com"
type="cite">
<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 moz-do-not-send="true"
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 class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>