From: Jakub Kuderski Date: Thu, 25 Aug 2022 20:54:26 +0000 (-0400) Subject: [mlir][spirv] Add convenience builders for AddICarry and SubIBorrow X-Git-Tag: upstream/17.0.6~35362 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e678cbae4d0f1522c5db8cc24a82672dbc8f0ca9;p=platform%2Fupstream%2Fllvm.git [mlir][spirv] Add convenience builders for AddICarry and SubIBorrow This is so that we do not have to spell out long structure types every time we create these ops. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D132629 --- diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td index 7ce34dc..beed00e 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td @@ -354,6 +354,14 @@ def SPV_IAddCarryOp : SPV_BinaryOp<"IAddCarry", SPV_AnyStruct:$result ); + let builders = [ + OpBuilder<(ins "Value":$operand1, "Value":$operand2), [{ + build($_builder, $_state, + ::mlir::spirv::StructType::get({operand1.getType(), operand1.getType()}), + operand1, operand2); + }]> + ]; + let hasVerifier = 1; } @@ -485,6 +493,14 @@ def SPV_ISubBorrowOp : SPV_BinaryOp<"ISubBorrow", SPV_AnyStruct, SPV_Integer, SPV_AnyStruct:$result ); + let builders = [ + OpBuilder<(ins "Value":$operand1, "Value":$operand2), [{ + build($_builder, $_state, + ::mlir::spirv::StructType::get({operand1.getType(), operand1.getType()}), + operand1, operand2); + }]> + ]; + let hasVerifier = 1; } diff --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp index 9b7621f..6ca37c6 100644 --- a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp +++ b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp @@ -854,11 +854,9 @@ LogicalResult AddICarryOpPattern::matchAndRewrite(arith::AddUICarryOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const { Type dstElemTy = adaptor.getLhs().getType(); - auto resultTy = spirv::StructType::get({dstElemTy, dstElemTy}); - Location loc = op->getLoc(); Value result = rewriter.create( - loc, resultTy, adaptor.getLhs(), adaptor.getRhs()); + loc, adaptor.getLhs(), adaptor.getRhs()); Value sumResult = rewriter.create( loc, result, llvm::makeArrayRef(0));