register-allocation

Algorithm for register allocation

喜夏-厌秋 提交于 2019-12-07 09:23:27
问题 I'm trying to implement a code generation/register allocation algorithm for Trees in favor of my old one, where I put everything on stack. Now I'm trying to implement Sethi-Ullman algorithm but from only contents I've found on Wikipedia and some web pages some parts of the algorithm remain unclear to me. I'm looking for an explanation to parts I'm missing with some pseudo-code/C/C++ working code. 1) Which approach should I use to chose free register? ie, the stack of registers beging used. I

GCC not saving/restoring reserved registers on function calls

天大地大妈咪最大 提交于 2019-11-30 09:33:17
问题 I have a scenario in GCC causing me problems. The behaviour I get is not the behaviour I expect. To summarise the situation, I am proposing several new instructions for x86-64 which are implemented in a hardware simulator. In order to test these instructions I am taking existing C source code and handcoding the new instructions using hexidecimal. Because these instructions interact with the existing x86-64 registers, I use the input/output/clobber lists to declare dependencies for GCC. What's

Register allocation and spilling, the easy way?

天涯浪子 提交于 2019-11-29 20:22:24
I'm looking for a way to allocate local variables to registers. I'm aware of a couple of serious methods for doing it (namely, those mentioned on Wikipedia ), but I'm stuck on how "spilling" is accomplished. Also, the relevant literature is quite intimidating. I'm hoping there's something simpler that will satisfy my priorities: Correctness -- an algorithm that will generate correct code regardless of how many local variables there are. Simplicity -- something I can understand without having to read too much literature. Efficiency -- it needs to be better than the current method, which is:

GCC not saving/restoring reserved registers on function calls

白昼怎懂夜的黑 提交于 2019-11-29 16:12:47
I have a scenario in GCC causing me problems. The behaviour I get is not the behaviour I expect. To summarise the situation, I am proposing several new instructions for x86-64 which are implemented in a hardware simulator. In order to test these instructions I am taking existing C source code and handcoding the new instructions using hexidecimal. Because these instructions interact with the existing x86-64 registers, I use the input/output/clobber lists to declare dependencies for GCC. What's happening is that if I call a function e.g. printf, the dependent registers aren't saved and restored.

Register allocation and spilling, the easy way?

自古美人都是妖i 提交于 2019-11-28 15:51:16
问题 I'm looking for a way to allocate local variables to registers. I'm aware of a couple of serious methods for doing it (namely, those mentioned on Wikipedia), but I'm stuck on how "spilling" is accomplished. Also, the relevant literature is quite intimidating. I'm hoping there's something simpler that will satisfy my priorities: Correctness -- an algorithm that will generate correct code regardless of how many local variables there are. Simplicity -- something I can understand without having

GCC: Prohibit use of some registers

蹲街弑〆低调 提交于 2019-11-27 08:37:33
This is a strange request but I have a feeling that it could be possible. What I would like is to insert some pragmas or directives into areas of my code (written in C) so that GCC's register allocator will not use them. I understand that I can do something like this, which might set aside this register for this variable register int var1 asm ("EBX") = 1984; register int var2 asm ("r9") = 101; The problem is that I'm inserting new instructions (for a hardware simulator) directly and GCC and GAS don't recognise these yet. My new instructions can use the existing general purpose registers and I

Address of register variable

坚强是说给别人听的谎言 提交于 2019-11-27 01:58:43
In C, we cannot use & to find out the address of a register variable but in C++ we can do the same. Why is it legal in C++ but not in C? Can someone please explain this concept in-depth. Here's an excerpt from Section 6.7.1 (footnote 101) of the C99 standard (pdf) : The implementation may treat any register declaration simply as an auto declaration. However, whether or not addressable storage is actually used, the address of any part of an object declared with storage-class specifier register cannot be computed , either explicitly (by use of the unary & operator as discussed in 6.5.3.2) or

GCC: Prohibit use of some registers

十年热恋 提交于 2019-11-26 17:46:15
问题 This is a strange request but I have a feeling that it could be possible. What I would like is to insert some pragmas or directives into areas of my code (written in C) so that GCC's register allocator will not use them. I understand that I can do something like this, which might set aside this register for this variable register int var1 asm ("EBX") = 1984; register int var2 asm ("r9") = 101; The problem is that I'm inserting new instructions (for a hardware simulator) directly and GCC and

Address of register variable

陌路散爱 提交于 2019-11-26 08:28:29
问题 In C, we cannot use & to find out the address of a register variable but in C++ we can do the same. Why is it legal in C++ but not in C? Can someone please explain this concept in-depth. 回答1: Here's an excerpt from Section 6.7.1 (footnote 101) of the C99 standard (pdf): The implementation may treat any register declaration simply as an auto declaration. However, whether or not addressable storage is actually used, the address of any part of an object declared with storage-class specifier