@@ -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 getZeroAttr (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>())
@@ -763,6 +757,46 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
763
757
return create<mlir::cir::GetMemberOp>(loc, result, base, name, index );
764
758
}
765
759
760
+ mlir::Value createComplexCreate (mlir::Location loc, mlir::Value real,
761
+ mlir::Value imag) {
762
+ auto resultComplexTy =
763
+ mlir::cir::ComplexType::get (getContext (), real.getType ());
764
+ return create<mlir::cir::ComplexCreateOp>(loc, resultComplexTy, real, imag);
765
+ }
766
+
767
+ // / Create a cir.complex.real_ptr operation that derives a pointer to the real
768
+ // / part of the complex value pointed to by the specified pointer value.
769
+ mlir::Value createRealPtr (mlir::Location loc, mlir::Value value) {
770
+ auto srcComplexElemTy = value.getType ()
771
+ .cast <mlir::cir::PointerType>()
772
+ .getPointee ()
773
+ .cast <mlir::cir::ComplexType>()
774
+ .getElementTy ();
775
+ return create<mlir::cir::ComplexRealPtrOp>(
776
+ loc, getPointerTo (srcComplexElemTy), value);
777
+ }
778
+
779
+ Address createRealPtr (mlir::Location loc, Address addr) {
780
+ return Address{createRealPtr (loc, addr.getPointer ()), addr.getAlignment ()};
781
+ }
782
+
783
+ // / Create a cir.complex.imag_ptr operation that derives a pointer to the
784
+ // / imaginary part of the complex value pointed to by the specified pointer
785
+ // / value.
786
+ mlir::Value createImagPtr (mlir::Location loc, mlir::Value value) {
787
+ auto srcComplexElemTy = value.getType ()
788
+ .cast <mlir::cir::PointerType>()
789
+ .getPointee ()
790
+ .cast <mlir::cir::ComplexType>()
791
+ .getElementTy ();
792
+ return create<mlir::cir::ComplexImagPtrOp>(
793
+ loc, getPointerTo (srcComplexElemTy), value);
794
+ }
795
+
796
+ Address createImagPtr (mlir::Location loc, Address addr) {
797
+ return Address{createImagPtr (loc, addr.getPointer ()), addr.getAlignment ()};
798
+ }
799
+
766
800
// / Cast the element type of the given address to a different type,
767
801
// / preserving information like the alignment.
768
802
cir::Address createElementBitCast (mlir::Location loc, cir::Address addr,
@@ -775,14 +809,17 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
775
809
addr.getAlignment ());
776
810
}
777
811
778
- mlir::Value createLoad (mlir::Location loc, Address addr) {
812
+ mlir::Value createLoad (mlir::Location loc, Address addr,
813
+ bool isVolatile = false ) {
779
814
auto ptrTy = addr.getPointer ().getType ().dyn_cast <mlir::cir::PointerType>();
780
815
if (addr.getElementType () != ptrTy.getPointee ())
781
816
addr = addr.withPointer (
782
817
createPtrBitcast (addr.getPointer (), addr.getElementType ()));
783
818
784
- return create<mlir::cir::LoadOp>(loc, addr.getElementType (),
785
- addr.getPointer ());
819
+ return create<mlir::cir::LoadOp>(
820
+ loc, addr.getElementType (), addr.getPointer (), /* isDeref=*/ false ,
821
+ /* is_volatile=*/ isVolatile, /* alignment=*/ mlir::IntegerAttr{},
822
+ /* mem_order=*/ mlir::cir::MemOrderAttr{});
786
823
}
787
824
788
825
mlir::Value createAlignedLoad (mlir::Location loc, mlir::Type ty,
0 commit comments