Except for when doing whole program optimization and with at least hidden symbols, the compiler can't assign variables to specific register slots across function calls in a safe manner. The register globals extension is used to allow e.g. the VM program counter or (for a stack machine) stack pointer to be placed in registers across multiple functions.
You can think of this as, almost, a custom calling convention exteennsion. Indeed, if you had one (e.g. Watcom's pragma based method) this would probably not be necessary (though, then again, it may still produce cleaner code)
better registers representation in C?
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: better registers representation in C?
That's what optimizing linkers are for---making things clean (e.g., LLVM gold plugin)
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: better registers representation in C?
Hi,
Just putting this for informational purposes only, the good old Turbo / Borland C++ had the feature of accessing registers like this. I do not have access to a Borland compiler right now , but i guess newer versions allows access to 32 bit registers
--Thomas
Just putting this for informational purposes only, the good old Turbo / Borland C++ had the feature of accessing registers like this. I do not have access to a Borland compiler right now , but i guess newer versions allows access to 32 bit registers
Code: Select all
_AX = 2 ;
_BX = 3 ;
_CX = _AX + _BX ;
--Thomas
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: better registers representation in C?
Yes, miker00lz already mentioned that. At least what Owen (who will get his 5th start after just two more posts from the time I post this ) mentions is useful for a sucky toolchain...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: better registers representation in C?
Sorry , missed that . However redundancy does improve reliability at timesYes, miker00lz already mentioned that. At least what Owen (who will get his 5th start after just two more posts from the time I post this ) mentions is useful for a sucky toolchain...
--Thomas