-
Notifications
You must be signed in to change notification settings - Fork 183
[CIR] Emit bitcast for equal-width types #1991
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
[CIR] Emit bitcast for equal-width types #1991
Conversation
Implement VisitAsTypeExpr to lower AsTypeExpr expressions. - Emit an error when source and destination types differ in bitwidth. - When types already match, return the source value (no-op). - Otherwise lower to a CIR bitcast using cir::CastOp with CastKind::bitcast.
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 normally don't do code reviews, but you should follow the skeleton for this function from OG codegen — see. We try not to deviate too much from it unless there's a strong enough reason for that.
Please do whenever you feel like, we really appreciate it :) |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
bcardosolopes
left a comment
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.
Seems like there's some code formatting issues, but LGTM after that!
1b96e30 to
898b7cc
Compare
Fixed.. |
|
@mahmood82 after your first PR lands the testing should happen automatically, I suggest you run clang-format in your commits before pushing the PR |
This patch adds support for emitting a
cir.bitcastwhen reinterpretingvalues that have the same bit-width. This enables correct handling of
vector reinterpretation in CIR and aligns with the behavior of the LLVM IR
lowering.
Previously, equal-width reinterpretations were not handled, which caused
assertions or incorrect lowering when working with vector types or other
equal-sized aggregates.
Key points:
cir.bitcastemission when source and destination types haveequal width and only reinterpretation is required.
current type conversion pipeline.
Testing: