Lines Matching refs:rewriter
63 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
67 Value real = complexStruct.real(rewriter, op.getLoc()); in matchAndRewrite()
68 Value imag = complexStruct.imaginary(rewriter, op.getLoc()); in matchAndRewrite()
71 Value sqNorm = rewriter.create<LLVM::FAddOp>( in matchAndRewrite()
72 loc, rewriter.create<LLVM::FMulOp>(loc, real, real, fmf), in matchAndRewrite()
73 rewriter.create<LLVM::FMulOp>(loc, imag, imag, fmf), fmf); in matchAndRewrite()
75 rewriter.replaceOpWithNewOp<LLVM::SqrtOp>(op, sqNorm); in matchAndRewrite()
85 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
88 *getTypeConverter(), rewriter); in matchAndRewrite()
97 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
101 auto complexStruct = ComplexStructBuilder::undef(rewriter, loc, structType); in matchAndRewrite()
102 complexStruct.setReal(rewriter, loc, adaptor.getReal()); in matchAndRewrite()
103 complexStruct.setImaginary(rewriter, loc, adaptor.getImaginary()); in matchAndRewrite()
105 rewriter.replaceOp(complexOp, {complexStruct}); in matchAndRewrite()
115 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
118 Value real = complexStruct.real(rewriter, op.getLoc()); in matchAndRewrite()
119 rewriter.replaceOp(op, real); in matchAndRewrite()
130 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
133 Value imaginary = complexStruct.imaginary(rewriter, op.getLoc()); in matchAndRewrite()
134 rewriter.replaceOp(op, imaginary); in matchAndRewrite()
148 ConversionPatternRewriter &rewriter) { in unpackBinaryComplexOperands() argument
154 unpacked.lhs.real(lhs.real(rewriter, loc)); in unpackBinaryComplexOperands()
155 unpacked.lhs.imag(lhs.imaginary(rewriter, loc)); in unpackBinaryComplexOperands()
157 unpacked.rhs.real(rhs.real(rewriter, loc)); in unpackBinaryComplexOperands()
158 unpacked.rhs.imag(rhs.imaginary(rewriter, loc)); in unpackBinaryComplexOperands()
168 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
171 unpackBinaryComplexOperands<complex::AddOp>(op, adaptor, rewriter); in matchAndRewrite()
175 auto result = ComplexStructBuilder::undef(rewriter, loc, structType); in matchAndRewrite()
180 rewriter.create<LLVM::FAddOp>(loc, arg.lhs.real(), arg.rhs.real(), fmf); in matchAndRewrite()
182 rewriter.create<LLVM::FAddOp>(loc, arg.lhs.imag(), arg.rhs.imag(), fmf); in matchAndRewrite()
183 result.setReal(rewriter, loc, real); in matchAndRewrite()
184 result.setImaginary(rewriter, loc, imag); in matchAndRewrite()
186 rewriter.replaceOp(op, {result}); in matchAndRewrite()
196 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
199 unpackBinaryComplexOperands<complex::DivOp>(op, adaptor, rewriter); in matchAndRewrite()
203 auto result = ComplexStructBuilder::undef(rewriter, loc, structType); in matchAndRewrite()
212 Value rhsSqNorm = rewriter.create<LLVM::FAddOp>( in matchAndRewrite()
213 loc, rewriter.create<LLVM::FMulOp>(loc, rhsRe, rhsRe, fmf), in matchAndRewrite()
214 rewriter.create<LLVM::FMulOp>(loc, rhsIm, rhsIm, fmf), fmf); in matchAndRewrite()
216 Value resultReal = rewriter.create<LLVM::FAddOp>( in matchAndRewrite()
217 loc, rewriter.create<LLVM::FMulOp>(loc, lhsRe, rhsRe, fmf), in matchAndRewrite()
218 rewriter.create<LLVM::FMulOp>(loc, lhsIm, rhsIm, fmf), fmf); in matchAndRewrite()
220 Value resultImag = rewriter.create<LLVM::FSubOp>( in matchAndRewrite()
221 loc, rewriter.create<LLVM::FMulOp>(loc, lhsIm, rhsRe, fmf), in matchAndRewrite()
222 rewriter.create<LLVM::FMulOp>(loc, lhsRe, rhsIm, fmf), fmf); in matchAndRewrite()
225 rewriter, loc, in matchAndRewrite()
226 rewriter.create<LLVM::FDivOp>(loc, resultReal, rhsSqNorm, fmf)); in matchAndRewrite()
228 rewriter, loc, in matchAndRewrite()
229 rewriter.create<LLVM::FDivOp>(loc, resultImag, rhsSqNorm, fmf)); in matchAndRewrite()
231 rewriter.replaceOp(op, {result}); in matchAndRewrite()
241 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
244 unpackBinaryComplexOperands<complex::MulOp>(op, adaptor, rewriter); in matchAndRewrite()
248 auto result = ComplexStructBuilder::undef(rewriter, loc, structType); in matchAndRewrite()
257 Value real = rewriter.create<LLVM::FSubOp>( in matchAndRewrite()
258 loc, rewriter.create<LLVM::FMulOp>(loc, rhsRe, lhsRe, fmf), in matchAndRewrite()
259 rewriter.create<LLVM::FMulOp>(loc, rhsIm, lhsIm, fmf), fmf); in matchAndRewrite()
261 Value imag = rewriter.create<LLVM::FAddOp>( in matchAndRewrite()
262 loc, rewriter.create<LLVM::FMulOp>(loc, lhsIm, rhsRe, fmf), in matchAndRewrite()
263 rewriter.create<LLVM::FMulOp>(loc, lhsRe, rhsIm, fmf), fmf); in matchAndRewrite()
265 result.setReal(rewriter, loc, real); in matchAndRewrite()
266 result.setImaginary(rewriter, loc, imag); in matchAndRewrite()
268 rewriter.replaceOp(op, {result}); in matchAndRewrite()
278 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
281 unpackBinaryComplexOperands<complex::SubOp>(op, adaptor, rewriter); in matchAndRewrite()
285 auto result = ComplexStructBuilder::undef(rewriter, loc, structType); in matchAndRewrite()
290 rewriter.create<LLVM::FSubOp>(loc, arg.lhs.real(), arg.rhs.real(), fmf); in matchAndRewrite()
292 rewriter.create<LLVM::FSubOp>(loc, arg.lhs.imag(), arg.rhs.imag(), fmf); in matchAndRewrite()
293 result.setReal(rewriter, loc, real); in matchAndRewrite()
294 result.setImaginary(rewriter, loc, imag); in matchAndRewrite()
296 rewriter.replaceOp(op, {result}); in matchAndRewrite()