Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!lll-winken!gauss.llnl.gov!casey From: casey@gauss.llnl.gov (Casey Leedom) Newsgroups: gnu.gcc Subject: Re: short jumps Keywords: port Message-ID: <47277@lll-winken.LLNL.GOV> Date: 4 Feb 90 20:39:22 GMT References: <1049@tuvie> <25CA909C.21229@paris.ics.uci.edu> <1051@tuvie> Sender: usenet@lll-winken.LLNL.GOV Reply-To: casey@gauss.llnl.gov (Casey Leedom) Organization: Lawrence Livermore National Laboratory Lines: 40 | From: mike@vlsivie.uucp (Michael K. Gschwind) | | The problem is that the jumps have *COMPLETELY* different semantics. | This means that I have to clobber a register because far jumps are always | register indirect. Now I could say, "OK, every jump clobbers a register", | but this I do not want to do. This actually might not be such a terrible solution. It's what the Mips assembler does for instance. There are several instances where the Mips assembler needs a scratch register in order to implement some assembly instructions. Some of these case can be easily detected at compile time (load constant for instance), but others, like yours, can only be easily detected if you know about instruction sequence lengths, etc. These cases could be done by the compiler, but by the time you finished you'd have duplicated most of the assemblers guts in the compiler. Instead Mips' assembler has virtual instructions for things like ``jump foo'', ``load reg,foo'', etc. and it generates the right sequences. Now it's true that if the compiler did do this work, it would know exactly when it needed a scratch register and when it didn't and thus have use of an extra register from time to time. I think the compiler writers at Mips probably looked at it as follows: ``1. we have a lot of registers to play with, so losing one wouldn't be a major lose; 2. we may need a scratch register fairly often and thus not be saving much in the way of potential register time; 3. it would be a hell of a lot of work to put this into the compiler; and 4. the poor old assembly programmers would still need the virtual instructions provided by the assembler in order to not go crazy trying to make code compile.'' Thus, it doesn't cost that much to allocate a register out of the register set for an assembler temporary and it costs a lot in effort not to do it that way. Your situation might not be similar for any number of reasons (you don't have as many registers to play with, there aren't as many cases where you need a scratch register, etc.), but I don't think you should discount the idea without first giving it some thought. If your situation is like Mips', it may make a lot of sense. Casey