Lines Matching refs:rewriter
86 PatternRewriter &rewriter) { in createConstantAllBitsSet() argument
88 return rewriter.create<LLVM::ConstantOp>( in createConstantAllBitsSet()
91 minusOneIntegerAttribute(srcType, rewriter))); in createConstantAllBitsSet()
93 return rewriter.create<LLVM::ConstantOp>( in createConstantAllBitsSet()
94 loc, dstType, minusOneIntegerAttribute(srcType, rewriter)); in createConstantAllBitsSet()
99 PatternRewriter &rewriter, double value) { in createFPConstant() argument
102 return rewriter.create<LLVM::ConstantOp>( in createFPConstant()
105 rewriter.getFloatAttr(floatType, value))); in createFPConstant()
108 return rewriter.create<LLVM::ConstantOp>( in createFPConstant()
109 loc, dstType, rewriter.getFloatAttr(floatType, value)); in createFPConstant()
120 PatternRewriter &rewriter) { in optionallyTruncateOrExtend() argument
128 return rewriter.create<LLVM::ZExtOp>(loc, llvmType, value); in optionallyTruncateOrExtend()
134 return rewriter.create<LLVM::TruncOp>(loc, llvmType, value); in optionallyTruncateOrExtend()
141 ConversionPatternRewriter &rewriter) { in broadcast() argument
144 auto llvmI32Type = typeConverter.convertType(rewriter.getIntegerType(32)); in broadcast()
145 Value broadcasted = rewriter.create<LLVM::UndefOp>(loc, llvmVectorType); in broadcast()
147 auto index = rewriter.create<LLVM::ConstantOp>( in broadcast()
148 loc, llvmI32Type, rewriter.getI32IntegerAttr(i)); in broadcast()
149 broadcasted = rewriter.create<LLVM::InsertElementOp>( in broadcast()
158 ConversionPatternRewriter &rewriter) { in optionallyBroadcast() argument
161 return broadcast(loc, value, numElements, typeConverter, rewriter); in optionallyBroadcast()
178 ConversionPatternRewriter &rewriter) { in processCountOrOffset() argument
180 optionallyBroadcast(loc, value, srcType, converter, rewriter); in processCountOrOffset()
181 return optionallyTruncateOrExtend(loc, broadcasted, dstType, rewriter); in processCountOrOffset()
212 static Value createI32ConstantOf(Location loc, PatternRewriter &rewriter, in createI32ConstantOf() argument
214 return rewriter.create<LLVM::ConstantOp>( in createI32ConstantOf()
215 loc, IntegerType::get(rewriter.getContext(), 32), in createI32ConstantOf()
216 rewriter.getIntegerAttr(rewriter.getI32Type(), value)); in createI32ConstantOf()
221 ConversionPatternRewriter &rewriter, in replaceWithLoadOrStore() argument
229 rewriter.replaceOpWithNewOp<LLVM::LoadOp>( in replaceWithLoadOrStore()
236 rewriter.replaceOpWithNewOp<LLVM::StoreOp>(storeOp, adaptor.value(), in replaceWithLoadOrStore()
306 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
316 Value zero = rewriter.create<LLVM::ConstantOp>( in matchAndRewrite()
317 op.getLoc(), llvmIndexType, rewriter.getIntegerAttr(indexType, 0)); in matchAndRewrite()
319 rewriter.replaceOpWithNewOp<LLVM::GEPOp>(op, dstType, adaptor.base_ptr(), in matchAndRewrite()
331 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
335 rewriter.replaceOpWithNewOp<LLVM::AddressOfOp>(op, dstType, op.variable()); in matchAndRewrite()
347 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
356 typeConverter, rewriter); in matchAndRewrite()
358 typeConverter, rewriter); in matchAndRewrite()
361 Value minusOne = createConstantAllBitsSet(loc, srcType, dstType, rewriter); in matchAndRewrite()
363 rewriter.create<LLVM::ShlOp>(loc, dstType, minusOne, count); in matchAndRewrite()
364 Value negated = rewriter.create<LLVM::XOrOp>(loc, dstType, in matchAndRewrite()
367 rewriter.create<LLVM::ShlOp>(loc, dstType, negated, offset); in matchAndRewrite()
368 Value mask = rewriter.create<LLVM::XOrOp>( in matchAndRewrite()
374 rewriter.create<LLVM::AndOp>(loc, dstType, op.base(), mask); in matchAndRewrite()
376 rewriter.create<LLVM::ShlOp>(loc, dstType, op.insert(), offset); in matchAndRewrite()
377 rewriter.replaceOpWithNewOp<LLVM::OrOp>(op, dstType, baseAndMask, in matchAndRewrite()
391 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
407 auto signlessType = rewriter.getIntegerType(getBitWidth(srcType)); in matchAndRewrite()
411 rewriter.replaceOpWithNewOp<LLVM::ConstantOp>( in matchAndRewrite()
418 auto dstAttr = rewriter.getIntegerAttr(signlessType, srcAttr.getValue()); in matchAndRewrite()
419 rewriter.replaceOpWithNewOp<LLVM::ConstantOp>(constOp, dstType, dstAttr); in matchAndRewrite()
422 rewriter.replaceOpWithNewOp<LLVM::ConstantOp>( in matchAndRewrite()
435 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
444 typeConverter, rewriter); in matchAndRewrite()
446 typeConverter, rewriter); in matchAndRewrite()
455 auto baseSize = rewriter.getIntegerAttr(integerType, getBitWidth(srcType)); in matchAndRewrite()
458 ? rewriter.create<LLVM::ConstantOp>( in matchAndRewrite()
461 : rewriter.create<LLVM::ConstantOp>(loc, dstType, baseSize); in matchAndRewrite()
466 rewriter.create<LLVM::AddOp>(loc, dstType, count, offset); in matchAndRewrite()
468 rewriter.create<LLVM::SubOp>(loc, dstType, size, countPlusOffset); in matchAndRewrite()
469 Value baseShiftedLeft = rewriter.create<LLVM::ShlOp>( in matchAndRewrite()
474 rewriter.create<LLVM::AddOp>(loc, dstType, offset, amountToShiftLeft); in matchAndRewrite()
475 rewriter.replaceOpWithNewOp<LLVM::AShrOp>(op, dstType, baseShiftedLeft, in matchAndRewrite()
488 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
497 typeConverter, rewriter); in matchAndRewrite()
499 typeConverter, rewriter); in matchAndRewrite()
502 Value minusOne = createConstantAllBitsSet(loc, srcType, dstType, rewriter); in matchAndRewrite()
504 rewriter.create<LLVM::ShlOp>(loc, dstType, minusOne, count); in matchAndRewrite()
505 Value mask = rewriter.create<LLVM::XOrOp>(loc, dstType, maskShiftedByCount, in matchAndRewrite()
510 rewriter.create<LLVM::LShrOp>(loc, dstType, op.base(), offset); in matchAndRewrite()
511 rewriter.replaceOpWithNewOp<LLVM::AndOp>(op, dstType, shiftedBase, mask); in matchAndRewrite()
522 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
523 rewriter.replaceOpWithNewOp<LLVM::BrOp>(branchOp, adaptor.getOperands(), in matchAndRewrite()
537 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
541 VectorType weightType = VectorType::get(2, rewriter.getI32Type()); in matchAndRewrite()
545 rewriter.replaceOpWithNewOp<LLVM::CondBrOp>( in matchAndRewrite()
563 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
572 Value index = createI32ConstantOf(loc, rewriter, value.getInt()); in matchAndRewrite()
573 rewriter.replaceOpWithNewOp<LLVM::ExtractElementOp>( in matchAndRewrite()
577 rewriter.replaceOpWithNewOp<LLVM::ExtractValueOp>( in matchAndRewrite()
593 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
602 Value index = createI32ConstantOf(loc, rewriter, value.getInt()); in matchAndRewrite()
603 rewriter.replaceOpWithNewOp<LLVM::InsertElementOp>( in matchAndRewrite()
607 rewriter.replaceOpWithNewOp<LLVM::InsertValueOp>( in matchAndRewrite()
622 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
626 rewriter.template replaceOpWithNewOp<LLVMOp>( in matchAndRewrite()
641 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
656 MLIRContext *context = rewriter.getContext(); in matchAndRewrite()
657 OpBuilder::InsertionGuard guard(rewriter); in matchAndRewrite()
658 rewriter.setInsertionPointToStart(module.getBody()); in matchAndRewrite()
676 auto global = rewriter.create<LLVM::GlobalOp>( in matchAndRewrite()
682 Block *block = rewriter.createBlock(®ion); in matchAndRewrite()
685 rewriter.setInsertionPoint(block, block->begin()); in matchAndRewrite()
686 Value structValue = rewriter.create<LLVM::UndefOp>(loc, structType); in matchAndRewrite()
688 rewriter.create<LLVM::ConstantOp>(loc, llvmI32Type, executionModeAttr); in matchAndRewrite()
689 structValue = rewriter.create<LLVM::InsertValueOp>( in matchAndRewrite()
692 {rewriter.getIntegerAttr(rewriter.getI32Type(), 0)})); in matchAndRewrite()
697 Value entry = rewriter.create<LLVM::ConstantOp>(loc, llvmI32Type, attr); in matchAndRewrite()
698 structValue = rewriter.create<LLVM::InsertValueOp>( in matchAndRewrite()
701 {rewriter.getIntegerAttr(rewriter.getI32Type(), 1), in matchAndRewrite()
702 rewriter.getIntegerAttr(rewriter.getI32Type(), i)})); in matchAndRewrite()
704 rewriter.create<LLVM::ReturnOp>(loc, ArrayRef<Value>({structValue})); in matchAndRewrite()
705 rewriter.eraseOp(op); in matchAndRewrite()
721 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
760 auto newGlobalOp = rewriter.replaceOpWithNewOp<LLVM::GlobalOp>( in matchAndRewrite()
781 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
791 rewriter.template replaceOpWithNewOp<LLVMExtOp>(operation, dstType, in matchAndRewrite()
796 rewriter.template replaceOpWithNewOp<LLVMTruncOp>(operation, dstType, in matchAndRewrite()
811 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
813 rewriter.replaceOpWithNewOp<LLVM::CallOp>( in matchAndRewrite()
820 rewriter.replaceOpWithNewOp<LLVM::CallOp>( in matchAndRewrite()
834 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
840 rewriter.template replaceOpWithNewOp<LLVM::FCmpOp>( in matchAndRewrite()
855 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
861 rewriter.template replaceOpWithNewOp<LLVM::ICmpOp>( in matchAndRewrite()
875 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
882 Value one = createFPConstant(loc, srcType, dstType, rewriter, 1.0); in matchAndRewrite()
883 Value sqrt = rewriter.create<LLVM::SqrtOp>(loc, dstType, op.operand()); in matchAndRewrite()
884 rewriter.replaceOpWithNewOp<LLVM::FDivOp>(op, dstType, one, sqrt); in matchAndRewrite()
897 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
899 return replaceWithLoadOrStore(op, adaptor.getOperands(), rewriter, in matchAndRewrite()
914 return replaceWithLoadOrStore(op, adaptor.getOperands(), rewriter, in matchAndRewrite()
933 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
940 IntegerAttr minusOne = minusOneIntegerAttribute(srcType, rewriter); in matchAndRewrite()
942 ? rewriter.create<LLVM::ConstantOp>( in matchAndRewrite()
946 : rewriter.create<LLVM::ConstantOp>(loc, dstType, minusOne); in matchAndRewrite()
947 rewriter.template replaceOpWithNewOp<LLVM::XOrOp>(notOp, dstType, in matchAndRewrite()
961 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
962 rewriter.eraseOp(op); in matchAndRewrite()
973 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
974 rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(returnOp, ArrayRef<Type>(), in matchAndRewrite()
986 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
987 rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(returnValueOp, ArrayRef<Type>(), in matchAndRewrite()
1047 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1056 Block *currentBlock = rewriter.getBlock(); in matchAndRewrite()
1058 Block *endBlock = rewriter.splitBlock(currentBlock, position); in matchAndRewrite()
1068 rewriter.setInsertionPointToEnd(currentBlock); in matchAndRewrite()
1069 rewriter.create<LLVM::BrOp>(loc, brOp.getBlockArguments(), headerBlock); in matchAndRewrite()
1070 rewriter.eraseBlock(entryBlock); in matchAndRewrite()
1076 rewriter.setInsertionPointToEnd(mergeBlock); in matchAndRewrite()
1077 rewriter.create<LLVM::BrOp>(loc, terminatorOperands, endBlock); in matchAndRewrite()
1079 rewriter.inlineRegionBefore(loopOp.body(), endBlock); in matchAndRewrite()
1080 rewriter.replaceOp(loopOp, endBlock->getArguments()); in matchAndRewrite()
1094 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1106 rewriter.eraseOp(op); in matchAndRewrite()
1114 auto *currentBlock = rewriter.getInsertionBlock(); in matchAndRewrite()
1115 rewriter.setInsertionPointAfter(op); in matchAndRewrite()
1116 auto position = rewriter.getInsertionPoint(); in matchAndRewrite()
1117 auto *continueBlock = rewriter.splitBlock(currentBlock, position); in matchAndRewrite()
1129 rewriter.eraseBlock(headerBlock); in matchAndRewrite()
1135 rewriter.setInsertionPointToEnd(mergeBlock); in matchAndRewrite()
1136 rewriter.create<LLVM::BrOp>(loc, terminatorOperands, continueBlock); in matchAndRewrite()
1141 rewriter.setInsertionPointToEnd(currentBlock); in matchAndRewrite()
1142 rewriter.create<LLVM::CondBrOp>(loc, condBrOp.condition(), trueBlock, in matchAndRewrite()
1146 rewriter.inlineRegionBefore(op.body(), continueBlock); in matchAndRewrite()
1147 rewriter.replaceOp(op, continueBlock->getArguments()); in matchAndRewrite()
1163 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1173 rewriter.template replaceOpWithNewOp<LLVMOp>(operation, dstType, in matchAndRewrite()
1181 extended = rewriter.template create<LLVM::ZExtOp>(loc, dstType, in matchAndRewrite()
1184 extended = rewriter.template create<LLVM::SExtOp>(loc, dstType, in matchAndRewrite()
1187 Value result = rewriter.template create<LLVMOp>( in matchAndRewrite()
1189 rewriter.replaceOp(operation, result); in matchAndRewrite()
1200 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1206 Value sin = rewriter.create<LLVM::SinOp>(loc, dstType, tanOp.operand()); in matchAndRewrite()
1207 Value cos = rewriter.create<LLVM::CosOp>(loc, dstType, tanOp.operand()); in matchAndRewrite()
1208 rewriter.replaceOpWithNewOp<LLVM::FDivOp>(tanOp, dstType, sin, cos); in matchAndRewrite()
1225 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1232 Value two = createFPConstant(loc, srcType, dstType, rewriter, 2.0); in matchAndRewrite()
1234 rewriter.create<LLVM::FMulOp>(loc, dstType, two, tanhOp.operand()); in matchAndRewrite()
1235 Value exponential = rewriter.create<LLVM::ExpOp>(loc, dstType, multiplied); in matchAndRewrite()
1236 Value one = createFPConstant(loc, srcType, dstType, rewriter, 1.0); in matchAndRewrite()
1238 rewriter.create<LLVM::FSubOp>(loc, dstType, exponential, one); in matchAndRewrite()
1240 rewriter.create<LLVM::FAddOp>(loc, dstType, exponential, one); in matchAndRewrite()
1241 rewriter.replaceOpWithNewOp<LLVM::FDivOp>(tanhOp, dstType, numerator, in matchAndRewrite()
1253 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1266 Value size = createI32ConstantOf(loc, rewriter, 1); in matchAndRewrite()
1268 rewriter.replaceOpWithNewOp<LLVM::AllocaOp>(varOp, dstType, size); in matchAndRewrite()
1271 Value allocated = rewriter.create<LLVM::AllocaOp>(loc, dstType, size); in matchAndRewrite()
1272 rewriter.create<LLVM::StoreOp>(loc, adaptor.initializer(), allocated); in matchAndRewrite()
1273 rewriter.replaceOp(varOp, allocated); in matchAndRewrite()
1288 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1303 auto newFuncOp = rewriter.create<LLVM::LLVMFuncOp>(loc, name, llvmType); in matchAndRewrite()
1330 rewriter.inlineRegionBefore(funcOp.getBody(), newFuncOp.getBody(), in matchAndRewrite()
1332 if (failed(rewriter.convertRegionTypes(&newFuncOp.getBody(), typeConverter, in matchAndRewrite()
1336 rewriter.eraseOp(funcOp); in matchAndRewrite()
1351 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1354 rewriter.create<ModuleOp>(spvModuleOp.getLoc(), spvModuleOp.getName()); in matchAndRewrite()
1355 rewriter.inlineRegionBefore(spvModuleOp.getRegion(), newModuleOp.getBody()); in matchAndRewrite()
1358 rewriter.eraseBlock(&newModuleOp.getBodyRegion().back()); in matchAndRewrite()
1359 rewriter.eraseOp(spvModuleOp); in matchAndRewrite()
1374 ConversionPatternRewriter &rewriter) const override { in matchAndRewrite()
1382 rewriter.replaceOpWithNewOp<LLVM::ShuffleVectorOp>(op, vector1, vector2, in matchAndRewrite()
1390 auto *context = rewriter.getContext(); in matchAndRewrite()
1392 Value targetOp = rewriter.create<LLVM::UndefOp>(loc, dstType); in matchAndRewrite()
1408 Value dstIndex = rewriter.create<LLVM::ConstantOp>( in matchAndRewrite()
1409 loc, llvmI32Type, rewriter.getIntegerAttr(rewriter.getI32Type(), i)); in matchAndRewrite()
1410 Value index = rewriter.create<LLVM::ConstantOp>( in matchAndRewrite()
1412 rewriter.getIntegerAttr(rewriter.getI32Type(), indexVal - offsetVal)); in matchAndRewrite()
1414 auto extractOp = rewriter.create<LLVM::ExtractElementOp>( in matchAndRewrite()
1416 targetOp = rewriter.create<LLVM::InsertElementOp>(loc, dstType, targetOp, in matchAndRewrite()
1419 rewriter.replaceOp(op, targetOp); in matchAndRewrite()