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
18 changes: 9 additions & 9 deletions clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mlir::Value CIRGenBuilderTy::maybeBuildArrayDecay(mlir::Location loc,
if (arrayTy) {
cir::PointerType flatPtrTy =
getPointerTo(arrayTy.getElementType(), arrayPtrTy.getAddrSpace());
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 @@ -37,15 +37,15 @@ mlir::Value CIRGenBuilderTy::promoteArrayIndex(const clang::TargetInfo &ti,

// If this is a boolean, zero-extend it to the array index type.
if (auto boolTy = mlir::dyn_cast<cir::BoolType>(index.getType()))
return create<cir::CastOp>(loc, arrayIndexType, cir::CastKind::bool_to_int,
index);
return cir::CastOp::create(*this, loc, arrayIndexType,
cir::CastKind::bool_to_int, index);

// If this an integer, ensure that it is at least as width as the array index
// type.
if (auto intTy = mlir::dyn_cast<cir::IntType>(index.getType())) {
if (intTy.getWidth() < arrayIndexWidth)
return create<cir::CastOp>(loc, arrayIndexType, cir::CastKind::integral,
index);
return cir::CastOp::create(*this, loc, arrayIndexType,
cir::CastKind::integral, index);
}

return index;
Expand All @@ -65,7 +65,7 @@ mlir::Value CIRGenBuilderTy::getArrayElement(const clang::TargetInfo &ti,
if (shouldDecay && arrayTy && arrayTy == eltTy) {
auto eltPtrTy =
getPointerTo(arrayTy.getElementType(), arrayPtrTy.getAddrSpace());
return create<cir::GetElementOp>(arrayLocEnd, eltPtrTy, arrayPtr,
return cir::GetElementOp::create(*this, arrayLocEnd, eltPtrTy, arrayPtr,
promoteArrayIndex(ti, arrayLocBegin, idx));
}

Expand All @@ -74,7 +74,7 @@ mlir::Value CIRGenBuilderTy::getArrayElement(const clang::TargetInfo &ti,
if (shouldDecay)
basePtr = maybeBuildArrayDecay(arrayLocBegin, arrayPtr, eltTy);
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 @@ -96,7 +96,7 @@ 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));
}

void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset(
Expand Down
7 changes: 1 addition & 6 deletions clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,14 +1637,9 @@ mlir::Value ScalarExprEmitter::emitSub(const BinOpInfo &Ops) {
divisor = vlaSize.NumElts;

CharUnits eltSize = CGF.getContext().getTypeSizeInChars(elementType);
if (!eltSize.isOne()) {
cir::IntType cirIntTy = llvm::cast<cir::IntType>(CGF.PtrDiffTy);
cir::IntAttr eltSizeAttr =
cir::IntAttr::get(cirIntTy, eltSize.getQuantity());

if (!eltSize.isOne())
if (divisor.getType() != CGF.PtrDiffTy)
divisor = Builder.createIntCast(divisor, CGF.PtrDiffTy);
}
} else {
// cir::ptrdiff correctly computes the ABI difference of 2 pointers. We
// do not need to compute anything else here. We just return it.
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CIR/CodeGen/CIRGenStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *S,
case Stmt::OMPUnrollDirectiveClass:
case Stmt::OMPForDirectiveClass:
case Stmt::OMPForSimdDirectiveClass:
case Stmt::OMPFuseDirectiveClass:
case Stmt::OMPSectionsDirectiveClass:
case Stmt::OMPSectionDirectiveClass:
case Stmt::OMPSingleDirectiveClass:
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,14 +1393,14 @@ std::optional<FuncOp> LoweringPreparePass::buildHIPModuleDtor() {
auto handlePtrTy = llvm::cast<cir::PointerType>(handle.getType());
mlir::Value nullPtr = builder.getNullPtr(handlePtrTy, loc);
auto isNull = builder.createCompare(loc, cir::CmpOpKind::ne, handle, nullPtr);
builder.create<cir::BrCondOp>(loc, isNull, ifBlock, exitBlock);
cir::BrCondOp::create(builder, loc, isNull, ifBlock, exitBlock);
{
// When handle is not null we need to unregister it and store null to handle
mlir::OpBuilder::InsertionGuard guard(builder);
builder.setInsertionPointToStart(ifBlock);
builder.createCallOp(loc, unregisterFunc, handle);
builder.createStore(loc, nullPtr, builder.createGetGlobal(gpuBinGlobal));
builder.create<cir::BrOp>(loc, exitBlock);
cir::BrOp::create(builder, loc, exitBlock);
}
{
// Exit block
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/CIR/FrontendAction/CIRGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
case CIRGenAction::OutputType::EmitBC:
case CIRGenAction::OutputType::EmitObj:
case CIRGenAction::OutputType::EmitAssembly: {
auto &CGOpts = CI.getCodeGenOpts();

llvm::LLVMContext LlvmCtx;
LlvmCtx.setDefaultTargetCPU(TargetOpts.CPU);
LlvmCtx.setDefaultTargetFeatures(llvm::join(TargetOpts.Features, ","));
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,6 @@ mlir::LogicalResult CIRToLLVMAllocaOpLowering::matchAndRewrite(
rewriter.getIntegerAttr(rewriter.getIndexType(), 1));
auto elementTy =
convertTypeForMemory(*getTypeConverter(), dataLayout, op.getAllocaType());
auto resultTy = getTypeConverter()->convertType(op.getType());
// Verification between the CIR alloca AS and the one from data layout.
auto allocaAS = [&]() {
auto dlAllocaASAttr = mlir::cast_if_present<mlir::IntegerAttr>(
Expand Down