-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIR][CIRGen] Support for builtin __atomic_thread_fence
#1287
base: main
Are you sure you want to change the base?
Conversation
I have just created the ODS definition at the moment to be sure if this is the way to go. |
969faf7
to
c2cc1a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial step looks good, some inline comments. Note that this PR should come with CIRGen and LLVM lowering support, I suggest you first handle a very simple case of the fence and mark all paths not currently support with llvm_unrecheable("NYI")
, so that you can go about working in incremental PRs to complete this.
__atomic_thread_fence
__atomic_thread_fence
c2cc1a9
to
e8758ac
Compare
We just went over a rebase against upstream, apologies for the churn but please update your branch for this PR and force-push! |
Resolves llvm#1274 Implements atomic thread fence synchronization primitive corresponding to `atomic.thread_fence` CIR.
e8758ac
to
ca75a57
Compare
@@ -820,6 +821,16 @@ class CIRToLLVMAtomicFetchLowering | |||
mlir::ConversionPatternRewriter &) const override; | |||
}; | |||
|
|||
// class CIRToLLVMAtomicFenceLowering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good, time to add support for LLVM lowering as well, so we make sure the CIR operations contain all the info we need to lower to LLVM. You also need to add tests to this PR, see example in clang/test/CIR/CodeGen/abstract-cond.c
.
auto orderingAttr = | ||
orderingVal.getDefiningOp()->getAttrOfType<mlir::IntegerAttr>("value"); | ||
|
||
cir::MemOrder ordering; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably no need for the switch: the order of the enum is already the value you are checking for, so just cast it directly:
// Memory order according to C++11 memory model
enum class MemOrder : uint32_t {
Relaxed = 0,
Consume = 1,
Acquire = 2,
Release = 3,
AcquireRelease = 4,
SequentiallyConsistent = 5,
};
Fix #1274
Implements atomic thread fence synchronization primitive corresponding to
atomic.thread_fence
CIR.