@@ -87,8 +87,7 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(fir::FirOpBuilder &);
8787 auto voidTy = fir::LLVMPointerType::get ( \
8888 builder.getContext (), \
8989 mlir::IntegerType::get (builder.getContext (), 8 )); \
90- auto size_tTy = mlir::IntegerType::get (builder.getContext (), \
91- 8 * sizeof (std::size_t )); \
90+ auto size_tTy = builder.getIntPtrType (); \
9291 auto refTy = fir::ReferenceType::get (f (builder)); \
9392 return mlir::FunctionType::get ( \
9493 builder.getContext (), \
@@ -188,14 +187,13 @@ constexpr TypeBuilderFunc getModel<const char32_t *>() {
188187template <>
189188constexpr TypeBuilderFunc getModel<char >() {
190189 return [](fir::FirOpBuilder &builder) -> mlir::Type {
191- return mlir::IntegerType::get ( builder.getContext (), 8 * sizeof ( char ) );
190+ return builder.getCCharType ( );
192191 };
193192}
194193template <>
195194constexpr TypeBuilderFunc getModel<signed char >() {
196195 return [](fir::FirOpBuilder &builder) -> mlir::Type {
197- return mlir::IntegerType::get (builder.getContext (),
198- 8 * sizeof (signed char ));
196+ return builder.getCCharType ();
199197 };
200198}
201199template <>
@@ -212,7 +210,7 @@ constexpr TypeBuilderFunc getModel<const signed char *>() {
212210template <>
213211constexpr TypeBuilderFunc getModel<char16_t >() {
214212 return [](fir::FirOpBuilder &builder) -> mlir::Type {
215- return mlir::IntegerType::get (builder.getContext (), 8 * sizeof ( char16_t ) );
213+ return mlir::IntegerType::get (builder.getContext (), 16 );
216214 };
217215}
218216template <>
@@ -225,7 +223,7 @@ constexpr TypeBuilderFunc getModel<char16_t *>() {
225223template <>
226224constexpr TypeBuilderFunc getModel<char32_t >() {
227225 return [](fir::FirOpBuilder &builder) -> mlir::Type {
228- return mlir::IntegerType::get (builder.getContext (), 8 * sizeof ( char32_t ) );
226+ return mlir::IntegerType::get (builder.getContext (), 32 );
229227 };
230228}
231229template <>
@@ -238,8 +236,7 @@ constexpr TypeBuilderFunc getModel<char32_t *>() {
238236template <>
239237constexpr TypeBuilderFunc getModel<unsigned char >() {
240238 return [](fir::FirOpBuilder &builder) -> mlir::Type {
241- return mlir::IntegerType::get (builder.getContext (),
242- 8 * sizeof (unsigned char ));
239+ return builder.getCCharType ();
243240 };
244241}
245242template <>
@@ -268,7 +265,7 @@ constexpr TypeBuilderFunc getModel<void **>() {
268265template <>
269266constexpr TypeBuilderFunc getModel<long >() {
270267 return [](fir::FirOpBuilder &builder) -> mlir::Type {
271- return mlir::IntegerType::get ( builder.getContext (), 8 * 4 );
268+ return builder.getCLongType ( );
272269 };
273270}
274271template <>
@@ -289,7 +286,7 @@ constexpr TypeBuilderFunc getModel<const long *>() {
289286template <>
290287constexpr TypeBuilderFunc getModel<long long >() {
291288 return [](fir::FirOpBuilder &builder) -> mlir::Type {
292- return mlir::IntegerType::get ( builder.getContext (), 8 * sizeof ( long long ) );
289+ return builder.getCLongLongType ( );
293290 };
294291}
295292template <>
@@ -317,14 +314,13 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
317314template <>
318315constexpr TypeBuilderFunc getModel<unsigned long >() {
319316 return [](fir::FirOpBuilder &builder) -> mlir::Type {
320- return mlir::IntegerType::get ( builder.getContext (), 8 * 4 );
317+ return builder.getCLongType ( );
321318 };
322319}
323320template <>
324321constexpr TypeBuilderFunc getModel<unsigned long long >() {
325322 return [](fir::FirOpBuilder &builder) -> mlir::Type {
326- return mlir::IntegerType::get (builder.getContext (),
327- 8 * sizeof (unsigned long long ));
323+ return builder.getCLongLongType ();
328324 };
329325}
330326template <>
@@ -420,6 +416,7 @@ constexpr TypeBuilderFunc getModel<bool *>() {
420416template <>
421417constexpr TypeBuilderFunc getModel<unsigned short >() {
422418 return [](fir::FirOpBuilder &builder) -> mlir::Type {
419+ // TODO: This has special signedness semantics?
423420 return mlir::IntegerType::get (
424421 builder.getContext (), 8 * sizeof (unsigned short ),
425422 mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -428,8 +425,8 @@ constexpr TypeBuilderFunc getModel<unsigned short>() {
428425template <>
429426constexpr TypeBuilderFunc getModel<unsigned char *>() {
430427 return [](fir::FirOpBuilder &builder) -> mlir::Type {
431- return fir::ReferenceType::get (
432- mlir::IntegerType ::get (builder. getContext (), 8 ));
428+ TypeBuilderFunc f{getModel< unsigned char >()};
429+ return fir::ReferenceType ::get (f (builder ));
433430 };
434431}
435432template <>
@@ -439,8 +436,8 @@ constexpr TypeBuilderFunc getModel<const unsigned char *>() {
439436template <>
440437constexpr TypeBuilderFunc getModel<unsigned short *>() {
441438 return [](fir::FirOpBuilder &builder) -> mlir::Type {
442- return fir::ReferenceType::get ( mlir::IntegerType::get (
443- builder. getContext (), 8 * sizeof ( unsigned short ) ));
439+ TypeBuilderFunc f{getModel< unsigned short >()};
440+ return fir::ReferenceType::get ( f (builder ));
444441 };
445442}
446443template <>
@@ -458,8 +455,8 @@ constexpr TypeBuilderFunc getModel<const unsigned *>() {
458455template <>
459456constexpr TypeBuilderFunc getModel<unsigned long *>() {
460457 return [](fir::FirOpBuilder &builder) -> mlir::Type {
461- return fir::ReferenceType::get ( mlir::IntegerType::get (
462- builder. getContext (), 8 * sizeof ( unsigned long ) ));
458+ TypeBuilderFunc f{getModel< unsigned long >()};
459+ return fir::ReferenceType::get ( f (builder ));
463460 };
464461}
465462template <>
@@ -469,8 +466,8 @@ constexpr TypeBuilderFunc getModel<const unsigned long *>() {
469466template <>
470467constexpr TypeBuilderFunc getModel<unsigned long long *>() {
471468 return [](fir::FirOpBuilder &builder) -> mlir::Type {
472- return fir::ReferenceType::get ( mlir::IntegerType::get (
473- builder. getContext (), 8 * sizeof ( unsigned long long ) ));
469+ TypeBuilderFunc f{getModel< unsigned long long >()};
470+ return fir::ReferenceType::get ( f (builder ));
474471 };
475472}
476473template <>
@@ -572,8 +569,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor *>() {
572569template <>
573570constexpr TypeBuilderFunc getModel<Fortran::common::TypeCategory>() {
574571 return [](fir::FirOpBuilder &builder) -> mlir::Type {
575- return mlir::IntegerType::get (builder.getContext (),
576- sizeof (Fortran::common::TypeCategory) * 8 );
572+ return builder.getCEnumType ();
577573 };
578574}
579575template <>
@@ -605,8 +601,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
605601template <>
606602constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
607603 return [](fir::FirOpBuilder &builder) -> mlir::Type {
608- return mlir::IntegerType::get (builder.getContext (),
609- 8 * sizeof (Fortran::runtime::io::Iostat));
604+ return builder.getCEnumType ();
610605 };
611606}
612607template <>
0 commit comments