Made casts explicit in the IRPrinter and StmtToHtml#9057
Made casts explicit in the IRPrinter and StmtToHtml#9057mcourteaux wants to merge 5 commits intohalide:mainfrom
Conversation
|
I worry this is going to make large bits of fixed-point IR harder to read. What was ambigious about it before? |
Before, it used to present |
|
Immediates were |
|
If that's too subtle of a difference, perhaps we should change how immediates print so that they look less like C-style casts? In large fixed-point Exprs you want to visually minimize the amount of real-estate the cast nodes take up, so that you can focus on the actual operators. This is why the ConciseCasts namespace exists for writing Exprs. |
|
One other reason is that several nodes print their resulting type in front of them. For example Lines 1478 to 1479 in 7e40343 Sometimes, Lines 995 to 997 in 7e40343
Lines 818 to 820 in 7e40343
Lines 1067 to 1077 in 7e40343 Perhaps we just use different syntax for casts: perhaps
Observe here that it's clear now that the |
That's even backwards from C, I just realized. Perhaps also confusing on it's own? I prefer C-style casts, and constructor-style literals:
Which is exactly backwards to what we have right now. |
|
In C++ you can use primitive types as constructors, so either way around makes a cast. |
Hm, I see. So nothing was ambiguous. I think @alexreinking and I were both fooled by the swapped notations compared to C++. What looks like a cast in C/C++ is a type-annotation in Halide IR, and what looks like a constructor-call in C++ is a cast in Halide IR. |
|
I think two core contributors being confused about a notation is reason enough to change it. |
|
We can already take away quite some confusion by just introducing suffixes from the non-int32 literals. I propose I'm not disliking this (cast is still with my
|
|
I suspect the reason for the confusion was that |
Yes, that's exactly it. Using cast syntax without a corresponding cast node is the crux of the confusion. |
|
Suffixes for literals are certainly an option, but that doesn't address vars and calls. I would also be supportive of shortening printing of the cast operators to the ones in ConciseCasts so that it looks more like user-written Halide (which I think was the rationale behind the PR) but without making the IR more verbose. We'd have to extend it for vector types though, so it wouldn't be literally copy-pasteable in all contexts. Consider Right now we have: Which personally looks fine to me, but maybe that's just familiarity. The type applied as a function is a cast, the ones in parens before an Expr are declarations of type. What do we want this to be?
I don't want to change it unless it's to something significantly better though, because this is user-facing and familiarity is also important for existing users. |
|
This is in design flux still, so I removed my "Approve" until we reach some sort of consensus. My MVP is "Doesn't look like a cast in the absence of a cast". |
alexreinking
left a comment
There was a problem hiding this comment.
Apparently re-requesting doesn't clear the old approval.
alexreinking
left a comment
There was a problem hiding this comment.
And neither does submitting a "Comment" review! Gah! Bad UX...
…alue; IRPrinter types have been shortened to the concise versions. IRPrinter immediates use suffixes, or true/false in case of UInt(1).
|
Commited this style, as it's the closest to what we had, but just a bit clearer with the Let/LetStmt, and with the suffixes: let x : i16 = ...
i8x4(ramp(x, 3_i16, 4)) |
Fixup correctness/callable_errors




Now printing as
cast<type>(value)