@@ -46,7 +46,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
4646 mlir::Value getConstAPSInt (mlir::Location loc, const llvm::APSInt &val) {
4747 auto ty =
4848 cir::IntType::get (getContext (), val.getBitWidth (), val.isSigned ());
49- return create< cir::ConstantOp>( loc, cir::IntAttr::get (ty, val));
49+ return cir::ConstantOp::create (* this , loc, cir::IntAttr::get (ty, val));
5050 }
5151
5252 mlir::Value getSignedInt (mlir::Location loc, int64_t val, unsigned numBits) {
@@ -63,20 +63,20 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
6363
6464 mlir::Value getConstAPInt (mlir::Location loc, mlir::Type typ,
6565 const llvm::APInt &val) {
66- return create< cir::ConstantOp>( loc, cir::IntAttr::get (typ, val));
66+ return cir::ConstantOp::create (* this , loc, cir::IntAttr::get (typ, val));
6767 }
6868
6969 cir::ConstantOp getConstant (mlir::Location loc, mlir::TypedAttr attr) {
70- return create< cir::ConstantOp>( loc, attr);
70+ return cir::ConstantOp::create (* this , loc, attr);
7171 }
7272
7373 // Creates constant null value for integral type ty.
7474 cir::ConstantOp getNullValue (mlir::Type ty, mlir::Location loc) {
75- return create< cir::ConstantOp>( loc, getZeroInitAttr (ty));
75+ return cir::ConstantOp::create (* this , loc, getZeroInitAttr (ty));
7676 }
7777
7878 cir::ConstantOp getBool (bool state, mlir::Location loc) {
79- return create< cir::ConstantOp>( loc, getCIRBoolAttr (state));
79+ return cir::ConstantOp::create (* this , loc, getCIRBoolAttr (state));
8080 }
8181 cir::ConstantOp getFalse (mlir::Location loc) { return getBool (false , loc); }
8282 cir::ConstantOp getTrue (mlir::Location loc) { return getBool (true , loc); }
@@ -164,7 +164,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
164164 bool isVolatile = false , bool isNontemporal = false ,
165165 uint64_t alignment = 0 ) {
166166 mlir::IntegerAttr alignmentAttr = getAlignmentAttr (alignment);
167- return create< cir::LoadOp>( loc, ptr, /* isDeref=*/ false , isVolatile,
167+ return cir::LoadOp::create (* this , loc, ptr, /* isDeref=*/ false , isVolatile,
168168 isNontemporal,
169169 /* alignment=*/ alignmentAttr,
170170 /* mem_order=*/
@@ -179,13 +179,13 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
179179 }
180180
181181 mlir::Value createNot (mlir::Value value) {
182- return create< cir::UnaryOp>( value.getLoc (), value.getType (),
182+ return cir::UnaryOp::create (* this , value.getLoc (), value.getType (),
183183 cir::UnaryOpKind::Not, value);
184184 }
185185
186186 cir::CmpOp createCompare (mlir::Location loc, cir::CmpOpKind kind,
187187 mlir::Value lhs, mlir::Value rhs) {
188- return create< cir::CmpOp>( loc, getBoolTy (), kind, lhs, rhs);
188+ return cir::CmpOp::create (* this , loc, getBoolTy (), kind, lhs, rhs);
189189 }
190190
191191 mlir::Value createIsNaN (mlir::Location loc, mlir::Value operand) {
@@ -194,28 +194,29 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
194194
195195 mlir::Value createUnaryOp (mlir::Location loc, cir::UnaryOpKind kind,
196196 mlir::Value operand) {
197- return create< cir::UnaryOp>( loc, kind, operand);
197+ return cir::UnaryOp::create (* this , loc, kind, operand);
198198 }
199199
200200 mlir::Value createBinop (mlir::Value lhs, cir::BinOpKind kind,
201201 const llvm::APInt &rhs) {
202- return create< cir::BinOp>( lhs.getLoc (), lhs.getType (), kind, lhs,
202+ return cir::BinOp::create (* this , lhs.getLoc (), lhs.getType (), kind, lhs,
203203 getConstAPInt (lhs.getLoc (), lhs.getType (), rhs));
204204 }
205205
206206 mlir::Value createBinop (mlir::Value lhs, cir::BinOpKind kind,
207207 mlir::Value rhs) {
208- return create<cir::BinOp>(lhs.getLoc (), lhs.getType (), kind, lhs, rhs);
208+ return cir::BinOp::create (*this , lhs.getLoc (), lhs.getType (), kind, lhs,
209+ rhs);
209210 }
210211
211212 mlir::Value createBinop (mlir::Location loc, mlir::Value lhs,
212213 cir::BinOpKind kind, mlir::Value rhs) {
213- return create< cir::BinOp>( loc, lhs.getType (), kind, lhs, rhs);
214+ return cir::BinOp::create (* this , loc, lhs.getType (), kind, lhs, rhs);
214215 }
215216
216217 mlir::Value createShift (mlir::Value lhs, const llvm::APInt &rhs,
217218 bool isShiftLeft) {
218- return create< cir::ShiftOp>( lhs.getLoc (), lhs.getType (), lhs,
219+ return cir::ShiftOp::create (* this , lhs.getLoc (), lhs.getType (), lhs,
219220 getConstAPInt (lhs.getLoc (), lhs.getType (), rhs),
220221 isShiftLeft);
221222 }
@@ -265,7 +266,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
265266
266267 mlir::Value createMul (mlir::Value lhs, mlir::Value rhs, bool hasNUW = false ,
267268 bool hasNSW = false ) {
268- auto op = create< cir::BinOp>( lhs.getLoc (), lhs.getType (),
269+ auto op = cir::BinOp::create (* this , lhs.getLoc (), lhs.getType (),
269270 cir::BinOpKind::Mul, lhs, rhs);
270271 if (hasNUW)
271272 op.setNoUnsignedWrap (true );
@@ -289,8 +290,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
289290 mlir::Value trueValue, mlir::Value falseValue) {
290291 assert (trueValue.getType () == falseValue.getType () &&
291292 " trueValue and falseValue should have the same type" );
292- return create< cir::SelectOp>( loc, trueValue.getType (), condition, trueValue ,
293- falseValue);
293+ return cir::SelectOp::create (* this , loc, trueValue.getType (), condition,
294+ trueValue, falseValue);
294295 }
295296
296297 mlir::Value createLogicalAnd (mlir::Location loc, mlir::Value lhs,
@@ -306,23 +307,27 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
306307 mlir::Value createComplexCreate (mlir::Location loc, mlir::Value real,
307308 mlir::Value imag) {
308309 auto resultComplexTy = cir::ComplexType::get (real.getType ());
309- return create<cir::ComplexCreateOp>(loc, resultComplexTy, real, imag);
310+ return cir::ComplexCreateOp::create (*this , loc, resultComplexTy, real,
311+ imag);
310312 }
311313
312314 mlir::Value createComplexReal (mlir::Location loc, mlir::Value operand) {
313315 auto operandTy = mlir::cast<cir::ComplexType>(operand.getType ());
314- return create<cir::ComplexRealOp>(loc, operandTy.getElementType (), operand);
316+ return cir::ComplexRealOp::create (*this , loc, operandTy.getElementType (),
317+ operand);
315318 }
316319
317320 mlir::Value createComplexImag (mlir::Location loc, mlir::Value operand) {
318321 auto operandTy = mlir::cast<cir::ComplexType>(operand.getType ());
319- return create<cir::ComplexImagOp>(loc, operandTy.getElementType (), operand);
322+ return cir::ComplexImagOp::create (*this , loc, operandTy.getElementType (),
323+ operand);
320324 }
321325
322326 mlir::Value createComplexBinOp (mlir::Location loc, mlir::Value lhs,
323327 cir::ComplexBinOpKind kind, mlir::Value rhs,
324328 cir::ComplexRangeKind range, bool promoted) {
325- return create<cir::ComplexBinOp>(loc, kind, lhs, rhs, range, promoted);
329+ return cir::ComplexBinOp::create (*this , loc, kind, lhs, rhs, range,
330+ promoted);
326331 }
327332
328333 mlir::Value createComplexAdd (mlir::Location loc, mlir::Value lhs,
@@ -356,16 +361,16 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
356361 if (mlir::cast<cir::PointerType>(dst.getType ()).getPointee () !=
357362 val.getType ())
358363 dst = createPtrBitcast (dst, val.getType ());
359- return create< cir::StoreOp>( loc, val, dst, isVolatile, isNontemporal, align ,
360- order,
364+ return cir::StoreOp::create (* this , loc, val, dst, isVolatile, isNontemporal,
365+ align, order,
361366 /* tbaa=*/ cir::TBAAAttr{});
362367 }
363368
364369 mlir::Value createAlloca (mlir::Location loc, cir::PointerType addrType,
365370 mlir::Type type, llvm::StringRef name,
366371 mlir::IntegerAttr alignment,
367372 mlir::Value dynAllocSize) {
368- return create< cir::AllocaOp>( loc, addrType, type, name, alignment,
373+ return cir::AllocaOp::create (* this , loc, addrType, type, name, alignment,
369374 dynAllocSize);
370375 }
371376
@@ -380,7 +385,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
380385 mlir::Value createAlloca (mlir::Location loc, cir::PointerType addrType,
381386 mlir::Type type, llvm::StringRef name,
382387 mlir::IntegerAttr alignment) {
383- return create< cir::AllocaOp>( loc, addrType, type, name, alignment);
388+ return cir::AllocaOp::create (* this , loc, addrType, type, name, alignment);
384389 }
385390
386391 mlir::Value createAlloca (mlir::Location loc, cir::PointerType addrType,
@@ -392,8 +397,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
392397
393398 mlir::Value createGetGlobal (mlir::Location loc, cir::GlobalOp global,
394399 bool threadLocal = false ) {
395- return create< cir::GetGlobalOp> (
396- loc, getPointerTo (global.getSymType (), global.getAddrSpace ()),
400+ return cir::GetGlobalOp::create (
401+ * this , loc, getPointerTo (global.getSymType (), global.getAddrSpace ()),
397402 global.getName (), threadLocal);
398403 }
399404
@@ -404,23 +409,23 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
404409 // / Create a copy with inferred length.
405410 cir::CopyOp createCopy (mlir::Value dst, mlir::Value src,
406411 bool isVolatile = false ) {
407- return create< cir::CopyOp>( dst.getLoc (), dst, src, isVolatile,
412+ return cir::CopyOp::create (* this , dst.getLoc (), dst, src, isVolatile,
408413 /* tbaa=*/ cir::TBAAAttr{});
409414 }
410415
411416 cir::MemCpyOp createMemCpy (mlir::Location loc, mlir::Value dst,
412417 mlir::Value src, mlir::Value len) {
413- return create< cir::MemCpyOp>( loc, dst, src, len);
418+ return cir::MemCpyOp::create (* this , loc, dst, src, len);
414419 }
415420
416421 cir::SignBitOp createSignBit (mlir::Location loc, mlir::Value val) {
417422 auto resTy = cir::BoolType::get (getContext ());
418- return create< cir::SignBitOp>( loc, resTy, val);
423+ return cir::SignBitOp::create (* this , loc, resTy, val);
419424 }
420425
421426 mlir::Value createSub (mlir::Value lhs, mlir::Value rhs, bool hasNUW = false ,
422427 bool hasNSW = false , bool saturated = false ) {
423- auto op = create< cir::BinOp>( lhs.getLoc (), lhs.getType (),
428+ auto op = cir::BinOp::create (* this , lhs.getLoc (), lhs.getType (),
424429 cir::BinOpKind::Sub, lhs, rhs);
425430 if (hasNUW)
426431 op.setNoUnsignedWrap (true );
@@ -441,7 +446,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
441446
442447 mlir::Value createAdd (mlir::Value lhs, mlir::Value rhs, bool hasNUW = false ,
443448 bool hasNSW = false , bool saturated = false ) {
444- auto op = create< cir::BinOp>( lhs.getLoc (), lhs.getType (),
449+ auto op = cir::BinOp::create (* this , lhs.getLoc (), lhs.getType (),
445450 cir::BinOpKind::Add, lhs, rhs);
446451 if (hasNUW)
447452 op.setNoUnsignedWrap (true );
@@ -468,7 +473,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
468473 cir::IntType resultTy,
469474 cir::BinOpOverflowKind kind,
470475 mlir::Value lhs, mlir::Value rhs) {
471- auto op = create<cir::BinOpOverflowOp>(loc, resultTy, kind, lhs, rhs);
476+ auto op =
477+ cir::BinOpOverflowOp::create (*this , loc, resultTy, kind, lhs, rhs);
472478 return {op.getResult (), op.getOverflow ()};
473479 }
474480
@@ -480,7 +486,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
480486 mlir::Value src, mlir::Type newTy) {
481487 if (newTy == src.getType ())
482488 return src;
483- return create< cir::CastOp>( loc, newTy, kind, src);
489+ return cir::CastOp::create (* this , loc, newTy, kind, src);
484490 }
485491
486492 mlir::Value createCast (cir::CastKind kind, mlir::Value src,
@@ -507,7 +513,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
507513 assert (mlir::isa<cir::RecordType>(recordBaseTy));
508514 auto fldTy = mlir::cast<cir::RecordType>(recordBaseTy).getMembers ()[idx];
509515 auto fldPtrTy = cir::PointerType::get (fldTy);
510- return create<cir::GetMemberOp>(loc, fldPtrTy, recordPtr, fldName, idx);
516+ return cir::GetMemberOp::create (*this , loc, fldPtrTy, recordPtr, fldName,
517+ idx);
511518 }
512519
513520 mlir::Value createPtrToInt (mlir::Value src, mlir::Type newTy) {
@@ -610,15 +617,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
610617 mlir::Location loc,
611618 llvm::function_ref<void (mlir::OpBuilder &, mlir::Location)> condBuilder,
612619 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)> bodyBuilder) {
613- return create< cir::DoWhileOp>( loc, condBuilder, bodyBuilder);
620+ return cir::DoWhileOp::create (* this , loc, condBuilder, bodyBuilder);
614621 }
615622
616623 // / Create a while operation.
617624 cir::WhileOp createWhile (
618625 mlir::Location loc,
619626 llvm::function_ref<void (mlir::OpBuilder &, mlir::Location)> condBuilder,
620627 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)> bodyBuilder) {
621- return create< cir::WhileOp>( loc, condBuilder, bodyBuilder);
628+ return cir::WhileOp::create (* this , loc, condBuilder, bodyBuilder);
622629 }
623630
624631 // / Create a for operation.
@@ -627,7 +634,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
627634 llvm::function_ref<void (mlir::OpBuilder &, mlir::Location)> condBuilder,
628635 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)> bodyBuilder,
629636 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)> stepBuilder) {
630- return create<cir::ForOp>(loc, condBuilder, bodyBuilder, stepBuilder);
637+ return cir::ForOp::create (*this , loc, condBuilder, bodyBuilder,
638+ stepBuilder);
631639 }
632640
633641 mlir::TypedAttr getConstPtrAttr (mlir::Type t, int64_t v) {
@@ -642,22 +650,22 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
642650 // Creates constant nullptr for pointer type ty.
643651 cir::ConstantOp getNullPtr (mlir::Type ty, mlir::Location loc) {
644652 assert (!MissingFeatures::targetCodeGenInfoGetNullPointer ());
645- return create< cir::ConstantOp>( loc, getConstPtrAttr (ty, 0 ));
653+ return cir::ConstantOp::create (* this , loc, getConstPtrAttr (ty, 0 ));
646654 }
647655
648656 // / Create a loop condition.
649657 cir::ConditionOp createCondition (mlir::Value condition) {
650- return create< cir::ConditionOp>( condition.getLoc (), condition);
658+ return cir::ConditionOp::create (* this , condition.getLoc (), condition);
651659 }
652660
653661 // / Create a yield operation.
654662 cir::YieldOp createYield (mlir::Location loc, mlir::ValueRange value = {}) {
655- return create< cir::YieldOp>( loc, value);
663+ return cir::YieldOp::create (* this , loc, value);
656664 }
657665
658666 cir::PtrStrideOp createPtrStride (mlir::Location loc, mlir::Value base,
659667 mlir::Value stride) {
660- return create< cir::PtrStrideOp>( loc, base.getType (), base, stride);
668+ return cir::PtrStrideOp::create (* this , loc, base.getType (), base, stride);
661669 }
662670
663671 cir::CallOp createCallOp (mlir::Location loc,
@@ -668,8 +676,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
668676 cir::SideEffect sideEffect = cir::SideEffect::All,
669677 cir::ExtraFuncAttributesAttr extraFnAttr = {}) {
670678
671- cir::CallOp callOp = create< cir::CallOp>( loc, callee, returnType, operands ,
672- callingConv, sideEffect);
679+ cir::CallOp callOp = cir::CallOp::create (* this , loc, callee, returnType,
680+ operands, callingConv, sideEffect);
673681
674682 if (extraFnAttr) {
675683 callOp->setAttr (" extra_attrs" , extraFnAttr);
@@ -723,9 +731,9 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
723731 cir::CallingConv callingConv = cir::CallingConv::C,
724732 cir::SideEffect sideEffect = cir::SideEffect::All,
725733 cir::ExtraFuncAttributesAttr extraFnAttr = {}) {
726- cir::CallOp tryCallOp =
727- create<cir::CallOp>( loc, callee, returnType, operands, callingConv,
728- sideEffect, /* exception=*/ getUnitAttr ());
734+ cir::CallOp tryCallOp = cir::CallOp::create (
735+ * this , loc, callee, returnType, operands, callingConv, sideEffect ,
736+ /* exception=*/ getUnitAttr ());
729737 if (extraFnAttr) {
730738 tryCallOp->setAttr (" extra_attrs" , extraFnAttr);
731739 } else {
@@ -783,8 +791,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
783791 assert (!MissingFeatures::addressSpace ());
784792 auto calleeTy = getPointerTo (calleeFuncTy);
785793
786- auto op = create< cir::GetMethodOp>( loc, calleeTy, adjustedThisTy, method ,
787- objectPtr);
794+ auto op = cir::GetMethodOp::create (* this , loc, calleeTy, adjustedThisTy,
795+ method, objectPtr);
788796 return {op.getCallee (), op.getAdjustedThis ()};
789797 }
790798};
0 commit comments