@@ -96,7 +96,7 @@ In case of `len_type1`, the size, offset, etc. of `fld1` and `fld2` depend on
96
96
the runtime values of ` i ` and ` j ` when the components are inlined into the
97
97
derived type. At runtime, this information needs to be computed to be retrieved.
98
98
While lowering the PDT, compiler generated functions can be created in order to
99
- compute this information.
99
+ compute this information.
100
100
101
101
Note: The type description tables generated by semantics and used throughout the
102
102
runtime have component offsets as constants. Inlining component would require
@@ -127,7 +127,7 @@ type len_type2(i, j)
127
127
! allocatable components managed by the compiler. The
128
128
! `compiler_managed_allocatable` is not a proper keyword but just added here
129
129
! to have a better understanding.
130
- character(i+j), compiler_managed_allocatable :: fld1
130
+ character(i+j), compiler_managed_allocatable :: fld1
131
131
character(j-i+2), compiler_managed_allocatable :: fld2
132
132
end type
133
133
```
@@ -266,7 +266,7 @@ the offset of `fld1` in `len_type1` could be 0; its size would be computed as
266
266
function.
267
267
268
268
** FIR**
269
- ``` c
269
+ ```
270
270
// Example of compiler generated functions to compute offsets, size, etc.
271
271
// This is just an example and actual implementation might have more functions.
272
272
@@ -337,7 +337,7 @@ pdt_inlined_array(1)%field%fld2
337
337
```
338
338
339
339
Example of offset computation in the PDTs.
340
- ``` c
340
+ ```
341
341
%0 = call @_len_type3.field.typeparam.1(%i, %j) : (index, index) -> index
342
342
%1 = call @_len_type3.field.typeparam.2(%i, %j) : (index, index) -> index
343
343
%2 = call @_len_type3.offset.fld(%i, %j) : (index, index) -> index
@@ -367,7 +367,7 @@ operation can take the length type parameters needed for size/offset
367
367
computation.
368
368
369
369
** FIR**
370
- ``` c
370
+ ```
371
371
%5 = fir.field_index i, !fir.type<_QMmod1Tt{l:i32,i:!fir.array<?xi32>}>(%n : i32)
372
372
```
373
373
@@ -431,7 +431,7 @@ allocate(t1(2)::p)
431
431
```
432
432
433
433
** FIR**
434
- ``` c
434
+ ```
435
435
// For allocatable
436
436
%5 = fir.call @_FortranAAllocatableInitDerived(%desc, %type) : (!fir.box<none>, ) -> ()
437
437
// The AllocatableSetDerivedLength functions is called for each length type parameters.
@@ -455,8 +455,8 @@ The `DEALLOCATE` statement is lowered to a runtime call to
455
455
deallocate(pdt1)
456
456
```
457
457
458
- ** FIR**
459
- ``` c
458
+ ** FIR**
459
+ ```
460
460
// For allocatable
461
461
%8 = fir.call @_FortranAAllocatableDeallocate(%desc1) : (!fir.box<none>) -> (i32)
462
462
@@ -475,7 +475,7 @@ NULLIFY(p)
475
475
```
476
476
477
477
** FIR**
478
- ``` c
478
+ ```
479
479
%0 = fir.call @_FortranAPointerNullifyDerived(%desc, %type) : (!fir.box<none>, !fir.tdesc) -> ()
480
480
```
481
481
@@ -507,11 +507,11 @@ end subroutine
507
507
```
508
508
509
509
** FIR**
510
- ``` c
510
+ ```
511
511
func.func @_QMpdtPprint_pdt() {
512
512
%l = arith.constant = 10
513
513
%0 = fir.alloca !fir.type<_QMpdtTt{l:i32,i:!fir.array<?xi32>}> (%l : i32) {bindc_name = "x", uniq_name = "_QMpdt_initFlocalEx"}
514
- %1 = fir.embox %0 : (!fir.ref<! fir.type<_QMpdtTt{l:i32,i:!fir.array<?xi32> }>>) (typeparams %l : i32) -> !fir.box<! fir.type<_QMpdt_initTt{l:i32,i:!fir.array<2xi32> }>>
514
+ %1 = fir.embox %0 : (!fir.ref<!fir.type<_QMpdtTt{l:i32,i:!fir.array<?xi32>}>>) (typeparams %l : i32) -> !fir.box<!fir.type<_QMpdt_initTt{l:i32,i:!fir.array<2xi32>}>>
515
515
%2 = fir.address_of(@_QQcl.2E2F6669725F7064745F6578616D706C652E66393000) : !fir.ref<!fir.char<1,22>>
516
516
%c8_i32 = arith.constant 8 : i32
517
517
%3 = fir.convert %1 : (!fir.box<!fir.type<_QMpdtTt{l:i32,i:!fir.array<?xi32>}>>) -> !fir.box<none>
@@ -564,7 +564,7 @@ type(t(10)) :: a, b
564
564
type(t(20)) :: c
565
565
type(t(:)), allocatable :: d
566
566
a = b ! Legal assignment
567
- c = b ! Illegal assignment because `c` does not have the same length type
567
+ c = b ! Illegal assignment because `c` does not have the same length type
568
568
! parameter value than `b`.
569
569
d = c ! Legal because `d` is allocatable
570
570
```
@@ -607,12 +607,12 @@ module m
607
607
end type
608
608
609
609
contains
610
-
610
+
611
611
subroutine finalize_t1s(x)
612
612
type(t(kind(0.0))) x
613
613
if (associated(x%vector)) deallocate(x%vector)
614
614
END subroutine
615
-
615
+
616
616
subroutine finalize_t1v(x)
617
617
type(t(kind(0.0))) x(:)
618
618
do i = lbound(x,1), ubound(x,1)
@@ -832,7 +832,7 @@ allocating a PDT, the length type parameters are passed to the
832
832
operation so its size can be computed accordingly.
833
833
834
834
** FIR**
835
- ``` c
835
+ ```
836
836
%i = arith.constant 10 : i32
837
837
%0 = fir.alloca !fir.type<_QMmod1Tpdt{i:i32,data:!fir.array<?xf32>}> (%i : i32)
838
838
// %i is the ssa value of the length type parameter
@@ -845,7 +845,7 @@ value of the given type. When creating a PDT, the length type parameters are
845
845
passed so the size can be computed accordingly.
846
846
847
847
** FIR**
848
- ```c
848
+ ```
849
849
%i = arith.constant 10 : i32
850
850
%0 = fir.alloca !fir.type<_QMmod1Tpdt{i:i32,data:!fir.array<?xf32>}> (%i : i32)
851
851
// ...
@@ -866,7 +866,7 @@ end subroutine
866
866
```
867
867
868
868
** FIR**
869
- ``` c
869
+ ```
870
870
func.func @_QMpdt_initPlocal() {
871
871
%c2_i32 = arith.constant 2 : i32
872
872
%0 = fir.alloca !fir.type<_QMpdt_initTt{l:i32,i:!fir.array<?xi32>}> (%c2 : i32)
@@ -892,7 +892,7 @@ a field identifier in a derived-type. The operation takes length type parameter
892
892
values with a PDT so it can compute a correct offset.
893
893
894
894
** FIR**
895
- ``` c
895
+ ```
896
896
%l = arith.constant 10 : i32
897
897
%1 = fir.field_index i, !fir.type<_QMpdt_initTt{l:i32,i:i32}> (%l : i32)
898
898
%2 = fir.coordinate_of %ref, %1 : (!fir.type<_QMpdt_initTt{l:i32,i:i32}>, !fir.field) -> !fir.ref<i32>
@@ -905,7 +905,7 @@ return %3
905
905
This operation is used to get the length type parameter offset in from a PDT.
906
906
907
907
** FIR**
908
- ```c
908
+ ```
909
909
func.func @_QPpdt_len_value(%arg0: !fir.box<!fir.type<t1{l:i32,!fir.array<?xi32>}>>) -> i32 {
910
910
%0 = fir.len_param_index l, !fir.box<!fir.type<t1{l:i32,!fir.array<?xi32>}>>
911
911
%1 = fir.coordinate_of %arg0, %0 : (!fir.box<!fir.type<t1{l:i32,!fir.array<?xi32>}>>, !fir.len) -> !fir.ref<i32>
@@ -921,7 +921,7 @@ a memory location given the shape and LEN parameters of the result. Length type
921
921
parameters is passed if the PDT is not boxed.
922
922
923
923
** FIR**
924
- ``` c
924
+ ```
925
925
func.func @return_pdt(%buffer: !fir.ref<!fir.type<t2(l1:i32,l2:i32){x:f32}>>) {
926
926
%l1 = arith.constant 3 : i32
927
927
%l2 = arith.constant 5 : i32
@@ -938,7 +938,7 @@ parameters operands. This is designed to use PDT without descriptor directly in
938
938
FIR.
939
939
940
940
** FIR**
941
- ``` c
941
+ ```
942
942
// Operation used with a boxed PDT does not need the length type parameters as
943
943
// they are directly retrieved from the box.
944
944
%0 = fir.array_coor %boxed_pdt, %i, %j (fir.box<fir.array<?x?xfir.type<!fir.type<_QMpdt_initTt{l:i32,i:!fir.array<?xi32>}>>>>, index, index) -> !fir.ref<fir.type<!fir.type<_QMpdt_initTt{l:i32,i:!fir.array<?xi32>}>>>
0 commit comments