[cfe-commits] [PATCH] MS style inline assembly support

Eli Friedman eli.friedman at gmail.com
Fri Jun 8 13:42:46 PDT 2012

On Fri, Jun 8, 2012 at 11:52 AM, Chad Rosier <mcrosier at apple.com> wrote:
> The attached patch etches out a new code path for MS style inline assembly in the Parser, Sema, AST, and CodeGen.  This is _largely_ a WIP!
> The idea is to translate the MS style inline assembly into IR that is equivalent to the GNU style inline assembly.  That way the backend doesn't need to be modified (nor does our assembler implementation).  I was hoping to make further progress on this today, so please take a look if you have a quick second.

You'll need to extend LLVM IR and the backend slightly so that it can
perform MS-style operand interpolation ("8(%esp)" vs. "[esp+8]", for
example); otherwise, that seems feasible.

Various review comments:

Please don't use StringLiteral for any of the pieces of MS inline
assembly; they're not actually written as strings in the source, so
using it here is confusing.

+  /** \brief A MS inline assembly statement extension.
+   */
+  CXCursor_MSAsmStmt                     = 216,
   /** \brief Objective-C's overall @try- at catch-@finally statement.
-  CXCursor_ObjCAtTryStmt                 = 216,
+  CXCursor_ObjCAtTryStmt                 = 217,

Please don't renumber the CXCursor enum; just add an entry at the end.

In MSAsmStmt, does it actually make sense to talk in terms of "input
operands" and "output operands"?  For GNU-style inline asm, the
distinction makes sense because there are actually two separate lists
in the source code, but as far as I can tell the distinction isn't
useful here.

I think it's important to figure out a design for how we keep track of
source locations though the AST and IRGen before you get too much
further because rewriting your data structures later on will be a

Instead of comments like "FIXME: MS style inline asm still a WIP",
please use something more specific, like "serialization for MS-style
inline asm not yet implemented".


More information about the cfe-commits mailing list