I would like to propose two changes to the IR:
At the moment, I setup the MIR arithmetic and comparison instructions to mostly only allow pairs of arguments of the same type. For example, you can add a pair of 16 bit integers, or a pair of 32 bit integers, but not a 16 bit int and a 32 bit int.
Do you think it would make sense to always allow adding any two kinds of integers? Eg: an int64 could be added to either a 16, 32 or 64 bit integer. Would this complicate the back-end? What about adding signed and unsigned integer values together? I was thinking that should probably not be directly allowed, that it should require an explicit cast.
On another note, I currently have 3 of each add/mul/divide/modulo instructions (untyped, integer, and floating-point add/mul/divide/etc.) in the IR. I am considering combining all of these 3 (but not add/sub/mul with overflow) into one instruction, so as to make it easier to generate code for typed operations using standard arithmetic operators. That is, the front-end would try to use the same "add" instruction when generating code for the JavaScript operator "+", no matter the type of the operands. I would like your opinion on this as well.
- Maxime