[LLVMdev] RFC building a target MCAsmParser

Krzysztof Parzyszek kparzysz at codeaurora.org
Tue Apr 14 11:43:54 PDT 2015


On 4/14/2015 1:21 PM, Joerg Sonnenberger wrote:
> On Tue, Apr 14, 2015 at 12:58:51PM -0500, Colin LeMahieu wrote:
>> We found the Hexagon grammar to be straight forward to implement using plain
>> lex / parse but harder within the MCTargetAsmParser.
>
> Can you go into more detail what exactly you find difficult? X86 already
> has the problem of integrating two quite different assembler variants.
> Your grammar also seems to lack a number of things like how to specify
> sections and similar meta data?

Hexagon assembly syntax doesn't have mnemonics in the same sense as 
other architectures.  Take "add" as an example:

   r0 = add(r1, r2)
   r0 = add(r1, #2)
r1:0 = add(r3:2, r5:4)
r1:0 = add(r2, r5:4)

There is more:

   r0  = add(r1, add(r2, #5))
r1:0  = add(r3:2, r5:4):sat
   r0 += add(r1, #3)

predicated versions:

   if (!p0) r0 = add(r1, #4)

etc.

In the architecture definition they all have different tags, which we 
use in the .td files, but for the assembly programmer there is "add" 
stuck in various places in the instruction string.  Most architectures 
use the syntax where the mnemonic comes first, followed by operands. 
Ours is very different.

-Krzysztof



-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list