jcmvbkbc / gcc-xtensa

gcc for xtensa
GNU General Public License v2.0
131 stars 58 forks source link

"register" directive not honored correctly. #6

Closed cnlohr closed 7 years ago

cnlohr commented 7 years ago

Inside functions, I can declare a "register" directive to a variable. Amazingly, GCC sometimes follows it, but most of the time, it does not. Though it will usually generate code using the variable as a register, it doesn't always seem to work. Additionally, sometimes GCC will clobber my registers with its own code.

Furthermore, GCC does not seem to back up these registers inside a function call. Even if I list a register as clobbering in my volatile asm, it simply ignores that. I may clobber registers that could have serious consequences and GCC won't back them up. Ordinarily I'd just work around this, but the whole not saving registers thing is a pretty big annoyance.

jcmvbkbc commented 7 years ago

I can declare a "register" directive to a variable. Amazingly, GCC sometimes follows it, but most of the time, it does not. ... Furthermore, GCC does not seem to back up these registers inside a function call.

It doesn't have to. Please see https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables for more details. If you feel that you have a case that should work according to the documentation, please provide an example code to reproduce it and description of what exactly was expected and what's wrong.

cnlohr commented 7 years ago

I did not realize it would only be for io operands, I was sticking them in my clobber lists and it was still re-using them, though.

I don't know how much I care about this any more, since I've just taken to writing my function in the assembler since I need to get much more control over my stack and when/how I push things. Thank you for that reference though. I've never seen that page!

P.S. If the issue comes up again, I will re-open ticket.