Translation of multidimensional arrays
Paul Brook
paul@codesourcery.com
Mon May 15 18:46:00 GMT 2006
> There are two reasons presented in trans-types.c for why this haven't
> been done this way since the beginning:
>
> 1) "there is no way to explicitly set the array stride, so
> all data must be packed" -- this is no longer true, it is possible to
> specify the stride in ARRAY_REF arbitrarily.
> 2) it is difficult to construct the correct type for such an array,
> requiring use of PLACEHOLDER_EXPR. This is just a technical
> difficulty, not really an unsurmountable problem. Also,
> it is possible to avoid use of PLACEHOLDER_EXPRs; in fact, as
> long as the stride and lower bound is specified explicitly in the
> ARRAY_REF, the bounds and sizes specified in the type are not
> really used anywhere, so even keeping them NULL when they are
> non-constant would work (although that would be a bit hacky).
As long as the backend doesn't assume these values are invariant, this should
be ok. Allocatable arrays can be re-allocated with a different shape, and
the expressions may not even be valid at all points where the variable is in
scope. These as middle-end questions as much as anything else.
3) Maintaining type consistency and proper alias information gets harder.
Especially when you include modules and inlining. Currently we use the same
type_t[0...<unknown>] for pretty much everything and TBAA assumes they can
all alias. There are probably complications where we have two representations
or temporary copies of an array (eg. with function arguments). Also there
will probably be issues with the way reshape() and constant array
constructors are implemented.
> So I think doing this transition should be fairly straightforward,
> although of course time consuming.
I'd expect there to be a significant number of awkward corner cases, and doing
the conversion is a fairly big job.
If you're rewriting all this stuff it may be a convenient time to reconsider
whether strides are stored in bytes or elements.
Paul
More information about the Fortran
mailing list