@@ -47,7 +47,8 @@ class CIR_TypeSummaries<list<Type> types> {
4747// Bool Type predicates
4848//===----------------------------------------------------------------------===//
4949
50- def CIR_AnyBoolType : CIR_TypeBase<"::cir::BoolType", "boolean type">;
50+ def CIR_AnyBoolType : CIR_TypeBase<"::cir::BoolType", "boolean type">,
51+ BuildableType<"$_builder.getType<" # cppType # ">()">;
5152
5253//===----------------------------------------------------------------------===//
5354// IntType predicates
@@ -132,18 +133,25 @@ def CIR_AnyFundamentalSIntType
132133// Float Type predicates
133134//===----------------------------------------------------------------------===//
134135
135- def CIR_AnySingleType : CIR_TypeBase<"::cir::SingleType", "single float type">;
136+ def CIR_AnySingleType : CIR_TypeBase<"::cir::SingleType", "single float type">,
137+ BuildableType<"$_builder.getType<" # cppType # ">()">;
136138def CIR_AnyFP32Type : TypeAlias<CIR_AnySingleType>;
137139
138- def CIR_AnyDoubleType : CIR_TypeBase<"::cir::DoubleType", "double float type">;
140+ def CIR_AnyDoubleType : CIR_TypeBase<"::cir::DoubleType", "double float type">,
141+ BuildableType<"$_builder.getType<" # cppType # ">()">;
139142def CIR_AnyFP64Type : TypeAlias<CIR_AnyDoubleType>;
140143
141- def CIR_AnyFP16Type : CIR_TypeBase<"::cir::FP16Type", "f16 type">;
142- def CIR_AnyBFloat16Type : CIR_TypeBase<"::cir::BF16Type", "bf16 type">;
143- def CIR_AnyFP80Type : CIR_TypeBase<"::cir::FP80Type", "f80 type">;
144- def CIR_AnyFP128Type : CIR_TypeBase<"::cir::FP128Type", "f128 type">;
144+ def CIR_AnyFP16Type : CIR_TypeBase<"::cir::FP16Type", "f16 type">,
145+ BuildableType<"$_builder.getType<" # cppType # ">()">;
146+ def CIR_AnyBFloat16Type : CIR_TypeBase<"::cir::BF16Type", "bf16 type">,
147+ BuildableType<"$_builder.getType<" # cppType # ">()">;
148+ def CIR_AnyFP80Type : CIR_TypeBase<"::cir::FP80Type", "f80 type">,
149+ BuildableType<"$_builder.getType<" # cppType # ">()">;
150+ def CIR_AnyFP128Type : CIR_TypeBase<"::cir::FP128Type", "f128 type">,
151+ BuildableType<"$_builder.getType<" # cppType # ">()">;
145152def CIR_AnyLongDoubleType : CIR_TypeBase<"::cir::LongDoubleType",
146- "long double type">;
153+ "long double type">,
154+ BuildableType<"$_builder.getType<" # cppType # ">()">;
147155
148156def CIR_AnyFloatType : AnyTypeOf<[
149157 CIR_AnySingleType, CIR_AnyDoubleType, CIR_AnyFP16Type,
@@ -196,19 +204,25 @@ def CIR_AnyArrayType : CIR_TypeBase<"::cir::ArrayType", "array type">;
196204def CIR_AnyPtrType : CIR_TypeBase<"::cir::PointerType", "pointer type">;
197205
198206// Pointer to type constraint bases
199- class CIR_IsPtrToPred<code type> : CPred<"$_self.isPtrTo<" # type # ">()">;
207+ class CIR_IsPtrToPred<Type type>
208+ : CPred<"$_self.isPtrTo<" # type.cppType # ">()">;
200209
201- class CIR_PtrTo<code type, string summary>
210+ class CIR_PtrTo<Type type, string summary>
202211 : CIR_ConfinedType<CIR_AnyPtrType, [CIR_IsPtrToPred<type>],
203- "pointer to " # summary>;
212+ "pointer to " # summary>,
213+ SameBuildabilityAs<type,
214+ "$_builder.getType<" # cppType # ">(" # type.builderCall # ")">;
204215
205216// Pointer to pointer constraint bases
206- class CIR_IsPtrToPtrToPred<code type>
207- : CPred<"$_self.isPtrToPtrTo<" # type # ">()">;
217+ class CIR_IsPtrToPtrToPred<Type type>
218+ : CPred<"$_self.isPtrToPtrTo<" # type.cppType # ">()">;
208219
209- class CIR_PtrToPtrTo<code type, string summary>
220+ class CIR_PtrToPtrTo<Type type, string summary>
210221 : CIR_ConfinedType<CIR_AnyPtrType, [CIR_IsPtrToPtrToPred<type>],
211- "pointer to pointer to " # summary>;
222+ "pointer to pointer to " # summary>,
223+ SameBuildabilityAs<type,
224+ "$_builder.getType<" # cppType # ">($_builder.getType<" # cppType #
225+ ">(" # type.builderCall # "))">;
212226
213227// Pointee type constraint bases
214228class CIR_PointeePred<Pred pred> : SubstLeaves<"$_self",
@@ -221,17 +235,14 @@ class CIR_PtrToAnyOf<list<Type> types, string summary = "">
221235 "pointer to " # CIR_TypeSummaries<types>.value,
222236 summary)>;
223237
238+ // Void type constraints
239+ def CIR_AnyVoidType : CIR_TypeBase<"::cir::VoidType", "void type">,
240+ BuildableType<"$_builder.getType<" # cppType # ">()">;
241+
224242// Void pointer type constraints
225- def CIR_VoidPtrType
226- : CIR_PtrTo<"::cir::VoidType", "void type">,
227- BuildableType<"$_builder.getType<" # cppType # ">("
228- "cir::VoidType::get($_builder.getContext()))">;
243+ def CIR_VoidPtrType : CIR_PtrTo<CIR_AnyVoidType, "void type">;
229244
230- def CIR_PtrToVoidPtrType
231- : CIR_PtrToPtrTo<"::cir::VoidType", "void type">,
232- BuildableType<"$_builder.getType<" # cppType # ">("
233- "$_builder.getType<" # cppType # ">("
234- "cir::VoidType::get($_builder.getContext())))">;
245+ def CIR_PtrToVoidPtrType : CIR_PtrToPtrTo<CIR_AnyVoidType, "void type">;
235246
236247class CIR_PtrToType<Type type> : CIR_PtrToAnyOf<[type]>;
237248
@@ -323,9 +334,12 @@ def CIR_AnyDataMemberType : CIR_TypeBase<"::cir::DataMemberType",
323334// VPtr type predicates
324335//===----------------------------------------------------------------------===//
325336
326- def CIR_AnyVPtrType : CIR_TypeBase<"::cir::VPtrType", "vptr type">;
337+ def CIR_AnyVPtrType : CIR_TypeBase<"::cir::VPtrType", "vptr type">,
338+ BuildableType<"$_builder.getType<" # cppType # ">()">;
327339
328- def CIR_PtrToVPtr : CIR_PtrToType<CIR_AnyVPtrType>;
340+ def CIR_PtrToVPtr : CIR_PtrToType<CIR_AnyVPtrType>,
341+ BuildableType<"$_builder.getType<" # cppType # ">("
342+ "$_builder.getType<::cir::VPtrType>())">;
329343
330344//===----------------------------------------------------------------------===//
331345// Scalar Type predicates
0 commit comments