On 2010-08-25, at 10:57 PM, chevalma@iro.umontreal.ca wrote:
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.
The x86, and most processors, only implement operations on same size operands. If you want to add a uint8 to and uint32 then you need an instruction to extend the uint8 to a uint32 and then perform the addition. So I don't see the point of allowing mixed size operations. It would be more complex, and yield absolutely no benefit in code quality.
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.
I don't understand your point. Can you elaborate?
Marc