Skip to content

Commit

Permalink
add a spec for loop unroll (#263)
Browse files Browse the repository at this point in the history
* add a spec for loop unroll
  • Loading branch information
farzonl authored Jul 11, 2024
1 parent 91e96ac commit 9b8f96d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions specs/language/statements.tex
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
\Ch{Statements}{Stmt}
\begin{grammar}
\define{statement}\br
labeled-statement\br
\opt{attribute-specifier-sequence} expression-statement\br
\opt{attribute-specifier-sequence} compound-statement\br
\opt{attribute-specifier-sequence} iteration-statement\br
\opt{attribute-specifier-sequence} selection-statement\br
declaration-statement
\end{grammar}
\Sec{Label Statements}{Stmt.Label}
\p The optional \textit{attribute-specifier-sequence} applies to the statement
that immediately follows it.
\Sec{Attributes}{Stmt.Attr}
\Sub{Unroll Attribute}{Stmt.Attr.Unroll}
\p The \textit{[unroll]} attribute is only valid when applied to
\textit{iteration-statements}. It is used to indicate that
\textit{iteration-statements} like \texttt{for}, \texttt{while} and
\texttt{do while} can be unrolled. This attribute qualifier can be used to
specify full unrolling or partial unrolling by a specified amount. This is a
compiler hint and the compiler may ignore this directive.

\p The unroll attribute may optionally have an unroll factor represented as a
single argument \texttt{n} that is an integer constant expression value
greater than zero. If n is not specified, the compiler determines the
unrolling factor for the loop. The \textit{[unroll]} attribute can not be
applied to the same \textit{iteration-statement} as the \texttt{[loop]}
attribute.

\Sub{Loop Attribute}{Stmt.Attr.Loop}
\p The Attribute \texttt{[loop]} tells the compiler to execute each iteration
of the loop. In other words, its a hint to indicate a loop should not be
unrolled. Therefore it is not compatible with the \texttt{[unroll]} attribute.

0 comments on commit 9b8f96d

Please sign in to comment.