[CIR][NFC] Rename AtomicFence to AtomicFenceOp (#171248)

This fixes missed suffix `Op` of `CIR_AtomicFence` defination and also
improves API `makeAtomicFenceValue`.
This commit is contained in:
Haocong Lu 2025-12-11 01:30:55 +08:00 committed by GitHub
parent 0ab6a63c4f
commit 6cacbdbc38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 16 deletions

View File

@ -5568,7 +5568,7 @@ def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
}];
}
def CIR_AtomicFence : CIR_Op<"atomic.fence"> {
def CIR_AtomicFenceOp : CIR_Op<"atomic.fence"> {
let summary = "Atomic thread fence";
let description = [{
C/C++ Atomic thread fence synchronization primitive. Implements the builtin

View File

@ -60,9 +60,8 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
return RValue::get(result);
}
static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
const CallExpr *expr,
cir::SyncScopeKind syncScope) {
static void emitAtomicFenceOp(CIRGenFunction &cgf, const CallExpr *expr,
cir::SyncScopeKind syncScope) {
CIRGenBuilderTy &builder = cgf.getBuilder();
mlir::Value orderingVal = cgf.emitScalarExpr(expr->getArg(0));
@ -72,7 +71,7 @@ static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
// TODO(cir): Emit code to switch on `orderingVal`,
// and creating the fence op for valid values.
cgf.cgm.errorNYI("Variable atomic fence ordering");
return {};
return;
}
auto constOrderingAttr = constOrdering.getValueAttr<cir::IntAttr>();
@ -80,11 +79,9 @@ static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
auto ordering = static_cast<cir::MemOrder>(constOrderingAttr.getUInt());
cir::AtomicFence::create(
cir::AtomicFenceOp::create(
builder, cgf.getLoc(expr->getSourceRange()), ordering,
cir::SyncScopeKindAttr::get(&cgf.getMLIRContext(), syncScope));
return {};
}
namespace {
@ -1010,12 +1007,14 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
case Builtin::BI__atomic_test_and_set:
case Builtin::BI__atomic_clear:
return errorBuiltinNYI(*this, e, builtinID);
case Builtin::BI__atomic_thread_fence:
return RValue::get(
makeAtomicFenceValue(*this, e, cir::SyncScopeKind::System));
case Builtin::BI__atomic_signal_fence:
return RValue::get(
makeAtomicFenceValue(*this, e, cir::SyncScopeKind::SingleThread));
case Builtin::BI__atomic_thread_fence: {
emitAtomicFenceOp(*this, e, cir::SyncScopeKind::System);
return RValue::get(nullptr);
}
case Builtin::BI__atomic_signal_fence: {
emitAtomicFenceOp(*this, e, cir::SyncScopeKind::SingleThread);
return RValue::get(nullptr);
}
case Builtin::BI__c11_atomic_thread_fence:
case Builtin::BI__c11_atomic_signal_fence:
case Builtin::BI__scoped_atomic_thread_fence:

View File

@ -868,8 +868,8 @@ mlir::LogicalResult CIRToLLVMAtomicClearOpLowering::matchAndRewrite(
return mlir::success();
}
mlir::LogicalResult CIRToLLVMAtomicFenceLowering::matchAndRewrite(
cir::AtomicFence op, OpAdaptor adaptor,
mlir::LogicalResult CIRToLLVMAtomicFenceOpLowering::matchAndRewrite(
cir::AtomicFenceOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
mlir::LLVM::AtomicOrdering llvmOrder = getLLVMMemOrder(adaptor.getOrdering());