aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/Dialect
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CIR/Dialect')
-rw-r--r--clang/lib/CIR/Dialect/IR/CIRDialect.cpp8
-rw-r--r--clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp4
-rw-r--r--clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp53
-rw-r--r--clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp41
-rw-r--r--clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp37
5 files changed, 72 insertions, 71 deletions
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index fa180f5..2d2ef42 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -95,8 +95,8 @@ Operation *cir::CIRDialect::materializeConstant(mlir::OpBuilder &builder,
mlir::Attribute value,
mlir::Type type,
mlir::Location loc) {
- return builder.create<cir::ConstantOp>(loc, type,
- mlir::cast<mlir::TypedAttr>(value));
+ return cir::ConstantOp::create(builder, loc, type,
+ mlir::cast<mlir::TypedAttr>(value));
}
//===----------------------------------------------------------------------===//
@@ -184,7 +184,7 @@ static LogicalResult ensureRegionTerm(OpAsmParser &parser, Region &region,
// Terminator was omitted correctly: recreate it.
builder.setInsertionPointToEnd(&block);
- builder.create<cir::YieldOp>(eLoc);
+ cir::YieldOp::create(builder, eLoc);
return success();
}
@@ -977,7 +977,7 @@ void cir::IfOp::print(OpAsmPrinter &p) {
/// Default callback for IfOp builders.
void cir::buildTerminatedBody(OpBuilder &builder, Location loc) {
// add cir.yield to end of the block
- builder.create<cir::YieldOp>(loc);
+ cir::YieldOp::create(builder, loc);
}
/// Given the region at `index`, or the parent operation if `index` is None,
diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
index 7e96ae9..66469e2 100644
--- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
@@ -34,8 +34,8 @@ llvm::SmallVector<MemorySlot> cir::AllocaOp::getPromotableSlots() {
Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot,
OpBuilder &builder) {
- return builder.create<cir::ConstantOp>(getLoc(),
- cir::UndefAttr::get(slot.elemType));
+ return cir::ConstantOp::create(builder, getLoc(),
+ cir::UndefAttr::get(slot.elemType));
}
void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot,
diff --git a/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp b/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
index 46bd186..21c96fe 100644
--- a/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
@@ -100,8 +100,8 @@ struct CIRIfFlattening : public mlir::OpRewritePattern<cir::IfOp> {
}
rewriter.setInsertionPointToEnd(currentBlock);
- rewriter.create<cir::BrCondOp>(loc, ifOp.getCondition(), thenBeforeBody,
- elseBeforeBody);
+ cir::BrCondOp::create(rewriter, loc, ifOp.getCondition(), thenBeforeBody,
+ elseBeforeBody);
if (!emptyElse) {
rewriter.setInsertionPointToEnd(elseAfterBody);
@@ -154,7 +154,7 @@ public:
// Save stack and then branch into the body of the region.
rewriter.setInsertionPointToEnd(currentBlock);
assert(!cir::MissingFeatures::stackSaveOp());
- rewriter.create<cir::BrOp>(loc, mlir::ValueRange(), beforeBody);
+ cir::BrOp::create(rewriter, loc, mlir::ValueRange(), beforeBody);
// Replace the scopeop return with a branch that jumps out of the body.
// Stack restore before leaving the body region.
@@ -195,26 +195,27 @@ public:
cir::IntType sIntType = cir::IntType::get(op.getContext(), 32, true);
cir::IntType uIntType = cir::IntType::get(op.getContext(), 32, false);
- cir::ConstantOp rangeLength = rewriter.create<cir::ConstantOp>(
- op.getLoc(), cir::IntAttr::get(sIntType, upperBound - lowerBound));
+ cir::ConstantOp rangeLength = cir::ConstantOp::create(
+ rewriter, op.getLoc(),
+ cir::IntAttr::get(sIntType, upperBound - lowerBound));
- cir::ConstantOp lowerBoundValue = rewriter.create<cir::ConstantOp>(
- op.getLoc(), cir::IntAttr::get(sIntType, lowerBound));
+ cir::ConstantOp lowerBoundValue = cir::ConstantOp::create(
+ rewriter, op.getLoc(), cir::IntAttr::get(sIntType, lowerBound));
cir::BinOp diffValue =
- rewriter.create<cir::BinOp>(op.getLoc(), sIntType, cir::BinOpKind::Sub,
- op.getCondition(), lowerBoundValue);
+ cir::BinOp::create(rewriter, op.getLoc(), sIntType, cir::BinOpKind::Sub,
+ op.getCondition(), lowerBoundValue);
// Use unsigned comparison to check if the condition is in the range.
- cir::CastOp uDiffValue = rewriter.create<cir::CastOp>(
- op.getLoc(), uIntType, CastKind::integral, diffValue);
- cir::CastOp uRangeLength = rewriter.create<cir::CastOp>(
- op.getLoc(), uIntType, CastKind::integral, rangeLength);
-
- cir::CmpOp cmpResult = rewriter.create<cir::CmpOp>(
- op.getLoc(), cir::BoolType::get(op.getContext()), cir::CmpOpKind::le,
- uDiffValue, uRangeLength);
- rewriter.create<cir::BrCondOp>(op.getLoc(), cmpResult, rangeDestination,
- defaultDestination);
+ cir::CastOp uDiffValue = cir::CastOp::create(
+ rewriter, op.getLoc(), uIntType, CastKind::integral, diffValue);
+ cir::CastOp uRangeLength = cir::CastOp::create(
+ rewriter, op.getLoc(), uIntType, CastKind::integral, rangeLength);
+
+ cir::CmpOp cmpResult = cir::CmpOp::create(
+ rewriter, op.getLoc(), cir::BoolType::get(op.getContext()),
+ cir::CmpOpKind::le, uDiffValue, uRangeLength);
+ cir::BrCondOp::create(rewriter, op.getLoc(), cmpResult, rangeDestination,
+ defaultDestination);
return resBlock;
}
@@ -262,7 +263,7 @@ public:
rewriteYieldOp(rewriter, switchYield, exitBlock);
rewriter.setInsertionPointToEnd(originalBlock);
- rewriter.create<cir::BrOp>(op.getLoc(), swopBlock);
+ cir::BrOp::create(rewriter, op.getLoc(), swopBlock);
}
// Allocate required data structures (disconsider default case in
@@ -331,8 +332,8 @@ public:
mlir::Block *newBlock =
rewriter.splitBlock(oldBlock, nextOp->getIterator());
rewriter.setInsertionPointToEnd(oldBlock);
- rewriter.create<cir::BrOp>(nextOp->getLoc(), mlir::ValueRange(),
- newBlock);
+ cir::BrOp::create(rewriter, nextOp->getLoc(), mlir::ValueRange(),
+ newBlock);
rewriteYieldOp(rewriter, yieldOp, newBlock);
}
}
@@ -346,7 +347,7 @@ public:
// Create a branch to the entry of the inlined region.
rewriter.setInsertionPointToEnd(oldBlock);
- rewriter.create<cir::BrOp>(caseOp.getLoc(), &entryBlock);
+ cir::BrOp::create(rewriter, caseOp.getLoc(), &entryBlock);
}
// Remove all cases since we've inlined the regions.
@@ -427,7 +428,7 @@ public:
// Setup loop entry branch.
rewriter.setInsertionPointToEnd(entry);
- rewriter.create<cir::BrOp>(op.getLoc(), &op.getEntry().front());
+ cir::BrOp::create(rewriter, op.getLoc(), &op.getEntry().front());
// Branch from condition region to body or exit.
auto conditionOp = cast<cir::ConditionOp>(cond->getTerminator());
@@ -499,7 +500,7 @@ public:
locs.push_back(loc);
Block *continueBlock =
rewriter.createBlock(remainingOpsBlock, op->getResultTypes(), locs);
- rewriter.create<cir::BrOp>(loc, remainingOpsBlock);
+ cir::BrOp::create(rewriter, loc, remainingOpsBlock);
Region &trueRegion = op.getTrueRegion();
Block *trueBlock = &trueRegion.front();
@@ -542,7 +543,7 @@ public:
rewriter.inlineRegionBefore(falseRegion, continueBlock);
rewriter.setInsertionPointToEnd(condBlock);
- rewriter.create<cir::BrCondOp>(loc, op.getCond(), trueBlock, falseBlock);
+ cir::BrCondOp::create(rewriter, loc, op.getCond(), trueBlock, falseBlock);
rewriter.replaceOp(op, continueBlock->getArguments());
diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
index d99c362..cba0464 100644
--- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
@@ -155,7 +155,7 @@ cir::FuncOp LoweringPreparePass::buildRuntimeFunction(
cir::FuncOp f = dyn_cast_or_null<FuncOp>(SymbolTable::lookupNearestSymbolFrom(
mlirModule, StringAttr::get(mlirModule->getContext(), name)));
if (!f) {
- f = builder.create<cir::FuncOp>(loc, name, type);
+ f = cir::FuncOp::create(builder, loc, name, type);
f.setLinkageAttr(
cir::GlobalLinkageKindAttr::get(builder.getContext(), linkage));
mlir::SymbolTable::setSymbolVisibility(
@@ -400,12 +400,12 @@ buildRangeReductionComplexDiv(CIRBaseBuilderTy &builder, mlir::Location loc,
builder.createYield(loc, result);
};
- auto cFabs = builder.create<cir::FAbsOp>(loc, c);
- auto dFabs = builder.create<cir::FAbsOp>(loc, d);
+ auto cFabs = cir::FAbsOp::create(builder, loc, c);
+ auto dFabs = cir::FAbsOp::create(builder, loc, d);
cir::CmpOp cmpResult =
builder.createCompare(loc, cir::CmpOpKind::ge, cFabs, dFabs);
- auto ternary = builder.create<cir::TernaryOp>(
- loc, cmpResult, trueBranchBuilder, falseBranchBuilder);
+ auto ternary = cir::TernaryOp::create(builder, loc, cmpResult,
+ trueBranchBuilder, falseBranchBuilder);
return ternary.getResult();
}
@@ -612,18 +612,17 @@ static mlir::Value lowerComplexMul(LoweringPreparePass &pass,
mlir::Value resultRealAndImagAreNaN =
builder.createLogicalAnd(loc, resultRealIsNaN, resultImagIsNaN);
- return builder
- .create<cir::TernaryOp>(
- loc, resultRealAndImagAreNaN,
- [&](mlir::OpBuilder &, mlir::Location) {
- mlir::Value libCallResult = buildComplexBinOpLibCall(
- pass, builder, &getComplexMulLibCallName, loc, complexTy,
- lhsReal, lhsImag, rhsReal, rhsImag);
- builder.createYield(loc, libCallResult);
- },
- [&](mlir::OpBuilder &, mlir::Location) {
- builder.createYield(loc, algebraicResult);
- })
+ return cir::TernaryOp::create(
+ builder, loc, resultRealAndImagAreNaN,
+ [&](mlir::OpBuilder &, mlir::Location) {
+ mlir::Value libCallResult = buildComplexBinOpLibCall(
+ pass, builder, &getComplexMulLibCallName, loc, complexTy,
+ lhsReal, lhsImag, rhsReal, rhsImag);
+ builder.createYield(loc, libCallResult);
+ },
+ [&](mlir::OpBuilder &, mlir::Location) {
+ builder.createYield(loc, algebraicResult);
+ })
.getResult();
}
@@ -920,15 +919,15 @@ static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder,
loc,
/*condBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
- auto currentElement = b.create<cir::LoadOp>(loc, eltTy, tmpAddr);
+ auto currentElement = cir::LoadOp::create(b, loc, eltTy, tmpAddr);
mlir::Type boolTy = cir::BoolType::get(b.getContext());
- auto cmp = builder.create<cir::CmpOp>(loc, boolTy, cir::CmpOpKind::ne,
- currentElement, stop);
+ auto cmp = cir::CmpOp::create(builder, loc, boolTy, cir::CmpOpKind::ne,
+ currentElement, stop);
builder.createCondition(cmp);
},
/*bodyBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
- auto currentElement = b.create<cir::LoadOp>(loc, eltTy, tmpAddr);
+ auto currentElement = cir::LoadOp::create(b, loc, eltTy, tmpAddr);
cir::CallOp ctorCall;
op->walk([&](cir::CallOp c) { ctorCall = c; });
diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp
index 11ce2a8..5a067f8 100644
--- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp
@@ -77,10 +77,11 @@ buildDynamicCastAfterNullCheck(cir::CIRBaseBuilderTy &builder,
if (op.isRefCast()) {
// Emit a cir.if that checks the casted value.
mlir::Value castedValueIsNull = builder.createPtrIsNull(castedPtr);
- builder.create<cir::IfOp>(
- loc, castedValueIsNull, false, [&](mlir::OpBuilder &, mlir::Location) {
- buildBadCastCall(builder, loc, castInfo.getBadCastFunc());
- });
+ cir::IfOp::create(builder, loc, castedValueIsNull, false,
+ [&](mlir::OpBuilder &, mlir::Location) {
+ buildBadCastCall(builder, loc,
+ castInfo.getBadCastFunc());
+ });
}
// Note that castedPtr is a void*. Cast it to a pointer to the destination
@@ -154,19 +155,19 @@ LoweringPrepareItaniumCXXABI::lowerDynamicCast(cir::CIRBaseBuilderTy &builder,
return buildDynamicCastAfterNullCheck(builder, op);
mlir::Value srcValueIsNotNull = builder.createPtrToBoolCast(srcValue);
- return builder
- .create<cir::TernaryOp>(
- loc, srcValueIsNotNull,
- [&](mlir::OpBuilder &, mlir::Location) {
- mlir::Value castedValue =
- op.isCastToVoid()
- ? buildDynamicCastToVoidAfterNullCheck(builder, astCtx, op)
- : buildDynamicCastAfterNullCheck(builder, op);
- builder.createYield(loc, castedValue);
- },
- [&](mlir::OpBuilder &, mlir::Location) {
- builder.createYield(
- loc, builder.getNullPtr(op.getType(), loc).getResult());
- })
+ return cir::TernaryOp::create(
+ builder, loc, srcValueIsNotNull,
+ [&](mlir::OpBuilder &, mlir::Location) {
+ mlir::Value castedValue =
+ op.isCastToVoid()
+ ? buildDynamicCastToVoidAfterNullCheck(builder, astCtx,
+ op)
+ : buildDynamicCastAfterNullCheck(builder, op);
+ builder.createYield(loc, castedValue);
+ },
+ [&](mlir::OpBuilder &, mlir::Location) {
+ builder.createYield(
+ loc, builder.getNullPtr(op.getType(), loc).getResult());
+ })
.getResult();
}