Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ mlir::Value CIRGenBuilderTy::maybeBuildArrayDecay(mlir::Location loc,

if (arrayTy) {
const cir::PointerType flatPtrTy = getPointerTo(arrayTy.getElementType());
return create<cir::CastOp>(loc, flatPtrTy, cir::CastKind::array_to_ptrdecay,
arrayPtr);
return cir::CastOp::create(*this, loc, flatPtrTy,
cir::CastKind::array_to_ptrdecay, arrayPtr);
}

assert(arrayPtrTy.getPointee() == eltTy &&
Expand All @@ -40,7 +40,7 @@ mlir::Value CIRGenBuilderTy::getArrayElement(mlir::Location arrayLocBegin,
if (shouldDecay)
basePtr = maybeBuildArrayDecay(arrayLocBegin, arrayPtr, eltTy);
const mlir::Type flatPtrTy = basePtr.getType();
return create<cir::PtrStrideOp>(arrayLocEnd, flatPtrTy, basePtr, idx);
return cir::PtrStrideOp::create(*this, arrayLocEnd, flatPtrTy, basePtr, idx);
}

cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc,
Expand All @@ -60,14 +60,14 @@ cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc,
cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc, mlir::Type t,
uint64_t c) {
assert(mlir::isa<cir::IntType>(t) && "expected cir::IntType");
return create<cir::ConstantOp>(loc, cir::IntAttr::get(t, c));
return cir::ConstantOp::create(*this, loc, cir::IntAttr::get(t, c));
}

cir::ConstantOp
clang::CIRGen::CIRGenBuilderTy::getConstFP(mlir::Location loc, mlir::Type t,
llvm::APFloat fpVal) {
assert(mlir::isa<cir::FPTypeInterface>(t) && "expected floating point type");
return create<cir::ConstantOp>(loc, cir::FPAttr::get(t, fpVal));
return cir::ConstantOp::create(*this, loc, cir::FPAttr::get(t, fpVal));
}

void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset(
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
ImplicitParamDecl *vd = getThisDecl(cgf);
Address addr = cgf.getAddrOfLocalVar(vd);
return cgf.getBuilder().create<cir::LoadOp>(
cgf.getLoc(vd->getLocation()), addr.getElementType(), addr.getPointer());
return cir::LoadOp::create(cgf.getBuilder(), cgf.getLoc(vd->getLocation()),
addr.getElementType(), addr.getPointer());
}

void CIRGenCXXABI::setCXXABIThisValue(CIRGenFunction &cgf,
Expand Down
27 changes: 13 additions & 14 deletions clang/lib/CIR/CodeGen/CIRGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ static LValue emitFunctionDeclLValue(CIRGenFunction &cgf, const Expr *e,

mlir::Type fnTy = funcOp.getFunctionType();
mlir::Type ptrTy = cir::PointerType::get(fnTy);
mlir::Value addr = cgf.getBuilder().create<cir::GetGlobalOp>(
loc, ptrTy, funcOp.getSymName());
mlir::Value addr = cir::GetGlobalOp::create(cgf.getBuilder(), loc, ptrTy,
funcOp.getSymName());

if (funcOp.getFunctionType() != cgf.convertType(fd->getType())) {
fnTy = cgf.convertType(fd->getType());
Expand Down Expand Up @@ -2020,18 +2020,17 @@ mlir::Value CIRGenFunction::emitOpOnBoolExpr(mlir::Location loc,
mlir::Value condV = emitOpOnBoolExpr(loc, condOp->getCond());

mlir::Value ternaryOpRes =
builder
.create<cir::TernaryOp>(
loc, condV, /*thenBuilder=*/
[this, trueExpr](mlir::OpBuilder &b, mlir::Location loc) {
mlir::Value lhs = emitScalarExpr(trueExpr);
cir::YieldOp::create(b, loc, lhs);
},
/*elseBuilder=*/
[this, falseExpr](mlir::OpBuilder &b, mlir::Location loc) {
mlir::Value rhs = emitScalarExpr(falseExpr);
cir::YieldOp::create(b, loc, rhs);
})
cir::TernaryOp::create(
builder, loc, condV, /*thenBuilder=*/
[this, trueExpr](mlir::OpBuilder &b, mlir::Location loc) {
mlir::Value lhs = emitScalarExpr(trueExpr);
cir::YieldOp::create(b, loc, lhs);
},
/*elseBuilder=*/
[this, falseExpr](mlir::OpBuilder &b, mlir::Location loc) {
mlir::Value rhs = emitScalarExpr(falseExpr);
cir::YieldOp::create(b, loc, rhs);
})
.getResult();

return emitScalarConversion(ternaryOpRes, condOp->getType(),
Expand Down
33 changes: 16 additions & 17 deletions clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,23 +969,22 @@ mlir::Value ComplexExprEmitter::VisitAbstractConditionalOperator(
Expr *cond = e->getCond()->IgnoreParens();
mlir::Value condValue = cgf.evaluateExprAsBool(cond);

return builder
.create<cir::TernaryOp>(
loc, condValue,
/*thenBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
eval.beginEvaluation();
mlir::Value trueValue = Visit(e->getTrueExpr());
cir::YieldOp::create(b, loc, trueValue);
eval.endEvaluation();
},
/*elseBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
eval.beginEvaluation();
mlir::Value falseValue = Visit(e->getFalseExpr());
cir::YieldOp::create(b, loc, falseValue);
eval.endEvaluation();
})
return cir::TernaryOp::create(
builder, loc, condValue,
/*thenBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
eval.beginEvaluation();
mlir::Value trueValue = Visit(e->getTrueExpr());
cir::YieldOp::create(b, loc, trueValue);
eval.endEvaluation();
},
/*elseBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
eval.beginEvaluation();
mlir::Value falseValue = Visit(e->getFalseExpr());
cir::YieldOp::create(b, loc, falseValue);
eval.endEvaluation();
})
.getResult();
}

Expand Down
31 changes: 16 additions & 15 deletions clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,8 +1568,9 @@ static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
}

assert(!cir::MissingFeatures::sanitizers());
return cgf.getBuilder().create<cir::PtrStrideOp>(
cgf.getLoc(op.e->getExprLoc()), pointer.getType(), pointer, index);
return cir::PtrStrideOp::create(cgf.getBuilder(),
cgf.getLoc(op.e->getExprLoc()),
pointer.getType(), pointer, index);
}

mlir::Value ScalarExprEmitter::emitMul(const BinOpInfo &ops) {
Expand Down Expand Up @@ -2075,8 +2076,9 @@ mlir::Value ScalarExprEmitter::VisitInitListExpr(InitListExpr *e) {
vectorType.getSize() - numInitElements, zeroValue);
}

return cgf.getBuilder().create<cir::VecCreateOp>(
cgf.getLoc(e->getSourceRange()), vectorType, elements);
return cir::VecCreateOp::create(cgf.getBuilder(),
cgf.getLoc(e->getSourceRange()), vectorType,
elements);
}

// C++11 value-initialization for the scalar.
Expand Down Expand Up @@ -2364,17 +2366,16 @@ mlir::Value ScalarExprEmitter::VisitAbstractConditionalOperator(
}
};

mlir::Value result = builder
.create<cir::TernaryOp>(
loc, condV,
/*trueBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
emitBranch(b, loc, lhsExpr);
},
/*falseBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
emitBranch(b, loc, rhsExpr);
})
mlir::Value result = cir::TernaryOp::create(
builder, loc, condV,
/*trueBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
emitBranch(b, loc, lhsExpr);
},
/*falseBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
emitBranch(b, loc, rhsExpr);
})
.getResult();

if (!insertPoints.empty()) {
Expand Down
23 changes: 11 additions & 12 deletions clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
28 changes: 14 additions & 14 deletions clang/lib/CIR/Dialect/Transforms/LoweringPrepareItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,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();
}
Loading