next up previous contents index
Next: Scalar subscripts in sequential Up: Basic translation Previous: Translating element access   Contents   Index


Translating array sections

The rules for translating array sections are more complicated than any other part of the basic translation scheme.

We will break it down into three cases: the case where there are no scalar subscripts--integer or distributed index; the case where integer scalar subscripts appear in sequential dimensions only; and the general case where scalar subscripts may appear in distributed dimensions. The scheme for translating the first case is illustrated in Figure A.27.

The macro PROCESS_SUBSCRIPTS will be defined here in a tail-recursive way. The intention is that it should be expanded to a compile-time loop over $s$.

Let $R$ be the rank of the subscripted array. If $s = R$, then the macro $\mbox{\it PROCESS\_SUBSCRIPTS}\left(v, r, a, s\right)$ is empty. Otherwise, if $\mbox{\it subs}_s$ is the degenerate triplet, :, then

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it PR...
...SCRIPTS}\left(v, r+1, a, s+1\right)$\end{tabbing}\end{minipage}\end{displaymath}

Otherwise, if $\mbox{\it subs}_s$ is the triplet, $e_{\mbox{\small lo}}$: $e_{\mbox{\small hi}}$: $e_{\mbox{\small stp}}$, and the $s$th dimension of $a$ is distributed, then

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it PR...
...SCRIPTS}\left(v, r+1, a, s+1\right)$\end{tabbing}\end{minipage}\end{displaymath}

where $a'_s = {\bf T}_{s}\left[{a}\right]$, $e_{\mbox{\small lo}}' = {\bf T}\left[{e_{\mbox{\small lo}}}\right]$, $e_{\mbox{\small hi}}' = {\bf T}\left[{e_{\mbox{\small hi}}}\right]$, and $e_{\mbox{\small stp}}' = {\bf T}\left[{e_{\mbox{\small stp}}}\right]$. Otherwise, if $\mbox{\it subs}_s$ is the triplet, $e_{\mbox{\small lo}}$: $e_{\mbox{\small hi}}$: $e_{\mbox{\small stp}}$, and the $s$th dimension of $a$ is sequential, then

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it PR...
...SCRIPTS}\left(v, r+1, a, s+1\right)$\end{tabbing}\end{minipage}\end{displaymath}

with definitions as above. Two similar cases using the two-argument form of subrng() take care of triplets of the form $e_{\mbox{\small lo}}$: $e_{\mbox{\small hi}}$. Otherwise, if $\mbox{\it subs}_s$ is the splitting subscript, <>, then

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it PR...
...SCRIPTS}\left(v, r+2, a, s+1\right)$\end{tabbing}\end{minipage}\end{displaymath}

where $x$, $u$, and $z$ are the names of new temporaries.

Figure A.28: Translation of array section without any scalar subscripts in distributed dimensions.

SOURCE:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$v$\verb$ = $...
... $\mbox{\it subs}_{R-1}$\verb$]] ;$
\end{tabbing}\end{minipage}\end{displaymath}

TRANSLATION:


\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$int $$b...
...t]$\verb$.group, $$b$\verb$) ;$ \\
\end{tabbing}\end{minipage}\end{displaymath}

where:

\begin{displaymath}
\begin{array}{l}
\mbox{The expression $v$ is the assigned a...
... {\it PROCESS\_SUBSCRIPTS} is defined in the text.}
\end{array}\end{displaymath}



Subsections
next up previous contents index
Next: Scalar subscripts in sequential Up: Basic translation Previous: Translating element access   Contents   Index
Bryan Carpenter 2003-04-15