diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index e1d1d4f28db1b..f90533721421c 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -601,8 +601,8 @@ def LLVM_ShuffleVectorOp : LLVM_Op<"shufflevector", [NoSideEffect]> { OpBuilder<(ins "Value":$v1, "Value":$v2, "ArrayAttr":$mask, CArg<"ArrayRef", "{}">:$attrs)>]; let verifier = [{ - auto type1 = v1().getType(); - auto type2 = v2().getType(); + auto type1 = getV1().getType(); + auto type2 = getV2().getType(); if (::mlir::LLVM::getVectorElementType(type1) != ::mlir::LLVM::getVectorElementType(type2)) return emitOpError("expected matching LLVM IR Dialect element types"); @@ -701,7 +701,7 @@ def LLVM_ResumeOp : LLVM_TerminatorOp<"resume", []> { let arguments = (ins LLVM_Type:$value); string llvmBuilder = [{ builder.CreateResume($value); }]; let verifier = [{ - if (!isa_and_nonnull(value().getDefiningOp())) + if (!isa_and_nonnull(getValue().getDefiningOp())) return emitOpError("expects landingpad value as operand"); // No check for personality of function - landingpad op verifies it. return success(); @@ -753,13 +753,13 @@ def LLVM_SwitchOp : LLVM_TerminatorOp<"switch", let extraClassDeclaration = [{ /// Return the operands for the case destination block at the given index. OperandRange getCaseOperands(unsigned index) { - return caseOperands()[index]; + return getCaseOperands()[index]; } /// Return a mutable range of operands for the case destination block at the /// given index. MutableOperandRange getCaseOperandsMutable(unsigned index) { - return caseOperandsMutable()[index]; + return getCaseOperandsMutable()[index]; } }]; } @@ -870,8 +870,8 @@ def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof"> { CArg<"ArrayRef", "{}">:$attrs), [{ build($_builder, $_state, - LLVM::LLVMPointerType::get(global.getType(), global.addr_space()), - global.sym_name()); + LLVM::LLVMPointerType::get(global.getType(), global.getAddrSpace()), + global.getSymName()); $_state.addAttributes(attrs); }]>, OpBuilder<(ins "LLVMFuncOp":$func, @@ -1126,7 +1126,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global", } /// Return the initializer attribute if it exists, or a null attribute. Attribute getValueOrNull() { - return value().getValueOr(Attribute()); + return getValue().getValueOr(Attribute()); } /// Return the initializer region. This may be empty, but if it is not it /// terminates in an `llvm.return` op with the initializer value. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td index 495518621015a..671e19a36d5e9 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td @@ -24,7 +24,7 @@ def FastmathFlagsInterface : OpInterface<"FastmathFlagsInterface"> { let methods = [ InterfaceMethod<"Get fastmath flags", "::mlir::LLVM::FastmathFlags", - "fastmathFlags">, + "getFastmathFlags">, ]; } diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index d9df01bdea9a9..315909bf3f46f 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -220,7 +220,7 @@ def AtomicRMWOp : Std_Op<"atomic_rmw", [ let extraClassDeclaration = [{ MemRefType getMemRefType() { - return memref().getType().cast(); + return getMemref().getType().cast(); } }]; } @@ -276,7 +276,7 @@ def GenericAtomicRMWOp : Std_Op<"generic_atomic_rmw", [ return getRegion().getArgument(0); } MemRefType getMemRefType() { - return memref().getType().cast(); + return getMemref().getType().cast(); } }]; } @@ -555,7 +555,7 @@ def CondBranchOp : Std_Op<"cond_br", /// Erase the operand at 'index' from the true operand list. void eraseTrueOperand(unsigned index) { - trueDestOperandsMutable().erase(index); + getTrueDestOperandsMutable().erase(index); } // Accessors for operands to the 'false' destination. @@ -575,7 +575,7 @@ def CondBranchOp : Std_Op<"cond_br", /// Erase the operand at 'index' from the false operand list. void eraseFalseOperand(unsigned index) { - falseDestOperandsMutable().erase(index); + getFalseDestOperandsMutable().erase(index); } private: @@ -889,13 +889,13 @@ def SwitchOp : Std_Op<"switch", let extraClassDeclaration = [{ /// Return the operands for the case destination block at the given index. OperandRange getCaseOperands(unsigned index) { - return caseOperands()[index]; + return getCaseOperands()[index]; } /// Return a mutable range of operands for the case destination block at the /// given index. MutableOperandRange getCaseOperandsMutable(unsigned index) { - return caseOperandsMutable()[index]; + return getCaseOperandsMutable()[index]; } }]; diff --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp index 99e15a2f25a11..9f1e0a41a77a5 100644 --- a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp +++ b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp @@ -637,7 +637,7 @@ LogicalResult CmpIOpBooleanPattern::matchAndRewrite( #define DISPATCH(cmpPredicate, spirvOp) \ case cmpPredicate: \ rewriter.replaceOpWithNewOp(op, op.getResult().getType(), \ - adaptor.lhs(), adaptor.rhs()); \ + adaptor.getLhs(), adaptor.getRhs()); \ return success(); DISPATCH(arith::CmpIPredicate::eq, spirv::LogicalEqualOp); @@ -669,7 +669,7 @@ CmpIOpPattern::matchAndRewrite(arith::CmpIOp op, OpAdaptor adaptor, "bitwidth emulation is not implemented yet on unsigned op"); \ } \ rewriter.replaceOpWithNewOp(op, op.getResult().getType(), \ - adaptor.lhs(), adaptor.rhs()); \ + adaptor.getLhs(), adaptor.getRhs()); \ return success(); DISPATCH(arith::CmpIPredicate::eq, spirv::IEqualOp); @@ -699,7 +699,7 @@ CmpFOpPattern::matchAndRewrite(arith::CmpFOp op, OpAdaptor adaptor, #define DISPATCH(cmpPredicate, spirvOp) \ case cmpPredicate: \ rewriter.replaceOpWithNewOp(op, op.getResult().getType(), \ - adaptor.lhs(), adaptor.rhs()); \ + adaptor.getLhs(), adaptor.getRhs()); \ return success(); // Ordered. diff --git a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp index 795bfb8549246..29c6ad3d91544 100644 --- a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp +++ b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp @@ -43,7 +43,7 @@ struct ExpM1OpLowering : public ConvertOpToLLVMPattern { LogicalResult matchAndRewrite(math::ExpM1Op op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - auto operandType = adaptor.operand().getType(); + auto operandType = adaptor.getOperand().getType(); if (!operandType || !LLVM::isCompatibleType(operandType)) return failure(); @@ -62,7 +62,7 @@ struct ExpM1OpLowering : public ConvertOpToLLVMPattern { } else { one = rewriter.create(loc, operandType, floatOne); } - auto exp = rewriter.create(loc, adaptor.operand()); + auto exp = rewriter.create(loc, adaptor.getOperand()); rewriter.replaceOpWithNewOp(op, operandType, exp, one); return success(); } @@ -96,7 +96,7 @@ struct Log1pOpLowering : public ConvertOpToLLVMPattern { LogicalResult matchAndRewrite(math::Log1pOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - auto operandType = adaptor.operand().getType(); + auto operandType = adaptor.getOperand().getType(); if (!operandType || !LLVM::isCompatibleType(operandType)) return rewriter.notifyMatchFailure(op, "unsupported operand type"); @@ -116,7 +116,7 @@ struct Log1pOpLowering : public ConvertOpToLLVMPattern { : rewriter.create(loc, operandType, floatOne); auto add = rewriter.create(loc, operandType, one, - adaptor.operand()); + adaptor.getOperand()); rewriter.replaceOpWithNewOp(op, operandType, add); return success(); } @@ -150,7 +150,7 @@ struct RsqrtOpLowering : public ConvertOpToLLVMPattern { LogicalResult matchAndRewrite(math::RsqrtOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - auto operandType = adaptor.operand().getType(); + auto operandType = adaptor.getOperand().getType(); if (!operandType || !LLVM::isCompatibleType(operandType)) return failure(); @@ -169,7 +169,7 @@ struct RsqrtOpLowering : public ConvertOpToLLVMPattern { } else { one = rewriter.create(loc, operandType, floatOne); } - auto sqrt = rewriter.create(loc, adaptor.operand()); + auto sqrt = rewriter.create(loc, adaptor.getOperand()); rewriter.replaceOpWithNewOp(op, operandType, one, sqrt); return success(); } diff --git a/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp index 9e96829e79c1d..95eca39d414aa 100644 --- a/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp +++ b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp @@ -45,7 +45,7 @@ class Log1pOpPattern final : public OpConversionPattern { assert(adaptor.getOperands().size() == 1); Location loc = operation.getLoc(); auto type = - this->getTypeConverter()->convertType(operation.operand().getType()); + this->getTypeConverter()->convertType(operation.getOperand().getType()); auto one = spirv::ConstantOp::getOne(type, operation.getLoc(), rewriter); auto onePlus = rewriter.create(loc, one, adaptor.getOperands()[0]); diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp index abcef4887e495..90d870fe82a28 100644 --- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp +++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp @@ -66,7 +66,7 @@ static bool matchSimpleReduction(Block &block) { /// scf.reduce.return %1 template < typename CompareOpTy, typename SelectOpTy, - typename Predicate = decltype(std::declval().predicate())> + typename Predicate = decltype(std::declval().getPredicate())> static bool matchSelectReduction(Block &block, ArrayRef lessThanPredicates, ArrayRef greaterThanPredicates, bool &isMin) { diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp index 97f210db5d84a..e97afac9ca2d7 100644 --- a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp @@ -24,8 +24,8 @@ struct CeilDivUIOpConverter : public OpRewritePattern { LogicalResult matchAndRewrite(arith::CeilDivUIOp op, PatternRewriter &rewriter) const final { Location loc = op.getLoc(); - Value a = op.lhs(); - Value b = op.rhs(); + Value a = op.getLhs(); + Value b = op.getRhs(); Value zero = rewriter.create( loc, rewriter.getIntegerAttr(a.getType(), 0)); Value compare = diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 5577cecf8f52c..2c320a380d9c2 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1666,7 +1666,7 @@ static LogicalResult verify(GlobalOp op) { LogicalResult GlobalCtorsOp::verifySymbolUses(SymbolTableCollection &symbolTable) { - for (Attribute ctor : ctors()) { + for (Attribute ctor : getCtors()) { if (failed(verifySymbolAttrUse(ctor.cast(), *this, symbolTable))) return failure(); @@ -1675,7 +1675,7 @@ GlobalCtorsOp::verifySymbolUses(SymbolTableCollection &symbolTable) { } static LogicalResult verify(GlobalCtorsOp op) { - if (op.ctors().size() != op.priorities().size()) + if (op.getCtors().size() != op.getPriorities().size()) return op.emitError( "mismatch between the number of ctors and the number of priorities"); return success(); @@ -1687,7 +1687,7 @@ static LogicalResult verify(GlobalCtorsOp op) { LogicalResult GlobalDtorsOp::verifySymbolUses(SymbolTableCollection &symbolTable) { - for (Attribute dtor : dtors()) { + for (Attribute dtor : getDtors()) { if (failed(verifySymbolAttrUse(dtor.cast(), *this, symbolTable))) return failure(); @@ -1696,7 +1696,7 @@ GlobalDtorsOp::verifySymbolUses(SymbolTableCollection &symbolTable) { } static LogicalResult verify(GlobalDtorsOp op) { - if (op.dtors().size() != op.priorities().size()) + if (op.getDtors().size() != op.getPriorities().size()) return op.emitError( "mismatch between the number of dtors and the number of priorities"); return success(); diff --git a/mlir/lib/Dialect/Math/Transforms/AlgebraicSimplification.cpp b/mlir/lib/Dialect/Math/Transforms/AlgebraicSimplification.cpp index 2217cfe4688ba..86905463f2dc7 100644 --- a/mlir/lib/Dialect/Math/Transforms/AlgebraicSimplification.cpp +++ b/mlir/lib/Dialect/Math/Transforms/AlgebraicSimplification.cpp @@ -41,13 +41,13 @@ LogicalResult PowFStrengthReduction::matchAndRewrite(math::PowFOp op, PatternRewriter &rewriter) const { Location loc = op.getLoc(); - Value x = op.lhs(); + Value x = op.getLhs(); FloatAttr scalarExponent; DenseFPElementsAttr vectorExponent; - bool isScalar = matchPattern(op.rhs(), m_Constant(&scalarExponent)); - bool isVector = matchPattern(op.rhs(), m_Constant(&vectorExponent)); + bool isScalar = matchPattern(op.getRhs(), m_Constant(&scalarExponent)); + bool isVector = matchPattern(op.getRhs(), m_Constant(&vectorExponent)); // Returns true if exponent is a constant equal to `value`. auto isExponentValue = [&](double value) -> bool { diff --git a/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp b/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp index 3fb6f11bda7a2..3c3d7a80b6bf1 100644 --- a/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp +++ b/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp @@ -23,13 +23,13 @@ using namespace mlir; /// 1) 1-exp^{-2x} / 1+exp^{-2x}, if x => 0 /// 2) exp^{2x}-1 / exp^{2x}+1 , if x < 0 static LogicalResult convertTanhOp(math::TanhOp op, PatternRewriter &rewriter) { - auto floatType = op.operand().getType(); + auto floatType = op.getOperand().getType(); Location loc = op.getLoc(); auto floatOne = rewriter.getFloatAttr(floatType, 1.0); auto floatTwo = rewriter.getFloatAttr(floatType, 2.0); Value one = rewriter.create(loc, floatOne); Value two = rewriter.create(loc, floatTwo); - Value doubledX = rewriter.create(loc, op.operand(), two); + Value doubledX = rewriter.create(loc, op.getOperand(), two); // Case 1: tanh(x) = 1-exp^{-2x} / 1+exp^{-2x} Value negDoubledX = rewriter.create(loc, doubledX); @@ -48,7 +48,7 @@ static LogicalResult convertTanhOp(math::TanhOp op, PatternRewriter &rewriter) { auto floatZero = rewriter.getFloatAttr(floatType, 0.0); Value zero = rewriter.create(loc, floatZero); Value cmpRes = rewriter.create(loc, arith::CmpFPredicate::OGE, - op.operand(), zero); + op.getOperand(), zero); rewriter.replaceOpWithNewOp(op, cmpRes, positiveRes, negativeRes); return success(); } diff --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp index 97ba3c0795ff9..c15d61773e0dc 100644 --- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp +++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp @@ -295,10 +295,10 @@ struct TanhApproximation : public OpRewritePattern { LogicalResult TanhApproximation::matchAndRewrite(math::TanhOp op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -308,12 +308,12 @@ TanhApproximation::matchAndRewrite(math::TanhOp op, // Clamp operand into [plusClamp, minusClamp] range. Value minusClamp = bcast(f32Cst(builder, -7.99881172180175781f)); Value plusClamp = bcast(f32Cst(builder, 7.99881172180175781f)); - Value x = clamp(builder, op.operand(), minusClamp, plusClamp); + Value x = clamp(builder, op.getOperand(), minusClamp, plusClamp); // Mask for tiny values that are approximated with `operand`. Value tiny = bcast(f32Cst(builder, 0.0004f)); Value tinyMask = builder.create( - arith::CmpFPredicate::OLT, builder.create(op.operand()), + arith::CmpFPredicate::OLT, builder.create(op.getOperand()), tiny); // The monomial coefficients of the numerator polynomial (odd). @@ -383,10 +383,10 @@ template LogicalResult LogApproximationBase::logMatchAndRewrite(Op op, PatternRewriter &rewriter, bool base2) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -415,7 +415,7 @@ LogApproximationBase::logMatchAndRewrite(Op op, PatternRewriter &rewriter, Value cstCephesLogP7 = bcast(f32Cst(builder, -2.4999993993E-1f)); Value cstCephesLogP8 = bcast(f32Cst(builder, +3.3333331174E-1f)); - Value x = op.operand(); + Value x = op.getOperand(); // Truncate input values to the minimum positive normal. x = max(builder, x, cstMinNormPos); @@ -469,11 +469,11 @@ LogApproximationBase::logMatchAndRewrite(Op op, PatternRewriter &rewriter, } Value invalidMask = builder.create(arith::CmpFPredicate::ULT, - op.operand(), cstZero); + op.getOperand(), cstZero); Value zeroMask = builder.create(arith::CmpFPredicate::OEQ, - op.operand(), cstZero); + op.getOperand(), cstZero); Value posInfMask = builder.create(arith::CmpFPredicate::OEQ, - op.operand(), cstPosInf); + op.getOperand(), cstPosInf); // Filter out invalid values: // • x == 0 -> -INF @@ -530,10 +530,10 @@ struct Log1pApproximation : public OpRewritePattern { LogicalResult Log1pApproximation::matchAndRewrite(math::Log1pOp op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -547,7 +547,7 @@ Log1pApproximation::matchAndRewrite(math::Log1pOp op, // ^^^^^^^^^^^^^^^^^^^^^^ // "logLarge" below. Value cstOne = bcast(f32Cst(builder, 1.0f)); - Value x = op.operand(); + Value x = op.getOperand(); Value u = builder.create(x, cstOne); Value uSmall = builder.create(arith::CmpFPredicate::OEQ, u, cstOne); @@ -577,10 +577,10 @@ Log1pApproximation::matchAndRewrite(math::Log1pOp op, LogicalResult ErfPolynomialApproximation::matchAndRewrite(math::ErfOp op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -637,9 +637,9 @@ ErfPolynomialApproximation::matchAndRewrite(math::ErfOp op, bounds[2] = bcast(f32Cst(builder, 3.75f)); Value isNegativeArg = builder.create(arith::CmpFPredicate::OLT, - op.operand(), zero); - Value negArg = builder.create(op.operand()); - Value x = builder.create(isNegativeArg, negArg, op.operand()); + op.getOperand(), zero); + Value negArg = builder.create(op.getOperand()); + Value x = builder.create(isNegativeArg, negArg, op.getOperand()); Value offset = offsets[0]; Value p[polyDegree + 1]; @@ -701,10 +701,10 @@ struct ExpApproximation : public OpRewritePattern { LogicalResult ExpApproximation::matchAndRewrite(math::ExpOp op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); @@ -735,7 +735,7 @@ ExpApproximation::matchAndRewrite(math::ExpOp op, Value cstCephesExpP4 = bcast(f32Cst(builder, 0.03668965196652099192f)); Value cstCephesExpP5 = bcast(f32Cst(builder, 0.01314350012789660196f)); - Value x = op.operand(); + Value x = op.getOperand(); // Reduced y = x - floor(x / ln(2)) * ln(2) = x - k * ln(2) Value xL2Inv = mul(x, cstLog2E); @@ -823,10 +823,10 @@ struct ExpM1Approximation : public OpRewritePattern { LogicalResult ExpM1Approximation::matchAndRewrite(math::ExpM1Op op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -838,7 +838,7 @@ ExpM1Approximation::matchAndRewrite(math::ExpM1Op op, // and when the input is ~= -inf, i.e. u - 1 ~= -1. Value cstOne = bcast(f32Cst(builder, 1.0f)); Value cstNegOne = bcast(f32Cst(builder, -1.0f)); - Value x = op.operand(); + Value x = op.getOperand(); Value u = builder.create(x); Value uEqOne = builder.create(arith::CmpFPredicate::OEQ, u, cstOne); @@ -892,10 +892,10 @@ LogicalResult SinAndCosApproximation::matchAndRewrite( llvm::is_one_of::value, "SinAndCosApproximation pattern expects math::SinOp or math::CosOp"); - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); ImplicitLocOpBuilder builder(op->getLoc(), rewriter); auto bcast = [&](Value value) -> Value { @@ -941,7 +941,7 @@ LogicalResult SinAndCosApproximation::matchAndRewrite( Value twoOverPi = bcast(f32Cst(builder, TWO_OVER_PI)); Value piOverTwo = bcast(f32Cst(builder, PI_OVER_2)); - Value x = op.operand(); + Value x = op.getOperand(); Value k = floor(mul(x, twoOverPi)); @@ -1015,10 +1015,10 @@ struct RsqrtApproximation : public OpRewritePattern { LogicalResult RsqrtApproximation::matchAndRewrite(math::RsqrtOp op, PatternRewriter &rewriter) const { - if (!getElementTypeOrSelf(op.operand()).isF32()) + if (!getElementTypeOrSelf(op.getOperand()).isF32()) return rewriter.notifyMatchFailure(op, "unsupported operand type"); - ArrayRef shape = vectorShape(op.operand()); + ArrayRef shape = vectorShape(op.getOperand()); // Only support already-vectorized rsqrt's. if (shape.empty() || shape.back() % 8 != 0) @@ -1034,14 +1034,14 @@ RsqrtApproximation::matchAndRewrite(math::RsqrtOp op, Value cstNegHalf = bcast(f32Cst(builder, -0.5f)); Value cstMinNormPos = bcast(f32FromBits(builder, 0x00800000u)); - Value negHalf = builder.create(op.operand(), cstNegHalf); + Value negHalf = builder.create(op.getOperand(), cstNegHalf); // Select only the inverse sqrt of positive normals (denormals are // flushed to zero). - Value ltMinMask = builder.create(arith::CmpFPredicate::OLT, - op.operand(), cstMinNormPos); + Value ltMinMask = builder.create( + arith::CmpFPredicate::OLT, op.getOperand(), cstMinNormPos); Value infMask = builder.create(arith::CmpFPredicate::OEQ, - op.operand(), cstPosInf); + op.getOperand(), cstPosInf); Value notNormalFiniteMask = builder.create(ltMinMask, infMask); // Compute an approximate result. diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp index 6abb0a5c0ab8e..cc8800df0095f 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp @@ -161,7 +161,7 @@ static llvm::FastMathFlags getFastmathFlags(FastmathFlagsInterface &op) { // clang-format on }; llvm::FastMathFlags ret; - auto fmf = op.fastmathFlags(); + auto fmf = op.getFastmathFlags(); for (auto it : handlers) if (bitEnumContains(fmf, it.first)) (ret.*(it.second))(true); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index db0e7c2d84780..5d8345d48a6c6 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -610,8 +610,8 @@ LogicalResult ModuleTranslation::convertGlobals() { auto dtorOp = dyn_cast(op); if (!ctorOp && !dtorOp) continue; - auto range = ctorOp ? llvm::zip(ctorOp.ctors(), ctorOp.priorities()) - : llvm::zip(dtorOp.dtors(), dtorOp.priorities()); + auto range = ctorOp ? llvm::zip(ctorOp.getCtors(), ctorOp.getPriorities()) + : llvm::zip(dtorOp.getDtors(), dtorOp.getPriorities()); auto appendGlobalFn = ctorOp ? llvm::appendToGlobalCtors : llvm::appendToGlobalDtors; for (auto symbolAndPriority : range) { diff --git a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp index 06c2330a660dd..1a92f4a162ee2 100644 --- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp @@ -121,6 +121,7 @@ static bool emitOneBuilder(const Record &record, raw_ostream &os) { llvm::raw_string_ostream bs(builder); while (auto loc = findNextVariable(builderStrRef)) { auto name = loc.in(builderStrRef).drop_front(); + auto getterName = op.getGetterName(name); // First, insert the non-matched part as is. bs << builderStrRef.substr(0, loc.pos); // Then, rewrite the name based on its kind. @@ -128,13 +129,13 @@ static bool emitOneBuilder(const Record &record, raw_ostream &os) { if (isOperandName(op, name)) { auto result = isVariadicOperand - ? formatv("moduleTranslation.lookupValues(op.{0}())", name) - : formatv("moduleTranslation.lookupValue(op.{0}())", name); + ? formatv("moduleTranslation.lookupValues(op.{0}())", getterName) + : formatv("moduleTranslation.lookupValue(op.{0}())", getterName); bs << result; } else if (isAttributeName(op, name)) { - bs << formatv("op.{0}()", name); + bs << formatv("op.{0}()", getterName); } else if (isResultName(op, name)) { - bs << formatv("moduleTranslation.mapValue(op.{0}())", name); + bs << formatv("moduleTranslation.mapValue(op.{0}())", getterName); } else if (name == "_resultType") { bs << "moduleTranslation.convertType(op.getResult().getType())"; } else if (name == "_hasResult") {