Skip to content

Commit f60335d

Browse files
authored
[CIR] Use free op create functions (NFC) (#1966)
The builder create methods are deprecated: https://mlir.llvm.org/deprecation/. See https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.
1 parent 375bfbf commit f60335d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1673
-1639
lines changed

clang/lib/CIR/CodeGen/CIRAsm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,9 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &S) {
620620
operands.push_back(InArgs);
621621
operands.push_back(InOutArgs);
622622

623-
auto IA = builder.create<cir::InlineAsmOp>(
624-
getLoc(S.getAsmLoc()), ResultType, operands, AsmString, Constraints,
625-
HasSideEffect, inferFlavor(CGM, S), mlir::ArrayAttr());
623+
auto IA = cir::InlineAsmOp::create(
624+
builder, getLoc(S.getAsmLoc()), ResultType, operands, AsmString,
625+
Constraints, HasSideEffect, inferFlavor(CGM, S), mlir::ArrayAttr());
626626

627627
if (false /*IsGCCAsmGoto*/) {
628628
assert(!cir::MissingFeatures::asmGoto());

clang/lib/CIR/CodeGen/CIRGenAtomic.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ static bool isCstWeak(mlir::Value weakVal, bool &val) {
378378
static void emitDefaultCase(CIRGenBuilderTy &builder, mlir::Location loc) {
379379
auto EmptyArrayAttr = builder.getArrayAttr({});
380380
mlir::OpBuilder::InsertPoint insertPoint;
381-
builder.create<cir::CaseOp>(loc, EmptyArrayAttr, cir::CaseOpKind::Default,
382-
insertPoint);
381+
cir::CaseOp::create(builder, loc, EmptyArrayAttr, cir::CaseOpKind::Default,
382+
insertPoint);
383383
builder.restoreInsertionPoint(insertPoint);
384384
}
385385

@@ -392,8 +392,8 @@ static void emitSingleMemOrderCase(CIRGenBuilderTy &builder, mlir::Location loc,
392392
cir::IntAttr::get(Type, static_cast<int>(Order))};
393393
auto OneAttribute = builder.getArrayAttr(OneOrder);
394394
mlir::OpBuilder::InsertPoint insertPoint;
395-
builder.create<cir::CaseOp>(loc, OneAttribute, cir::CaseOpKind::Equal,
396-
insertPoint);
395+
cir::CaseOp::create(builder, loc, OneAttribute, cir::CaseOpKind::Equal,
396+
insertPoint);
397397
builder.restoreInsertionPoint(insertPoint);
398398
}
399399

@@ -408,8 +408,8 @@ static void emitDoubleMemOrderCase(CIRGenBuilderTy &builder, mlir::Location loc,
408408
cir::IntAttr::get(Type, static_cast<int>(Order2))};
409409
auto TwoAttributes = builder.getArrayAttr(TwoOrders);
410410
mlir::OpBuilder::InsertPoint insertPoint;
411-
builder.create<cir::CaseOp>(loc, TwoAttributes, cir::CaseOpKind::Anyof,
412-
insertPoint);
411+
cir::CaseOp::create(builder, loc, TwoAttributes, cir::CaseOpKind::Anyof,
412+
insertPoint);
413413
builder.restoreInsertionPoint(insertPoint);
414414
}
415415

@@ -424,18 +424,18 @@ static void emitAtomicCmpXchg(CIRGenFunction &CGF, AtomicExpr *E, bool IsWeak,
424424
auto Expected = builder.createLoad(loc, Val1);
425425
auto Desired = builder.createLoad(loc, Val2);
426426
auto boolTy = builder.getBoolTy();
427-
auto cmpxchg = builder.create<cir::AtomicCmpXchg>(
428-
loc, Expected.getType(), boolTy, Ptr.getPointer(), Expected, Desired,
429-
cir::MemOrderAttr::get(&CGF.getMLIRContext(), SuccessOrder),
427+
auto cmpxchg = cir::AtomicCmpXchg::create(
428+
builder, loc, Expected.getType(), boolTy, Ptr.getPointer(), Expected,
429+
Desired, cir::MemOrderAttr::get(&CGF.getMLIRContext(), SuccessOrder),
430430
cir::MemOrderAttr::get(&CGF.getMLIRContext(), FailureOrder),
431431
cir::MemScopeKindAttr::get(&CGF.getMLIRContext(), Scope),
432432
builder.getI64IntegerAttr(Ptr.getAlignment().getAsAlign().value()));
433433
cmpxchg.setIsVolatile(E->isVolatile());
434434
cmpxchg.setWeak(IsWeak);
435435

436436
auto cmp = builder.createNot(cmpxchg.getCmp());
437-
builder.create<cir::IfOp>(
438-
loc, cmp, false, [&](mlir::OpBuilder &, mlir::Location) {
437+
cir::IfOp::create(
438+
builder, loc, cmp, false, [&](mlir::OpBuilder &, mlir::Location) {
439439
auto ptrTy = mlir::cast<cir::PointerType>(Val1.getPointer().getType());
440440
if (Val1.getElementType() != ptrTy.getPointee()) {
441441
Val1 = Val1.withPointer(builder.createPtrBitcast(
@@ -496,8 +496,8 @@ static void emitAtomicCmpXchgFailureSet(
496496
// can't handle a runtime value; all memory orders must be hard coded.
497497
// Generate a "switch" statement that converts the runtime value into a
498498
// compile-time value.
499-
CGF.getBuilder().create<cir::SwitchOp>(
500-
FailureOrderVal.getLoc(), FailureOrderVal,
499+
cir::SwitchOp::create(
500+
CGF.getBuilder(), FailureOrderVal.getLoc(), FailureOrderVal,
501501
[&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
502502
auto &builder = CGF.getBuilder();
503503

@@ -1268,8 +1268,8 @@ RValue CIRGenFunction::emitAtomicExpr(AtomicExpr *E) {
12681268
// can't handle runtime memory orders; the memory order must be hard coded.
12691269
// Generate a "switch" statement that converts a runtime value into a
12701270
// compile-time value.
1271-
builder.create<cir::SwitchOp>(
1272-
Order.getLoc(), Order,
1271+
cir::SwitchOp::create(
1272+
builder, Order.getLoc(), Order,
12731273
[&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
12741274
mlir::Block *switchBlock = builder.getBlock();
12751275

0 commit comments

Comments
 (0)