[cfe-commits] [PATCH] Support for const type-qualifier for inline asm

Chad Rosier mcrosier at apple.com
Tue May 8 15:12:15 PDT 2012


The attached patches (one for clang and another for llvm) add support for the const type-qualifier for inline assembly.

The syntax is the same as when using the volatile keyword:

asm const("mov $0x0, %0" : "=r" (ptr));

Here is what the resulting IR looks like:
%0 = tail call i8* asm constant "mov $$0x12345678, $0", "=r,~{dirflag},~{fpsr},~{flags}"() nounwind readnone

Note that the constant keyword as been added as well as the call has been marked as readnone.  The former indicates the inline assembly has no effects except the return value.  The readnone attribute allows CSE to eliminate redundant inline assembly calls that have been marked const (see test cases).

The patch makes changes to the clang parser, llvm asm parser/writer, as well as the bitcode reader/writer (without breaking backward compatibility).

 Chad

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: clang-const-asm.txt
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120508/a68b7c71/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: llvm-const-asm.txt
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120508/a68b7c71/attachment-0001.txt>


More information about the cfe-commits mailing list