Skip to content

Commit 3a89328

Browse files
committed
fixes for most things
1 parent 59eeb7f commit 3a89328

File tree

1 file changed

+21
-26
lines changed
  • flang/include/flang/Optimizer/Builder/Runtime

1 file changed

+21
-26
lines changed

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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 *>() {
188187
template <>
189188
constexpr 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
}
194193
template <>
195194
constexpr 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
}
201199
template <>
@@ -212,7 +210,7 @@ constexpr TypeBuilderFunc getModel<const signed char *>() {
212210
template <>
213211
constexpr 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
}
218216
template <>
@@ -225,7 +223,7 @@ constexpr TypeBuilderFunc getModel<char16_t *>() {
225223
template <>
226224
constexpr 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
}
231229
template <>
@@ -238,8 +236,7 @@ constexpr TypeBuilderFunc getModel<char32_t *>() {
238236
template <>
239237
constexpr 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
}
245242
template <>
@@ -268,7 +265,7 @@ constexpr TypeBuilderFunc getModel<void **>() {
268265
template <>
269266
constexpr 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
}
274271
template <>
@@ -289,7 +286,7 @@ constexpr TypeBuilderFunc getModel<const long *>() {
289286
template <>
290287
constexpr 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
}
295292
template <>
@@ -317,14 +314,13 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
317314
template <>
318315
constexpr 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
}
323320
template <>
324321
constexpr 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
}
330326
template <>
@@ -420,6 +416,7 @@ constexpr TypeBuilderFunc getModel<bool *>() {
420416
template <>
421417
constexpr 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>() {
428425
template <>
429426
constexpr 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
}
435432
template <>
@@ -439,8 +436,8 @@ constexpr TypeBuilderFunc getModel<const unsigned char *>() {
439436
template <>
440437
constexpr 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
}
446443
template <>
@@ -458,8 +455,8 @@ constexpr TypeBuilderFunc getModel<const unsigned *>() {
458455
template <>
459456
constexpr 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
}
465462
template <>
@@ -469,8 +466,8 @@ constexpr TypeBuilderFunc getModel<const unsigned long *>() {
469466
template <>
470467
constexpr 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
}
476473
template <>
@@ -572,8 +569,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor *>() {
572569
template <>
573570
constexpr 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
}
579575
template <>
@@ -605,8 +601,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
605601
template <>
606602
constexpr 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
}
612607
template <>

0 commit comments

Comments
 (0)