[PATCH] D125350: [PoC][Clang] Add a check if the target supports atomicrmw instruction with specific operator and type

Shilei Tian via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 20:23:01 PDT 2022


tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: mattd, gchakrabarti, asavonic, jholewinski.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

With respect of `atomicrmw` instruction, different targets have different
backend support. The front end can always emit the intruction, but when it comes
to the backend, the compiler could crash at instruction selection because the
target doesn't support the instruction/operator at all. Currently we don't have
a way in the front end to tell if an `atomicrmw` with specific operator and type
is supported. This patch adds a virtual function `hasAtomicrmw` to the class
`TargetInfo` and it is expected to be implemented by all targets accordingly.
In this way, we can always try to emit `atomicrmw` first because it has better
performance than falling back to CAS loop. Currently at the PoC stage, I only make
it in NVPTX, but if the community is happy with this change, I'll add to all the
targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125350

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125350.428557.patch
Type: text/x-patch
Size: 3799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220511/b4e4154a/attachment.bin>


More information about the cfe-commits mailing list