-
Notifications
You must be signed in to change notification settings - Fork 36
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
Specification language to describe flat conversions and aggregate splats. #358
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,19 @@ | |
of boolean type. A zero value is converted to \texttt{false}; all other values | ||
are converted to \texttt{true}. | ||
|
||
\Sec{Flat conversion}{Conv.flat} | ||
|
||
\p There is a flattened order of subobjects for an aggregate, \texttt{A}, | ||
\texttt{A$^\prime$}, as described in section \ref{Decl.Init.Agg}. An aggregate, | ||
\texttt{A}, can be flat converted to an aggregate, \texttt{B}, whose flattened | ||
form is \texttt{B$^\prime$}, if the following conditions are true: | ||
\begin{itemize} | ||
\item The length of \texttt{A$^\prime$}, \texttt{N}, is greater than or equal to the | ||
length of \texttt{B$^\prime$}, \texttt{M}. | ||
\item For every index \texttt{I} from \texttt{0} to \texttt{M-1}, there exists an | ||
implicit conversion from \texttt{A$^\prime$[I]} to \texttt{B$^\prime$[I]}. | ||
\end{itemize} | ||
|
||
\Sec{Vector splat conversion}{Conv.vsplat} | ||
|
||
\p A glvalue of type \texttt{T} can be converted to a cxvalue of type | ||
|
@@ -130,6 +143,42 @@ | |
prvalue of type \texttt{matrix<T,x,y>}. The destination value is the source | ||
value replicated into each element of the destination. | ||
|
||
\p A glvalue of type \texttt{vector<T,1>} can be converted to a cxvalue of type | ||
\texttt{vector<T,x>} or a prvalue of type \texttt{vector<T,1>} can be converted | ||
to a prvalue of type \texttt{vector<T,x>}. The destination value is the value in | ||
the source vector replicated into each element of the destination. | ||
|
||
\Sec{Array and Class splat conversion}{Conv.asplat} | ||
|
||
\p A glvalue of type \texttt{T} can be converted to a cxvalue of type | ||
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. I believe that this conversion can only produce a prvalue, not a cxvalue. The only place cxvalues are created is for struct S {
float V[4];
};
void fn(inout float4 F) {}
export void call() {
S V = {1.xxxx};
fn((float4)V);
fn(V);
} |
||
\texttt{struct S} or a prvalue of type \texttt{T} can be converted to a | ||
prvalue of type \texttt{struct S}, if there are valid conversions from | ||
\texttt{T} to each \texttt{U} in flattened \texttt{S}, see section | ||
\ref{Decl.init.Agg} for description of a flattened ordering. The destination | ||
value is the source value \texttt{T} replicated into each element of the | ||
flattened \texttt{S}. | ||
|
||
\p A glvalue of type \texttt{vector<T,1>} can be converted to a cxvalue of type | ||
\texttt{struct S} or a prvalue of type \texttt{vector<T,1>} can be converted to a | ||
prvalue of type \texttt{struct S}, if there are valid conversions from | ||
\texttt{T} to each \texttt{U} in flattened \texttt{S}. The destination value is | ||
the value in the source vector replicated into each element of the flattened | ||
\texttt{S}. | ||
|
||
\p A glvalue of type \texttt{T} can be converted to a cxvalue of type | ||
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. There is an odd case for vector<->array conversions where we can create a cxvalue, but only from an explicit cast: void fn(inout float4 F) {}
export void call() {
float V[4] = {1.xxxx};
fn((float4)V); // valid
fn(V); // invalid
} |
||
\texttt{U[]} or a prvalue of type \texttt{T} can be converted to a | ||
prvalue of type \texttt{U[]}, if there are valid conversions from | ||
\texttt{T} to each \texttt{V} in flattened \texttt{U}. The destination value | ||
is the source value \texttt{T} replicated into each element of the flattened | ||
\texttt{U[]}. | ||
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.
|
||
|
||
\p A glvalue of type \texttt{vector<T,1>} can be converted to a cxvalue of type | ||
\texttt{U[]} or a prvalue of type \texttt{vector<T,1>} can be converted to a | ||
prvalue of type \texttt{U[]}, if there are valid conversions from | ||
\texttt{T} to each \texttt{V} in flattened \texttt{U}. The destination value | ||
is the value in the source vector replicated into each element of the flattened | ||
\texttt{U[]}. | ||
|
||
\Sec{Vector and matrix truncation conversion}{Conv.vtrunc} | ||
|
||
\p A prvalue of type \texttt{vector<T,x>} can be converted to a prvalue of type: | ||
|
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 think this language is fine for now, but we should probably have some common definitions and unify this with the language in Decl.Init.Agg.
I filed #372 to track that separately.