@@ -136,11 +136,6 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
136
136
return mlir::cir::GlobalViewAttr::get (type, symbol, indices);
137
137
}
138
138
139
- mlir::TypedAttr getConstNullPtrAttr (mlir::Type t) {
140
- assert (mlir::isa<mlir::cir::PointerType>(t) && " expected cir.ptr" );
141
- return getConstPtrAttr (t, 0 );
142
- }
143
-
144
139
mlir::Attribute getString (llvm::StringRef str, mlir::Type eltTy,
145
140
unsigned size = 0 ) {
146
141
unsigned finalSize = size ? size : str.size ();
@@ -246,31 +241,6 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
246
241
return mlir::cir::DataMemberAttr::get (getContext (), ty, std::nullopt);
247
242
}
248
243
249
- mlir::TypedAttr getZeroInitAttr (mlir::Type ty) {
250
- if (mlir::isa<mlir::cir::IntType>(ty))
251
- return mlir::cir::IntAttr::get (ty, 0 );
252
- if (auto fltType = mlir::dyn_cast<mlir::cir::SingleType>(ty))
253
- return mlir::cir::FPAttr::getZero (fltType);
254
- if (auto fltType = mlir::dyn_cast<mlir::cir::DoubleType>(ty))
255
- return mlir::cir::FPAttr::getZero (fltType);
256
- if (auto fltType = mlir::dyn_cast<mlir::cir::FP16Type>(ty))
257
- return mlir::cir::FPAttr::getZero (fltType);
258
- if (auto fltType = mlir::dyn_cast<mlir::cir::BF16Type>(ty))
259
- return mlir::cir::FPAttr::getZero (fltType);
260
- if (auto complexType = mlir::dyn_cast<mlir::cir::ComplexType>(ty))
261
- return getZeroAttr (complexType);
262
- if (auto arrTy = mlir::dyn_cast<mlir::cir::ArrayType>(ty))
263
- return getZeroAttr (arrTy);
264
- if (auto ptrTy = mlir::dyn_cast<mlir::cir::PointerType>(ty))
265
- return getConstNullPtrAttr (ptrTy);
266
- if (auto structTy = mlir::dyn_cast<mlir::cir::StructType>(ty))
267
- return getZeroAttr (structTy);
268
- if (mlir::isa<mlir::cir::BoolType>(ty)) {
269
- return getCIRBoolAttr (false );
270
- }
271
- llvm_unreachable (" Zero initializer for given type is NYI" );
272
- }
273
-
274
244
// TODO(cir): Once we have CIR float types, replace this by something like a
275
245
// NullableValueInterface to allow for type-independent queries.
276
246
bool isNullValue (mlir::Attribute attr) const {
@@ -554,28 +524,12 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
554
524
mlir::cir::IntAttr::get (t, C));
555
525
}
556
526
557
- mlir::cir::ConstantOp getBool (bool state, mlir::Location loc) {
558
- return create<mlir::cir::ConstantOp>(loc, getBoolTy (),
559
- getCIRBoolAttr (state));
560
- }
561
- mlir::cir::ConstantOp getFalse (mlir::Location loc) {
562
- return getBool (false , loc);
563
- }
564
- mlir::cir::ConstantOp getTrue (mlir::Location loc) {
565
- return getBool (true , loc);
566
- }
567
-
568
527
// / Create constant nullptr for pointer-to-data-member type ty.
569
528
mlir::cir::ConstantOp getNullDataMemberPtr (mlir::cir::DataMemberType ty,
570
529
mlir::Location loc) {
571
530
return create<mlir::cir::ConstantOp>(loc, ty, getNullDataMemberAttr (ty));
572
531
}
573
532
574
- // Creates constant null value for integral type ty.
575
- mlir::cir::ConstantOp getNullValue (mlir::Type ty, mlir::Location loc) {
576
- return create<mlir::cir::ConstantOp>(loc, ty, getZeroInitAttr (ty));
577
- }
578
-
579
533
mlir::cir::ConstantOp getZero (mlir::Location loc, mlir::Type ty) {
580
534
// TODO: dispatch creation for primitive types.
581
535
assert ((mlir::isa<mlir::cir::StructType>(ty) ||
0 commit comments