inline Value getValue(unsigned pos) const {
assert(pos < getNumDimAndSymbolVars() && "Invalid position");
assert(hasValue(pos) && "variable's Value not set");
- return values[pos].value();
+ return *values[pos];
}
/// Returns true if the pos^th variable has an associated Value.
bool has_value() const { return impl.has_value(); }
/// Access the internal ParseResult value.
- ParseResult value() const { return impl.value(); }
+ ParseResult value() const { return *impl; }
ParseResult operator*() const { return value(); }
private:
[callback = std::forward<FnT>(callback)](
T type, SmallVectorImpl<Type> &results, ArrayRef<Type>) {
if (Optional<Type> resultOpt = callback(type)) {
- bool wasSuccess = static_cast<bool>(resultOpt.value());
+ bool wasSuccess = static_cast<bool>(*resultOpt);
if (wasSuccess)
- results.push_back(resultOpt.value());
+ results.push_back(*resultOpt);
return Optional<LogicalResult>(success(wasSuccess));
}
return Optional<LogicalResult>();
/// affine-expr ::= integer-literal
AffineExpr AffineParser::parseIntegerExpr() {
auto val = getToken().getUInt64IntegerValue();
- if (!val.has_value() || (int64_t)val.value() < 0)
+ if (!val.has_value() || (int64_t)*val < 0)
return emitError("constant too large for index"), nullptr;
consumeToken(Token::integer);
- return builder.getAffineConstantExpr((int64_t)val.value());
+ return builder.getAffineConstantExpr((int64_t)*val);
}
/// Parses an expression that can be a valid operand of an affine expression.
return emitError("expected integer column number in FileLineColLoc");
consumeToken(Token::integer);
- loc = FileLineColLoc::get(ctx, str, line.value(), column.value());
+ loc = FileLineColLoc::get(ctx, str, *line, *column);
return success();
}
<< "previously referenced here";
}
Location loc = entryArg.sourceLoc.has_value()
- ? entryArg.sourceLoc.value()
+ ? *entryArg.sourceLoc
: getEncodedSourceLocation(argInfo.location);
BlockArgument arg = block->addArgument(entryArg.type, loc);
auto width = getToken().getIntTypeBitwidth();
if (!width.has_value())
return (emitError("invalid integer width"), nullptr);
- if (width.value() > IntegerType::kMaxWidth) {
+ if (*width > IntegerType::kMaxWidth) {
emitError(getToken().getLoc(), "integer bitwidth is limited to ")
<< IntegerType::kMaxWidth << " bits";
return nullptr;
SmallVector<AffineMap, 2> affineMaps = {
rewriter.getMultiDimIdentityMap(resultTy.getRank())};
auto emptyTensor = b.create<tensor::EmptyOp>(resultTy.getShape(), resultETy,
- dynamicDimsOr.value());
+ *dynamicDimsOr);
auto genericOp = b.create<linalg::GenericOp>(
resultTy, ValueRange({}), ValueRange{emptyTensor}, affineMaps,
getNParallelLoopsAttrs(resultTy.getRank()));
if (!dynamicDimsOr.has_value())
return rewriter.notifyMatchFailure(
op, "tosa.gather currently only supports dynamic batch dimensions");
- SmallVector<Value> dynamicDims = dynamicDimsOr.value();
+ SmallVector<Value> dynamicDims = *dynamicDimsOr;
auto resultElementTy = resultTy.getElementType();
checkHasDynamicBatchDims(rewriter, op, {input, op.getOutput()});
if (!dynamicDimsOr.has_value())
return failure();
- SmallVector<Value> dynamicDims = dynamicDimsOr.value();
+ SmallVector<Value> dynamicDims = *dynamicDimsOr;
// Determine what the initial value needs to be for the max pool op.
Attribute initialAttr;
checkHasDynamicBatchDims(rewriter, op, {input, op.getOutput()});
if (!dynamicDimsOr.has_value())
return failure();
- SmallVector<Value> dynamicDims = dynamicDimsOr.value();
+ SmallVector<Value> dynamicDims = *dynamicDimsOr;
// Apply padding as necessary.
llvm::SmallVector<int64_t> pad;
if (!isBroadcast) {
AffineExpr d0, d1;
bindDims(xferOp.getContext(), d0, d1);
- Value offset = adaptor.getIndices()[dim.value()];
- indices[dim.value()] =
- makeComposedAffineApply(b, loc, d0 + d1, {offset, iv});
+ Value offset = adaptor.getIndices()[*dim];
+ indices[*dim] = makeComposedAffineApply(b, loc, d0 + d1, {offset, iv});
}
}
Optional<uint32_t> idxVal = getConstantUint32(idx);
if (!idxVal)
return false;
- indexVal += stride * idxVal.value();
+ indexVal += stride * *idxVal;
}
result += indexVal;
if (result > std::numeric_limits<uint32_t>::max())
auto ubConst = getConstantBound64(BoundType::UB, pos);
if (lbConst.has_value() && ubConst.has_value()) {
// Detect equality to a constant.
- if (lbConst.value() == ubConst.value()) {
- memo[pos] = getAffineConstantExpr(lbConst.value(), context);
+ if (*lbConst == *ubConst) {
+ memo[pos] = getAffineConstantExpr(*lbConst, context);
changed = true;
continue;
}
// Detect an variable as modulo of another variable w.r.t a
// constant.
- if (detectAsMod(*this, pos, lbConst.value(), ubConst.value(), memo,
- context)) {
+ if (detectAsMod(*this, pos, *lbConst, *ubConst, memo, context)) {
changed = true;
continue;
}
<< "WARNING: Potentially over-approximating slice lb\n");
auto lbConst = getConstantBound64(BoundType::LB, pos + offset);
if (lbConst.has_value()) {
- lbMap =
- AffineMap::get(numMapDims, numMapSymbols,
- getAffineConstantExpr(lbConst.value(), context));
+ lbMap = AffineMap::get(numMapDims, numMapSymbols,
+ getAffineConstantExpr(*lbConst, context));
}
}
if (!ubMap || ubMap.getNumResults() > 1) {
if (ubConst.has_value()) {
ubMap = AffineMap::get(
numMapDims, numMapSymbols,
- getAffineConstantExpr(ubConst.value() + ubAdjustment, context));
+ getAffineConstantExpr(*ubConst + ubAdjustment, context));
}
}
}
// Add and match domain of `rel` to domain of `this`.
for (unsigned i = 0, e = rel.getNumDomainDims(); i < e; ++i)
if (relMaybeValues[i].has_value())
- setValue(i, relMaybeValues[i].value());
+ setValue(i, *relMaybeValues[i]);
// Add and match range of `this` to range of `rel`.
for (unsigned i = 0, e = getNumRangeDims(); i < e; ++i) {
unsigned rangeIdx = rel.getNumDomainDims() + i;
if (thisMaybeValues[rangeIdx].has_value())
- rel.setValue(rangeIdx, thisMaybeValues[rangeIdx].value());
+ rel.setValue(rangeIdx, *thisMaybeValues[rangeIdx]);
}
// Append `this` to `rel` and simplify constraints.
for (auto resultExpr : map.getResults()) {
if (auto constExpr = resultExpr.dyn_cast<AffineConstantExpr>()) {
if (tripCount.has_value())
- tripCount = std::min(tripCount.value(),
- static_cast<uint64_t>(constExpr.getValue()));
+ tripCount =
+ std::min(*tripCount, static_cast<uint64_t>(constExpr.getValue()));
else
tripCount = constExpr.getValue();
} else
}
Optional<uint64_t> maybeConstTripCount = getConstantTripCount(forOp);
if (maybeConstTripCount.has_value()) {
- (*tripCountMap)[op] = maybeConstTripCount.value();
+ (*tripCountMap)[op] = *maybeConstTripCount;
continue;
}
return false;
// Slice bounds are created with a constant ub - lb difference.
if (!tripCount.has_value())
return false;
- (*tripCountMap)[op] = tripCount.value();
+ (*tripCountMap)[op] = *tripCount;
}
return true;
}
Optional<int64_t> size = region.second->getRegionSize();
if (!size.has_value())
return std::nullopt;
- totalSizeInBytes += size.value();
+ totalSizeInBytes += *size;
}
return totalSizeInBytes;
}
getMemoryFootprintBytes(forOp,
/*memorySpace=*/0);
return (footprint.has_value() &&
- static_cast<uint64_t>(footprint.value()) >
- fastMemCapacityBytes);
+ static_cast<uint64_t>(*footprint) > fastMemCapacityBytes);
};
// If the memory footprint of the 'affine.for' loop is higher than fast
for (unsigned k = 0, e = depComps.size(); k < e; k++) {
DependenceComponent depComp = depComps[k];
if (depComp.lb.has_value() && depComp.ub.has_value() &&
- depComp.lb.value() < depComp.ub.value() &&
- depComp.ub.value() < 0) {
+ *depComp.lb < *depComp.ub && *depComp.ub < 0) {
LLVM_DEBUG(llvm::dbgs()
- << "Dependence component lb = "
- << Twine(depComp.lb.value())
- << " ub = " << Twine(depComp.ub.value())
+ << "Dependence component lb = " << Twine(*depComp.lb)
+ << " ub = " << Twine(*depComp.ub)
<< " is negative at depth: " << Twine(d)
<< " and thus violates the legality rule.\n");
return false;
newLoops[width + i].setStep(origLoops[i].getStep());
// Set the upper bound.
- if (mayBeConstantCount && mayBeConstantCount.value() < tileSizes[i]) {
+ if (mayBeConstantCount && *mayBeConstantCount < tileSizes[i]) {
// Trip count is less than the tile size: upper bound is lower bound +
// trip count * stepSize.
- AffineMap ubMap = b.getSingleDimShiftAffineMap(
- mayBeConstantCount.value() * origLoops[i].getStep());
+ AffineMap ubMap = b.getSingleDimShiftAffineMap(*mayBeConstantCount *
+ origLoops[i].getStep());
newLoops[width + i].setUpperBound(
/*operands=*/newLoops[i].getInductionVar(), ubMap);
} else if (largestDiv % tileSizes[i] != 0) {
LogicalResult mlir::loopUnrollFull(AffineForOp forOp) {
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
if (mayBeConstantTripCount.has_value()) {
- uint64_t tripCount = mayBeConstantTripCount.value();
+ uint64_t tripCount = *mayBeConstantTripCount;
if (tripCount == 0)
return success();
if (tripCount == 1)
uint64_t unrollFactor) {
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
if (mayBeConstantTripCount.has_value() &&
- mayBeConstantTripCount.value() < unrollFactor)
- return loopUnrollByFactor(forOp, mayBeConstantTripCount.value());
+ *mayBeConstantTripCount < unrollFactor)
+ return loopUnrollByFactor(forOp, *mayBeConstantTripCount);
return loopUnrollByFactor(forOp, unrollFactor);
}
uint64_t unrollJamFactor) {
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
if (mayBeConstantTripCount.has_value() &&
- mayBeConstantTripCount.value() < unrollJamFactor)
- return loopUnrollJamByFactor(forOp, mayBeConstantTripCount.value());
+ *mayBeConstantTripCount < unrollJamFactor)
+ return loopUnrollJamByFactor(forOp, *mayBeConstantTripCount);
return loopUnrollJamByFactor(forOp, unrollJamFactor);
}
for (unsigned j = 0; j < maxLoopDepth; ++j) {
DependenceComponent &depComp = depComps[j];
assert(depComp.lb.has_value() && depComp.ub.has_value());
- if (depComp.lb.value() != 0 || depComp.ub.value() != 0)
+ if (*depComp.lb != 0 || *depComp.ub != 0)
isParallelLoop[j] = false;
}
}
// always bounded. However, when we have symbols, we may not be able to
// obtain a constant upper bound. Also, mapping to a negative space is
// invalid for normalization.
- if (!ubConst.has_value() || ubConst.value() < 0) {
+ if (!ubConst.has_value() || *ubConst < 0) {
LLVM_DEBUG(llvm::dbgs()
<< "can't normalize map due to unknown/invalid upper bound");
return memrefType;
}
// If dimension of new memrefType is dynamic, the value is -1.
- newShape[d] = ubConst.value() + 1;
+ newShape[d] = *ubConst + 1;
}
}
if (!maybeTargetISA.has_value())
return signalPassFailure();
- std::string targetISA = std::move(maybeTargetISA.value());
+ std::string targetISA = std::move(*maybeTargetISA);
LLVM_DEBUG({
llvm::dbgs() << "ISA for module: " << getOperation().getNameAttr() << "\n";
Optional<NamedAttribute> alignmentAttr =
result.attributes.getNamed("alignment");
if (alignmentAttr.has_value()) {
- auto alignmentInt =
- alignmentAttr.value().getValue().dyn_cast<IntegerAttr>();
+ auto alignmentInt = alignmentAttr->getValue().dyn_cast<IntegerAttr>();
if (!alignmentInt)
return parser.emitError(parser.getNameLoc(),
"expected integer alignment");
auto genericOp = bubbleUpPackOpThroughElemGenericOp(rewriter, packOp);
if (failed(genericOp))
return failure();
- rewriter.replaceOp(packOp, genericOp.value().getResults());
+ rewriter.replaceOp(packOp, genericOp->getResults());
return success();
}
};
FailureOr<Operation *> fusedOp = fuseElementwiseOps(rewriter, &opOperand);
if (succeeded(fusedOp)) {
auto replacements =
- fusedOp.value()->getResults().take_back(genericOp.getNumResults());
+ (*fusedOp)->getResults().take_back(genericOp.getNumResults());
rewriter.replaceOp(genericOp, replacements);
return success();
}
getConstantUpperBoundForIndex(materializedSize);
size = failed(upperBound)
? materializedSize
- : b.create<arith::ConstantIndexOp>(loc, upperBound.value());
+ : b.create<arith::ConstantIndexOp>(loc, *upperBound);
}
LLVM_DEBUG(llvm::dbgs() << "Extracted tightest: " << size << "\n");
fullSizes.push_back(size);
// 2. Create the ForeachThreadOp with an empty region.
scf::ForeachThreadOp foreachThreadOp = b.create<scf::ForeachThreadOp>(
- loc, identityTensor.value()->getResults(),
+ loc, (*identityTensor)->getResults(),
ValueRange(materializedNonZeroNumThreads), mapping);
// 3. Calculate the tile offsets and sizes for the subsequent loop that will
// 8. Return.
ForeachThreadReductionTilingResult results;
- results.initialOp = identityTensor.value();
+ results.initialOp = *identityTensor;
results.loops = foreachThreadOp;
results.parallelTiledOp = tiledOp;
results.mergeOp = mergeOp;
return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag));
}
- results.push_back(newBuffer.value());
+ results.push_back(*newBuffer);
return DiagnosedSilenceableFailure::success();
}
llvm::APFloat::IEEEdouble())))
return reader.emitError("invalid CalibratedQuantizedType"),
CalibratedQuantizedType();
- return CalibratedQuantizedType::get(expressedType,
- min.value().convertToDouble(),
- max.value().convertToDouble());
+ return CalibratedQuantizedType::get(expressedType, min->convertToDouble(),
+ max->convertToDouble());
}
void QuantDialectBytecodeInterface::write(CalibratedQuantizedType type,
DialectBytecodeWriter &writer) const {
return reader.emitError("invalid UniformQuantizedType"),
UniformQuantizedType();
return UniformQuantizedType::get(flags, storageType, expressedType,
- scale.value().convertToDouble(), zeroPoint,
+ scale->convertToDouble(), zeroPoint,
storageTypeMin, storageTypeMax);
}
void QuantDialectBytecodeInterface::write(UniformQuantizedType type,
FailureOr<APFloat> fl =
reader.readAPFloatWithKnownSemantics(APFloat::IEEEdouble());
if (succeeded(fl)) {
- val = fl.value().convertToDouble();
+ val = fl->convertToDouble();
return success();
}
return failure();
innerMostLoop.getRegionIterArgs());
}
- tilingResult.replacements = replacementOr.value();
+ tilingResult.replacements = *replacementOr;
LLVM_DEBUG({
if (!tilingResult.loops.empty()) {
// 3. Generate the tiled implementation within the inner most loop.
b.setInsertionPoint(loops.back().getBody()->getTerminator());
- Operation *parallelOp =
- op.tileToPartialReduction(b, loc, identityTensor.value()->getResults(),
- offsets, sizes, reductionDim);
+ Operation *parallelOp = op.tileToPartialReduction(
+ b, loc, (*identityTensor)->getResults(), offsets, sizes, reductionDim);
SmallVector<OpFoldResult> resultSizesList;
for (size_t i = 0; i < offsets.size(); i++)
b.createOrFold<tensor::DimOp>(loc, parallelOp->getResult(0), i));
SmallVector<OpFoldResult> outOffsets(offsets.size(), b.getIndexAttr(0));
FailureOr<SmallVector<Value>> replacementOr = yieldTiledValues(
- b, identityTensor.value()->getResults(), parallelOp->getResults(),
- outOffsets, resultSizesList, loops);
+ b, (*identityTensor)->getResults(), parallelOp->getResults(), outOffsets,
+ resultSizesList, loops);
if (failed(replacementOr))
return b.notifyMatchFailure(op, "failed to yield replacement");
// 4. Apply the merge reduction to combine all the partial values.
b.setInsertionPointAfter(*loops.begin());
- Operation *mergeOp =
- op.mergeReductions(b, loc, replacementOr.value(), reductionDim);
+ Operation *mergeOp = op.mergeReductions(b, loc, *replacementOr, reductionDim);
b.replaceOp(op, mergeOp->getResults());
SCFReductionTilingResult results;
- results.initialOp = identityTensor.value();
+ results.initialOp = *identityTensor;
results.loops = std::move(loops);
results.parallelTiledOp = parallelOp;
results.mergeOp = mergeOp;
fusableProducer);
if (failed(fusedProducerValue))
continue;
- rewriter.replaceOp(candidateSliceOp, fusedProducerValue.value());
+ rewriter.replaceOp(candidateSliceOp, *fusedProducerValue);
// 2d. The operands of the fused producer might themselved be slices of
// values produced by operations that implement the `TilingInterface`.
iterArgNumber.value(),
dstOp.getTiedOpOperand(fusableProducer)->get());
}
- if (auto dstOp = fusedProducerValue.value()
- .getDefiningOp<DestinationStyleOpInterface>()) {
+ if (auto dstOp = fusedProducerValue
+ ->getDefiningOp<DestinationStyleOpInterface>()) {
scf::ForOp innerMostLoop = tileAndFuseResult.loops.back();
updateDestinationOperandsForTiledOp(
rewriter, dstOp.getDpsInitOperand(resultNumber)->get(),
if (Optional<bool> rhs = getScalarOrSplatBoolAttr(operands.back())) {
// x && true = x
- if (rhs.value())
+ if (*rhs)
return getOperand1();
// x && false = false
- if (!rhs.value())
+ if (!*rhs)
return operands.back();
}
assert(operands.size() == 2 && "spirv.LogicalOr should take two operands");
if (auto rhs = getScalarOrSplatBoolAttr(operands.back())) {
- if (rhs.value())
+ if (*rhs)
// x || true = true
return operands.back();
// x || false = x
- if (!rhs.value())
+ if (!*rhs)
return getOperand1();
}
return funcOp.emitRemark("lower entry point failure: could not select "
"execution model based on 'spirv.target_env'");
- builder.create<spirv::EntryPointOp>(funcOp.getLoc(), executionModel.value(),
- funcOp, interfaceVars);
+ builder.create<spirv::EntryPointOp>(funcOp.getLoc(), *executionModel, funcOp,
+ interfaceVars);
// Specifies the spirv.ExecutionModeOp.
if (DenseI32ArrayAttr workgroupSizeAttr = entryPointAttr.getWorkgroupSize()) {
// Filter loops should be constructed after all the dependent loops,
// i.e., d0 + d1 < filter_loop(d0 + d1)
- if (tldx && merger.isFilterLoop(tldx.value())) {
+ if (tldx && merger.isFilterLoop(*tldx)) {
assert(!ta.isa<AffineDimExpr>() &&
!isDenseDLT(getDimLevelType(enc, d)));
addAffineOrderings(adjM, inDegree, ta, AffineExpr(), std::nullopt,
for (unsigned d = 0, rank = map.getNumResults(); d < rank; d++) {
AffineExpr a = map.getResult(toOrigDim(enc, d));
Optional<unsigned> sldx = merger.getLoopIdx(t.getOperandNumber(), d);
- if (sldx && merger.isFilterLoop(sldx.value())) {
- if (!codegen.getLoopIdxValue(sldx.value()))
+ if (sldx && merger.isFilterLoop(*sldx)) {
+ if (!codegen.getLoopIdxValue(*sldx))
// The filter loops has not been constructed.
return;
- if (sldx.value() == ldx)
+ if (*sldx == ldx)
atLevel = true;
} else if (!isInvariantAffine(codegen, a, ldx, atLevel))
return; // still in play
} else {
// sparse/singleton dim levels.
tids.push_back(tid);
- dims.push_back(dim.value());
+ dims.push_back(*dim);
}
});
return;
}
condTids.push_back(tid);
- condDims.push_back(dim.value());
+ condDims.push_back(*dim);
} else if (isDenseDLT(dlt)) {
// TODO: get rid of extraTids and extraDims.
extraTids.push_back(tid);
- extraDims.push_back(dim.value());
+ extraDims.push_back(*dim);
} else {
assert(isUndefDLT(dlt));
if (tid >= op.getNumDpsInputs())
if (!optExp.has_value())
return failure();
- unsigned exp = optExp.value();
+ unsigned exp = *optExp;
OpOperand *sparseOut = nullptr;
unsigned outerParNest = 0;
// Computes a topologically sorted iteration graph to ensure tensors
if (def->getNumOperands() == 1) {
auto x = buildTensorExp(op, def->getOperand(0));
if (x.has_value()) {
- unsigned e = x.value();
+ unsigned e = *x;
if (isa<math::AbsFOp>(def))
return addExp(kAbsF, e);
if (isa<complex::AbsOp>(def))
auto x = buildTensorExp(op, def->getOperand(0));
auto y = buildTensorExp(op, def->getOperand(1));
if (x.has_value() && y.has_value()) {
- unsigned e0 = x.value();
- unsigned e1 = y.value();
+ unsigned e0 = *x;
+ unsigned e1 = *y;
if (isa<arith::MulFOp>(def))
return addExp(kMulF, e0, e1);
if (isa<complex::MulOp>(def))
auto y = buildTensorExp(op, def->getOperand(1));
auto z = buildTensorExp(op, def->getOperand(2));
if (x.has_value() && y.has_value() && z.has_value()) {
- unsigned e0 = x.value();
- unsigned e1 = y.value();
+ unsigned e0 = *x;
+ unsigned e1 = *y;
if (auto redop = dyn_cast<sparse_tensor::ReduceOp>(def)) {
if (isAdmissibleBranch(redop, redop.getRegion()))
return addExp(kReduce, e0, e1, Value(), def);
SmallVector<Value> dynamicTileSizes;
dispatchIndexOpFoldResults(innerTiles, dynamicTileSizes, staticTileSizes);
build(builder, state, dest.getType(), source, dest,
- paddingValue ? paddingValue.value() : nullptr,
+ paddingValue ? *paddingValue : nullptr,
outerDimsPerm.empty() ? nullptr
: builder.getDenseI64ArrayAttr(outerDimsPerm),
builder.getDenseI64ArrayAttr(innerDimsPos), dynamicTileSizes,
getValueOrCreateConstantIndexOp(b, loc, tileSize));
std::optional<int64_t> cstInnerSize = getConstantIntValue(innerTileSize);
if (!failed(cstSize) && cstInnerSize) {
- if (cstSize.value() % cstInnerSize.value() == 0)
+ if (*cstSize % *cstInnerSize == 0)
info.isAlignedToInnerTileSize = true;
// If the tiling size equals to the inner tiling size, the outer dims are
// always 1.
- if (cstInnerSize.value() == cstSize.value()) {
+ if (*cstInnerSize == *cstSize) {
auto lhs = AV(dim0).bind(tileOffset);
auto rhs = AV(dim1).bind(innerTileSize);
info.sourceOffset = ab.floor(lhs, rhs);
return rewriter
.replaceOpWithNewOp<tensor::CollapseShapeOp>(
- op, sliceOp.getResult(), info->newReassociationIndices.value())
+ op, sliceOp.getResult(), *info->newReassociationIndices)
.getOperation();
}
if (failed(tiledResult))
return failure();
- return tiledResult.value();
+ return *tiledResult;
}
for (const auto &[nonUnitDim, indices] :
llvm::zip(*trivialSegments, reassociationIndices)) {
if (nonUnitDim) {
- sliceShape.push_back(sourceType.getDimSize(nonUnitDim.value()));
+ sliceShape.push_back(sourceType.getDimSize(*nonUnitDim));
continue;
}
llvm::append_range(sliceShape, llvm::map_range(indices, [&](int64_t idx) {
loc, op.getLhs(), b, acc, kind, rewriter, isInt);
if (!mult.has_value())
return failure();
- rewriter.replaceOp(op, mult.value());
+ rewriter.replaceOp(op, *mult);
return success();
}
createContractArithOp(loc, a, op.getRhs(), r, kind, rewriter, isInt);
if (!m.has_value())
return failure();
- result = rewriter.create<vector::InsertOp>(loc, resType, m.value(),
- result, pos);
+ result = rewriter.create<vector::InsertOp>(loc, resType, *m, result, pos);
}
rewriter.replaceOp(op, result);
return success();
auto newOp = lowerParallel(op, lhsIndex, rhsIndex, rewriter);
if (failed(newOp))
return failure();
- rewriter.replaceOp(op, newOp.value());
+ rewriter.replaceOp(op, *newOp);
return success();
}
auto newOp = lowerParallel(op, lhsIndex, /*rhsIndex=*/-1, rewriter);
if (failed(newOp))
return failure();
- rewriter.replaceOp(op, newOp.value());
+ rewriter.replaceOp(op, *newOp);
return success();
}
}
auto newOp = lowerParallel(op, /*lhsIndex=*/-1, rhsIndex, rewriter);
if (failed(newOp))
return failure();
- rewriter.replaceOp(op, newOp.value());
+ rewriter.replaceOp(op, *newOp);
return success();
}
}
auto newOp = lowerReduction(op, rewriter);
if (failed(newOp))
return failure();
- rewriter.replaceOp(op, newOp.value());
+ rewriter.replaceOp(op, *newOp);
return success();
}
return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) {
diag << "expected iterIndex=" << iterIndex << "to map to a RHS dimension";
});
- int64_t lhsIndex = lookupLhs.value();
- int64_t rhsIndex = lookupRhs.value();
+ int64_t lhsIndex = *lookupLhs;
+ int64_t rhsIndex = *lookupRhs;
int64_t dimSize = lhsType.getDimSize(lhsIndex);
if (dimSize != rhsType.getDimSize(rhsIndex))
return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) {
convertConstantExpr(globalVar->getInitializer());
if (failed(initializer))
return {};
- builder.create<ReturnOp>(globalOp.getLoc(), initializer.value());
+ builder.create<ReturnOp>(globalOp.getLoc(), *initializer);
}
if (globalVar->hasAtLeastLocalUnnamedAddr()) {
globalOp.setUnnamedAddr(
FailureOr<Value> converted = convertConstant(constantToConvert);
if (failed(converted))
return failure();
- mapValue(constantToConvert, converted.value());
+ mapValue(constantToConvert, *converted);
}
// Update the constant insertion point and return the converted constant.
FailureOr<Value> converted = convertValue(value);
if (failed(converted))
return failure();
- remapped.push_back(converted.value());
+ remapped.push_back(*converted);
}
return remapped;
}
IntegerAttr integerAttr;
FailureOr<Value> converted = convertValue(value);
bool success = succeeded(converted) &&
- matchPattern(converted.value(), m_Constant(&integerAttr));
+ matchPattern(*converted, m_Constant(&integerAttr));
assert(success && "expected a constant value");
(void)success;
return integerAttr;
FailureOr<Value> converted = convertValue(value);
if (failed(converted))
return failure();
- blockArguments.push_back(converted.value());
+ blockArguments.push_back(*converted);
}
return success();
}
FailureOr<Value> called = convertValue(callInst->getCalledOperand());
if (failed(called))
return failure();
- operands.push_back(called.value());
+ operands.push_back(*called);
}
SmallVector<llvm::Value *> args(callInst->args());
FailureOr<SmallVector<Value>> arguments = convertValues(args);
if (failed(arguments))
return failure();
- llvm::append_range(operands, arguments.value());
+ llvm::append_range(operands, *arguments);
return success();
}
FailureOr<Value> condition = convertValue(brInst->getCondition());
if (failed(condition))
return failure();
- builder.create<LLVM::CondBrOp>(loc, condition.value(), succBlocks.front(),
+ builder.create<LLVM::CondBrOp>(loc, *condition, succBlocks.front(),
succBlockArgs.front(), succBlocks.back(),
succBlockArgs.back());
} else {
caseBlocks[it.index()] = lookupBlock(succBB);
}
- builder.create<SwitchOp>(loc, condition.value(), lookupBlock(defaultBB),
+ builder.create<SwitchOp>(loc, *condition, lookupBlock(defaultBB),
defaultBlockArgs, caseValues, caseBlocks,
caseOperandRefs);
return success();
FailureOr<Value> operand = convertConstantExpr(lpInst->getClause(i));
if (failed(operand))
return failure();
- operands.push_back(operand.value());
+ operands.push_back(*operand);
}
Type type = convertType(lpInst->getType());
FailureOr<Value> index = convertValue(operand);
if (failed(index))
return failure();
- indices.push_back(index.value());
+ indices.push_back(*index);
}
Type type = convertType(inst->getType());
- Value res =
- builder.create<GEPOp>(loc, type, sourceElementType, basePtr.value(),
- indices, gepInst->isInBounds());
+ Value res = builder.create<GEPOp>(loc, type, sourceElementType, *basePtr,
+ indices, gepInst->isInBounds());
mapValue(inst, res);
return success();
}
getOverloadedDeclaration(op, id, module, moduleTranslation);
if (failed(fnOrFailure))
return failure();
- fn = fnOrFailure.value();
+ fn = *fnOrFailure;
} else {
fn = llvm::Intrinsic::getDeclaration(module, id, {});
}
for (const auto &dependenceComponent : dependenceComponents) {
std::string lbStr = "-inf";
if (dependenceComponent.lb.has_value() &&
- dependenceComponent.lb.value() != std::numeric_limits<int64_t>::min())
- lbStr = std::to_string(dependenceComponent.lb.value());
+ *dependenceComponent.lb != std::numeric_limits<int64_t>::min())
+ lbStr = std::to_string(*dependenceComponent.lb);
std::string ubStr = "+inf";
if (dependenceComponent.ub.has_value() &&
- dependenceComponent.ub.value() != std::numeric_limits<int64_t>::max())
- ubStr = std::to_string(dependenceComponent.ub.value());
+ *dependenceComponent.ub != std::numeric_limits<int64_t>::max())
+ ubStr = std::to_string(*dependenceComponent.ub);
result += "[" + lbStr + ", " + ubStr + "]";
}
llvm::Optional<std::reference_wrapper<shape::ShapeMappingAnalysis>>
maybeAnalysis = getCachedAnalysis<shape::ShapeMappingAnalysis>();
if (maybeAnalysis.has_value())
- maybeAnalysis.value().get().print(llvm::errs());
+ maybeAnalysis->get().print(llvm::errs());
else
llvm::errs() << "No cached ShapeMappingAnalysis existed.";
}
void LinalgTransformationFilter::replaceLinalgTransformationFilter(
PatternRewriter &rewriter, Operation *op) const {
if (replacement.has_value())
- op->setAttr(kLinalgTransformMarker, replacement.value());
+ op->setAttr(kLinalgTransformMarker, *replacement);
else
op->removeAttr(rewriter.getStringAttr(kLinalgTransformMarker));
}
as << formatv("if (failed(_llvmir_gen_operand_{0}))\n"
" return failure();\n",
name);
- bs << formatv("_llvmir_gen_operand_{0}.value()", name);
+ bs << formatv("*_llvmir_gen_operand_{0}", name);
}
} else if (isResultName(op, name)) {
if (op.getNumResults() != 1)