[clang] Implement `PointerLikeTraits` for `{File,Directory}EntryRef`
[llvm-project.git] / flang / module / iso_fortran_env.f90
blobac1847128beb35ee0322d0298e60e47d0e21c4b0
1 !===-- module/iso_fortran_env.f90 ------------------------------------------===!
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
7 !===------------------------------------------------------------------------===!
9 ! See Fortran 2018, clause 16.10.2
10 ! TODO: These are placeholder values so that some tests can be run.
12 include '../include/flang/Runtime/magic-numbers.h' ! for IOSTAT= error/end code values
14 module iso_fortran_env
16 use __Fortran_builtins, only: &
17 event_type => __builtin_event_type, &
18 lock_type => __builtin_lock_type, &
19 team_type => __builtin_team_type, &
20 atomic_int_kind => __builtin_atomic_int_kind, &
21 atomic_logical_kind => __builtin_atomic_logical_kind, &
22 compiler_options => __builtin_compiler_options, &
23 compiler_version => __builtin_compiler_version
25 implicit none
27 ! TODO: Use PACK([x],test) in place of the array constructor idiom
28 ! [(x, integer::j=1,COUNT([test]))] below once PACK() can be folded.
30 integer, parameter, private :: &
31 selectedASCII = selected_char_kind('ASCII'), &
32 selectedUCS_2 = selected_char_kind('UCS-2'), &
33 selectedUnicode = selected_char_kind('ISO_10646')
34 integer, parameter :: character_kinds(*) = [ &
35 [(selectedASCII, integer :: j=1, count([selectedASCII >= 0]))], &
36 [(selectedUCS_2, integer :: j=1, count([selectedUCS_2 >= 0]))], &
37 [(selectedUnicode, integer :: j=1, count([selectedUnicode >= 0]))]]
39 integer, parameter, private :: &
40 selectedInt8 = selected_int_kind(2), &
41 selectedInt16 = selected_int_kind(4), &
42 selectedInt32 = selected_int_kind(9), &
43 selectedInt64 = selected_int_kind(18),&
44 selectedInt128 = selected_int_kind(38), &
45 safeInt8 = merge(selectedInt8, selected_int_kind(0), &
46 selectedInt8 >= 0), &
47 safeInt16 = merge(selectedInt16, selected_int_kind(0), &
48 selectedInt16 >= 0), &
49 safeInt32 = merge(selectedInt32, selected_int_kind(0), &
50 selectedInt32 >= 0), &
51 safeInt64 = merge(selectedInt64, selected_int_kind(0), &
52 selectedInt64 >= 0), &
53 safeInt128 = merge(selectedInt128, selected_int_kind(0), &
54 selectedInt128 >= 0)
55 integer, parameter :: &
56 int8 = merge(selectedInt8, merge(-2, -1, selectedInt8 >= 0), &
57 digits(int(0,kind=safeInt8)) == 7), &
58 int16 = merge(selectedInt16, merge(-2, -1, selectedInt16 >= 0), &
59 digits(int(0,kind=safeInt16)) == 15), &
60 int32 = merge(selectedInt32, merge(-2, -1, selectedInt32 >= 0), &
61 digits(int(0,kind=safeInt32)) == 31), &
62 int64 = merge(selectedInt64, merge(-2, -1, selectedInt64 >= 0), &
63 digits(int(0,kind=safeInt64)) == 63), &
64 int128 = merge(selectedInt128, merge(-2, -1, selectedInt128 >= 0), &
65 digits(int(0,kind=safeInt128)) == 127)
67 integer, parameter :: integer_kinds(*) = [ &
68 selected_int_kind(0), &
69 ((selected_int_kind(k), &
70 integer :: j=1, count([selected_int_kind(k) >= 0 .and. &
71 selected_int_kind(k) /= &
72 selected_int_kind(k-1)])), &
73 integer :: k=1, 39)]
75 integer, parameter :: &
76 logical8 = int8, logical16 = int16, logical32 = int32, logical64 = int64
77 integer, parameter :: logical_kinds(*) = [ &
78 [(logical8, integer :: j=1, count([logical8 >= 0]))], &
79 [(logical16, integer :: j=1, count([logical16 >= 0]))], &
80 [(logical32, integer :: j=1, count([logical32 >= 0]))], &
81 [(logical64, integer :: j=1, count([logical64 >= 0]))]]
83 integer, parameter, private :: &
84 selectedReal16 = selected_real_kind(3, 4), & ! IEEE half
85 selectedBfloat16 = selected_real_kind(2, 37), & ! truncated IEEE single
86 selectedReal32 = selected_real_kind(6, 37), & ! IEEE single
87 selectedReal64 = selected_real_kind(15, 307), & ! IEEE double
88 selectedReal80 = selected_real_kind(18, 4931), & ! 80x87 extended
89 selectedReal64x2 = selected_real_kind(31, 307), & ! "double-double"
90 selectedReal128 = selected_real_kind(33, 4931), & ! IEEE quad
91 safeReal16 = merge(selectedReal16, selected_real_kind(0,0), &
92 selectedReal16 >= 0), &
93 safeBfloat16 = merge(selectedBfloat16, selected_real_kind(0,0), &
94 selectedBfloat16 >= 0), &
95 safeReal32 = merge(selectedReal32, selected_real_kind(0,0), &
96 selectedReal32 >= 0), &
97 safeReal64 = merge(selectedReal64, selected_real_kind(0,0), &
98 selectedReal64 >= 0), &
99 safeReal80 = merge(selectedReal80, selected_real_kind(0,0), &
100 selectedReal80 >= 0), &
101 safeReal64x2 = merge(selectedReal64x2, selected_real_kind(0,0), &
102 selectedReal64x2 >= 0), &
103 safeReal128 = merge(selectedReal128, selected_real_kind(0,0), &
104 selectedReal128 >= 0)
105 integer, parameter :: &
106 real16 = merge(selectedReal16, merge(-2, -1, selectedReal16 >= 0), &
107 digits(real(0,kind=safeReal16)) == 11), &
108 bfloat16 = merge(selectedBfloat16, merge(-2, -1, selectedBfloat16 >= 0), &
109 digits(real(0,kind=safeBfloat16)) == 8), &
110 real32 = merge(selectedReal32, merge(-2, -1, selectedReal32 >= 0), &
111 digits(real(0,kind=safeReal32)) == 24), &
112 real64 = merge(selectedReal64, merge(-2, -1, selectedReal64 >= 0), &
113 digits(real(0,kind=safeReal64)) == 53), &
114 real80 = merge(selectedReal80, merge(-2, -1, selectedReal80 >= 0), &
115 digits(real(0,kind=safeReal80)) == 64), &
116 real64x2 = merge(selectedReal64x2, merge(-2, -1, selectedReal64x2 >= 0), &
117 digits(real(0,kind=safeReal64x2)) == 106), &
118 real128 = merge(selectedReal128, merge(-2, -1, selectedReal128 >= 0), &
119 digits(real(0,kind=safeReal128)) == 113)
121 integer, parameter :: real_kinds(*) = [ &
122 [(real16, integer :: j=1, count([real16 >= 0]))], &
123 [(bfloat16, integer :: j=1, count([bfloat16 >= 0]))], &
124 [(real32, integer :: j=1, count([real32 >= 0]))], &
125 [(real64, integer :: j=1, count([real64 >= 0]))], &
126 [(real80, integer :: j=1, count([real80 >= 0]))], &
127 [(real64x2, integer :: j=1, count([real64x2 >= 0]))], &
128 [(real128, integer :: j=1, count([real128 >= 0]))]]
130 integer, parameter :: current_team = -1, initial_team = -2, parent_team = -3
132 integer, parameter :: input_unit = 5, output_unit = 6
133 integer, parameter :: error_unit = 0
134 integer, parameter :: iostat_end = FORTRAN_RUNTIME_IOSTAT_END
135 integer, parameter :: iostat_eor = FORTRAN_RUNTIME_IOSTAT_EOR
136 integer, parameter :: iostat_inquire_internal_unit = &
137 FORTRAN_RUNTIME_IOSTAT_INQUIRE_INTERNAL_UNIT
139 integer, parameter :: character_storage_size = 8
140 integer, parameter :: file_storage_size = 8
141 integer, parameter :: numeric_storage_size = 32
143 integer, parameter :: stat_failed_image = FORTRAN_RUNTIME_STAT_FAILED_IMAGE
144 integer, parameter :: stat_locked = FORTRAN_RUNTIME_STAT_LOCKED
145 integer, parameter :: stat_locked_other_image = FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE
146 integer, parameter :: stat_stopped_image = FORTRAN_RUNTIME_STAT_STOPPED_IMAGE
147 integer, parameter :: stat_unlocked = FORTRAN_RUNTIME_STAT_UNLOCKED
148 integer, parameter :: stat_unlocked_failed_image = FORTRAN_RUNTIME_STAT_UNLOCKED_FAILED_IMAGE
150 end module iso_fortran_env