1!===-- module/__fortran_type_info.f90 --------------------------------------===! 2! 3! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4! See https://llvm.org/LICENSE.txt for license information. 5! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6! 7!===------------------------------------------------------------------------===! 8 9! Fortran definitions of runtime type description schemata. 10! See flang/runtime/type-info.h for C++ perspective. 11! The Semantics phase of the compiler requires the module file of this module 12! in order to generate description tables for all other derived types. 13 14module __Fortran_type_info 15 16 private 17 18 integer, parameter :: int64 = selected_int_kind(18) 19 20 type, public :: __builtin_c_ptr 21 integer(kind=int64) :: __address 22 end type 23 24 type, public :: __builtin_c_funptr 25 integer(kind=int64) :: __address 26 end type 27 28 type :: DerivedType 29 ! "TBP" bindings appear first. Inherited bindings, with overrides already 30 ! applied, appear in the initial entries in the same order as they 31 ! appear in the parent type's bindings, if any. They are followed 32 ! by new local bindings in alphabetic order of theing binding names. 33 type(Binding), pointer :: binding(:) 34 character(len=:), pointer :: name 35 integer(kind=int64) :: sizeInBytes 36 type(DerivedType), pointer :: parent 37 ! Instances of parameterized derived types use the "uninstantiated" 38 ! component to point to the pristine original definition. 39 type(DerivedType), pointer :: uninstantiated 40 integer(kind=int64) :: typeHash 41 integer(kind=int64), pointer :: kindParameter(:) ! values of instance 42 integer(1), pointer :: lenParameterKind(:) ! INTEGER kinds of LEN types 43 ! Data components appear in alphabetic order. 44 ! The parent component, if any, appears explicitly. 45 type(Component), pointer :: component(:) ! data components 46 type(ProcPtrComponent), pointer :: procptr(:) ! procedure pointers 47 ! Special bindings of the ancestral types are not duplicated here. 48 type(SpecialBinding), pointer :: special(:) 49 end type 50 51 type :: Binding 52 type(__builtin_c_funptr) :: proc 53 character(len=:), pointer :: name 54 end type 55 56 ! Array bounds and type parameters of ocmponents are deferred 57 ! (for allocatables and pointers), explicit constants, or 58 ! taken from LEN type parameters for automatic components. 59 enum, bind(c) ! Value::Genre 60 enumerator :: Deferred = 1, Explicit = 2, LenParameter = 3 61 end enum 62 63 type, bind(c) :: Value 64 integer(1) :: genre ! Value::Genre 65 integer(1) :: __padding0(7) 66 integer(kind=int64) :: value 67 end type 68 69 enum, bind(c) ! Component::Genre 70 enumerator :: Data = 1, Pointer = 2, Allocatable = 3, Automatic = 4 71 end enum 72 73 enum, bind(c) ! common::TypeCategory 74 enumerator :: CategoryInteger = 0, CategoryReal = 1, & 75 CategoryComplex = 2, CategoryCharacter = 3, & 76 CategoryLogical = 4, CategoryDerived = 5 77 end enum 78 79 type :: Component ! data components, incl. object pointers 80 character(len=:), pointer :: name 81 integer(1) :: genre ! Component::Genre 82 integer(1) :: category 83 integer(1) :: kind 84 integer(1) :: rank 85 integer(1) :: __padding0(4) 86 integer(kind=int64) :: offset 87 type(Value) :: characterLen ! for category == Character 88 type(DerivedType), pointer :: derived ! for category == Derived 89 type(Value), pointer :: lenValue(:) ! (SIZE(derived%lenParameterKind)) 90 type(Value), pointer :: bounds(:, :) ! (2, rank): lower, upper 91 class(*), pointer :: initialization 92 end type 93 94 type :: ProcPtrComponent ! procedure pointer components 95 character(len=:), pointer :: name 96 integer(kind=int64) :: offset 97 type(__builtin_c_funptr) :: initialization 98 end type 99 100 enum, bind(c) ! SpecialBinding::Which 101 enumerator :: Assignment = 4, ElementalAssignment = 5 102 enumerator :: Final = 8, ElementalFinal = 9, AssumedRankFinal = 10 103 enumerator :: ReadFormatted = 16, ReadUnformatted = 17 104 enumerator :: WriteFormatted = 18, WriteUnformatted = 19 105 end enum 106 107 type, bind(c) :: SpecialBinding 108 integer(1) :: which ! SpecialBinding::Which 109 integer(1) :: rank ! for which == SpecialBinding::Which::Final only 110 integer(1) :: isArgDescriptorSet 111 integer(1) :: __padding0(5) 112 type(__builtin_c_funptr) :: proc 113 end type 114 115end module 116