@@ -533,6 +533,15 @@ def CIR_MemOrder : CIR_I32EnumAttr<
533533 I32EnumAttrCase<"SequentiallyConsistent", 5, "seq_cst">
534534]>;
535535
536+ //===----------------------------------------------------------------------===//
537+ // C/C++ sync scope definitions
538+ //===----------------------------------------------------------------------===//
539+
540+ def CIR_MemScopeKind : CIR_I32EnumAttr<"MemScopeKind", "memory scope kind", [
541+ I32EnumAttrCase<"SingleThread", 0, "single_thread">,
542+ I32EnumAttrCase<"System", 1, "system">
543+ ]>;
544+
536545//===----------------------------------------------------------------------===//
537546// AllocaOp
538547//===----------------------------------------------------------------------===//
@@ -670,17 +679,19 @@ def CIR_LoadOp : CIR_Op<"load", [
670679 %4 = cir.load volatile %0 : !cir.ptr<i32>, i32
671680
672681 // Others
673- %x = cir.load align(16) atomic(seq_cst) %0 : !cir.ptr<i32>, i32
682+ %x = cir.load align(16) syncscope(single_thread) atomic(seq_cst)
683+ %0 : !cir.ptr<i32>, i32
674684 ```
675685 }];
676686
677687 let arguments = (ins Arg<CIR_PointerType, "the address to load from",
678688 [MemRead]>:$addr, UnitAttr:$isDeref,
679689 UnitAttr:$is_volatile,
680690 UnitAttr:$is_nontemporal,
681- OptionalAttr<I64Attr>:$alignment,
682- OptionalAttr<CIR_MemOrder>:$mem_order,
683- OptionalAttr<CIR_AnyTBAAAttr>:$tbaa
691+ OptionalAttr<I64Attr>:$alignment,
692+ OptionalAttr<CIR_MemScopeKind>:$syncscope,
693+ OptionalAttr<CIR_MemOrder>:$mem_order,
694+ OptionalAttr<CIR_AnyTBAAAttr>:$tbaa
684695 );
685696 let results = (outs CIR_AnyType:$result);
686697
@@ -689,6 +700,7 @@ def CIR_LoadOp : CIR_Op<"load", [
689700 (`volatile` $is_volatile^)?
690701 (`nontemporal` $is_nontemporal^)?
691702 (`align` `(` $alignment^ `)`)?
703+ (`syncscope` `(` $syncscope^ `)`)?
692704 (`atomic` `(` $mem_order^ `)`)?
693705 $addr `:` qualified(type($addr)) `,` type($result) attr-dict
694706 (`tbaa` `(` $tbaa^ `)`)?
@@ -698,7 +710,8 @@ def CIR_LoadOp : CIR_Op<"load", [
698710 // TODO(CIR): The final interface here should include an argument for the
699711 // SyncScope::ID.
700712 // This should be used over the ODS generated setMemOrder.
701- void setAtomic(cir::MemOrder order);
713+ void setAtomic(cir::MemOrder order,
714+ cir::MemScopeKind scope);
702715 }];
703716
704717 // FIXME: add verifier.
@@ -6012,11 +6025,6 @@ def CIR_AtomicXchg : CIR_Op<"atomic.xchg", [
60126025 let hasVerifier = 1;
60136026}
60146027
6015- def CIR_MemScopeKind : CIR_I32EnumAttr<"MemScopeKind", "memory scope kind", [
6016- I32EnumAttrCase<"SingleThread", 0, "single_thread">,
6017- I32EnumAttrCase<"System", 1, "system">
6018- ]>;
6019-
60206028def CIR_AtomicCmpXchg : CIR_Op<"atomic.cmp_xchg", [
60216029 AllTypesMatch<["old", "expected", "desired"]>
60226030]> {
0 commit comments