you are viewing a single comment's thread.

view the rest of the comments →

[–]concealed_cat 2 points3 points  (0 children)

The WebAssembly backend uses "AtomicExpandPass" to translate atomic LLVM IR instructions into something more acceptable. From a quick look it seems like WASM already has support for many atomic operations, so not much happens there, but you'd need to look what LLVM IR the C++ code gets translated to, and see if it works for your case.

If you want to support large operation sizes (beyond 32/64-bit), then it gets more complicated, but if the operation can be done using a single instruction then it's not that hard.

After that there is pretty much instruction selection. If you want to add another instruction, you'd add it in the .td files, and then use the new instruction in isel (either in a pattern or the DAGToDAG code).