-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[OpenACC][CIR][NFC] Remove 'NYI' diagnostics, since we're done with t… #169543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…hese We've finished all of the clauses/etc that we're going to use this visitor for, so we can remove the SourceLocation we used just for that, and replace all NYI with unreachables.
|
@llvm/pr-subscribers-clangir Author: Erich Keane (erichkeane) Changes…hese We've finished all of the clauses/etc that we're going to use this visitor for, so we can remove the SourceLocation we used just for that, and replace all NYI with unreachables. Patch is 22.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/169543.diff 5 Files Affected:
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<OpenACCDeclareCleanup>(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 <typename Op>
Op emitOpenACCOp(mlir::Location start, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc,
llvm::ArrayRef<const OpenACCClause *> clauses);
// Function to do the basic implementation of an operation with an Associated
// Statement. Models AssociatedStmtConstruct.
template <typename Op, typename TermOp>
- mlir::LogicalResult emitOpenACCOpAssociatedStmt(
- mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *associatedStmt);
+ mlir::LogicalResult
+ emitOpenACCOpAssociatedStmt(mlir::Location start, mlir::Location end,
+ OpenACCDirectiveKind dirKind,
+ llvm::ArrayRef<const OpenACCClause *> clauses,
+ const Stmt *associatedStmt);
template <typename Op, typename TermOp>
mlir::LogicalResult emitOpenACCOpCombinedConstruct(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *loopStmt);
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *loopStmt);
template <typename Op>
void emitOpenACCClauses(Op &op, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc,
ArrayRef<const OpenACCClause *> 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 <typename ComputeOp, typename LoopOp>
void emitOpenACCClauses(ComputeOp &op, LoopOp &loopOp,
- OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ OpenACCDirectiveKind dirKind,
ArrayRef<const OpenACCClause *> 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<mlir::acc::DeviceType> 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<mlir::Operation *> 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<mlir::acc::LoopOp> 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<typename OpTy::ComputeOpTy> 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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>(op, recipeInsertLocation, cgf, builder,
- dirKind, dirLoc);
+ dirKind);
}
} // namespace
template <typename Op>
void CIRGenFunction::emitOpenACCClauses(
- Op &op, OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ Op &op, OpenACCDirectiveKind dirKind,
ArrayRef<const OpenACCClause *> 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>( \
- N &, OpenACCDirectiveKind, SourceLocation, \
- ArrayRef<const OpenACCClause *>);
+ N &, OpenACCDirectiveKind, ArrayRef<const OpenACCClause *>);
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 <typename ComputeOp, typename LoopOp>
void CIRGenFunction::emitOpenACCClauses(
ComputeOp &op, LoopOp &loopOp, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, ArrayRef<const OpenACCClause *> clauses) {
+ ArrayRef<const OpenACCClause *> clauses) {
static_assert(std::is_same_v<mlir::acc::LoopOp, LoopOp>);
CombinedConstructClauseInfo<ComputeOp> 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>( \
- N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, SourceLocation, \
+ N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, \
ArrayRef<const OpenACCClause *>);
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 <typename Op, typename TermOp>
mlir::LogicalResult CIRGenFunction::emitOpenACCOpAssociatedStmt(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *associatedStmt) {
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *associatedStmt) {
mlir::LogicalResult res = mlir::success();
llvm::SmallVector<mlir::Type> retTy;
llvm::SmallVector<mlir::Value> 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<KernelsOp> {
template <typename Op, typename TermOp>
mlir::LogicalResult CIRGenFunction::emitOpenACCOpCombinedConstruct(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *loopStmt) {
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *loopStmt) {
mlir::LogicalResult res = mlir::success();
llvm::SmallVector<mlir::Type> 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 <typename Op>
Op CIRGenFunction::emitOpenACCOp(
- mlir::Location start, OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ mlir::Location start, OpenACCDirectiveKind dirKind,
llvm::ArrayRef<const OpenACCClause *> clauses) {
llvm::SmallVector<mlir::Type> retTy;
llvm::SmallVector<mlir::Value> 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<ParallelOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getStructuredBlock());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock());
case OpenACCDirectiveKind::Serial:
return emitOpenACCOpAssociatedStmt<SerialOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getStructuredBlock());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock());
case OpenACCDirectiveKind::Kernels:
return emitOpenACCOpAssociatedStmt<KernelsOp, mlir::acc::TerminatorOp>(
- 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<DataOp, mlir::acc::TerminatorOp>(
- 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<InitOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<InitOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult
CIRGenFunction::emitOpenACCSetConstruct(const OpenACCSetConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<SetOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<SetOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult CIRGenFunction::emitOpenACCShutdownConstruct(
const OpenACCShutdownConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<ShutdownOp>(start, s.getDirectiveKind(),
- s.getDirectiveLoc(), s.clauses());
+ emitOpenACCOp<ShutdownOp>(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<WaitOp>(start, s.getDirectiveKind(),
- s.getDirectiveLoc(), s.clauses());
+ auto waitOp = emitOpenACCOp<WaitOp>(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<ParallelOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getLoop());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getLoop());
case OpenACCDirectiveKind::SerialLoop:
return emitOpenACCOpCombinedConstruct<SerialOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getLoop());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getLoop());
case OpenACCDirectiveKind::KernelsLoop:
return emitOpenACCOpCombinedConstruct<KernelsOp, mlir::acc::TerminatorOp>(
- 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<HostDataOp, mlir::acc::TerminatorOp>(
- 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<EnterDataOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<EnterDataOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult CIRGenFunction::emitOpenACCExitDataConstruct(
const OpenACCExitDataConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<ExitDataOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<ExitDataOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult
CIRGenFunction::emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &s) {
mlir::Location ...
[truncated]
|
|
@llvm/pr-subscribers-clang Author: Erich Keane (erichkeane) Changes…hese We've finished all of the clauses/etc that we're going to use this visitor for, so we can remove the SourceLocation we used just for that, and replace all NYI with unreachables. Patch is 22.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/169543.diff 5 Files Affected:
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<OpenACCDeclareCleanup>(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 <typename Op>
Op emitOpenACCOp(mlir::Location start, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc,
llvm::ArrayRef<const OpenACCClause *> clauses);
// Function to do the basic implementation of an operation with an Associated
// Statement. Models AssociatedStmtConstruct.
template <typename Op, typename TermOp>
- mlir::LogicalResult emitOpenACCOpAssociatedStmt(
- mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *associatedStmt);
+ mlir::LogicalResult
+ emitOpenACCOpAssociatedStmt(mlir::Location start, mlir::Location end,
+ OpenACCDirectiveKind dirKind,
+ llvm::ArrayRef<const OpenACCClause *> clauses,
+ const Stmt *associatedStmt);
template <typename Op, typename TermOp>
mlir::LogicalResult emitOpenACCOpCombinedConstruct(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *loopStmt);
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *loopStmt);
template <typename Op>
void emitOpenACCClauses(Op &op, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc,
ArrayRef<const OpenACCClause *> 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 <typename ComputeOp, typename LoopOp>
void emitOpenACCClauses(ComputeOp &op, LoopOp &loopOp,
- OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ OpenACCDirectiveKind dirKind,
ArrayRef<const OpenACCClause *> 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<mlir::acc::DeviceType> 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<mlir::Operation *> 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<mlir::acc::LoopOp> 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<typename OpTy::ComputeOpTy> 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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>) {
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<OpTy>(op, recipeInsertLocation, cgf, builder,
- dirKind, dirLoc);
+ dirKind);
}
} // namespace
template <typename Op>
void CIRGenFunction::emitOpenACCClauses(
- Op &op, OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ Op &op, OpenACCDirectiveKind dirKind,
ArrayRef<const OpenACCClause *> 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>( \
- N &, OpenACCDirectiveKind, SourceLocation, \
- ArrayRef<const OpenACCClause *>);
+ N &, OpenACCDirectiveKind, ArrayRef<const OpenACCClause *>);
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 <typename ComputeOp, typename LoopOp>
void CIRGenFunction::emitOpenACCClauses(
ComputeOp &op, LoopOp &loopOp, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, ArrayRef<const OpenACCClause *> clauses) {
+ ArrayRef<const OpenACCClause *> clauses) {
static_assert(std::is_same_v<mlir::acc::LoopOp, LoopOp>);
CombinedConstructClauseInfo<ComputeOp> 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>( \
- N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, SourceLocation, \
+ N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, \
ArrayRef<const OpenACCClause *>);
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 <typename Op, typename TermOp>
mlir::LogicalResult CIRGenFunction::emitOpenACCOpAssociatedStmt(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *associatedStmt) {
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *associatedStmt) {
mlir::LogicalResult res = mlir::success();
llvm::SmallVector<mlir::Type> retTy;
llvm::SmallVector<mlir::Value> 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<KernelsOp> {
template <typename Op, typename TermOp>
mlir::LogicalResult CIRGenFunction::emitOpenACCOpCombinedConstruct(
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
- SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
- const Stmt *loopStmt) {
+ llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *loopStmt) {
mlir::LogicalResult res = mlir::success();
llvm::SmallVector<mlir::Type> 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 <typename Op>
Op CIRGenFunction::emitOpenACCOp(
- mlir::Location start, OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
+ mlir::Location start, OpenACCDirectiveKind dirKind,
llvm::ArrayRef<const OpenACCClause *> clauses) {
llvm::SmallVector<mlir::Type> retTy;
llvm::SmallVector<mlir::Value> 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<ParallelOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getStructuredBlock());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock());
case OpenACCDirectiveKind::Serial:
return emitOpenACCOpAssociatedStmt<SerialOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getStructuredBlock());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getStructuredBlock());
case OpenACCDirectiveKind::Kernels:
return emitOpenACCOpAssociatedStmt<KernelsOp, mlir::acc::TerminatorOp>(
- 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<DataOp, mlir::acc::TerminatorOp>(
- 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<InitOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<InitOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult
CIRGenFunction::emitOpenACCSetConstruct(const OpenACCSetConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<SetOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<SetOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult CIRGenFunction::emitOpenACCShutdownConstruct(
const OpenACCShutdownConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<ShutdownOp>(start, s.getDirectiveKind(),
- s.getDirectiveLoc(), s.clauses());
+ emitOpenACCOp<ShutdownOp>(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<WaitOp>(start, s.getDirectiveKind(),
- s.getDirectiveLoc(), s.clauses());
+ auto waitOp = emitOpenACCOp<WaitOp>(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<ParallelOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getLoop());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getLoop());
case OpenACCDirectiveKind::SerialLoop:
return emitOpenACCOpCombinedConstruct<SerialOp, mlir::acc::YieldOp>(
- start, end, s.getDirectiveKind(), s.getDirectiveLoc(), s.clauses(),
- s.getLoop());
+ start, end, s.getDirectiveKind(), s.clauses(), s.getLoop());
case OpenACCDirectiveKind::KernelsLoop:
return emitOpenACCOpCombinedConstruct<KernelsOp, mlir::acc::TerminatorOp>(
- 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<HostDataOp, mlir::acc::TerminatorOp>(
- 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<EnterDataOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<EnterDataOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult CIRGenFunction::emitOpenACCExitDataConstruct(
const OpenACCExitDataConstruct &s) {
mlir::Location start = getLoc(s.getSourceRange().getBegin());
- emitOpenACCOp<ExitDataOp>(start, s.getDirectiveKind(), s.getDirectiveLoc(),
- s.clauses());
+ emitOpenACCOp<ExitDataOp>(start, s.getDirectiveKind(), s.clauses());
return mlir::success();
}
mlir::LogicalResult
CIRGenFunction::emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &s) {
mlir::Location ...
[truncated]
|
…hese
We've finished all of the clauses/etc that we're going to use this visitor for, so we can remove the SourceLocation we used just for that, and replace all NYI with unreachables.