I was thinking of only having pointer + offset, where both of these are SSA temporaries, and so the offset can either be a constant or a variable. The point is really to allow our object pointers to remain unchanged and safe for the GC to collect/modify while still allowing us to read and write in the middle of an object.
Optimizations that are specific to x86, such as those involving having the load/store instructions doing the actual pointer/offset arithmetic, should probably be done in the backend. LLVM seems to do it that way.
- Maxime
This sound fine. It keeps the IR simple and on the x86, our principal target, we can use the SIB addressing mode to combine the object reference with the offset (which can be a constant or in a register). By the way, you should support both constant offsets, register offsets, and a combination constant+register (as these are all useful and allowed by the x86, for example to implement the dynamic indexing of an array the reference to the object must be combined with an offset to cancel the tag and a register with the index). Perhaps you should also support a multiplier for the index... hmmm... that's pretty much the x86 addressing modes!
Marc
On 2010-08-25, at 1:52 PM, chevalma@iro.umontreal.ca wrote:
Following our discussion, we were thinking that we may want two pointer types in the IR:
- pointers to objects with built-in offsets (to facilitate GC)
- raw pointers to anywhere in memory (ignored by GC)
However, I have been wondering how efficient this would be in terms of performance, because pointers with offsets are bigger (up to twice as big) and the offset must be considered by many instruction operating on those pointers, adding extra overhead to these instructions. There is also the issue of extra GC concerns being mixed in with the IR.
I have been thinking that instead, a better solution might be to have only two pointer types in the IR:
- Pointers to the start address of an object (directly usable by GC)
- Raw pointers
Instead of passing an offset along, I am thinking of simply modifying the load and store instructions to take an offset along with an object pointer. This way, the backend can generate optimized code for those cases where we want to load and store at an offset, but the IR never sees anything but pointers to the start of an object.
Code that needs to iterate over addresses in an object would simply maintain the offset on its own, in a separate temporary. In addition, this may have the benefit of allowing a simple load with a immediate offset when the offset passed is a constant value.
- Maxime
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list