[Mlir-commits] [mlir] e678cba - [mlir][spirv] Add convenience builders for AddICarry and SubIBorrow
Jakub Kuderski
llvmlistbot at llvm.org
Thu Aug 25 13:58:56 PDT 2022
Author: Jakub Kuderski
Date: 2022-08-25T16:55:24-04:00
New Revision: e678cbae4d0f1522c5db8cc24a82672dbc8f0ca9
URL: https://github.com/llvm/llvm-project/commit/e678cbae4d0f1522c5db8cc24a82672dbc8f0ca9
DIFF: https://github.com/llvm/llvm-project/commit/e678cbae4d0f1522c5db8cc24a82672dbc8f0ca9.diff
LOG: [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
Added:
Modified:
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
index 7ce34dcd5dedb..beed00e077b3a 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 9b7621f2b6693..6ca37c667daba 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<spirv::IAddCarryOp>(
- loc, resultTy, adaptor.getLhs(), adaptor.getRhs());
+ loc, adaptor.getLhs(), adaptor.getRhs());
Value sumResult = rewriter.create<spirv::CompositeExtractOp>(
loc, result, llvm::makeArrayRef(0));
More information about the Mlir-commits
mailing list