Refactor AtomicExpand::expandAtomicRMWToCmpXchg into a standalone function.
authorJF Bastien <jfb@google.com>
Mon, 3 Aug 2015 15:29:47 +0000 (15:29 +0000)
committerJF Bastien <jfb@google.com>
Mon, 3 Aug 2015 15:29:47 +0000 (15:29 +0000)
commite8aad2998467f0a47ed39041056c62a936f93018
tree7c9276ca471b17e9408861ef88716b8c6ab6656d
parentfe17cee960edc2f7446097f61a7e4e677444aeb1
Refactor AtomicExpand::expandAtomicRMWToCmpXchg into a standalone function.

Summary:
This is useful for PNaCl's `RewriteAtomics` pass. NaCl intrinsics don't exist for some of the more exotic RMW instructions, so by refactoring this function into its own, `RewriteAtomics` can share code rewriting those atomics with `AtomicExpand` while additionally saving a few cycles by generating the `cmpxchg` NaCl-specific intrinsic with the callback. Without this patch, `RewriteAtomics` would require two extra passes over functions, by first requiring use of the full `AtomicExpand` pass to just expand the leftover exotic RMWs and then running itself again to expand resulting `cmpxchg`s.

NFC

Reviewers: jfb

Subscribers: jfb, llvm-commits

Differential Revision: http://reviews.llvm.org/D11422

llvm-svn: 243880
llvm/include/llvm/CodeGen/AtomicExpandUtils.h [new file with mode: 0644]
llvm/lib/CodeGen/AtomicExpandPass.cpp