Skip to content

Commit 969faf7

Browse files
committed
[CIRGen] Task 1: Support for builtin __atomic_thread_fence
Part of #1274 Implements atomic thread fence synchronization primitive corresponding to `atomic.thread_fence` CIR.
1 parent 0ae5000 commit 969faf7

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

+44
Original file line numberDiff line numberDiff line change
@@ -5403,6 +5403,50 @@ def AtomicCmpXchg : CIR_Op<"atomic.cmp_xchg",
54035403
let hasVerifier = 0;
54045404
}
54055405

5406+
def MemScopeEnum : EnumAttr<"Memory scope enumeration"> {
5407+
let underlying_type = "uint32_t";
5408+
let enumerants = [
5409+
Enumerant<"single_thread", "Applies to the calling thread only", 0>
5410+
Enumerant<"system", "Spans the entire system", 1>
5411+
];
5412+
}
5413+
5414+
def AtomicOrderingEnum : EnumAttr<"Atomic memory ordering enumeration"> {
5415+
let underlying_type = "uint32_t";
5416+
let enumerants = [
5417+
Enumerant<"relaxed", "No ordering constraints", 0>,
5418+
Enumerant<"acquire", "All subsequent memory operations occur after this fence", 1>,
5419+
Enumerant<"release", "All prior memory operations occur before this fence", 2>,
5420+
Enumerant<"acq_rel", "Combines acquire and release semantics", 3>,
5421+
Enumerant<"seq_cst", "Enforces sequential consistency", 4>
5422+
];
5423+
};
5424+
5425+
def AtomicFenceOp : CIR_Op<"atomic.thread_fence"> {
5426+
let summary = "Atomic thread fence";
5427+
let description = [{
5428+
C/C++ Atomic thread fence synchronization primitive. Implements the builtin
5429+
`__atomic_thread_fence` which enforces memory ordering constraints across
5430+
threads within the specified synchronization scope.
5431+
5432+
Example:
5433+
5434+
5435+
}];
5436+
let results = (outs);
5437+
let arguments = (ins Attr<EnumAttr<["single_thread", "system"]>,
5438+
"synchronization scope":$sync_scope,
5439+
Attr<EnumAttr<["relaxed", "acquire", "release", "acq_rel", "seq_cst"]>,
5440+
"atomic memory ordering":$ordering);
5441+
5442+
let assemblyFormat = [{
5443+
`(` `sync_scope` `=` $sync_scope `,`
5444+
`ordering` `=` $ordering `)` attr-dict
5445+
}];
5446+
5447+
let hasVerifier = 1;
5448+
}
5449+
54065450
def SignBitOp : CIR_Op<"signbit", [Pure]> {
54075451
let summary = "Checks the sign of a floating-point number";
54085452
let description = [{

0 commit comments

Comments
 (0)