@@ -136,14 +136,6 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
136
136
return mlir::cir::GlobalViewAttr::get (type, symbol, indices);
137
137
}
138
138
139
- mlir::TypedAttr getZeroAttr (mlir::Type t) {
140
- return mlir::cir::ZeroAttr::get (getContext (), t);
141
- }
142
-
143
- mlir::cir::BoolAttr getCIRBoolAttr (bool state) {
144
- return mlir::cir::BoolAttr::get (getContext (), getBoolTy (), state);
145
- }
146
-
147
139
mlir::TypedAttr getConstNullPtrAttr (mlir::Type t) {
148
140
assert (t.isa <mlir::cir::PointerType>() && " expected cir.ptr" );
149
141
return getConstPtrAttr (t, 0 );
@@ -265,6 +257,8 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
265
257
return mlir::cir::FPAttr::getZero (fltType);
266
258
if (auto fltType = ty.dyn_cast <mlir::cir::BF16Type>())
267
259
return mlir::cir::FPAttr::getZero (fltType);
260
+ if (auto complexType = ty.dyn_cast <mlir::cir::ComplexType>())
261
+ return mlir::cir::ImaginaryAttr::getZero (complexType);
268
262
if (auto arrTy = ty.dyn_cast <mlir::cir::ArrayType>())
269
263
return getZeroAttr (arrTy);
270
264
if (auto ptrTy = ty.dyn_cast <mlir::cir::PointerType>())
@@ -744,6 +738,46 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
744
738
return create<mlir::cir::GetMemberOp>(loc, result, base, name, index );
745
739
}
746
740
741
+ mlir::Value createComplexCreate (mlir::Location loc, mlir::Value real,
742
+ mlir::Value imag) {
743
+ auto resultComplexTy =
744
+ mlir::cir::ComplexType::get (getContext (), real.getType ());
745
+ return create<mlir::cir::ComplexCreateOp>(loc, resultComplexTy, real, imag);
746
+ }
747
+
748
+ // / Create a cir.complex.real_ptr operation that derives a pointer to the real
749
+ // / part of the complex value pointed to by the specified pointer value.
750
+ mlir::Value createRealPtr (mlir::Location loc, mlir::Value value) {
751
+ auto srcComplexElemTy = value.getType ()
752
+ .cast <mlir::cir::PointerType>()
753
+ .getPointee ()
754
+ .cast <mlir::cir::ComplexType>()
755
+ .getElementTy ();
756
+ return create<mlir::cir::ComplexRealPtrOp>(
757
+ loc, getPointerTo (srcComplexElemTy), value);
758
+ }
759
+
760
+ Address createRealPtr (mlir::Location loc, Address addr) {
761
+ return Address{createRealPtr (loc, addr.getPointer ()), addr.getAlignment ()};
762
+ }
763
+
764
+ // / Create a cir.complex.imag_ptr operation that derives a pointer to the
765
+ // / imaginary part of the complex value pointed to by the specified pointer
766
+ // / value.
767
+ mlir::Value createImagPtr (mlir::Location loc, mlir::Value value) {
768
+ auto srcComplexElemTy = value.getType ()
769
+ .cast <mlir::cir::PointerType>()
770
+ .getPointee ()
771
+ .cast <mlir::cir::ComplexType>()
772
+ .getElementTy ();
773
+ return create<mlir::cir::ComplexImagPtrOp>(
774
+ loc, getPointerTo (srcComplexElemTy), value);
775
+ }
776
+
777
+ Address createImagPtr (mlir::Location loc, Address addr) {
778
+ return Address{createImagPtr (loc, addr.getPointer ()), addr.getAlignment ()};
779
+ }
780
+
747
781
// / Cast the element type of the given address to a different type,
748
782
// / preserving information like the alignment.
749
783
cir::Address createElementBitCast (mlir::Location loc, cir::Address addr,
@@ -756,14 +790,17 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
756
790
addr.getAlignment ());
757
791
}
758
792
759
- mlir::Value createLoad (mlir::Location loc, Address addr) {
793
+ mlir::Value createLoad (mlir::Location loc, Address addr,
794
+ bool isVolatile = false ) {
760
795
auto ptrTy = addr.getPointer ().getType ().dyn_cast <mlir::cir::PointerType>();
761
796
if (addr.getElementType () != ptrTy.getPointee ())
762
797
addr = addr.withPointer (
763
798
createPtrBitcast (addr.getPointer (), addr.getElementType ()));
764
799
765
- return create<mlir::cir::LoadOp>(loc, addr.getElementType (),
766
- addr.getPointer ());
800
+ return create<mlir::cir::LoadOp>(
801
+ loc, addr.getElementType (), addr.getPointer (), /* isDeref=*/ false ,
802
+ /* is_volatile=*/ isVolatile, /* alignment=*/ mlir::IntegerAttr{},
803
+ /* mem_order=*/ mlir::cir::MemOrderAttr{});
767
804
}
768
805
769
806
mlir::Value createAlignedLoad (mlir::Location loc, mlir::Type ty,
0 commit comments