[flang-commits] [flang] [flang] Enumeration Type: (PR 4/5) Lowering (PR #193571)
via flang-commits
flang-commits at lists.llvm.org
Tue Sep 29 14:58:51 PDT 2026
================
@@ -385,6 +385,17 @@ struct TypeBuilderImpl {
if (tySpec.IsVectorType()) {
return genVectorType(tySpec);
}
+ // Check the type symbol's DerivedTypeDetails for the enumeration flag,
+ // because some DerivedTypeSpec instances may not have the
+ // EnumerationType category set (e.g., those created during USE
+ // association or variable declarations).
+ if (const auto *dtDetails =
+ tySpec.typeSymbol()
+ .detailsIf<Fortran::semantics::DerivedTypeDetails>()) {
+ if (dtDetails->isEnumerationType()) {
+ return mlir::IntegerType::get(&converter.getMLIRContext(), 32);
----------------
MattPD wrote:
To clarify my earlier question, I'm inclined toward preserving a distinct FIR type for each enumeration type without boxing ordinary values. Boxing the current `i32` would still identify it as an integer, and boxing every ordinary enumeration scalar would add descriptors without improving type identity.
The merge base's named `fir.type` with an i32 `__ordinal` reuses existing descriptor machinery, making it a practical near-term starting point. A dedicated FIR enum type could better model a nonderived scalar, but it would need broader FIR and descriptor support.
Simply restoring the record would not be enough. The new ordinal operations and procedure interfaces would also need updates.
https://github.com/llvm/llvm-project/pull/193571
More information about the flang-commits
mailing list