[LLVMdev] Directive parsing for AsmParser

Medic, Vladimir vmedic at mips.com
Wed May 9 06:26:49 PDT 2012


I'm trying to build a standalone assembler for Mips using AsmParser and I'm facing a problem with assembly directives. Mips assembler has following syntax for .set directive

  .set reorder

or

  .set noreorder

which allow/disallow assembler to change the order of instructions in the block that follows. As the implemented AsmParser requires .set directive to have the following syntax:

/// ParseDirectiveSet:
///   ::= .set identifier ',' expression

I am getting an error reported when '.set reoeder/noreorder' is met in the code. After some investigation it seems reasonable for me to move the code which handles target specific directive parsing from the end to the beginning of the block, like this (AsmParser::ParseStatement, AsmParser.cpp line 1225):

  // Otherwise, we have a normal instruction or directive.
  if (IDVal[0] == '.' && IDVal != ".") {

    // Target hook for parsing target specific directives.
    if (!getTargetParser().ParseDirective(ID))
      return false;
  .
  .
  .
  .
}
 thus allowing the target specific directives to be handled first rather then at the end.

What is your opinion regarding this change?

Kind regards

Vladimir

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120509/79c79aff/attachment.html>


More information about the llvm-dev mailing list