[flang-commits] [flang] [llvm] [Flang] KIND De-templatization (PR #216960)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Wed Oct 21 15:53:53 PDT 2026


================
@@ -52,15 +53,29 @@ using common::TypeCategory;
 class TargetCharacteristics;
 
 // Specific intrinsic types are represented by specializations of
-// this class template Type<CATEGORY, KIND>.
-template <TypeCategory CATEGORY, int KIND = 0> class Type;
+// this class template Type<CATEGORY>.
+// This used to be Type<CATEGORY,KIND>, but now KIND is passed at runtime.
+// TODO: Since they are functionally the same, replace all occurances of Type
+// with TypeCategory.
+template <TypeCategory CATEGORY> class Type;
 
-using SubscriptInteger = Type<TypeCategory::Integer, 8>;
-using CInteger = Type<TypeCategory::Integer, 4>;
-using LargestInt = Type<TypeCategory::Integer, 16>;
-using LogicalResult = Type<TypeCategory::Logical, 4>;
-using LargestReal = Type<TypeCategory::Real, 16>;
-using Ascii = Type<TypeCategory::Character, 1>;
+using SubscriptInteger = Type<TypeCategory::Integer>;
+inline constexpr int SubscriptIntegerKind{8};
+
+using CInteger = Type<TypeCategory::Integer>;
+inline constexpr int CIntegerKind{4};
+
+using LargestInt = Type<TypeCategory::Integer>;
+inline constexpr int LargestIntKind{16};
+
+using LogicalResult = Type<TypeCategory::Logical>;
----------------
eugeneepshteyn wrote:

With `LogicalResult` (like `Ascii` and `SubscriptInteger`) no longer tied to one kind, lookups such as `GetScalarConstantValue<LogicalResult>` in `openmp-utils.cpp` now also match LOGICAL(1/2/8) constants. A metadirective with `condition(.true._8)` now lowers directly to the selected branch where main emits a constant `fir.if`. That looks like a fine simplification, but it isn't NFC; could the description mention it, and a test cover it? The description also still lists #216958 as part of the stack and says the PR includes #213573 and #208760, which are all on main now.


https://github.com/llvm/llvm-project/pull/216960


More information about the flang-commits mailing list