lang0: split Conv into multiple operators - #160
Conversation
Instead of overloading `Conv` with many different meanings, it only performs float <-> int conversion now, with the other meanings taken over by new operators.
The code is largely taken from the previous `Conv` implementation. `Conv` only does int-to-float and float-to-int conversion now, and the implementation is changed accordingly.
Only the aggregate parameter lowering has code that needs to handle the new operators. Since they have the same shape as `Conv`, they're simply appended to the `of` branches already existing for `Conv`.
* replace usage of `Conv` with the new operators (where applicable) * don't emit conversions for pointers types * use the new operators for implementing MIR cast
... except for `Conv`, as its semantics aren't very well defined at the moment.
saem
left a comment
There was a problem hiding this comment.
I personally prefer source then destination (reading things as "from to") as the order, but if there is a good reason not to do that, I get it.
I chose the current order for reasons of regularity. For most other operators that return a value (e.g., There are some exceptions to the "first type operand is result type" rule, however, namely the comparison operators, |
Summary
Add the
Zext,Sext,Trunc,Promote, andDemoteoperators.Convstill exists, but is now only used for int-to-float and float-to-int conversions.
Details
The previous
Convoperator was modeled after the conversion operatorof NimSkull's MIR, making it fairly high-level and leaving too much
behaviour-related decision making to
pass0.It's split into multiple, lower-level operators, making the final
translation easier and also providing earlier transformation stages with
more precise conversion operators.
skullyis changed to:Conv(where applicable)pointers are translated to the same IL type)
Finally, tests for the new
L0operators are added, except forConv,whose semantics aren't very well-defined at the moment.
Notes For Reviewers
A preparation for #146, but the new operators should be helpful in general, especially once the source language starts to support numeric conversions.