Skip to content

Commit dce95b2

Browse files
authored
[OpenACC][CIR][NFC] Remove 'NYI' diagnostics, since we're done with t… (#169543)
…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.
1 parent 6c8ff4f commit dce95b2

File tree

5 files changed

+55
-107
lines changed

5 files changed

+55
-107
lines changed

clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ void CIRGenFunction::emitOpenACCDeclare(const OpenACCDeclareDecl &d) {
112112
builder, exprLoc, mlir::acc::DeclareTokenType::get(&cgm.getMLIRContext()),
113113
{});
114114

115-
emitOpenACCClauses(enterOp, OpenACCDirectiveKind::Declare, d.getBeginLoc(),
116-
d.clauses());
115+
emitOpenACCClauses(enterOp, OpenACCDirectiveKind::Declare, d.clauses());
117116

118117
ehStack.pushCleanup<OpenACCDeclareCleanup>(CleanupKind::NormalCleanup,
119118
enterOp);

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,25 +1968,23 @@ class CIRGenFunction : public CIRGenTypeCache {
19681968
private:
19691969
template <typename Op>
19701970
Op emitOpenACCOp(mlir::Location start, OpenACCDirectiveKind dirKind,
1971-
SourceLocation dirLoc,
19721971
llvm::ArrayRef<const OpenACCClause *> clauses);
19731972
// Function to do the basic implementation of an operation with an Associated
19741973
// Statement. Models AssociatedStmtConstruct.
19751974
template <typename Op, typename TermOp>
1976-
mlir::LogicalResult emitOpenACCOpAssociatedStmt(
1977-
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
1978-
SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
1979-
const Stmt *associatedStmt);
1975+
mlir::LogicalResult
1976+
emitOpenACCOpAssociatedStmt(mlir::Location start, mlir::Location end,
1977+
OpenACCDirectiveKind dirKind,
1978+
llvm::ArrayRef<const OpenACCClause *> clauses,
1979+
const Stmt *associatedStmt);
19801980

19811981
template <typename Op, typename TermOp>
19821982
mlir::LogicalResult emitOpenACCOpCombinedConstruct(
19831983
mlir::Location start, mlir::Location end, OpenACCDirectiveKind dirKind,
1984-
SourceLocation dirLoc, llvm::ArrayRef<const OpenACCClause *> clauses,
1985-
const Stmt *loopStmt);
1984+
llvm::ArrayRef<const OpenACCClause *> clauses, const Stmt *loopStmt);
19861985

19871986
template <typename Op>
19881987
void emitOpenACCClauses(Op &op, OpenACCDirectiveKind dirKind,
1989-
SourceLocation dirLoc,
19901988
ArrayRef<const OpenACCClause *> clauses);
19911989
// The second template argument doesn't need to be a template, since it should
19921990
// always be an mlir::acc::LoopOp, but as this is a template anyway, we make
@@ -1996,7 +1994,7 @@ class CIRGenFunction : public CIRGenTypeCache {
19961994
// instantiated 3x.
19971995
template <typename ComputeOp, typename LoopOp>
19981996
void emitOpenACCClauses(ComputeOp &op, LoopOp &loopOp,
1999-
OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
1997+
OpenACCDirectiveKind dirKind,
20001998
ArrayRef<const OpenACCClause *> clauses);
20011999

20022000
// The OpenACC LoopOp requires that we have auto, seq, or independent on all

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ class OpenACCClauseCIREmitter final
6161
// This is necessary since a few of the clauses emit differently based on the
6262
// directive kind they are attached to.
6363
OpenACCDirectiveKind dirKind;
64-
// TODO(cir): This source location should be able to go away once the NYI
65-
// diagnostics are gone.
66-
SourceLocation dirLoc;
6764

6865
llvm::SmallVector<mlir::acc::DeviceType> lastDeviceTypeValues;
6966
// Keep track of the async-clause so that we can shortcut updating the data
@@ -72,10 +69,6 @@ class OpenACCClauseCIREmitter final
7269
// Keep track of the data operands so that we can update their async clauses.
7370
llvm::SmallVector<mlir::Operation *> dataOperands;
7471

75-
void clauseNotImplemented(const OpenACCClause &c) {
76-
cgf.cgm.errorNYI(c.getSourceRange(), "OpenACC Clause", c.getClauseKind());
77-
}
78-
7972
void setLastDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
8073
lastDeviceTypeValues.clear();
8174

@@ -150,7 +143,7 @@ class OpenACCClauseCIREmitter final
150143
mlir::OpBuilder::InsertionGuard guardCase(builder);
151144
builder.setInsertionPoint(operation.loopOp);
152145
OpenACCClauseCIREmitter<mlir::acc::LoopOp> loopEmitter{
153-
operation.loopOp, recipeInsertLocation, cgf, builder, dirKind, dirLoc};
146+
operation.loopOp, recipeInsertLocation, cgf, builder, dirKind};
154147
loopEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
155148
loopEmitter.Visit(&c);
156149
}
@@ -161,12 +154,7 @@ class OpenACCClauseCIREmitter final
161154
mlir::OpBuilder::InsertionGuard guardCase(builder);
162155
builder.setInsertionPoint(operation.computeOp);
163156
OpenACCClauseCIREmitter<typename OpTy::ComputeOpTy> computeEmitter{
164-
operation.computeOp,
165-
recipeInsertLocation,
166-
cgf,
167-
builder,
168-
dirKind,
169-
dirLoc};
157+
operation.computeOp, recipeInsertLocation, cgf, builder, dirKind};
170158

171159
computeEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
172160

@@ -342,12 +330,12 @@ class OpenACCClauseCIREmitter final
342330
mlir::OpBuilder::InsertPoint &recipeInsertLocation,
343331
CIRGen::CIRGenFunction &cgf,
344332
CIRGen::CIRGenBuilderTy &builder,
345-
OpenACCDirectiveKind dirKind, SourceLocation dirLoc)
333+
OpenACCDirectiveKind dirKind)
346334
: operation(operation), recipeInsertLocation(recipeInsertLocation),
347-
cgf(cgf), builder(builder), dirKind(dirKind), dirLoc(dirLoc) {}
335+
cgf(cgf), builder(builder), dirKind(dirKind) {}
348336

349337
void VisitClause(const OpenACCClause &clause) {
350-
clauseNotImplemented(clause);
338+
llvm_unreachable("Unknown/unhandled clause kind");
351339
}
352340

353341
// The entry point for the CIR emitter. All users should use this rather than
@@ -406,9 +394,7 @@ class OpenACCClauseCIREmitter final
406394
// Nothing to do here either, combined constructs are just going to use
407395
// 'lastDeviceTypeValues' to set the value for the child visitor.
408396
} else {
409-
// TODO: When we've implemented this for everything, switch this to an
410-
// unreachable. routine construct remains.
411-
return clauseNotImplemented(clause);
397+
llvm_unreachable("Unknown construct kind in VisitDeviceTypeClause");
412398
}
413399
}
414400

@@ -472,9 +458,7 @@ class OpenACCClauseCIREmitter final
472458
} else if constexpr (isCombinedType<OpTy>) {
473459
applyToComputeOp(clause);
474460
} else {
475-
// TODO: When we've implemented this for everything, switch this to an
476-
// unreachable. Combined constructs remain. update construct remains.
477-
return clauseNotImplemented(clause);
461+
llvm_unreachable("Unknown construct kind in VisitAsyncClause");
478462
}
479463
}
480464

@@ -601,7 +585,7 @@ class OpenACCClauseCIREmitter final
601585
} else {
602586
// TODO: When we've implemented this for everything, switch this to an
603587
// unreachable. update construct remains.
604-
return clauseNotImplemented(clause);
588+
llvm_unreachable("Unknown construct kind in VisitWaitClause");
605589
}
606590
}
607591

@@ -620,9 +604,7 @@ class OpenACCClauseCIREmitter final
620604
} else if constexpr (isCombinedType<OpTy>) {
621605
applyToLoopOp(clause);
622606
} else {
623-
// TODO: When we've implemented this for everything, switch this to an
624-
// unreachable. Routine construct remains.
625-
return clauseNotImplemented(clause);
607+
llvm_unreachable("Unknown construct kind in VisitSeqClause");
626608
}
627609
}
628610

@@ -632,9 +614,7 @@ class OpenACCClauseCIREmitter final
632614
} else if constexpr (isCombinedType<OpTy>) {
633615
applyToLoopOp(clause);
634616
} else {
635-
// TODO: When we've implemented this for everything, switch this to an
636-
// unreachable. Routine, construct remains.
637-
return clauseNotImplemented(clause);
617+
llvm_unreachable("Unknown construct kind in VisitAutoClause");
638618
}
639619
}
640620

@@ -644,9 +624,7 @@ class OpenACCClauseCIREmitter final
644624
} else if constexpr (isCombinedType<OpTy>) {
645625
applyToLoopOp(clause);
646626
} else {
647-
// TODO: When we've implemented this for everything, switch this to an
648-
// unreachable. Routine construct remains.
649-
return clauseNotImplemented(clause);
627+
llvm_unreachable("Unknown construct kind in VisitIndependentClause");
650628
}
651629
}
652630

@@ -706,9 +684,7 @@ class OpenACCClauseCIREmitter final
706684
} else if constexpr (isCombinedType<OpTy>) {
707685
applyToLoopOp(clause);
708686
} else {
709-
// TODO: When we've implemented this for everything, switch this to an
710-
// unreachable. Combined constructs remain.
711-
return clauseNotImplemented(clause);
687+
llvm_unreachable("Unknown construct kind in VisitWorkerClause");
712688
}
713689
}
714690

@@ -724,9 +700,7 @@ class OpenACCClauseCIREmitter final
724700
} else if constexpr (isCombinedType<OpTy>) {
725701
applyToLoopOp(clause);
726702
} else {
727-
// TODO: When we've implemented this for everything, switch this to an
728-
// unreachable. Combined constructs remain.
729-
return clauseNotImplemented(clause);
703+
llvm_unreachable("Unknown construct kind in VisitVectorClause");
730704
}
731705
}
732706

@@ -1128,29 +1102,28 @@ auto makeClauseEmitter(OpTy &op,
11281102
mlir::OpBuilder::InsertPoint &recipeInsertLocation,
11291103
CIRGen::CIRGenFunction &cgf,
11301104
CIRGen::CIRGenBuilderTy &builder,
1131-
OpenACCDirectiveKind dirKind, SourceLocation dirLoc) {
1105+
OpenACCDirectiveKind dirKind) {
11321106
return OpenACCClauseCIREmitter<OpTy>(op, recipeInsertLocation, cgf, builder,
1133-
dirKind, dirLoc);
1107+
dirKind);
11341108
}
11351109
} // namespace
11361110

11371111
template <typename Op>
11381112
void CIRGenFunction::emitOpenACCClauses(
1139-
Op &op, OpenACCDirectiveKind dirKind, SourceLocation dirLoc,
1113+
Op &op, OpenACCDirectiveKind dirKind,
11401114
ArrayRef<const OpenACCClause *> clauses) {
11411115
mlir::OpBuilder::InsertionGuard guardCase(builder);
11421116

11431117
// Sets insertion point before the 'op', since every new expression needs to
11441118
// be before the operation.
11451119
builder.setInsertionPoint(op);
1146-
makeClauseEmitter(op, lastRecipeLocation, *this, builder, dirKind, dirLoc)
1120+
makeClauseEmitter(op, lastRecipeLocation, *this, builder, dirKind)
11471121
.emitClauses(clauses);
11481122
}
11491123

11501124
#define EXPL_SPEC(N) \
11511125
template void CIRGenFunction::emitOpenACCClauses<N>( \
1152-
N &, OpenACCDirectiveKind, SourceLocation, \
1153-
ArrayRef<const OpenACCClause *>);
1126+
N &, OpenACCDirectiveKind, ArrayRef<const OpenACCClause *>);
11541127
EXPL_SPEC(mlir::acc::ParallelOp)
11551128
EXPL_SPEC(mlir::acc::SerialOp)
11561129
EXPL_SPEC(mlir::acc::KernelsOp)
@@ -1174,20 +1147,20 @@ EXPL_SPEC(mlir::acc::DeclareEnterOp)
11741147
template <typename ComputeOp, typename LoopOp>
11751148
void CIRGenFunction::emitOpenACCClauses(
11761149
ComputeOp &op, LoopOp &loopOp, OpenACCDirectiveKind dirKind,
1177-
SourceLocation dirLoc, ArrayRef<const OpenACCClause *> clauses) {
1150+
ArrayRef<const OpenACCClause *> clauses) {
11781151
static_assert(std::is_same_v<mlir::acc::LoopOp, LoopOp>);
11791152

11801153
CombinedConstructClauseInfo<ComputeOp> inf{op, loopOp};
11811154
// We cannot set the insertion point here and do so in the emitter, but make
11821155
// sure we reset it with the 'guard' anyway.
11831156
mlir::OpBuilder::InsertionGuard guardCase(builder);
1184-
makeClauseEmitter(inf, lastRecipeLocation, *this, builder, dirKind, dirLoc)
1157+
makeClauseEmitter(inf, lastRecipeLocation, *this, builder, dirKind)
11851158
.emitClauses(clauses);
11861159
}
11871160

11881161
#define EXPL_SPEC(N) \
11891162
template void CIRGenFunction::emitOpenACCClauses<N, mlir::acc::LoopOp>( \
1190-
N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, SourceLocation, \
1163+
N &, mlir::acc::LoopOp &, OpenACCDirectiveKind, \
11911164
ArrayRef<const OpenACCClause *>);
11921165

11931166
EXPL_SPEC(mlir::acc::ParallelOp)

0 commit comments

Comments
 (0)