-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start working on HLSL initialization lists #329
Open
llvm-beanz
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
llvm-beanz:cbieneman/decl.init.agg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,65 @@ | |
|
||
\Sec{Declarators}{Decl.Decl} | ||
\Sec{Initializers}{Decl.Init} | ||
|
||
\p The process of initialization described in this section applies to all | ||
initializers regardless of the context. | ||
|
||
\begin{grammar} | ||
\define{initializer}\br | ||
brace-or-equal-initializer\br | ||
\terminal{(} expression-list \terminal{)}\br | ||
|
||
\define{brace-or-equal-initializer}\br | ||
\terminal{=} initializer-clause\br | ||
braced-init-list\br | ||
|
||
\define{initializer-clause}\br | ||
assignment-expression\br | ||
braced-init-list\br | ||
|
||
\define{braced-init-list}\br | ||
\terminal{\{} initializer-list \opt{\terminal{,}} \terminal{\}}\br | ||
\terminal{\{} \terminal{\}}\br | ||
|
||
\define{initializer-list}\br | ||
initializer-clause\br | ||
initializer-list \terminal{,} initializer-clause\br | ||
\end{grammar} | ||
|
||
\Sub{Aggregate Initialization}{Decl.Init.Agg} | ||
|
||
\p An \textit{aggregate} is a vector, matrix, array, or class. | ||
|
||
\p The subobjects of an aggregate have a defined order. For vectors and arrays | ||
the order is increasing subscript order. For matrices it is increasing subscript | ||
order with the subscript nesting such that in the notation | ||
\texttt{Mat[M][N]}, the ordering is \(Mat[0][0]...Mat[0][N]... | ||
Mat[M][0]...Mat[M][N]\). For classes the order is base class, followed by member | ||
subobjects in declaration order. | ||
|
||
\p A \textit{flattened ordering} of subobjects can be produced by performing a | ||
depth-first traversal of the subobjects of an object following the defined | ||
subobject ordering. | ||
|
||
\p Each \textit{braced initializer list} is comprised of zero or more | ||
\textit{initializer-clause} expressions, which in turn may be another | ||
initializer-list or an \textit{assignment-expression}. Each | ||
assignment-expression is an object, which may be a scalar or aggregate type. A | ||
\textit{flattened initializer sequence} is constructed by a depth-first | ||
traversal over each assignment-expression in an initializer-list and performing | ||
a depth-first traversal accessing each subobject of the assignment-expression. | ||
|
||
\p An initializer-list is a valid initializer if for each element \(E_n\) in the | ||
target object's flattened ordering there is a corresponding initializer \(I_n\) | ||
in the flattened initializer sequence which can be implicitly converted to the | ||
element's type. | ||
|
||
\p An initializer-list is invalid if the flattened initializer sequence contains | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An initializer-list is valid if too many elements are provided? |
||
more or fewer elements than the target object's flattened ordering, or if any | ||
initializer \(I_n\) cannot be implicitly converted to the corresponding element | ||
\(E_n\)'s type. | ||
|
||
\Sec{Function Definitions}{Decl.Function} | ||
\Sec{Attributes}{Decl.Attr} | ||
\Sub{Semantic Annotations}{Decl.Attr.Semantic} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen the whole grammar so maybe assignment-expression isn't used elsewhere, but it seems natural it would mean A=B (where = is used visually). I wonder if there is a better term for this. Like 'initializer-value'.
Also, maybe this is visualized with '=', then disregard my comment. But maybe it would be good to have a definition of 'assignment-expression' included in the provided grammar to clarify.
Edit: I now know C++ better