Skip to content

Commit c27d815

Browse files
[mlir] Use value instead of getValue (NFC)
1 parent 0e95921 commit c27d815

File tree

54 files changed

+169
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+169
-180
lines changed

mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
400400
inline Value getValue(unsigned pos) const {
401401
assert(pos < getNumDimAndSymbolVars() && "Invalid position");
402402
assert(hasValue(pos) && "variable's Value not set");
403-
return values[pos].getValue();
403+
return values[pos].value();
404404
}
405405

406406
/// Returns true if the pos^th variable has an associated Value.

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def LLVM_FNegOp : LLVM_UnaryFloatArithmeticOp<
348348
class MemoryOpWithAlignmentBase {
349349
code setAlignmentCode = [{
350350
if ($alignment.hasValue()) {
351-
auto align = $alignment.getValue();
351+
auto align = $alignment.value();
352352
if (align != 0)
353353
inst->setAlignment(llvm::Align(align));
354354
}

mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class MMA_SYNC_INTR {
569569
# " \"" # op[2].ptx_elt_type # "\" == eltypeC && "
570570
# " \"" # op[3].ptx_elt_type # "\" == eltypeD "
571571
# " && (sat.has_value() ? " # sat # " == static_cast<int>(*sat) : true)"
572-
# !if(!ne(b1op, ""), " && (b1Op.has_value() ? MMAB1Op::" # b1op # " == b1Op.getValue() : true)", "") # ")\n"
572+
# !if(!ne(b1op, ""), " && (b1Op.has_value() ? MMAB1Op::" # b1op # " == b1Op.value() : true)", "") # ")\n"
573573
# " return " #
574574
MMA_SYNC_NAME<layoutA, layoutB, b1op, sat, op[0], op[1], op[2], op[3]>.id # ";",
575575
"") // if supported
@@ -995,8 +995,8 @@ def NVVM_MmaOp : NVVM_Op<"mma.sync", [AttrSizedOperandSegments]> {
995995
$shape.getM(), $shape.getN(), $shape.getK(),
996996
$b1Op, $intOverflowBehavior,
997997
$layoutA, $layoutB,
998-
$multiplicandAPtxType.getValue(),
999-
$multiplicandBPtxType.getValue(),
998+
$multiplicandAPtxType.value(),
999+
$multiplicandBPtxType.value(),
10001000
op.accumPtxType(),
10011001
op.resultPtxType());
10021002

mlir/include/mlir/IR/OpDefinition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OptionalParseResult {
4747
bool hasValue() const { return impl.has_value(); }
4848

4949
/// Access the internal ParseResult value.
50-
ParseResult getValue() const { return impl.getValue(); }
50+
ParseResult getValue() const { return impl.value(); }
5151
ParseResult operator*() const { return getValue(); }
5252

5353
private:

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ class TypeConverter {
251251
[callback = std::forward<FnT>(callback)](
252252
T type, SmallVectorImpl<Type> &results, ArrayRef<Type>) {
253253
if (Optional<Type> resultOpt = callback(type)) {
254-
bool wasSuccess = static_cast<bool>(resultOpt.getValue());
254+
bool wasSuccess = static_cast<bool>(resultOpt.value());
255255
if (wasSuccess)
256-
results.push_back(resultOpt.getValue());
256+
results.push_back(resultOpt.value());
257257
return Optional<LogicalResult>(success(wasSuccess));
258258
}
259259
return Optional<LogicalResult>();

mlir/lib/Analysis/Presburger/IntegerRelation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
20292029
if (!constLb.has_value() || !constOtherLb.has_value())
20302030
return failure();
20312031
std::fill(minLb.begin(), minLb.end(), 0);
2032-
minLb.back() = std::min(constLb.getValue(), constOtherLb.getValue());
2032+
minLb.back() = std::min(constLb.value(), constOtherLb.value());
20332033
}
20342034

20352035
// Do the same for ub's but max of upper bounds. Identify max.
@@ -2045,7 +2045,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
20452045
if (!constUb.has_value() || !constOtherUb.has_value())
20462046
return failure();
20472047
std::fill(maxUb.begin(), maxUb.end(), 0);
2048-
maxUb.back() = std::max(constUb.getValue(), constOtherUb.getValue());
2048+
maxUb.back() = std::max(constUb.value(), constOtherUb.value());
20492049
}
20502050

20512051
std::fill(newLb.begin(), newLb.end(), 0);

mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ class ExecutionModePattern
646646
IntegerAttr executionModeAttr = op.execution_modeAttr();
647647
std::string moduleName;
648648
if (module.getName().has_value())
649-
moduleName = "_" + module.getName().getValue().str();
649+
moduleName = "_" + module.getName().value().str();
650650
else
651651
moduleName = "";
652652
std::string executionModeInfoName =
@@ -1585,10 +1585,10 @@ void mlir::encodeBindAttribute(ModuleOp module) {
15851585
if (descriptorSet && binding) {
15861586
// Encode these numbers into the variable's symbolic name. If the
15871587
// SPIR-V module has a name, add it at the beginning.
1588-
auto moduleAndName = spvModule.getName().has_value()
1589-
? spvModule.getName().getValue().str() + "_" +
1590-
op.sym_name().str()
1591-
: op.sym_name().str();
1588+
auto moduleAndName =
1589+
spvModule.getName().has_value()
1590+
? spvModule.getName().value().str() + "_" + op.sym_name().str()
1591+
: op.sym_name().str();
15921592
std::string name =
15931593
llvm::formatv("{0}_descriptor_set{1}_binding{2}", moduleAndName,
15941594
std::to_string(descriptorSet.getInt()),

mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
147147
cast<tosa::NegateOp>(op).quantization_info()) {
148148
auto quantizationInfo = cast<tosa::NegateOp>(op).quantization_info();
149149
int32_t inputBitWidth = elementTy.getIntOrFloatBitWidth();
150-
int64_t inZp = quantizationInfo.getValue().getInputZp();
151-
int64_t outZp = quantizationInfo.getValue().getOutputZp();
150+
int64_t inZp = quantizationInfo.value().getInputZp();
151+
int64_t outZp = quantizationInfo.value().getOutputZp();
152152

153153
// Compute the maximum value that can occur in the intermediate buffer.
154154
int64_t zpAdd = inZp + outZp;
@@ -1166,7 +1166,7 @@ class RescaleConverter : public OpRewritePattern<tosa::RescaleOp> {
11661166
checkHasDynamicBatchDims(rewriter, op, {input, op.output()});
11671167
if (!dynamicDimsOr.has_value())
11681168
return failure();
1169-
SmallVector<Value> dynamicDims = dynamicDimsOr.getValue();
1169+
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
11701170

11711171
// The shift and multiplier values.
11721172
SmallVector<int32_t> multiplierValues;
@@ -1358,7 +1358,7 @@ class ResizeConverter : public OpRewritePattern<tosa::ResizeOp> {
13581358
checkHasDynamicBatchDims(rewriter, op, {input, op.output()});
13591359
if (!dynamicDimsOr.has_value())
13601360
return failure();
1361-
SmallVector<Value> dynamicDims = dynamicDimsOr.getValue();
1361+
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
13621362

13631363
if (op.mode() != "NEAREST_NEIGHBOR" && op.mode() != "BILINEAR")
13641364
return failure();
@@ -2053,7 +2053,7 @@ class GatherConverter : public OpConversionPattern<tosa::GatherOp> {
20532053
checkHasDynamicBatchDims(rewriter, op, {input, indices, op.output()});
20542054
if (!dynamicDimsOr.has_value())
20552055
return failure();
2056-
SmallVector<Value> dynamicDims = dynamicDimsOr.getValue();
2056+
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
20572057

20582058
auto resultElementTy = resultTy.getElementType();
20592059

mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ class MaxPool2dConverter : public OpRewritePattern<tosa::MaxPool2dOp> {
696696
checkHasDynamicBatchDims(rewriter, op, {input, op.output()});
697697
if (!dynamicDimsOr.has_value())
698698
return failure();
699-
SmallVector<Value> dynamicDims = dynamicDimsOr.getValue();
699+
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
700700

701701
// Determine what the initial value needs to be for the max pool op.
702702
Attribute initialAttr;
@@ -773,7 +773,7 @@ class AvgPool2dConverter : public OpRewritePattern<tosa::AvgPool2dOp> {
773773
checkHasDynamicBatchDims(rewriter, op, {input, op.output()});
774774
if (!dynamicDimsOr.has_value())
775775
return failure();
776-
SmallVector<Value> dynamicDims = dynamicDimsOr.getValue();
776+
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
777777

778778
// Apply padding as necessary.
779779
llvm::SmallVector<int64_t> pad;

mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static void getXferIndices(OpBuilder &b, OpTy xferOp, Value iv,
9494
if (!isBroadcast) {
9595
AffineExpr d0, d1;
9696
bindDims(xferOp.getContext(), d0, d1);
97-
Value offset = adaptor.getIndices()[dim.getValue()];
98-
indices[dim.getValue()] =
97+
Value offset = adaptor.getIndices()[dim.value()];
98+
indices[dim.value()] =
9999
makeComposedAffineApply(b, loc, d0 + d1, {offset, iv});
100100
}
101101
}

mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,16 +1011,16 @@ void FlatAffineValueConstraints::getSliceBounds(
10111011
auto ubConst = getConstantBound(BoundType::UB, pos);
10121012
if (lbConst.has_value() && ubConst.has_value()) {
10131013
// Detect equality to a constant.
1014-
if (lbConst.getValue() == ubConst.getValue()) {
1015-
memo[pos] = getAffineConstantExpr(lbConst.getValue(), context);
1014+
if (lbConst.value() == ubConst.value()) {
1015+
memo[pos] = getAffineConstantExpr(lbConst.value(), context);
10161016
changed = true;
10171017
continue;
10181018
}
10191019

10201020
// Detect an variable as modulo of another variable w.r.t a
10211021
// constant.
1022-
if (detectAsMod(*this, pos, lbConst.getValue(), ubConst.getValue(),
1023-
memo, context)) {
1022+
if (detectAsMod(*this, pos, lbConst.value(), ubConst.value(), memo,
1023+
context)) {
10241024
changed = true;
10251025
continue;
10261026
}
@@ -1121,20 +1121,19 @@ void FlatAffineValueConstraints::getSliceBounds(
11211121
<< "WARNING: Potentially over-approximating slice lb\n");
11221122
auto lbConst = getConstantBound(BoundType::LB, pos + offset);
11231123
if (lbConst.has_value()) {
1124-
lbMap = AffineMap::get(
1125-
numMapDims, numMapSymbols,
1126-
getAffineConstantExpr(lbConst.getValue(), context));
1124+
lbMap =
1125+
AffineMap::get(numMapDims, numMapSymbols,
1126+
getAffineConstantExpr(lbConst.value(), context));
11271127
}
11281128
}
11291129
if (!ubMap || ubMap.getNumResults() > 1) {
11301130
LLVM_DEBUG(llvm::dbgs()
11311131
<< "WARNING: Potentially over-approximating slice ub\n");
11321132
auto ubConst = getConstantBound(BoundType::UB, pos + offset);
11331133
if (ubConst.has_value()) {
1134-
ubMap =
1135-
AffineMap::get(numMapDims, numMapSymbols,
1136-
getAffineConstantExpr(
1137-
ubConst.getValue() + ubAdjustment, context));
1134+
ubMap = AffineMap::get(
1135+
numMapDims, numMapSymbols,
1136+
getAffineConstantExpr(ubConst.value() + ubAdjustment, context));
11381137
}
11391138
}
11401139
}
@@ -1674,12 +1673,12 @@ void FlatAffineRelation::compose(const FlatAffineRelation &other) {
16741673
// Add and match domain of `rel` to domain of `this`.
16751674
for (unsigned i = 0, e = rel.getNumDomainDims(); i < e; ++i)
16761675
if (relMaybeValues[i].has_value())
1677-
setValue(i, relMaybeValues[i].getValue());
1676+
setValue(i, relMaybeValues[i].value());
16781677
// Add and match range of `this` to range of `rel`.
16791678
for (unsigned i = 0, e = getNumRangeDims(); i < e; ++i) {
16801679
unsigned rangeIdx = rel.getNumDomainDims() + i;
16811680
if (thisMaybeValues[rangeIdx].has_value())
1682-
rel.setValue(rangeIdx, thisMaybeValues[rangeIdx].getValue());
1681+
rel.setValue(rangeIdx, thisMaybeValues[rangeIdx].value());
16831682
}
16841683

16851684
// Append `this` to `rel` and simplify constraints.

mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Optional<uint64_t> mlir::getConstantTripCount(AffineForOp forOp) {
9393
for (auto resultExpr : map.getResults()) {
9494
if (auto constExpr = resultExpr.dyn_cast<AffineConstantExpr>()) {
9595
if (tripCount.has_value())
96-
tripCount = std::min(tripCount.getValue(),
96+
tripCount = std::min(tripCount.value(),
9797
static_cast<uint64_t>(constExpr.getValue()));
9898
else
9999
tripCount = constExpr.getValue();
@@ -133,12 +133,12 @@ uint64_t mlir::getLargestDivisorOfTripCount(AffineForOp forOp) {
133133
thisGcd = resultExpr.getLargestKnownDivisor();
134134
}
135135
if (gcd.has_value())
136-
gcd = llvm::GreatestCommonDivisor64(gcd.getValue(), thisGcd);
136+
gcd = llvm::GreatestCommonDivisor64(gcd.value(), thisGcd);
137137
else
138138
gcd = thisGcd;
139139
}
140140
assert(gcd.has_value() && "value expected per above logic");
141-
return gcd.getValue();
141+
return gcd.value();
142142
}
143143

144144
/// Given an induction variable `iv` of type AffineForOp and an access `index`

mlir/lib/Dialect/Affine/Analysis/Utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ Optional<int64_t> MemRefRegion::getConstantBoundingSizeAndShape(
376376
Optional<int64_t> diff =
377377
cstWithShapeBounds.getConstantBoundOnDimSize(d, &lb, &lbDivisor);
378378
if (diff.has_value()) {
379-
diffConstant = diff.getValue();
379+
diffConstant = diff.value();
380380
assert(diffConstant >= 0 && "Dim size bound can't be negative");
381381
assert(lbDivisor > 0);
382382
} else {
@@ -1013,7 +1013,7 @@ bool mlir::buildSliceTripCountMap(
10131013
}
10141014
Optional<uint64_t> maybeConstTripCount = getConstantTripCount(forOp);
10151015
if (maybeConstTripCount.has_value()) {
1016-
(*tripCountMap)[op] = maybeConstTripCount.getValue();
1016+
(*tripCountMap)[op] = maybeConstTripCount.value();
10171017
continue;
10181018
}
10191019
return false;
@@ -1022,7 +1022,7 @@ bool mlir::buildSliceTripCountMap(
10221022
// Slice bounds are created with a constant ub - lb difference.
10231023
if (!tripCount.has_value())
10241024
return false;
1025-
(*tripCountMap)[op] = tripCount.getValue();
1025+
(*tripCountMap)[op] = tripCount.value();
10261026
}
10271027
return true;
10281028
}
@@ -1322,7 +1322,7 @@ static Optional<int64_t> getMemoryFootprintBytes(Block &block,
13221322
Optional<int64_t> size = region.second->getRegionSize();
13231323
if (!size.has_value())
13241324
return None;
1325-
totalSizeInBytes += size.getValue();
1325+
totalSizeInBytes += size.value();
13261326
}
13271327
return totalSizeInBytes;
13281328
}

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static bool isDimOpValidSymbol(OpTy dimOp, Region *region) {
339339
Optional<int64_t> index = dimOp.getConstantIndex();
340340
assert(index.has_value() &&
341341
"expect only `dim` operations with a constant index");
342-
int64_t i = index.getValue();
342+
int64_t i = index.value();
343343
return TypeSwitch<Operation *, bool>(dimOp.getSource().getDefiningOp())
344344
.Case<memref::ViewOp, memref::SubViewOp, memref::AllocOp>(
345345
[&](auto op) { return isMemRefSizeValidSymbol(op, i, region); })
@@ -1897,8 +1897,7 @@ struct AffineForEmptyLoopFolder : public OpRewritePattern<AffineForOp> {
18971897
return failure();
18981898
// Bail out when the loop iterates more than once and it returns any iterArg
18991899
// out of order.
1900-
if (tripCount.has_value() && tripCount.getValue() >= 2 &&
1901-
iterArgsNotInOrder)
1900+
if (tripCount.has_value() && tripCount.value() >= 2 && iterArgsNotInOrder)
19021901
return failure();
19031902
rewriter.replaceOp(forOp, replacements);
19041903
return success();
@@ -1931,19 +1930,18 @@ OperandRange AffineForOp::getSuccessorEntryOperands(Optional<unsigned> index) {
19311930
void AffineForOp::getSuccessorRegions(
19321931
Optional<unsigned> index, ArrayRef<Attribute> operands,
19331932
SmallVectorImpl<RegionSuccessor> &regions) {
1934-
assert((!index.has_value() || index.getValue() == 0) &&
1935-
"expected loop region");
1933+
assert((!index.has_value() || index.value() == 0) && "expected loop region");
19361934
// The loop may typically branch back to its body or to the parent operation.
19371935
// If the predecessor is the parent op and the trip count is known to be at
19381936
// least one, branch into the body using the iterator arguments. And in cases
19391937
// we know the trip count is zero, it can only branch back to its parent.
19401938
Optional<uint64_t> tripCount = getTrivialConstantTripCount(*this);
19411939
if (!index.has_value() && tripCount.has_value()) {
1942-
if (tripCount.getValue() > 0) {
1940+
if (tripCount.value() > 0) {
19431941
regions.push_back(RegionSuccessor(&getLoopBody(), getRegionIterArgs()));
19441942
return;
19451943
}
1946-
if (tripCount.getValue() == 0) {
1944+
if (tripCount.value() == 0) {
19471945
regions.push_back(RegionSuccessor(getResults()));
19481946
return;
19491947
}
@@ -3771,8 +3769,8 @@ ParseResult AffineParallelOp::parse(OpAsmParser &parser,
37713769
arith::symbolizeAtomicRMWKind(attrVal.getValue());
37723770
if (!reduction)
37733771
return parser.emitError(loc, "invalid reduction value: ") << attrVal;
3774-
reductions.push_back(builder.getI64IntegerAttr(
3775-
static_cast<int64_t>(reduction.getValue())));
3772+
reductions.push_back(
3773+
builder.getI64IntegerAttr(static_cast<int64_t>(reduction.value())));
37763774
// While we keep getting commas, keep parsing.
37773775
return success();
37783776
};

mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void AffineDataCopyGeneration::runOnBlock(Block *block,
143143
getMemoryFootprintBytes(forOp,
144144
/*memorySpace=*/0);
145145
return (footprint.has_value() &&
146-
static_cast<uint64_t>(footprint.getValue()) >
146+
static_cast<uint64_t>(footprint.value()) >
147147
fastMemCapacityBytes);
148148
};
149149

0 commit comments

Comments
 (0)