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
2 changes: 1 addition & 1 deletion mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static void getTreePredicates(std::vector<PositionalPredicate> &predList,
.Case<OperandPosition, OperandGroupPosition>([&](auto *pos) {
getOperandTreePredicates(predList, val, builder, inputs, pos);
})
.Default([](auto *) { llvm_unreachable("unexpected position kind"); });
.DefaultUnreachable("unexpected position kind");
}

static void getAttributePredicates(pdl::AttributeOp op,
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ std::string getTypeMangling(Type ty, bool isUnsigned = false) {
llvm_unreachable("unhandled integer type");
}
})
.Default([](Type) -> std::string {
llvm_unreachable("unhandled type for mangling");
});
.DefaultUnreachable("unhandled type for mangling");
}

std::string mangle(StringRef baseName, ArrayRef<Type> types,
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class OuterProductFusion2Way
op2, op.getResultType(), lhs, rhs, lhsMask, rhsMask,
op1.getAcc());
})
.Default([&](auto) { llvm_unreachable("unexpected extend op!"); });
.DefaultUnreachable("unexpected extend op!");
} else if (kind == arm_sme::CombiningKind::Sub) {
TypeSwitch<Operation *>(extOp)
.Case<arith::ExtFOp>([&](auto) {
Expand All @@ -188,7 +188,7 @@ class OuterProductFusion2Way
op2, op.getResultType(), lhs, rhs, lhsMask, rhsMask,
op1.getAcc());
})
.Default([&](auto) { llvm_unreachable("unexpected extend op!"); });
.DefaultUnreachable("unexpected extend op!");
} else {
llvm_unreachable("unexpected arm_sme::CombiningKind!");
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void GPUDialect::printType(Type type, DialectAsmPrinter &os) const {
os << shape.back() << 'x' << fragTy.getElementType();
os << ", \"" << fragTy.getOperand() << "\"" << '>';
})
.Default([](Type) { llvm_unreachable("unexpected 'gpu' type kind"); });
.DefaultUnreachable("unexpected 'gpu' type kind");
}

static LogicalResult verifyKnownLaunchSizeAttr(Operation *op,
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,7 @@ getThreadIdBuilder(std::optional<TransformOpInterface> transformOp,
return GpuLaneIdBuilder(ctx, warpSize, useLinearMapping,
*maybeMaskingAttr);
})
.Default([&](DeviceMappingAttrInterface) -> GpuIdBuilder {
llvm_unreachable("unknown mapping attribute");
});
.DefaultUnreachable("unknown mapping attribute");
return DiagnosedSilenceableFailure::success();
}

Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,8 @@ static Value memsetGetStored(MemsetIntr op, const MemorySlot &slot,
Value intVal = buildMemsetValue(type.getWidth());
return LLVM::BitcastOp::create(builder, op.getLoc(), type, intVal);
})
.Default([](Type) -> Value {
llvm_unreachable(
"getStored should not be called on memset to unsupported type");
});
.DefaultUnreachable(
"getStored should not be called on memset to unsupported type");
}

template <class MemsetIntr>
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ static StringRef getTypeKeyword(Type type) {
.Case<LLVMStructType>([&](Type) { return "struct"; })
.Case<LLVMTargetExtType>([&](Type) { return "target"; })
.Case<LLVMX86AMXType>([&](Type) { return "x86_amx"; })
.Default([](Type) -> StringRef {
llvm_unreachable("unexpected 'llvm' type kind");
});
.DefaultUnreachable("unexpected 'llvm' type kind");
}

/// Prints a structure type. Keeps track of known struct names to handle self-
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void replaceIndexOpsByInductionVariables(RewriterBase &rewriter,
.Case([&](affine::AffineForOp affineForOp) {
allIvs.push_back(affineForOp.getInductionVar());
})
.Default([&](Operation *op) { assert(false && "unexpected op"); });
.DefaultUnreachable("unexpected op");
}
assert(linalgOp.getNumLoops() == allIvs.size() &&
"expected the number of loops and induction variables to match");
Expand Down
5 changes: 1 addition & 4 deletions mlir/lib/Dialect/Linalg/Transforms/NamedToElementwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ ElementwiseKind getKind(Operation *op) {
.Case([](SquareOp) { return ElementwiseKind::square; })
.Case([](TanhOp) { return ElementwiseKind::tanh; })
.Case([](ErfOp) { return ElementwiseKind::erf; })
.Default([&](Operation *op) {
llvm_unreachable("unhandled case in named to elementwise");
return ElementwiseKind::sub;
});
.DefaultUnreachable("unhandled case in named to elementwise");
}

template <typename NamedOpTy>
Expand Down
5 changes: 1 addition & 4 deletions mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,10 +1427,7 @@ FailureOr<Conv1DOp> DownscaleSizeOneWindowed2DConvolution<Conv2DOp, Conv1DOp>::
.Case([&](linalg::PoolingNchwMaxOp op) {
return std::make_tuple(0, 1, 2, 3);
})
.Default([&](Operation *op) {
llvm_unreachable("unexpected conv2d/pool2d operation.");
return std::make_tuple(0, 0, 0, 0);
});
.DefaultUnreachable("unexpected conv2d/pool2d operation.");

// Only handle the case where at least one of the window dimensions is
// of size 1. Other cases can rely on tiling to reduce to such cases.
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Dialect/Linalg/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,7 @@ static Operation *materializeTiledShape(OpBuilder &builder, Location loc,
builder, loc, valueToTile, sliceParams.offsets,
sliceParams.sizes, sliceParams.strides);
})
.Default([](ShapedType) -> Operation * {
llvm_unreachable("Unexpected shaped type");
});
.DefaultUnreachable("Unexpected shaped type");
return sliceOp;
}

Expand Down
12 changes: 6 additions & 6 deletions mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ LogicalResult LoadOpOfSubViewOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), subViewOp.getSource(), sourceIndices,
op.getTranspose(), op.getNumTiles());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down Expand Up @@ -367,7 +367,7 @@ LogicalResult LoadOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), expandShapeOp.getViewSource(), sourceIndices,
op.getMask(), op.getPassThru());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down Expand Up @@ -415,7 +415,7 @@ LogicalResult LoadOpOfCollapseShapeOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), collapseShapeOp.getViewSource(), sourceIndices,
op.getMask(), op.getPassThru());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down Expand Up @@ -482,7 +482,7 @@ LogicalResult StoreOpOfSubViewOpFolder<OpTy>::matchAndRewrite(
op, op.getSrc(), subViewOp.getSource(), sourceIndices,
op.getLeadDimension(), op.getTransposeAttr());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down Expand Up @@ -535,7 +535,7 @@ LogicalResult StoreOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite(
op, expandShapeOp.getViewSource(), sourceIndices, op.getMask(),
op.getValueToStore());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down Expand Up @@ -584,7 +584,7 @@ LogicalResult StoreOpOfCollapseShapeOpFolder<OpTy>::matchAndRewrite(
op, collapseShapeOp.getViewSource(), sourceIndices, op.getMask(),
op.getValueToStore());
})
.Default([](Operation *) { llvm_unreachable("unexpected operation."); });
.DefaultUnreachable("unexpected operation");
return success();
}

Expand Down
5 changes: 1 addition & 4 deletions mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3425,10 +3425,7 @@ void NewCliOp::getAsmResultNames(OpAsmSetValueNameFn setNameFn) {
}
llvm_unreachable("Unexpected generatee argument");
})
.Default([&](Operation *op) {
assert(false && "TODO: Custom name for this operation");
return "transformed";
});
.DefaultUnreachable("TODO: Custom name for this operation");
}

setNameFn(result, cliName);
Expand Down
7 changes: 3 additions & 4 deletions mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2177,10 +2177,9 @@ cloneAsInsertSlices(RewriterBase &rewriter,
auto clonedOp = cloneAsInsertSlice(rewriter, op);
clonedSlices.push_back(clonedOp);
})
.Default([&](Operation *op) {
// Assert here assuming this has already been checked.
assert(0 && "unexpected slice type while cloning as insert slice");
});
// Assert here assuming this has already been checked.
.DefaultUnreachable(
"unexpected slice type while cloning as insert slice");
}
return clonedSlices;
}
Expand Down
10 changes: 2 additions & 8 deletions mlir/lib/Dialect/Transform/IR/TransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2597,10 +2597,7 @@ transform::NumAssociationsOp::apply(transform::TransformRewriter &rewriter,
.Case([&](TransformParamTypeInterface param) {
return llvm::range_size(state.getParams(getHandle()));
})
.Default([](Type) {
llvm_unreachable("unknown kind of transform dialect type");
return 0;
});
.DefaultUnreachable("unknown kind of transform dialect type");
results.setParams(cast<OpResult>(getNum()),
rewriter.getI64IntegerAttr(numAssociations));
return DiagnosedSilenceableFailure::success();
Expand Down Expand Up @@ -2657,10 +2654,7 @@ transform::SplitHandleOp::apply(transform::TransformRewriter &rewriter,
.Case<TransformParamTypeInterface>([&](auto x) {
return llvm::range_size(state.getParams(getHandle()));
})
.Default([](auto x) {
llvm_unreachable("unknown transform dialect type interface");
return -1;
});
.DefaultUnreachable("unknown transform dialect type interface");

auto produceNumOpsError = [&]() {
return emitSilenceableError()
Expand Down
5 changes: 1 addition & 4 deletions mlir/lib/Interfaces/DataLayoutInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,7 @@ static DataLayoutSpecInterface getSpec(Operation *operation) {
return llvm::TypeSwitch<Operation *, DataLayoutSpecInterface>(operation)
.Case<ModuleOp, DataLayoutOpInterface>(
[&](auto op) { return op.getDataLayoutSpec(); })
.Default([](Operation *) {
llvm_unreachable("expected an op with data layout spec");
return DataLayoutSpecInterface();
});
.DefaultUnreachable("expected an op with data layout spec");
}

static TargetSystemSpecInterface getTargetSystemSpec(Operation *operation) {
Expand Down
8 changes: 2 additions & 6 deletions mlir/lib/Rewrite/ByteCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,7 @@ void Generator::generate(Operation *op, ByteCodeWriter &writer) {
pdl_interp::SwitchOperandCountOp, pdl_interp::SwitchOperationNameOp,
pdl_interp::SwitchResultCountOp>(
[&](auto interpOp) { this->generate(interpOp, writer); })
.Default([](Operation *) {
llvm_unreachable("unknown `pdl_interp` operation");
});
.DefaultUnreachable("unknown `pdl_interp` operation");
}

void Generator::generate(pdl_interp::ApplyConstraintOp op,
Expand Down Expand Up @@ -913,9 +911,7 @@ void Generator::generate(pdl_interp::ExtractOp op, ByteCodeWriter &writer) {
.Case([](pdl::OperationType) { return OpCode::ExtractOp; })
.Case([](pdl::ValueType) { return OpCode::ExtractValue; })
.Case([](pdl::TypeType) { return OpCode::ExtractType; })
.Default([](Type) -> OpCode {
llvm_unreachable("unsupported element type");
});
.DefaultUnreachable("unsupported element type");
writer.append(opCode, op.getRange(), op.getIndex(), op.getResult());
}
void Generator::generate(pdl_interp::FinalizeOp op, ByteCodeWriter &writer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4716,10 +4716,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
info.HasNoWait = updateDataOp.getNowait();
return success();
})
.Default([&](Operation *op) {
llvm_unreachable("unexpected operation");
return failure();
});
.DefaultUnreachable("unexpected operation");

if (failed(result))
return failure();
Expand Down Expand Up @@ -5312,9 +5309,7 @@ extractHostEvalClauses(omp::TargetOp targetOp, Value &numThreads,
(void)found;
assert(found && "unsupported host_eval use");
})
.Default([](Operation *) {
llvm_unreachable("unsupported host_eval use");
});
.DefaultUnreachable("unsupported host_eval use");
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ class TypeToLLVMIRTranslatorImpl {
LLVM::LLVMPointerType, LLVM::LLVMStructType, VectorType,
LLVM::LLVMTargetExtType, PtrLikeTypeInterface>(
[this](auto type) { return this->translate(type); })
.Default([](Type t) -> llvm::Type * {
llvm_unreachable("unknown LLVM dialect type");
});
.DefaultUnreachable("unknown LLVM dialect type");

// Cache the result of the conversion and return.
knownTranslations.try_emplace(type, translated);
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void NodePrinter::print(Type type) {
})
.Case([&](TypeType) { os << "Type"; })
.Case([&](ValueType) { os << "Value"; })
.Default([](Type) { llvm_unreachable("unknown AST type"); });
.DefaultUnreachable("unknown AST type");
}

void NodePrinter::print(const Node *node) {
Expand Down Expand Up @@ -182,7 +182,7 @@ void NodePrinter::print(const Node *node) {
const VariableDecl,

const Module>([&](auto derivedNode) { this->printImpl(derivedNode); })
.Default([](const Node *) { llvm_unreachable("unknown AST node"); });
.DefaultUnreachable("unknown AST node");
elementIndentStack.pop_back();
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Tools/PDLL/AST/Nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class NodeVisitor {

const Module>(
[&](auto derivedNode) { this->visitImpl(derivedNode); })
.Default([](const Node *) { llvm_unreachable("unknown AST node"); });
.DefaultUnreachable("unknown AST node");
}

private:
Expand Down
5 changes: 1 addition & 4 deletions mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ static ParameterElement *getEncapsulatedParameterElement(FormatElement *el) {
.Case<ParameterElement>([&](auto param) { return param; })
.Case<RefDirective>(
[&](auto ref) { return cast<ParameterElement>(ref->getArg()); })
.Default([&](auto el) {
assert(false && "unexpected struct element type");
return nullptr;
});
.DefaultUnreachable("unexpected struct element type");
}

/// Shorthand functions that can be used with ranged-based conditions.
Expand Down