From 6d5fc1e3d5ac4d241421d5e3a086ff97fed69b5e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 Jun 2022 23:20:25 -0700 Subject: [PATCH] [mlir] Don't use Optional::getValue (NFC) --- mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td | 2 +- mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h | 2 +- mlir/include/mlir/IR/DialectImplementation.h | 2 +- mlir/lib/Analysis/Presburger/IntegerRelation.cpp | 2 +- mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp | 4 ++-- mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp | 2 +- .../GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp | 5 ++--- mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp | 2 +- .../Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp | 2 +- mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp | 5 ++--- mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp | 2 +- mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp | 8 ++++---- mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp | 2 +- mlir/lib/Dialect/Affine/Analysis/Utils.cpp | 4 ++-- mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp | 4 ++-- mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp | 4 ++-- mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp | 4 ++-- mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | 13 ++++++------- .../Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp | 2 +- .../Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp | 2 +- .../Transforms/FuncBufferizableOpInterfaceImpl.cpp | 3 +-- mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp | 2 +- mlir/lib/Dialect/EmitC/IR/EmitC.cpp | 4 ++-- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp | 2 +- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 8 ++++---- mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 6 +++--- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 2 +- mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp | 6 +++--- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp | 5 ++--- mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp | 3 +-- mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp | 12 ++++++------ mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 5 ++--- mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | 8 ++++---- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | 3 +-- mlir/lib/Dialect/SCF/IR/SCF.cpp | 2 +- mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp | 6 +++--- mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp | 4 ++-- mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp | 8 ++++---- .../SparseTensor/Transforms/SparseTensorConversion.cpp | 2 +- mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | 4 ++-- mlir/lib/Dialect/Tensor/Transforms/SplitPadding.cpp | 2 +- mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 2 +- mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeConv2D.cpp | 2 +- .../Dialect/Tosa/Transforms/TosaDecomposeTransposeConv.cpp | 5 ++--- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 2 +- mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 2 +- mlir/lib/ExecutionEngine/JitRunner.cpp | 3 +-- mlir/lib/IR/AffineExpr.cpp | 3 +-- mlir/lib/Parser/AttributeParser.cpp | 4 ++-- mlir/lib/Parser/Parser.cpp | 2 +- mlir/lib/Parser/TypeParser.cpp | 6 +++--- .../LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp | 2 +- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 4 ++-- mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp | 4 ++-- mlir/lib/Target/SPIRV/Serialization/Serializer.cpp | 6 +++--- mlir/lib/Transforms/Utils/DialectConversion.cpp | 4 ++-- mlir/test/lib/Dialect/Test/TestTypes.h | 2 +- mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp | 2 +- mlir/tools/mlir-tblgen/OpFormatGen.cpp | 2 +- 59 files changed, 108 insertions(+), 119 deletions(-) diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td index c793b51..d5c2537 100644 --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td @@ -875,7 +875,7 @@ def MemRef_GlobalOp : MemRef_Op<"global", [Symbol]> { let extraClassDeclaration = [{ bool isExternal() { return !initial_value(); } bool isUninitialized() { - return !isExternal() && initial_value().getValue().isa(); + return !isExternal() && initial_value()->isa(); } /// Returns the constant initial value if the memref.global is a constant, /// or null otherwise. diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h b/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h index 36d66f1..9c307bc 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h @@ -32,7 +32,7 @@ parseEnumKeywordAttr(EnumClass &value, ParserType &parser, if (parser.parseKeyword(&keyword)) return failure(); if (Optional attr = spirv::symbolizeEnum(keyword)) { - value = attr.getValue(); + value = *attr; return success(); } return parser.emitError(loc, "invalid ") diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h index e9ec9d2..02d14e69 100644 --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -118,7 +118,7 @@ struct FieldParser< auto element = FieldParser::parse(parser); if (failed(element)) return failure(); - elements.push_back(element.getValue()); + elements.push_back(*element); return success(); }; if (parser.parseCommaSeparatedList(elementParser)) diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp index fc2fbd5..25d89f9 100644 --- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp @@ -771,7 +771,7 @@ Optional> IntegerRelation::findIntegerSample() const { SmallVector coneSample(llvm::map_range(shrunkenConeSample, ceil)); // 6) Return transform * concat(boundedSample, coneSample). - SmallVector &sample = boundedSample.getValue(); + SmallVector &sample = *boundedSample; sample.append(coneSample.begin(), coneSample.end()); return transform.postMultiplyWithColumn(sample); } diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index f94e973..1e0d1ad 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -224,7 +224,7 @@ public: arith::symbolizeAtomicRMWKind( static_cast(reduction.cast().getInt())); assert(reductionOp && "Reduction operation cannot be of None Type"); - arith::AtomicRMWKind reductionOpValue = reductionOp.getValue(); + arith::AtomicRMWKind reductionOpValue = *reductionOp; identityVals.push_back( arith::getIdentityValue(reductionOpValue, resultType, rewriter, loc)); } @@ -244,7 +244,7 @@ public: arith::symbolizeAtomicRMWKind( reductions[i].cast().getInt()); assert(reductionOp && "Reduction Operation cannot be of None Type"); - arith::AtomicRMWKind reductionOpValue = reductionOp.getValue(); + arith::AtomicRMWKind reductionOpValue = *reductionOp; rewriter.setInsertionPoint(&parOp.getBody()->back()); auto reduceOp = rewriter.create( loc, affineParOpTerminator->getOperand(i)); diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp index dacee99..b9d4b3f 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -314,7 +314,7 @@ LogicalResult GPUModuleConversion::matchAndRewrite( // Add a keyword to the module name to avoid symbolic conflict. std::string spvModuleName = (kSPIRVModule + moduleOp.getName()).str(); auto spvModule = rewriter.create( - moduleOp.getLoc(), addressingModel, memoryModel.getValue(), llvm::None, + moduleOp.getLoc(), addressingModel, *memoryModel, llvm::None, StringRef(spvModuleName)); // Move the region from the module op into the SPIR-V module. diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp index e7e64ae..9428de0 100644 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -103,8 +103,7 @@ private: /// Checks whether the given LLVM::CallOp is a vulkan launch call op. bool isVulkanLaunchCallOp(LLVM::CallOp callOp) { - return (callOp.getCallee() && - callOp.getCallee().getValue() == kVulkanLaunch && + return (callOp.getCallee() && *callOp.getCallee() == kVulkanLaunch && callOp.getNumOperands() >= kVulkanLaunchNumConfigOperands); } @@ -112,7 +111,7 @@ private: /// op. bool isCInterfaceVulkanLaunchCallOp(LLVM::CallOp callOp) { return (callOp.getCallee() && - callOp.getCallee().getValue() == kCInterfaceVulkanLaunch && + *callOp.getCallee() == kCInterfaceVulkanLaunch && callOp.getNumOperands() >= kVulkanLaunchNumConfigOperands); } diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp index 750ec9b..98013df 100644 --- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp +++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp @@ -402,7 +402,7 @@ private: // Take advantage if index is constant. MemRefType memRefType = operandType.cast(); if (Optional index = getConstantDimIndex(dimOp)) { - int64_t i = index.getValue(); + int64_t i = *index; if (memRefType.isDynamicDim(i)) { // extract dynamic size from the memref descriptor. MemRefDescriptor descriptor(adaptor.source()); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp index 663fa89..f383f9a 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -121,7 +121,7 @@ static LogicalResult getKernelGlobalVariables( /// Encodes the SPIR-V module's symbolic name into the name of the entry point /// function. static LogicalResult encodeKernelName(spirv::ModuleOp module) { - StringRef spvModuleName = module.sym_name().getValue(); + StringRef spvModuleName = *module.sym_name(); // We already know that the module contains exactly one entry point function // based on `getKernelGlobalVariables()` call. Update this function's name // to: diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp index 1a830b9..6e0f007 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -539,8 +539,7 @@ public: ElementsAttr branchWeights = nullptr; if (auto weights = op.branch_weights()) { VectorType weightType = VectorType::get(2, rewriter.getI32Type()); - branchWeights = - DenseElementsAttr::get(weightType, weights.getValue().getValue()); + branchWeights = DenseElementsAttr::get(weightType, weights->getValue()); } rewriter.replaceOpWithNewOp( @@ -902,7 +901,7 @@ public: /*isVolatile=*/false, /*isNonTemporal=*/false); } - auto memoryAccess = op.memory_access().getValue(); + auto memoryAccess = *op.memory_access(); switch (memoryAccess) { case spirv::MemoryAccess::Aligned: case spirv::MemoryAccess::None: diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp index 134f1c0..133a363 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -1847,7 +1847,7 @@ public: } else if (elementTy.isa() && !padOp.quantization_info()) { constantAttr = rewriter.getIntegerAttr(elementTy, 0); } else if (elementTy.isa() && padOp.quantization_info()) { - int64_t value = padOp.quantization_info().getValue().getInputZp(); + int64_t value = padOp.quantization_info()->getInputZp(); constantAttr = rewriter.getIntegerAttr(elementTy, value); } if (constantAttr) diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp index e75de86..866fea8 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp @@ -540,7 +540,7 @@ public: return success(); } - auto quantizationInfo = op.quantization_info().getValue(); + auto quantizationInfo = *op.quantization_info(); auto aZp = rewriter.create( loc, rewriter.getI32IntegerAttr(quantizationInfo.getAZp())); auto bZp = rewriter.create( @@ -650,7 +650,7 @@ public: return success(); } - auto quantizationInfo = op.quantization_info().getValue(); + auto quantizationInfo = *op.quantization_info(); auto inputZp = rewriter.create( loc, rewriter.getI32IntegerAttr(quantizationInfo.getInputZp())); auto outputZp = rewriter.create( @@ -890,7 +890,7 @@ public: // If we have quantization information we need to apply an offset // for the input zp value. if (op.quantization_info()) { - auto quantizationInfo = op.quantization_info().getValue(); + auto quantizationInfo = *op.quantization_info(); auto inputZp = rewriter.create( loc, b.getIntegerAttr(accETy, quantizationInfo.getInputZp())); Value offset = @@ -926,7 +926,7 @@ public: // If we have quantization information we need to apply output // zeropoint. if (op.quantization_info()) { - auto quantizationInfo = op.quantization_info().getValue(); + auto quantizationInfo = *op.quantization_info(); auto outputZp = rewriter.create( loc, b.getIntegerAttr(scaled.getType(), quantizationInfo.getOutputZp())); diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index a212a49..9ead9e2 100644 --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -171,7 +171,7 @@ static Value generateInBoundsCheck( vector::createOrFoldDimOp(b, loc, xferOp.getSource(), *dim); AffineExpr d0, d1; bindDims(xferOp.getContext(), d0, d1); - Value base = xferOp.getIndices()[dim.getValue()]; + Value base = xferOp.getIndices()[*dim]; Value memrefIdx = makeComposedAffineApply(b, loc, d0 + d1, {base, iv}); cond = lb.create(arith::CmpIPredicate::sgt, memrefDim, memrefIdx); diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp index 00331a9..6a9a0388 100644 --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -634,7 +634,7 @@ Optional MemRefRegion::getRegionSize() { LLVM_DEBUG(llvm::dbgs() << "Dynamic shapes not yet supported\n"); return None; } - return getMemRefEltSizeInBytes(memRefType) * numElements.getValue(); + return getMemRefEltSizeInBytes(memRefType) * *numElements; } /// Returns the size of memref data in bytes if it's statically shaped, None @@ -964,7 +964,7 @@ mlir::computeSliceUnion(ArrayRef opsA, ArrayRef opsB, LLVM_DEBUG(llvm::dbgs() << "Cannot determine if the slice is valid\n"); return SliceComputationResult::GenericFailure; } - if (!isSliceValid.getValue()) + if (!*isSliceValid) return SliceComputationResult::IncorrectSliceFailure; return SliceComputationResult::Success; diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp index 9d22053..b77ef90 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp @@ -639,7 +639,7 @@ static bool canRemoveSrcNodeAfterFusion( return false; } - if (!isMaximal.getValue()) { + if (!*isMaximal) { LLVM_DEBUG(llvm::dbgs() << "Src loop can't be removed: fusion is not maximal\n"); return false; @@ -1247,7 +1247,7 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst, } // Set dstLoopDepth based on best values from search. - *dstLoopDepth = bestDstLoopDepth.getValue(); + *dstLoopDepth = *bestDstLoopDepth; LLVM_DEBUG( llvm::dbgs() << " LoopFusion fusion stats:" diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp index 7e82a47..3cdae8a 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp @@ -73,7 +73,7 @@ static void adjustToDivisorsOfTripCounts(ArrayRef band, continue; // Adjust the tile size to largest factor of the trip count less than // tSize. - uint64_t constTripCount = mayConst.getValue(); + uint64_t constTripCount = *mayConst; if (constTripCount > 1 && tSizeAdjusted > constTripCount / 2) tSizeAdjusted = constTripCount / 2; while (constTripCount % tSizeAdjusted != 0) @@ -129,7 +129,7 @@ void LoopTiling::getTileSizes(ArrayRef band, // Check how many times larger the cache size is when compared to footprint. uint64_t cacheSizeBytes = cacheSizeInKiB * 1024; - uint64_t excessFactor = llvm::divideCeil(fp.getValue(), cacheSizeBytes); + uint64_t excessFactor = llvm::divideCeil(*fp, cacheSizeBytes); if (excessFactor <= 1) { // No need of any tiling - set tile size to 1. std::fill(tileSizes->begin(), tileSizes->end(), 1); diff --git a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp index 1870781..7378418 100644 --- a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp @@ -370,7 +370,7 @@ LogicalResult promoteSingleIterReductionLoop(AffineForOp forOp, bool siblingFusionUser) { // Check if the reduction loop is a single iteration loop. Optional tripCount = getConstantTripCount(forOp); - if (!tripCount || tripCount.getValue() != 1) + if (!tripCount || *tripCount != 1) return failure(); auto iterOperands = forOp.getIterOperands(); auto *parentOp = forOp->getParentOp(); @@ -509,7 +509,7 @@ bool mlir::getLoopNestStats(AffineForOp forOpRoot, LoopNestStats *stats) { return WalkResult::interrupt(); } - stats->tripCountMap[childForOp] = maybeConstTripCount.getValue(); + stats->tripCountMap[childForOp] = *maybeConstTripCount; return WalkResult::advance(); }); return !walkResult.wasInterrupted(); diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp index ea10dbb..09f11eb 100644 --- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp @@ -130,7 +130,7 @@ static void replaceIterArgsAndYieldResults(AffineForOp forOp) { // TODO: extend this for arbitrary affine bounds. LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { Optional tripCount = getConstantTripCount(forOp); - if (!tripCount || tripCount.getValue() != 1) + if (!tripCount || *tripCount != 1) return failure(); if (forOp.getLowerBoundMap().getNumResults() != 1) @@ -250,7 +250,7 @@ LogicalResult mlir::affineForOpBodySkew(AffineForOp forOp, LLVM_DEBUG(forOp.emitRemark("non-constant trip count loop not handled")); return success(); } - uint64_t tripCount = mayBeConstTripCount.getValue(); + uint64_t tripCount = *mayBeConstTripCount; assert(isOpwiseShiftValid(forOp, shifts) && "shifts will lead to an invalid transformation\n"); @@ -1437,7 +1437,7 @@ static bool checkLoopInterchangeDependences( for (unsigned j = 0; j < maxLoopDepth; ++j) { unsigned permIndex = loopPermMapInv[j]; assert(depComps[permIndex].lb); - int64_t depCompLb = depComps[permIndex].lb.getValue(); + int64_t depCompLb = *depComps[permIndex].lb; if (depCompLb > 0) break; if (depCompLb < 0) @@ -2095,7 +2095,7 @@ static LogicalResult generateCopy( return failure(); } - if (numElements.getValue() == 0) { + if (*numElements == 0) { LLVM_DEBUG(llvm::dbgs() << "Nothing to copy\n"); *sizeInBytes = 0; return success(); @@ -2173,7 +2173,7 @@ static LogicalResult generateCopy( // Record it. fastBufferMap[memref] = fastMemRef; // fastMemRefType is a constant shaped memref. - *sizeInBytes = getMemRefSizeInBytes(fastMemRefType).getValue(); + *sizeInBytes = *getMemRefSizeInBytes(fastMemRefType); LLVM_DEBUG(emitRemarkForBlock(*block) << "Creating fast buffer of type " << fastMemRefType << " and size " << llvm::divideCeil(*sizeInBytes, 1024) @@ -2184,8 +2184,7 @@ static LogicalResult generateCopy( *sizeInBytes = 0; } - auto numElementsSSA = - top.create(loc, numElements.getValue()); + auto numElementsSSA = top.create(loc, *numElements); Value dmaStride = nullptr; Value numEltPerDmaStride = nullptr; diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp index b73c903..bd4b9d7 100644 --- a/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp @@ -41,7 +41,7 @@ struct ConstantOpInterface getGlobalFor(constantOp, options.bufferAlignment); if (failed(globalOp)) return failure(); - memref::GlobalOp globalMemref = globalOp.getValue(); + memref::GlobalOp globalMemref = *globalOp; replaceOpWithNewBufferizedOp( rewriter, op, globalMemref.type(), globalMemref.getName()); diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp index 18c2f2e..959d633 100644 --- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp @@ -498,7 +498,7 @@ AsyncRuntimePolicyBasedRefCountingPass::addRefCounting(Value value) { if (failed(refCount)) return failure(); - int cnt = refCount.getValue(); + int cnt = *refCount; // Create `add_ref` operation before the operand owner. if (cnt > 0) { diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp index 9b4831e..3689522 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp @@ -246,8 +246,7 @@ struct CallOpInterface getAliasingOpOperand(op, opResult, state); assert(aliasingOpOperands.size() == 1 && "expected exactly 1 aliasing OpOperand"); - assert(aliasingOpOperands.front()->getOperandNumber() == - maybeEquiv.getValue() && + assert(aliasingOpOperands.front()->getOperandNumber() == *maybeEquiv && "inconsistent analysis state"); #endif return BufferRelation::Equivalent; diff --git a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp index aaaf390..41ce156 100644 --- a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp +++ b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp @@ -745,7 +745,7 @@ static LogicalResult simplifyPassThroughSwitch(SwitchOp op, return failure(); rewriter.replaceOpWithNewOp(op, op.getFlag(), defaultDest, - defaultOperands, caseValues.getValue(), + defaultOperands, *caseValues, newCaseDests, newCaseOperands); return success(); } diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp index a310495..be6dd41 100644 --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -85,7 +85,7 @@ LogicalResult emitc::CallOp::verify() { return emitOpError("callee must not be empty"); if (Optional argsAttr = args()) { - for (Attribute arg : argsAttr.getValue()) { + for (Attribute arg : *argsAttr) { if (arg.getType().isa()) { int64_t index = arg.cast().getInt(); // Args with elements of type index must be in range @@ -101,7 +101,7 @@ LogicalResult emitc::CallOp::verify() { } if (Optional templateArgsAttr = template_args()) { - for (Attribute tArg : templateArgsAttr.getValue()) { + for (Attribute tArg : *templateArgsAttr) { if (!tArg.isa() && !tArg.isa() && !tArg.isa() && !tArg.isa()) return emitOpError("template argument has invalid type"); diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp index 7f830b7..2b0a8ac 100644 --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp @@ -292,7 +292,7 @@ SerializeToHsacoPass::translateToLLVMIR(llvm::LLVMContext &llvmContext) { } llvm::Linker linker(*ret); - for (std::unique_ptr &libModule : mbModules.getValue()) { + for (std::unique_ptr &libModule : *mbModules) { // This bitcode linking code is substantially similar to what is used in // hip-clang It imports the library functions into the module, allowing LLVM // optimization passes (which must run after linking) to optimize across the diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 1ed13fe..63a89d5 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -158,7 +158,7 @@ static ParseResult parseCmpOp(OpAsmParser &parser, OperationState &result) { return parser.emitError(predicateLoc) << "'" << predicateAttr.getValue() << "' is an incorrect value of the 'predicate' attribute"; - predicateValue = static_cast(predicate.getValue()); + predicateValue = static_cast(*predicate); } else { Optional predicate = symbolizeFCmpPredicate(predicateAttr.getValue()); @@ -166,7 +166,7 @@ static ParseResult parseCmpOp(OpAsmParser &parser, OperationState &result) { return parser.emitError(predicateLoc) << "'" << predicateAttr.getValue() << "' is an incorrect value of the 'predicate' attribute"; - predicateValue = static_cast(predicate.getValue()); + predicateValue = static_cast(*predicate); } result.attributes.set("predicate", @@ -2425,7 +2425,7 @@ static ParseResult parseAtomicBinOp(OpAsmParser &parser, OperationState &result, << "' attribute"; } - auto value = static_cast(kind.getValue()); + auto value = static_cast(*kind); auto attr = parser.getBuilder().getI64IntegerAttr(value); result.addAttribute(attrName, attr); @@ -2452,7 +2452,7 @@ static ParseResult parseAtomicOrdering(OpAsmParser &parser, << "' attribute"; } - auto value = static_cast(kind.getValue()); + auto value = static_cast(*kind); auto attr = parser.getBuilder().getI64IntegerAttr(value); result.addAttribute(attrName, attr); diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp index f5439ca..7d4691a 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -372,7 +372,7 @@ LogicalResult MmaOp::verify() { if (mmaShape[0] == 16) { int64_t kFactor; Type multiplicandFragType; - switch (getMultiplicandAPtxType().getValue()) { + switch (*getMultiplicandAPtxType()) { case MMATypes::tf32: kFactor = 4; multiplicandFragType = i32Ty; @@ -421,7 +421,7 @@ LogicalResult MmaOp::verify() { // In the M=8 case, there is only 1 possible case per data type. if (mmaShape[0] == 8) { - if (getMultiplicandAPtxType().getValue() == MMATypes::f16) { + if (*getMultiplicandAPtxType() == MMATypes::f16) { expectedA.emplace_back(2, f16x2Ty); expectedB.emplace_back(2, f16x2Ty); expectedResult.push_back(f16x2x4StructTy); @@ -430,7 +430,7 @@ LogicalResult MmaOp::verify() { expectedC.emplace_back(8, f32Ty); allowedShapes.push_back({8, 8, 4}); } - if (getMultiplicandAPtxType().getValue() == MMATypes::f64) { + if (*getMultiplicandAPtxType() == MMATypes::f64) { Type f64Ty = Float64Type::get(context); expectedA.emplace_back(1, f64Ty); expectedB.emplace_back(1, f64Ty); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 9c6e1b3..e22da09 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1472,7 +1472,7 @@ AffineMap mlir::linalg::extractOrIdentityMap(Optional maybeMap, unsigned rank, MLIRContext *context) { if (maybeMap) - return maybeMap.getValue(); + return *maybeMap; if (rank == 0) return AffineMap::get(context); return AffineMap::getMultiDimIdentityMap(rank, context); diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp index 2d35deb..f8bb0e4 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @@ -841,7 +841,7 @@ public: fuseWithReshapeByExpansion(genericOp, reshapeOp, opOperand, rewriter); if (!replacementValues) return failure(); - rewriter.replaceOp(genericOp, replacementValues.getValue()); + rewriter.replaceOp(genericOp, *replacementValues); return success(); } return failure(); @@ -876,7 +876,7 @@ struct FoldReshapeWithGenericOpByExpansion producer, reshapeOp, producer.getOutputOperand(0), rewriter); if (!replacementValues) return failure(); - rewriter.replaceOp(reshapeOp, replacementValues.getValue()); + rewriter.replaceOp(reshapeOp, *replacementValues); return success(); } @@ -1465,7 +1465,7 @@ public: genericOp, "failed to do the fusion by collapsing transformation"); } - rewriter.replaceOp(genericOp, replacements.getValue()); + rewriter.replaceOp(genericOp, *replacements); return success(); } return failure(); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index 4a3a538..2b783a8 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -302,8 +302,7 @@ findFusableProducer(OpOperand &consumerOpOperand, elem.getIndexingOpViewOperandNum(); return isa(elem.getDependentOp()) && v == consumerOpOperand.get() && operandNum && - operandNum.getValue() == - consumerOpOperand.getOperandNumber(); + *operandNum == consumerOpOperand.getOperandNumber(); })) { // Consumer consumes this view, `isStructurallyFusableProducer` also // checks whether it is a strict subview of the producer view. @@ -533,7 +532,7 @@ static bool doesTransposeAccess(AffineMap map, lastFusableLoop = pos; continue; } - if (pos <= lastFusableLoop.getValue()) + if (pos <= *lastFusableLoop) return true; lastFusableLoop = pos; } diff --git a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp index ca968a4..669d596 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp @@ -288,8 +288,7 @@ LogicalResult TileLoopNest::tileRootOp( .setTileSizes(tileSizes) .setLoopType(LinalgTilingLoopType::Loops); if (tileDistribution) - tilingOptions = - tilingOptions.setDistributionOptions(tileDistribution.getValue()); + tilingOptions = tilingOptions.setDistributionOptions(*tileDistribution); // TODO: Propagate RewriterBase everywhere. IRRewriter rewriter(b); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index bba097b..a3b95b3 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -116,7 +116,7 @@ bool mlir::linalg::LinalgTransformationFilter::hasReplacementFilter( return false; auto attr = op->getAttr(LinalgTransforms::kLinalgTransformMarker) .dyn_cast(); - return attr && attr == replacement.getValue(); + return attr && attr == *replacement; } LinalgTilingOptions & @@ -239,7 +239,7 @@ static FailureOr padOperandToSmallestStaticBoundingBox( LLVM_DEBUG(DBGS() << "No constant bounding box can be found for padding"); return failure(); } - paddedShape[shapeIdx++] = upperBound.getValue(); + paddedShape[shapeIdx++] = *upperBound; } assert(shapeIdx == static_cast(shape.size()) && "expect the dynamic and static ranks to match"); @@ -393,7 +393,7 @@ LogicalResult mlir::linalg::LinalgBaseTileAndFusePattern::matchAndRewrite( // could assert, but continue if this is not the case. if (!operandNumber) continue; - if (!fusionOptions.indicesToFuse.count(operandNumber.getValue())) + if (!fusionOptions.indicesToFuse.count(*operandNumber)) continue; if (isa(dependence.getDependentOp())) producers.insert(dependence.getDependentOp()); @@ -554,7 +554,7 @@ mlir::linalg::LinalgPaddingPattern::returningMatchAndRewrite( padOp, en.value(), transposeVector, hoistedOp, transposeOps); if (failed(newResult)) continue; - rewriter.replaceOp(padOp, newResult.getValue()); + rewriter.replaceOp(padOp, *newResult); // Do not apply hoist padding to the newly introduced transpose operations. for (GenericOp transposeOp : transposeOps) @@ -562,7 +562,7 @@ mlir::linalg::LinalgPaddingPattern::returningMatchAndRewrite( } // Replace the original operation to pad. - rewriter.replaceOp(linalgOp, newResults.getValue()); + rewriter.replaceOp(linalgOp, *newResults); filter.replaceLinalgTransformationFilter(rewriter, paddedOp); return paddedOp; @@ -969,7 +969,7 @@ LogicalResult ExtractSliceOfPadTensorSwapPattern::matchAndRewrite( bool zeroSliceGuard = true; if (controlFn) { if (Optional control = controlFn(sliceOp)) - zeroSliceGuard = control.getValue(); + zeroSliceGuard = *control; else return failure(); } diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp index c9eb42b..6e68686 100644 --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -257,8 +257,7 @@ void getUpperBoundForIndex(Value value, AffineMap &boundMap, if (!ubConst) return; - boundMap = - AffineMap::getConstantMap(ubConst.getValue(), value.getContext()); + boundMap = AffineMap::getConstantMap(*ubConst, value.getContext()); return; } @@ -714,7 +713,7 @@ void GenerateLoopNest::doit( // Modify the lb, ub, and step based on the distribution options. SmallVector distributionMethod; if (distributionOptions) { - auto &options = distributionOptions.getValue(); + auto &options = *distributionOptions; distributionMethod.assign(distributionOptions->distributionMethod.begin(), distributionOptions->distributionMethod.end()); SmallVector parallelLoopRanges; diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp index 5f26e4b..ee1218a 100644 --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -762,7 +762,7 @@ LogicalResult DimOp::verify() { // Check that constant index is not knowingly out of range. auto type = source().getType(); if (auto memrefType = type.dyn_cast()) { - if (index.getValue() >= memrefType.getRank()) + if (*index >= memrefType.getRank()) return emitOpError("index is out of range"); } else if (type.isa()) { // Assume index to be in range. @@ -1316,7 +1316,7 @@ LogicalResult GlobalOp::verify() { } if (Optional alignAttr = alignment()) { - uint64_t alignment = alignAttr.getValue(); + uint64_t alignment = *alignAttr; if (!llvm::isPowerOf2_64(alignment)) return emitError() << "alignment attribute value " << alignment @@ -2452,7 +2452,7 @@ static MemRefType getCanonicalSubViewResultType( } AffineMap layoutMap = nonRankReducedType.getLayout().getAffineMap(); if (!layoutMap.isIdentity()) - layoutMap = getProjectedMap(layoutMap, unusedDims.getValue()); + layoutMap = getProjectedMap(layoutMap, *unusedDims); return MemRefType::get(shape, nonRankReducedType.getElementType(), layoutMap, nonRankReducedType.getMemorySpace()); } @@ -2499,7 +2499,7 @@ static bool isTrivialSubViewOp(SubViewOp subViewOp) { ArrayRef sourceShape = subViewOp.getSourceType().getShape(); for (const auto &size : llvm::enumerate(mixedSizes)) { Optional intValue = getConstantIntValue(size.value()); - if (!intValue || intValue.getValue() != sourceShape[size.index()]) + if (!intValue || *intValue != sourceShape[size.index()]) return false; } // All conditions met. The `SubViewOp` is foldable as a no-op. diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp index 24c9a4c..b480016e 100644 --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -791,8 +791,7 @@ LogicalResult OrderedOp::verify() { << "nested inside a worksharing-loop with ordered " << "clause with parameter present"; - if (container.ordered_valAttr().getInt() != - (int64_t)num_loops_val().getValue()) + if (container.ordered_valAttr().getInt() != (int64_t)*num_loops_val()) return emitOpError() << "number of variables in depend clause does not " << "match number of iteration variables in the " << "doacross loop"; diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index 40275ea..012499f 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -497,7 +497,7 @@ void ForOp::getSuccessorRegions(Optional index, } // Otherwise, the loop may branch back to itself or the parent operation. - assert(index.getValue() == 0 && "expected loop region"); + assert(*index == 0 && "expected loop region"); regions.push_back(RegionSuccessor(&getLoopBody(), getRegionIterArgs())); regions.push_back(RegionSuccessor(getResults())); } diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp index 98cc0dc..ee717d2 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -268,7 +268,7 @@ static LogicalResult parseOptionalArrayStride(const SPIRVDialect &dialect, if (!optStride) return failure(); - if (!(stride = optStride.getValue())) { + if (!(stride = *optStride)) { parser.emitError(strideLoc, "ArrayStride must be greater than zero"); return failure(); } @@ -507,7 +507,7 @@ template struct ParseCommaSeparatedList { Optional> operator()(SPIRVDialect const &dialect, DialectAsmParser &parser) const { if (auto value = parseAndVerify(dialect, parser)) - return std::tuple(value.getValue()); + return std::tuple(*value); return llvm::None; } }; @@ -542,7 +542,7 @@ static Type parseImageType(SPIRVDialect const &dialect, if (parser.parseGreater()) return Type(); - return ImageType::get(value.getValue()); + return ImageType::get(*value); } // sampledImage-type :: = `!spv.sampledImage<` image-type `>` diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp index f52cd9f..4e7338f 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -188,7 +188,7 @@ parseEnumStrAttr(EnumClass &value, OpAsmParser &parser, return parser.emitError(loc, "invalid ") << attrName << " attribute specification: " << attrVal; } - value = attrOptional.getValue(); + value = *attrOptional; return success(); } @@ -2497,7 +2497,7 @@ void spirv::GlobalVariableOp::print(OpAsmPrinter &printer) { // Print optional initializer if (auto initializer = this->initializer()) { printer << " " << kInitializerAttrName << '('; - printer.printSymbolName(initializer.getValue()); + printer.printSymbolName(*initializer); printer << ')'; elidedAttrs.push_back(kInitializerAttrName); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp index bad8922..9a94f19 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -207,7 +207,7 @@ getTypeNumBytes(const SPIRVTypeConverter::Options &options, Type type) { auto elementSize = getTypeNumBytes(options, vecType.getElementType()); if (!elementSize) return llvm::None; - return vecType.getNumElements() * elementSize.getValue(); + return vecType.getNumElements() * *elementSize; } if (auto memRefType = type.dyn_cast()) { @@ -239,7 +239,7 @@ getTypeNumBytes(const SPIRVTypeConverter::Options &options, Type type) { for (const auto &shape : enumerate(dims)) memrefSize = std::max(memrefSize, shape.value() * strides[shape.index()]); - return (offset + memrefSize) * elementSize.getValue(); + return (offset + memrefSize) * *elementSize; } if (auto tensorType = type.dyn_cast()) { @@ -250,7 +250,7 @@ getTypeNumBytes(const SPIRVTypeConverter::Options &options, Type type) { if (!elementSize) return llvm::None; - int64_t size = elementSize.getValue(); + int64_t size = *elementSize; for (auto shape : tensorType.getShape()) size *= shape; @@ -604,7 +604,7 @@ static spirv::GlobalVariableOp getBuiltinVariable(Block &body, spirv::SPIRVDialect::getAttributeName( spirv::Decoration::BuiltIn))) { auto varBuiltIn = spirv::symbolizeBuiltIn(builtinAttr.getValue()); - if (varBuiltIn && varBuiltIn.getValue() == builtin) { + if (varBuiltIn && *varBuiltIn == builtin) { return varOp; } } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp index e147ecd..dae3784 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -415,7 +415,7 @@ public: return failure(); // Generate the call. Value src = adaptor.getOperands()[0]; - int64_t idx = index.getValue(); + int64_t idx = *index; rewriter.replaceOp(op, genDimSizeCall(rewriter, op, enc, src, idx)); return success(); } diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp index 19283f1..6352db7 100644 --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -309,7 +309,7 @@ LogicalResult DimOp::verify() { // Check that constant index is not knowingly out of range. auto type = source().getType(); if (auto tensorType = type.dyn_cast()) { - if (index.getValue() >= tensorType.getRank()) + if (*index >= tensorType.getRank()) return emitOpError("index is out of range"); } else if (type.isa()) { // Assume index to be in range. @@ -1138,7 +1138,7 @@ llvm::SmallBitVector ExtractSliceOp::getDroppedDims() { // If the size is not 1, or if the current matched dimension of the result // is the same static shape as the size value (which is 1), then the // dimension is preserved. - if (!sizeVal || sizeVal.getValue() != 1 || + if (!sizeVal || *sizeVal != 1 || (shapePos < resultShape.size() && resultShape[shapePos] == 1)) { shapePos++; continue; diff --git a/mlir/lib/Dialect/Tensor/Transforms/SplitPadding.cpp b/mlir/lib/Dialect/Tensor/Transforms/SplitPadding.cpp index fbf3ca1..79c9246 100644 --- a/mlir/lib/Dialect/Tensor/Transforms/SplitPadding.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/SplitPadding.cpp @@ -27,7 +27,7 @@ using namespace mlir; /// Returns true if the the given `attrOrValue` is a constant zero. static bool isZero(OpFoldResult attrOrValue) { if (Optional val = getConstantIntValue(attrOrValue)) - return val.getValue() == 0; + return *val == 0; return false; } diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp index 562f5db..89fc4e3 100644 --- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp @@ -347,7 +347,7 @@ struct MaterializePadValue : public OpRewritePattern { } else if (elementTy.isa() && !op.quantization_info()) { constantAttr = rewriter.getIntegerAttr(elementTy, 0); } else if (elementTy.isa() && op.quantization_info()) { - auto value = op.quantization_info().getValue().getInputZp(); + auto value = op.quantization_info()->getInputZp(); constantAttr = rewriter.getIntegerAttr(elementTy, value); } diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeConv2D.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeConv2D.cpp index ef94e55..4361100 100644 --- a/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeConv2D.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeConv2D.cpp @@ -87,7 +87,7 @@ struct Conv2DIsFullyConnected : public OpRewritePattern { rewriter .create( op.getLoc(), fullyConnectedShapeType, reshapedInput, - reshapedWeight, op.bias(), op.quantization_info().getValue()) + reshapedWeight, op.bias(), *op.quantization_info()) .getResult(); } else { fullyConnectedValue = rewriter diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeTransposeConv.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeTransposeConv.cpp index d4845dd..120e502 100644 --- a/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeTransposeConv.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaDecomposeTransposeConv.cpp @@ -134,8 +134,7 @@ public: conv2d = rewriter.create( loc, resultTy, input, reverse2, bias, rewriter.getI64ArrayAttr(convPad), rewriter.getI64ArrayAttr(stride), - rewriter.getI64ArrayAttr(dilation), - op.quantization_info().getValue()); + rewriter.getI64ArrayAttr(dilation), *op.quantization_info()); } else { conv2d = rewriter.create( loc, resultTy, input, reverse2, bias, @@ -304,7 +303,7 @@ public: /*pad=*/rewriter.getI64ArrayAttr({0, 0, 0, 0}), /*stride=*/rewriter.getI64ArrayAttr({1, 1}), /*dilation=*/rewriter.getI64ArrayAttr({1, 1}), - op.quantization_info().getValue()) + *op.quantization_info()) .getResult(); } else { conv2d = createOpAndInfer( diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index d7c306c..ebf3662 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -272,7 +272,7 @@ Attribute CombiningKindAttr::parse(AsmParser &parser, Type type) { if (failed(parser.parseGreater())) return {}; - return CombiningKindAttr::get(kind.getValue(), parser.getContext()); + return CombiningKindAttr::get(*kind, parser.getContext()); } Attribute VectorDialect::parseAttribute(DialectAsmParser &parser, diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index cd61a9d..72e6c05 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -303,7 +303,7 @@ ExecutionEngine::create(ModuleOp m, const ExecutionEngineOptions &options) { auto compileFunctionCreator = [&](JITTargetMachineBuilder jtmb) -> Expected> { if (options.jitCodeGenOptLevel) - jtmb.setCodeGenOptLevel(options.jitCodeGenOptLevel.getValue()); + jtmb.setCodeGenOptLevel(*options.jitCodeGenOptLevel); auto tm = jtmb.createTargetMachine(); if (!tm) return tm.takeError(); diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp index 827d9b2..53fdde6 100644 --- a/mlir/lib/ExecutionEngine/JitRunner.cpp +++ b/mlir/lib/ExecutionEngine/JitRunner.cpp @@ -148,8 +148,7 @@ static Error compileAndExecute(Options &options, ModuleOp module, CompileAndExecuteConfig config, void **args) { Optional jitCodeGenOptLevel; if (auto clOptLevel = getCommandLineOptLevel(options)) - jitCodeGenOptLevel = - static_cast(clOptLevel.getValue()); + jitCodeGenOptLevel = static_cast(*clOptLevel); // If shared library implements custom mlir-runner library init and destroy // functions, we'll use them to register the library with the execution diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 44bf53b..5a19535 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -580,8 +580,7 @@ static AffineExpr simplifyAdd(AffineExpr lhs, AffineExpr rhs) { if (rLhsConst && rRhsConst && firstExpr == secondExpr) return getAffineBinaryOpExpr( AffineExprKind::Mul, firstExpr, - getAffineConstantExpr(rLhsConst.getValue() + rRhsConst.getValue(), - lhs.getContext())); + getAffineConstantExpr(*rLhsConst + *rRhsConst, lhs.getContext())); // When doing successive additions, bring constant to the right: turn (d0 + 2) // + d1 into (d0 + d1) + 2. diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp index 0df2f59..efc1c22 100644 --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -325,7 +325,7 @@ Attribute Parser::parseFloatAttr(Type type, bool isNegative) { if (!type.isa()) return (emitError("floating point value not valid for specified type"), nullptr); - return FloatAttr::get(type, isNegative ? -val.getValue() : val.getValue()); + return FloatAttr::get(type, isNegative ? -*val : *val); } /// Construct an APint from a parsed value, a known attribute type and @@ -696,7 +696,7 @@ DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, } std::string data; - if (parseElementAttrHexValues(p, hexStorage.getValue(), data)) + if (parseElementAttrHexValues(p, *hexStorage, data)) return nullptr; ArrayRef rawData(data.data(), data.size()); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 551535e..170d571 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -776,7 +776,7 @@ ParseResult OperationParser::parseSSAUse(UnresolvedOperand &result, return emitError("result number not allowed in argument list"); if (auto value = getToken().getHashIdentifierNumber()) - result.number = value.getValue(); + result.number = *value; else return emitError("invalid SSA value result number"); consumeToken(Token::hash_identifier); diff --git a/mlir/lib/Parser/TypeParser.cpp b/mlir/lib/Parser/TypeParser.cpp index a391e89..52fae4b 100644 --- a/mlir/lib/Parser/TypeParser.cpp +++ b/mlir/lib/Parser/TypeParser.cpp @@ -161,7 +161,7 @@ ParseResult Parser::parseStridedLayout(int64_t &offset, bool question = getToken().is(Token::question); if (!maybeOffset && !question) return emitWrongTokenError("invalid offset"); - offset = maybeOffset ? static_cast(maybeOffset.getValue()) + offset = maybeOffset ? static_cast(*maybeOffset) : MemRefType::getDynamicStrideOrOffset(); consumeToken(); @@ -323,7 +323,7 @@ Type Parser::parseNonFunctionType() { signSemantics = *signedness ? IntegerType::Signed : IntegerType::Unsigned; consumeToken(Token::inttype); - return IntegerType::get(getContext(), width.getValue(), signSemantics); + return IntegerType::get(getContext(), *width, signSemantics); } // float-type @@ -590,7 +590,7 @@ ParseResult Parser::parseIntegerInDimensionList(int64_t &value) { if (!dimension || *dimension > (uint64_t)std::numeric_limits::max()) return emitError("invalid dimension"); - value = (int64_t)dimension.getValue(); + value = (int64_t)*dimension; consumeToken(Token::integer); } return success(); diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp index 4583ad2..d0cb2d3 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -536,7 +536,7 @@ convertOmpOrdered(Operation &opInst, llvm::IRBuilderBase &builder, omp::ClauseDepend dependType = *orderedOp.depend_type_val(); bool isDependSource = dependType == omp::ClauseDepend::dependsource; - unsigned numLoops = orderedOp.num_loops_val().getValue(); + unsigned numLoops = *orderedOp.num_loops_val(); SmallVector vecValues = moduleTranslation.lookupValues(orderedOp.depend_vec_vars()); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 0be3828..923cffc1 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1005,7 +1005,7 @@ LogicalResult ModuleTranslation::createAliasScopeMetadata() { llvm::SmallVector operands; operands.push_back({}); // Placeholder for self-reference if (Optional description = op.getDescription()) - operands.push_back(llvm::MDString::get(ctx, description.getValue())); + operands.push_back(llvm::MDString::get(ctx, *description)); llvm::MDNode *domain = llvm::MDNode::get(ctx, operands); domain->replaceOperandWith(0, domain); // Self-reference for uniqueness aliasScopeDomainMetadataMapping.insert({op, domain}); @@ -1024,7 +1024,7 @@ LogicalResult ModuleTranslation::createAliasScopeMetadata() { operands.push_back({}); // Placeholder for self-reference operands.push_back(domain); if (Optional description = op.getDescription()) - operands.push_back(llvm::MDString::get(ctx, description.getValue())); + operands.push_back(llvm::MDString::get(ctx, *description)); llvm::MDNode *scope = llvm::MDNode::get(ctx, operands); scope->replaceOperandWith(0, scope); // Self-reference for uniqueness aliasScopeMetadataMapping.insert({op, scope}); diff --git a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp index d0e7f77..cdf7fc5 100644 --- a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp @@ -143,7 +143,7 @@ Serializer::processSpecConstantOperationOp(spirv::SpecConstantOperationOp op) { return failure(); } - operands.push_back(static_cast(enclosedOpcode.getValue())); + operands.push_back(static_cast(*enclosedOpcode)); // Append operands to the enclosed op to the list of operands. for (Value operand : enclosedOp.getOperands()) { @@ -332,7 +332,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) { // Encode initialization. if (auto initializer = varOp.initializer()) { - auto initializerID = getVariableID(initializer.getValue()); + auto initializerID = getVariableID(*initializer); if (!initializerID) { return emitError(varOp.getLoc(), "invalid usage of undefined variable as initializer"); diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp index 7405821..942650b 100644 --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp @@ -210,7 +210,7 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, << attrName; } SmallVector args; - switch (decoration.getValue()) { + switch (*decoration) { case spirv::Decoration::Binding: case spirv::Decoration::DescriptorSet: case spirv::Decoration::Location: @@ -223,7 +223,7 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, if (auto strAttr = attr.getValue().dyn_cast()) { auto enumVal = spirv::symbolizeBuiltIn(strAttr.getValue()); if (enumVal) { - args.push_back(static_cast(enumVal.getValue())); + args.push_back(static_cast(*enumVal)); break; } return emitError(loc, "invalid ") @@ -244,7 +244,7 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, default: return emitError(loc, "unhandled decoration ") << decorationName; } - return emitDecoration(resultID, decoration.getValue(), args); + return emitDecoration(resultID, *decoration, args); } LogicalResult Serializer::processName(uint32_t resultID, StringRef name) { diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 6582be4..e205bf5 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1337,7 +1337,7 @@ FailureOr ConversionPatternRewriterImpl::convertBlockSignature( argReplacements); if (failed(result)) return failure(); - if (Block *newBlock = result.getValue()) { + if (Block *newBlock = *result) { if (newBlock != block) blockActions.push_back(BlockAction::getTypeConversion(newBlock)); } @@ -3044,7 +3044,7 @@ Value TypeConverter::materializeConversion( OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) { for (MaterializationCallbackFn &fn : llvm::reverse(materializations)) if (Optional result = fn(builder, resultType, inputs, loc)) - return result.getValue(); + return *result; return nullptr; } diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h index d7b1163..bd6421d 100644 --- a/mlir/test/lib/Dialect/Test/TestTypes.h +++ b/mlir/test/lib/Dialect/Test/TestTypes.h @@ -61,7 +61,7 @@ struct FieldParser { auto value = FieldParser::parse(parser); if (failed(value)) return failure(); - return test::CustomParam{value.getValue()}; + return test::CustomParam{*value}; } }; diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp index 99d3563..9140c53 100644 --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -419,7 +419,7 @@ findTypeValue(StringRef typeVar, SmallVectorImpl &args) { it.value().kind != LinalgOperandDefKind::Scalar && it.value().kind != LinalgOperandDefKind::OutputTensor) continue; - if (it.value().typeVar.getValue() == typeVar) + if (*it.value().typeVar == typeVar) return llvm::formatv("block.getArgument({0}).getType()", it.index()) .str(); } diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index ce0a9af..212fe0e 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -1043,7 +1043,7 @@ static void genEnumAttrParser(const NamedAttribute *var, MethodBody &body, { llvm::raw_string_ostream os(attrBuilderStr); os << tgfmt(enumAttr.getConstBuilderTemplate(), &attrTypeCtx, - "attrOptional.getValue()"); + "attrOptional.value()"); } // Build a string containing the cases that can be formatted as a keyword. -- 2.7.4