diff --git a/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp b/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp index 405c1aad2f159..d52986db49ea6 100644 --- a/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp @@ -112,8 +112,7 @@ void CIRGenFunction::emitOpenACCDeclare(const OpenACCDeclareDecl &d) { builder, exprLoc, mlir::acc::DeclareTokenType::get(&cgm.getMLIRContext()), {}); - emitOpenACCClauses(enterOp, OpenACCDirectiveKind::Declare, d.getBeginLoc(), - d.clauses()); + emitOpenACCClauses(enterOp, OpenACCDirectiveKind::Declare, d.clauses()); ehStack.pushCleanup(CleanupKind::NormalCleanup, enterOp); diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h b/clang/lib/CIR/CodeGen/CIRGenFunction.h index a3a7b4a207a81..57363d851e0e0 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h @@ -1968,25 +1968,23 @@ class CIRGenFunction : public CIRGenTypeCache { private: template Op emitOpenACCOp(mlir::Location start, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, llvm::ArrayRef clauses); // Function to do the basic implementation of an operation with an Associated // Statement. Models AssociatedStmtConstruct. template - mlir::LogicalResult emitOpenACCOpAssociatedStmt( - mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, llvm::ArrayRef clauses, - const Stmt *associatedStmt); + mlir::LogicalResult + emitOpenACCOpAssociatedStmt(mlir::Location start, mlir::Location end, + OpenACCDirectiveKind dirKind, + llvm::ArrayRef clauses, + const Stmt *associatedStmt); template mlir::LogicalResult emitOpenACCOpCombinedConstruct( mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, llvm::ArrayRef clauses, - const Stmt *loopStmt); + llvm::ArrayRef clauses, const Stmt *loopStmt); template void emitOpenACCClauses(Op &op, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, ArrayRef clauses); // The second template argument doesn't need to be a template, since it should // always be an mlir::acc::LoopOp, but as this is a template anyway, we make @@ -1996,7 +1994,7 @@ class CIRGenFunction : public CIRGenTypeCache { // instantiated 3x. template void emitOpenACCClauses(ComputeOp &op, LoopOp &loopOp, - OpenACCDirectiveKind dirKind, SourceLocation dirLoc, + OpenACCDirectiveKind dirKind, ArrayRef clauses); // The OpenACC LoopOp requires that we have auto, seq, or independent on all diff --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp index 25ba6b0369bce..2d4ed23a46d1c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp @@ -61,9 +61,6 @@ class OpenACCClauseCIREmitter final // This is necessary since a few of the clauses emit differently based on the // directive kind they are attached to. OpenACCDirectiveKind dirKind; - // TODO(cir): This source location should be able to go away once the NYI - // diagnostics are gone. - SourceLocation dirLoc; llvm::SmallVector lastDeviceTypeValues; // Keep track of the async-clause so that we can shortcut updating the data @@ -72,10 +69,6 @@ class OpenACCClauseCIREmitter final // Keep track of the data operands so that we can update their async clauses. llvm::SmallVector dataOperands; - void clauseNotImplemented(const OpenACCClause &c) { - cgf.cgm.errorNYI(c.getSourceRange(), "OpenACC Clause", c.getClauseKind()); - } - void setLastDeviceTypeClause(const OpenACCDeviceTypeClause &clause) { lastDeviceTypeValues.clear(); @@ -150,7 +143,7 @@ class OpenACCClauseCIREmitter final mlir::OpBuilder::InsertionGuard guardCase(builder); builder.setInsertionPoint(operation.loopOp); OpenACCClauseCIREmitter loopEmitter{ - operation.loopOp, recipeInsertLocation, cgf, builder, dirKind, dirLoc}; + operation.loopOp, recipeInsertLocation, cgf, builder, dirKind}; loopEmitter.lastDeviceTypeValues = lastDeviceTypeValues; loopEmitter.Visit(&c); } @@ -161,12 +154,7 @@ class OpenACCClauseCIREmitter final mlir::OpBuilder::InsertionGuard guardCase(builder); builder.setInsertionPoint(operation.computeOp); OpenACCClauseCIREmitter computeEmitter{ - operation.computeOp, - recipeInsertLocation, - cgf, - builder, - dirKind, - dirLoc}; + operation.computeOp, recipeInsertLocation, cgf, builder, dirKind}; computeEmitter.lastDeviceTypeValues = lastDeviceTypeValues; @@ -342,12 +330,12 @@ class OpenACCClauseCIREmitter final mlir::OpBuilder::InsertPoint &recipeInsertLocation, CIRGen::CIRGenFunction &cgf, CIRGen::CIRGenBuilderTy &builder, - OpenACCDirectiveKind dirKind, SourceLocation dirLoc) + OpenACCDirectiveKind dirKind) : operation(operation), recipeInsertLocation(recipeInsertLocation), - cgf(cgf), builder(builder), dirKind(dirKind), dirLoc(dirLoc) {} + cgf(cgf), builder(builder), dirKind(dirKind) {} void VisitClause(const OpenACCClause &clause) { - clauseNotImplemented(clause); + llvm_unreachable("Unknown/unhandled clause kind"); } // The entry point for the CIR emitter. All users should use this rather than @@ -406,9 +394,7 @@ class OpenACCClauseCIREmitter final // Nothing to do here either, combined constructs are just going to use // 'lastDeviceTypeValues' to set the value for the child visitor. } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. routine construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitDeviceTypeClause"); } } @@ -472,9 +458,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToComputeOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Combined constructs remain. update construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitAsyncClause"); } } @@ -601,7 +585,7 @@ class OpenACCClauseCIREmitter final } else { // TODO: When we've implemented this for everything, switch this to an // unreachable. update construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitWaitClause"); } } @@ -620,9 +604,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToLoopOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Routine construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitSeqClause"); } } @@ -632,9 +614,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToLoopOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Routine, construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitAutoClause"); } } @@ -644,9 +624,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToLoopOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Routine construct remains. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitIndependentClause"); } } @@ -706,9 +684,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToLoopOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Combined constructs remain. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitWorkerClause"); } } @@ -724,9 +700,7 @@ class OpenACCClauseCIREmitter final } else if constexpr (isCombinedType) { applyToLoopOp(clause); } else { - // TODO: When we've implemented this for everything, switch this to an - // unreachable. Combined constructs remain. - return clauseNotImplemented(clause); + llvm_unreachable("Unknown construct kind in VisitVectorClause"); } } @@ -1128,29 +1102,28 @@ auto makeClauseEmitter(OpTy &op, mlir::OpBuilder::InsertPoint &recipeInsertLocation, CIRGen::CIRGenFunction &cgf, CIRGen::CIRGenBuilderTy &builder, - OpenACCDirectiveKind dirKind, SourceLocation dirLoc) { + OpenACCDirectiveKind dirKind) { return OpenACCClauseCIREmitter(op, recipeInsertLocation, cgf, builder, - dirKind, dirLoc); + dirKind); } } // namespace template void CIRGenFunction::emitOpenACCClauses( - Op &op, OpenACCDirectiveKind dirKind, SourceLocation dirLoc, + Op &op, OpenACCDirectiveKind dirKind, ArrayRef clauses) { mlir::OpBuilder::InsertionGuard guardCase(builder); // Sets insertion point before the 'op', since every new expression needs to // be before the operation. builder.setInsertionPoint(op); - makeClauseEmitter(op, lastRecipeLocation, *this, builder, dirKind, dirLoc) + makeClauseEmitter(op, lastRecipeLocation, *this, builder, dirKind) .emitClauses(clauses); } #define EXPL_SPEC(N) \ template void CIRGenFunction::emitOpenACCClauses( \ - N &, OpenACCDirectiveKind, SourceLocation, \ - ArrayRef); + N &, OpenACCDirectiveKind, ArrayRef); EXPL_SPEC(mlir::acc::ParallelOp) EXPL_SPEC(mlir::acc::SerialOp) EXPL_SPEC(mlir::acc::KernelsOp) @@ -1174,20 +1147,20 @@ EXPL_SPEC(mlir::acc::DeclareEnterOp) template void CIRGenFunction::emitOpenACCClauses( ComputeOp &op, LoopOp &loopOp, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, ArrayRef clauses) { + ArrayRef clauses) { static_assert(std::is_same_v); CombinedConstructClauseInfo inf{op, loopOp}; // We cannot set the insertion point here and do so in the emitter, but make // sure we reset it with the 'guard' anyway. mlir::OpBuilder::InsertionGuard guardCase(builder); - makeClauseEmitter(inf, lastRecipeLocation, *this, builder, dirKind, dirLoc) + makeClauseEmitter(inf, lastRecipeLocation, *this, builder, dirKind) .emitClauses(clauses); } #define EXPL_SPEC(N) \ template void CIRGenFunction::emitOpenACCClauses( \ - N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, SourceLocation, \ + N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, \ ArrayRef); EXPL_SPEC(mlir::acc::ParallelOp) diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp index 80de920c075e7..11aad17187fbc 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp @@ -24,15 +24,14 @@ using namespace mlir::acc; template mlir::LogicalResult CIRGenFunction::emitOpenACCOpAssociatedStmt( mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, llvm::ArrayRef clauses, - const Stmt *associatedStmt) { + llvm::ArrayRef clauses, const Stmt *associatedStmt) { mlir::LogicalResult res = mlir::success(); llvm::SmallVector retTy; llvm::SmallVector operands; auto op = Op::create(builder, start, retTy, operands); - emitOpenACCClauses(op, dirKind, dirLoc, clauses); + emitOpenACCClauses(op, dirKind, clauses); { mlir::Block &block = op.getRegion().emplaceBlock(); @@ -66,8 +65,7 @@ template <> struct CombinedType { template mlir::LogicalResult CIRGenFunction::emitOpenACCOpCombinedConstruct( mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind, - SourceLocation dirLoc, llvm::ArrayRef clauses, - const Stmt *loopStmt) { + llvm::ArrayRef clauses, const Stmt *loopStmt) { mlir::LogicalResult res = mlir::success(); llvm::SmallVector retTy; @@ -102,7 +100,7 @@ mlir::LogicalResult CIRGenFunction::emitOpenACCOpCombinedConstruct( mlir::acc::YieldOp::create(builder, end); } - emitOpenACCClauses(computeOp, loopOp, dirKind, dirLoc, clauses); + emitOpenACCClauses(computeOp, loopOp, dirKind, clauses); updateLoopOpParallelism(loopOp, /*isOrphan=*/false, dirKind); @@ -114,13 +112,13 @@ mlir::LogicalResult CIRGenFunction::emitOpenACCOpCombinedConstruct( template Op CIRGenFunction::emitOpenACCOp( - mlir::Location start, OpenACCDirectiveKind dirKind, SourceLocation dirLoc, + mlir::Location start, OpenACCDirectiveKind dirKind, llvm::ArrayRef clauses) { llvm::SmallVector retTy; llvm::SmallVector operands; auto op = Op::create(builder, start, retTy, operands); - emitOpenACCClauses(op, dirKind, dirLoc, clauses); + emitOpenACCClauses(op, dirKind, clauses); return op; } @@ -132,16 +130,13 @@ CIRGenFunction::emitOpenACCComputeConstruct(const OpenACCComputeConstruct &s) { switch (s.getDirectiveKind()) { case OpenACCDirectiveKind::Parallel: return emitOpenACCOpAssociatedStmt( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getStructuredBlock()); + start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock()); case OpenACCDirectiveKind::Serial: return emitOpenACCOpAssociatedStmt( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getStructuredBlock()); + start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock()); case OpenACCDirectiveKind::Kernels: return emitOpenACCOpAssociatedStmt( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getStructuredBlock()); + start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock()); default: llvm_unreachable("invalid compute construct kind"); } @@ -153,39 +148,34 @@ CIRGenFunction::emitOpenACCDataConstruct(const OpenACCDataConstruct &s) { mlir::Location end = getLoc(s.getSourceRange().getEnd()); return emitOpenACCOpAssociatedStmt( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getStructuredBlock()); + start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock()); } mlir::LogicalResult CIRGenFunction::emitOpenACCInitConstruct(const OpenACCInitConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOpenACCSetConstruct(const OpenACCSetConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOpenACCShutdownConstruct( const OpenACCShutdownConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), - s.getDirectiveLoc(), s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOpenACCWaitConstruct(const OpenACCWaitConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - auto waitOp = emitOpenACCOp(start, s.getDirectiveKind(), - s.getDirectiveLoc(), s.clauses()); + auto waitOp = emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); auto createIntExpr = [this](const Expr *intExpr) { mlir::Value expr = emitScalarExpr(intExpr); @@ -225,16 +215,13 @@ mlir::LogicalResult CIRGenFunction::emitOpenACCCombinedConstruct( switch (s.getDirectiveKind()) { case OpenACCDirectiveKind::ParallelLoop: return emitOpenACCOpCombinedConstruct( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getLoop()); + start, end, s.getDirectiveKind(), s.clauses(), s.getLoop()); case OpenACCDirectiveKind::SerialLoop: return emitOpenACCOpCombinedConstruct( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getLoop()); + start, end, s.getDirectiveKind(), s.clauses(), s.getLoop()); case OpenACCDirectiveKind::KernelsLoop: return emitOpenACCOpCombinedConstruct( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getLoop()); + start, end, s.getDirectiveKind(), s.clauses(), s.getLoop()); default: llvm_unreachable("invalid compute construct kind"); } @@ -246,31 +233,27 @@ mlir::LogicalResult CIRGenFunction::emitOpenACCHostDataConstruct( mlir::Location end = getLoc(s.getSourceRange().getEnd()); return emitOpenACCOpAssociatedStmt( - start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(), - s.getStructuredBlock()); + start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock()); } mlir::LogicalResult CIRGenFunction::emitOpenACCEnterDataConstruct( const OpenACCEnterDataConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOpenACCExitDataConstruct( const OpenACCExitDataConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } mlir::LogicalResult CIRGenFunction::emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &s) { mlir::Location start = getLoc(s.getSourceRange().getBegin()); - emitOpenACCOp(start, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCOp(start, s.getDirectiveKind(), s.clauses()); return mlir::success(); } @@ -400,23 +383,20 @@ CIRGenFunction::emitOpenACCAtomicConstruct(const OpenACCAtomicConstruct &s) { assert(inf.Form == OpenACCAtomicConstruct::StmtInfo::StmtForm::Read); mlir::acc::AtomicReadOp op = emitAtomicRead(*this, builder, start, inf.First); - emitOpenACCClauses(op, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCClauses(op, s.getDirectiveKind(), s.clauses()); return mlir::success(); } case OpenACCAtomicKind::Write: { assert(inf.Form == OpenACCAtomicConstruct::StmtInfo::StmtForm::Write); auto op = emitAtomicWrite(*this, builder, start, inf.First); - emitOpenACCClauses(op, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCClauses(op, s.getDirectiveKind(), s.clauses()); return mlir::success(); } case OpenACCAtomicKind::None: case OpenACCAtomicKind::Update: { assert(inf.Form == OpenACCAtomicConstruct::StmtInfo::StmtForm::Update); auto [res, op] = emitAtomicUpdate(*this, builder, start, end, inf.First); - emitOpenACCClauses(op, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCClauses(op, s.getDirectiveKind(), s.clauses()); return res; } case OpenACCAtomicKind::Capture: { @@ -424,8 +404,7 @@ CIRGenFunction::emitOpenACCAtomicConstruct(const OpenACCAtomicConstruct &s) { // read + update, or read + write. As a result, the IR represents the // capture region as having those two 'inside' of it. auto op = mlir::acc::AtomicCaptureOp::create(builder, start, /*ifCond=*/{}); - emitOpenACCClauses(op, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCClauses(op, s.getDirectiveKind(), s.clauses()); mlir::LogicalResult res = mlir::success(); { mlir::OpBuilder::InsertionGuard guardCase(builder); diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp index c5b89bd7b1fb6..406b1a5af4e92 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp @@ -117,8 +117,7 @@ CIRGenFunction::emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s) { // // Emit all clauses. - emitOpenACCClauses(op, s.getDirectiveKind(), s.getDirectiveLoc(), - s.clauses()); + emitOpenACCClauses(op, s.getDirectiveKind(), s.clauses()); updateLoopOpParallelism(op, s.isOrphanedLoopConstruct(), s.getParentComputeConstructKind());