Skip to content
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 specifying standard conversions #58

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

llvm-beanz
Copy link
Collaborator

This change adds some basic language to describe values then moves into describing HLSL's standard conversions and standard conversion sequences.

This change adds some basic language to describe values then moves into describing HLSL's standard conversions and standard conversion sequences.
Copy link
Collaborator

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some grammar pointers.

chapter enumerates the full set of conversions. A \textit{standard conversion
sequence} is a sequence of standard conversions in the following order:
\begin{enumerate}
\item Zero or one conversion of either lvalue-to-rvalue, array-to-pinter or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: array-to-pointer


\Sec{Floating point-integral conversion}{Conv.fpint}

\p A glvalue of floating point type can be converted to a cxvalue of integer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence should be separated into two.

discarding the fractional value. The behavior is undefined if the truncated
value cannot be represented in the destination type.

\p A glvalue of integer type can be converted to a cxvalue of floating point
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here.

\p A glvalue of type \texttt{matrix<T,x,y>} can be converted to a cxvalue of type
\texttt{matrix<T,z,w>}, or a prvalue of type \texttt{matrix<T,x,y>} can be
converted to a prvalue of type \texttt{matrix<T,z,w>} only if \texttt{x} is less
than or equal to \texttt{z} and \texttt{y} is less than or equal to \texttt{w}.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why not use the latex /leq operator?

\Sec{Qualification conversion}{Conv.qual}

A prvalue of type "\textit{cv1} \texttt{T}" can be converted to a prvalue of type
"\textit{cv2} \texttt{T}" type "\textit{cv2} \texttt{T}" is more cv-qualified
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a sentence break here?

\p A glvalue of floating point type can be converted to a cxvalue of integer
type. A prvalue of floating point type can be converted to a prvalue of
integer type. Conversion of floating point values to integer values truncates by
discarding the fractional value. The behavior is undefined if the truncated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "undefined" here different to "implementation defined" on line 53?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, "undefined" and "implementation defined" are defined terms earlier in the full document:

https://github.com/microsoft/hlsl-specs/blob/main/specs/language/introduction.tex#L148

Basically "implementation defined" behavior needs to be documented by the relevant part of the implementation (compiler, runtime, ISA, DXIL, SPIR-V, etc).

point type. If the destination type can exactly represent the source value, the
result is the exact value. If the destination type cannot exactly represent the
source value, the conversion to a best-approximation of the source value is
implementation defined.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to talk about rounding modes here? I worry that "best-approximation" is very ambiguous otherwise. If we're just going to kick the can and worry about those details later I'd just say "approximation".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the rounding modes falls under the "implementation defined" aspect and I would expect us to document the DXIL & SPIR-V behaviors separately since they may be different.

\p A glvalue of type \texttt{matrix<T,x,y>} can be converted to a cxvalue of type
\texttt{matrix<T,z,w>}, or a prvalue of type \texttt{matrix<T,x,y>} can be
converted to a prvalue of type \texttt{matrix<T,z,w>} only if \( x \leq z \)
and \(y \leq w \)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to have a brief code listing with examples for each section of conversions. Is that something that would be practical without it taking up too much space?

@llvm-beanz llvm-beanz merged commit e37a0b9 into microsoft:main Oct 24, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants