diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -365,7 +365,7 @@ static mlir::LogicalResult verify(StructAccessOp op) { StructType structTy = op.input().getType().cast(); - size_t index = op.index().getZExtValue(); + size_t index = op.index(); if (index >= structTy.getNumElementTypes()) return op.emitOpError() << "index should be within the range of the input struct type"; diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -42,7 +42,7 @@ if (!structAttr) return nullptr; - size_t elementIndex = index().getZExtValue(); + size_t elementIndex = index(); return structAttr[elementIndex]; } diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -215,17 +215,9 @@ // Common code definition that is used to verify and set the alignment attribute // of LLVM ops that accept such an attribute. class MemoryOpWithAlignmentBase { - code alignmentVerifierCode = [{ - if (alignment().hasValue()) { - auto align = alignment().getValue().getSExtValue(); - if (align < 0) - return emitOpError("expected positive alignment"); - } - return success(); - }]; code setAlignmentCode = [{ if ($alignment.hasValue()) { - auto align = $alignment.getValue().getZExtValue(); + auto align = $alignment.getValue(); if (align != 0) inst->setAlignment(llvm::Align(align)); } @@ -266,7 +258,6 @@ }]>]; let parser = [{ return parseAllocaOp(parser, result); }]; let printer = [{ printAllocaOp(p, *this); }]; - let verifier = alignmentVerifierCode; } def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", [NoSideEffect]>, Arguments<(ins LLVM_Type:$base, Variadic:$indices)>, @@ -301,7 +292,6 @@ "bool isNonTemporal = false">]; let parser = [{ return parseLoadOp(parser, result); }]; let printer = [{ printLoadOp(p, *this); }]; - let verifier = alignmentVerifierCode; } def LLVM_StoreOp : MemoryOpWithAlignmentAndAttributes, @@ -321,7 +311,6 @@ ]; let parser = [{ return parseStoreOp(parser, result); }]; let printer = [{ printStoreOp(p, *this); }]; - let verifier = alignmentVerifierCode; } // Casts. @@ -646,7 +635,7 @@ OpBuilder<"OpBuilder &builder, OperationState &result, GlobalOp global, " "ArrayRef attrs = {}", [{ build(builder, result, - global.getType().getPointerTo(global.addr_space().getZExtValue()), + global.getType().getPointerTo(global.addr_space()), global.sym_name(), attrs);}]>, OpBuilder<"OpBuilder &builder, OperationState &result, LLVMFuncOp func, " @@ -917,8 +906,8 @@ llvm::Align align = dl.getABITypeAlign( $data->getType()->getPointerElementType()); $res = mb.CreateColumnMajorLoad( - $data, align, $stride, $isVolatile.getZExtValue(), $rows.getZExtValue(), - $columns.getZExtValue()); + $data, align, $stride, $isVolatile, $rows, + $columns); }]; let assemblyFormat = "$data `,` `<` `stride` `=` $stride `>` attr-dict" "`:` type($res) `from` type($data) `stride` type($stride)"; @@ -943,8 +932,8 @@ llvm::Align align = dl.getABITypeAlign( $data->getType()->getPointerElementType()); mb.CreateColumnMajorStore( - $matrix, $data, align, $stride, $isVolatile.getZExtValue(), - $rows.getZExtValue(), $columns.getZExtValue()); + $matrix, $data, align, $stride, $isVolatile, + $rows, $columns); }]; let assemblyFormat = "$matrix `,` $data `,` `<` `stride` `=` $stride `>` " "attr-dict`:` type($matrix) `to` type($data) `stride` type($stride)"; @@ -960,8 +949,8 @@ string llvmBuilder = [{ llvm::MatrixBuilder mb(builder); $res = mb.CreateMatrixMultiply( - $lhs, $rhs, $lhs_rows.getZExtValue(), $lhs_columns.getZExtValue(), - $rhs_columns.getZExtValue()); + $lhs, $rhs, $lhs_rows, $lhs_columns, + $rhs_columns); }]; let assemblyFormat = "$lhs `,` $rhs attr-dict " "`:` `(` type($lhs) `,` type($rhs) `)` `->` type($res)"; @@ -975,7 +964,7 @@ string llvmBuilder = [{ llvm::MatrixBuilder mb(builder); $res = mb.CreateMatrixTranspose( - $matrix, $rows.getZExtValue(), $columns.getZExtValue()); + $matrix, $rows, $columns); }]; let assemblyFormat = "$matrix attr-dict `:` type($matrix) `into` type($res)"; } @@ -999,9 +988,9 @@ Variadic:$pass_thru, I32Attr:$alignment)> { string llvmBuilder = [{ $res = $pass_thru.empty() ? builder.CreateMaskedLoad( - $data, llvm::Align($alignment.getZExtValue()), $mask) : + $data, llvm::Align($alignment), $mask) : builder.CreateMaskedLoad( - $data, llvm::Align($alignment.getZExtValue()), $mask, $pass_thru[0]); + $data, llvm::Align($alignment), $mask, $pass_thru[0]); }]; let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)"; @@ -1014,7 +1003,7 @@ I32Attr:$alignment)> { string llvmBuilder = [{ builder.CreateMaskedStore( - $value, $data, llvm::Align($alignment.getZExtValue()), $mask); + $value, $data, llvm::Align($alignment), $mask); }]; let assemblyFormat = "$value `,` $data `,` $mask attr-dict `:` " "type($value) `,` type($mask) `into` type($data)"; @@ -1027,9 +1016,9 @@ Variadic:$pass_thru, I32Attr:$alignment)> { string llvmBuilder = [{ $res = $pass_thru.empty() ? builder.CreateMaskedGather( - $ptrs, llvm::Align($alignment.getZExtValue()), $mask) : + $ptrs, llvm::Align($alignment), $mask) : builder.CreateMaskedGather( - $ptrs, llvm::Align($alignment.getZExtValue()), $mask, $pass_thru[0]); + $ptrs, llvm::Align($alignment), $mask, $pass_thru[0]); }]; let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)"; @@ -1042,7 +1031,7 @@ I32Attr:$alignment)> { string llvmBuilder = [{ builder.CreateMaskedScatter( - $value, $ptrs, llvm::Align($alignment.getZExtValue()), $mask); + $value, $ptrs, llvm::Align($alignment), $mask); }]; let assemblyFormat = "$value `,` $ptrs `,` $mask attr-dict `:` " "type($value) `,` type($mask) `into` type($ptrs)"; diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -477,9 +477,9 @@ }; } - unsigned getNumInputs() { return args_in().getSExtValue(); } + unsigned getNumInputs() { return args_in(); } - unsigned getNumOutputs() { return args_out().getSExtValue(); } + unsigned getNumOutputs() { return args_out(); } StringRef getLibraryCallName() { return library_call().hasValue() ? library_call().getValue() : ""; @@ -498,7 +498,7 @@ llvm::Optional getSymbolSource() { auto ss = symbol_source(); return ss.hasValue() ? - llvm::Optional(ss.getValue().getLimitedValue()) : llvm::None; + llvm::Optional(ss.getValue()) : llvm::None; } }]; diff --git a/mlir/include/mlir/Dialect/Quant/QuantOps.td b/mlir/include/mlir/Dialect/Quant/QuantOps.td --- a/mlir/include/mlir/Dialect/Quant/QuantOps.td +++ b/mlir/include/mlir/Dialect/Quant/QuantOps.td @@ -248,7 +248,7 @@ auto shape = tensorArg.getShape(); auto argSliceSize = std::accumulate(std::next(shape.begin(), - axis()->getSExtValue()), shape.end(), 1, std::multiplies()); + *axis()), shape.end(), 1, std::multiplies()); auto axisStatsType = axisStats()->getType(); if (!axisStatsType.getElementType().isa()) { diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -2045,20 +2045,6 @@ IntMaxValue<3>]>:$localityHint, BoolAttr:$isDataCache); - let builders = [OpBuilder< - "OpBuilder &builder, OperationState &result, Value memref," - "ArrayRef indices, bool isWrite, unsigned hint, bool isData", - [{ - auto hintAttr = builder.getI32IntegerAttr(hint); - auto isWriteAttr = builder.getBoolAttr(isWrite); - auto isDataCacheAttr = builder.getBoolAttr(isData); - result.addOperands(memref); - result.addOperands(indices); - result.addAttribute("localityHint", hintAttr); - result.addAttribute("isWrite", isWriteAttr); - result.addAttribute("isDataCache", isDataCacheAttr); - }]>]; - let extraClassDeclaration = [{ MemRefType getMemRefType() { return memref().getType().cast(); diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -904,12 +904,24 @@ descr> { let returnType = [{ ::llvm::APInt }]; } +// Base class for signless integer attributes of fixed width that have a +// correpsonding C++ type. +class TypedSignlessIntegerAttrBase + : SignlessIntegerAttrBase { + let returnType = retType; + let convertFromStorage = "$_self.getValue().getZExtValue()"; +} -def I1Attr : SignlessIntegerAttrBase; -def I8Attr : SignlessIntegerAttrBase; -def I16Attr : SignlessIntegerAttrBase; -def I32Attr : SignlessIntegerAttrBase; -def I64Attr : SignlessIntegerAttrBase; +def I1Attr : TypedSignlessIntegerAttrBase< + I1, "bool", "1-bit signless integer attribute">; +def I8Attr : TypedSignlessIntegerAttrBase< + I8, "uint8_t", "8-bit signless integer attribute">; +def I16Attr : TypedSignlessIntegerAttrBase< + I16, "uint16_t", "16-bit signless integer attribute">; +def I32Attr : TypedSignlessIntegerAttrBase< + I32, "uint32_t", "32-bit signless integer attribute">; +def I64Attr : TypedSignlessIntegerAttrBase< + I64, "uint64_t", "64-bit signless integer attribute">; // Base class for signed integer attributes of fixed width. class SignedIntegerAttrBase : @@ -921,17 +933,24 @@ descr> { let returnType = [{ ::llvm::APInt }]; } +// Base class for signed integer attributes of fixed width that have a +// correpsonding C++ type. +class TypedSignedIntegerAttrBase + : SignedIntegerAttrBase { + let returnType = retType; + let convertFromStorage = "$_self.getValue().getSExtValue()"; +} -def SI1Attr : SignedIntegerAttrBase< - SI1, "1-bit signed integer attribute">; -def SI8Attr : SignedIntegerAttrBase< - SI8, "8-bit signed integer attribute">; -def SI16Attr : SignedIntegerAttrBase< - SI16, "16-bit signed integer attribute">; -def SI32Attr : SignedIntegerAttrBase< - SI32, "32-bit signed integer attribute">; -def SI64Attr : SignedIntegerAttrBase< - SI64, "64-bit signed integer attribute">; +def SI1Attr : TypedSignedIntegerAttrBase< + SI1, "bool", "1-bit signed integer attribute">; +def SI8Attr : TypedSignedIntegerAttrBase< + SI8, "int8_t", "8-bit signed integer attribute">; +def SI16Attr : TypedSignedIntegerAttrBase< + SI16, "int16_t", "16-bit signed integer attribute">; +def SI32Attr : TypedSignedIntegerAttrBase< + SI32, "int32_t", "32-bit signed integer attribute">; +def SI64Attr : TypedSignedIntegerAttrBase< + SI64, "int64_t", "64-bit signed integer attribute">; // Base class for unsigned integer attributes of fixed width. class UnsignedIntegerAttrBase : @@ -943,17 +962,24 @@ descr> { let returnType = [{ ::llvm::APInt }]; } +// Base class for unsigned integer attributes of fixed width that have a +// correpsonding C++ type. +class TypedUnsignedIntegerAttrBase + : UnsignedIntegerAttrBase { + let returnType = retType; + let convertFromStorage = "$_self.getValue().getZExtValue()"; +} -def UI1Attr : UnsignedIntegerAttrBase< - UI1, "1-bit unsigned integer attribute">; -def UI8Attr : UnsignedIntegerAttrBase< - UI8, "8-bit unsigned integer attribute">; -def UI16Attr : UnsignedIntegerAttrBase< - UI16, "16-bit unsigned integer attribute">; -def UI32Attr : UnsignedIntegerAttrBase< - UI32, "32-bit unsigned integer attribute">; -def UI64Attr : UnsignedIntegerAttrBase< - UI64, "64-bit unsigned integer attribute">; +def UI1Attr : TypedUnsignedIntegerAttrBase< + UI1, "bool", "1-bit unsigned integer attribute">; +def UI8Attr : TypedUnsignedIntegerAttrBase< + UI8, "uint8_t", "8-bit unsigned integer attribute">; +def UI16Attr : TypedUnsignedIntegerAttrBase< + UI16, "uint16_t", "16-bit unsigned integer attribute">; +def UI32Attr : TypedUnsignedIntegerAttrBase< + UI32, "uint32_t", "32-bit unsigned integer attribute">; +def UI64Attr : TypedUnsignedIntegerAttrBase< + UI64, "uint64_t", "64-bit unsigned integer attribute">; // Base class for float attributes of fixed width. class FloatAttrBase : @@ -1220,7 +1246,7 @@ let convertFromStorage = "$_self"; } -def DictionaryAttr +def DictionaryAttr : DictionaryAttrBase()">, "dictionary of named attribute values">; diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -502,9 +502,9 @@ return failure(); // Build std.prefetch memref[expandedMap.results]. - rewriter.replaceOpWithNewOp( - op, op.memref(), *resultOperands, op.isWrite(), - op.localityHint().getZExtValue(), op.isDataCache()); + rewriter.replaceOpWithNewOp(op, op.memref(), *resultOperands, + op.isWrite(), op.localityHint(), + op.isDataCache()); return success(); } }; diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h @@ -100,8 +100,8 @@ Value address = rewriter.create(loc, global); auto elementType = global.getType().getArrayElementType(); Value memory = rewriter.create( - loc, elementType.getPointerTo(global.addr_space().getZExtValue()), - address, ArrayRef{zero, zero}); + loc, elementType.getPointerTo(global.addr_space()), address, + ArrayRef{zero, zero}); // Build a memref descriptor pointing to the buffer to plug with the // existing memref infrastructure. This may use more registers than diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -71,8 +71,7 @@ return llvm::None; // Make sure this is reduction with one input and one output. - if (genericOp.args_in().getZExtValue() != 1 || - genericOp.args_out().getZExtValue() != 1) + if (genericOp.args_in() != 1 || genericOp.args_out() != 1) return llvm::None; auto originalInputType = op->getOperand(0).getType().cast(); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -766,9 +766,8 @@ case spirv::MemoryAccess::None: case spirv::MemoryAccess::Nontemporal: case spirv::MemoryAccess::Volatile: { - unsigned alignment = memoryAccess == spirv::MemoryAccess::Aligned - ? op.alignment().getValue().getZExtValue() - : 0; + unsigned alignment = + memoryAccess == spirv::MemoryAccess::Aligned ? *op.alignment() : 0; bool isNonTemporal = memoryAccess == spirv::MemoryAccess::Nontemporal; bool isVolatile = memoryAccess == spirv::MemoryAccess::Volatile; replaceWithLoadOrStore(op, rewriter, this->typeConverter, alignment, diff --git a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp --- a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp +++ b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp @@ -70,7 +70,6 @@ LogicalResult matchAndRewrite(ConstSizeOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op, op.value().getSExtValue()); return success(); } diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -1804,8 +1804,8 @@ if (!typeConverter.getOptions().useAlignedAlloc) return None; - if (allocOp.alignment()) - return allocOp.alignment().getValue().getSExtValue(); + if (Optional alignment = allocOp.alignment()) + return *alignment; // Whenever we don't have alignment set, we will use an alignment // consistent with the element type; since the allocation size has to be a @@ -1843,8 +1843,7 @@ accessAlignment = nullptr; return rewriter.create( loc, elementPtrType, cumulativeSize, - allocaOp.alignment() ? allocaOp.alignment().getValue().getSExtValue() - : 0); + allocaOp.alignment() ? *allocaOp.alignment() : 0); } // Heap allocations. @@ -1892,9 +1891,8 @@ callArgs = {alignedAllocAlignmentValue, cumulativeSize}; } else { // Adjust the allocation size to consider alignment. - if (allocOp.alignment()) { - accessAlignment = createIndexConstant( - rewriter, loc, allocOp.alignment().getValue().getSExtValue()); + if (Optional alignment = allocOp.alignment()) { + accessAlignment = createIndexConstant(rewriter, loc, *alignment); cumulativeSize = rewriter.create( loc, rewriter.create(loc, cumulativeSize, accessAlignment), @@ -2537,7 +2535,7 @@ rewriter.getI32IntegerAttr(prefetchOp.isWrite())); auto localityHint = rewriter.create( op->getLoc(), llvmI32Type, - rewriter.getI32IntegerAttr(prefetchOp.localityHint().getZExtValue())); + rewriter.getI32IntegerAttr(prefetchOp.localityHint())); auto isData = rewriter.create( op->getLoc(), llvmI32Type, rewriter.getI32IntegerAttr(prefetchOp.isDataCache())); @@ -3063,7 +3061,7 @@ ConversionPatternRewriter &rewriter) const override { AssumeAlignmentOp::Adaptor transformed(operands); Value memref = transformed.memref(); - unsigned alignment = cast(op).alignment().getZExtValue(); + unsigned alignment = cast(op).alignment(); MemRefDescriptor memRefDescriptor(memref); Value ptr = memRefDescriptor.alignedPtr(rewriter, memref.getLoc()); diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -878,9 +878,8 @@ PatternRewriter &rewriter, AffinePrefetchOp prefetch, AffineMap map, ArrayRef mapOperands) const { rewriter.replaceOpWithNewOp( - prefetch, prefetch.memref(), map, mapOperands, - prefetch.localityHint().getZExtValue(), prefetch.isWrite(), - prefetch.isDataCache()); + prefetch, prefetch.memref(), map, mapOperands, prefetch.localityHint(), + prefetch.isWrite(), prefetch.isDataCache()); } template <> void SimplifyAffineOp::replaceAffineOp( diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -124,7 +124,7 @@ op.getContext()); p << op.getOperationName() << ' ' << op.arraySize() << " x " << elemTy; - if (op.alignment().hasValue() && op.alignment()->getSExtValue() != 0) + if (op.alignment().hasValue() && *op.alignment() != 0) p.printOptionalAttrDict(op.getAttrs()); else p.printOptionalAttrDict(op.getAttrs(), {"alignment"}); @@ -914,9 +914,8 @@ return op.emitOpError( "must reference a global defined by 'llvm.mlir.global' or 'llvm.func'"); - if (global && - global.getType().getPointerTo(global.addr_space().getZExtValue()) != - op.getResult().getType()) + if (global && global.getType().getPointerTo(global.addr_space()) != + op.getResult().getType()) return op.emitOpError( "the type must be a pointer to the type of the referenced global"); diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp --- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp @@ -89,9 +89,9 @@ QuantizedType convertFakeQuantAttrsToType(ConstFakeQuant fqOp, Type expressedType) const { return fakeQuantAttrsToType( - fqOp.getLoc(), fqOp.num_bits().getSExtValue(), - fqOp.min().convertToFloat(), fqOp.max().convertToFloat(), - fqOp.narrow_range(), expressedType, fqOp.is_signed()); + fqOp.getLoc(), fqOp.num_bits(), fqOp.min().convertToFloat(), + fqOp.max().convertToFloat(), fqOp.narrow_range(), expressedType, + fqOp.is_signed()); } }; @@ -115,9 +115,8 @@ for (auto m : fqOp.max()) max.push_back(m.cast().getValueAsDouble()); - return fakeQuantAttrsToType(fqOp.getLoc(), fqOp.num_bits().getSExtValue(), - fqOp.axis().getSExtValue(), min, max, - fqOp.narrow_range(), expressedType, + return fakeQuantAttrsToType(fqOp.getLoc(), fqOp.num_bits(), fqOp.axis(), + min, max, fqOp.narrow_range(), expressedType, fqOp.is_signed()); } }; diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -250,7 +250,7 @@ MemoryOpTy memoryOp, OpAsmPrinter &printer, SmallVectorImpl &elidedAttrs, Optional memoryAccessAtrrValue = None, - Optional alignmentAttrValue = None) { + Optional alignmentAttrValue = None) { // Print optional memory access attribute. if (auto memAccess = (memoryAccessAtrrValue ? memoryAccessAtrrValue : memoryOp.memory_access())) { @@ -280,7 +280,7 @@ MemoryOpTy memoryOp, OpAsmPrinter &printer, SmallVectorImpl &elidedAttrs, Optional memoryAccessAtrrValue = None, - Optional alignmentAttrValue = None) { + Optional alignmentAttrValue = None) { printer << ", "; diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -468,7 +468,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(AssumeAlignmentOp op) { - unsigned alignment = op.alignment().getZExtValue(); + unsigned alignment = op.alignment(); if (!llvm::isPowerOf2_32(alignment)) return op.emitOpError("alignment must be power of 2"); return success(); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -721,7 +721,7 @@ ((linkage == llvm::GlobalVariable::ExternalLinkage && isa(cst)) || linkage == llvm::GlobalVariable::ExternalWeakLinkage); - auto addrSpace = op.addr_space().getLimitedValue(); + auto addrSpace = op.addr_space(); auto *var = new llvm::GlobalVariable( *llvmModule, type, op.constant(), linkage, anyExternalLinkage ? nullptr : cst, op.sym_name(), diff --git a/mlir/test/Dialect/LLVMIR/invalid.mlir b/mlir/test/Dialect/LLVMIR/invalid.mlir --- a/mlir/test/Dialect/LLVMIR/invalid.mlir +++ b/mlir/test/Dialect/LLVMIR/invalid.mlir @@ -62,13 +62,6 @@ // ----- -func @alloca_nonpositive_alignment(%size : !llvm.i64) { - // expected-error@+1 {{expected positive alignment}} - llvm.alloca %size x !llvm.i32 {alignment = -1} : (!llvm.i64) -> (!llvm.ptr) -} - -// ----- - func @gep_missing_input_result_type(%pos : !llvm.i64, %base : !llvm.ptr) { // expected-error@+1 {{2 operands present, but expected 0}} llvm.getelementptr %base[%pos] : () -> () diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -457,8 +457,7 @@ PatternRewriter &rewriter) const final { // Decrement the depth of the op in-place. rewriter.updateRootInPlace(op, [&] { - op.setAttr("depth", - rewriter.getI64IntegerAttr(op.depth().getSExtValue() - 1)); + op.setAttr("depth", rewriter.getI64IntegerAttr(op.depth() - 1)); }); return success(); } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -138,8 +138,8 @@ // DEF: ::mlir::Attribute BOp::any_attr() // DEF: bool BOp::bool_attr() -// DEF: ::llvm::APInt BOp::i32_attr() -// DEF: ::llvm::APInt BOp::i64_attr() +// DEF: uint32_t BOp::i32_attr() +// DEF: uint64_t BOp::i64_attr() // DEF: ::llvm::APFloat BOp::f32_attr() // DEF: ::llvm::APFloat BOp::f64_attr() // DEF: ::llvm::StringRef BOp::str_attr() @@ -196,7 +196,7 @@ } // DECL-LABEL: DOp declarations -// DECL: static void build({{.*}}, ::llvm::APInt i32_attr, ::llvm::APFloat f64_attr, ::llvm::StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, ::llvm::APInt dv_i32_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef dv_str_attr = "abc", bool dv_bool_attr = true, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) +// DECL: static void build({{.*}}, uint32_t i32_attr, ::llvm::APFloat f64_attr, ::llvm::StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, uint32_t dv_i32_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef dv_str_attr = "abc", bool dv_bool_attr = true, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) // DEF-LABEL: DOp definitions // DEF: odsState.addAttribute("str_attr", odsBuilder.getStringAttr(str_attr)); @@ -238,7 +238,7 @@ } // DECL-LABEL: EOp declarations -// DECL: static void build({{.*}}, ::llvm::APInt i32_attr, ::llvm::APInt dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) +// DECL: static void build({{.*}}, uint32_t i32_attr, uint32_t dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) // Test mixing operands and attributes in arbitrary order // --- diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -77,12 +77,12 @@ // CHECK: ::mlir::Region &someRegion(); // CHECK: ::mlir::MutableArrayRef someRegions(); // CHECK: ::mlir::IntegerAttr attr1Attr() -// CHECK: ::llvm::APInt attr1(); +// CHECK: uint32_t attr1(); // CHECK: ::mlir::FloatAttr attr2Attr() // CHECK: ::llvm::Optional< ::llvm::APFloat > attr2(); // CHECK: static void build(Value val); // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::llvm::ArrayRef<::mlir::Type> s, ::mlir::Value a, ::mlir::ValueRange b, ::mlir::IntegerAttr attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount) -// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::llvm::ArrayRef<::mlir::Type> s, ::mlir::Value a, ::mlir::ValueRange b, ::llvm::APInt attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount) +// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::llvm::ArrayRef<::mlir::Type> s, ::mlir::Value a, ::mlir::ValueRange b, uint32_t attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount) // CHECK: static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::Type> resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) // CHECK: static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); // CHECK: void print(::mlir::OpAsmPrinter &p);