Sunday, March 1, 2015

I've been putting off working on GCC because I know the next thing to work on is the bad subreg instruction. This has always been a long, frustrating processs, so I'm not excitied to dive back into this. Oh well, this isn't going to get any easier...

I won't copy my debug notes here, since there were a lot of false starts and dead ends. Much frustration was had, and several implite words were directed at the fine people at Texas Instruments for their chosen method of working with byte values.

Finally, I found the source of the invalid instruction. The problem is that the code I added to insert SWPB instruction when needed to convert between data formats can emit multiple SWPB instructions.

During development, I noticed that the compiler evaluates the same chunks of code several times before moving on. To prevent multiple SWPB instructions frm being inserted, I added a check to make sure this wouldn't happen. If the location of the last inserted SWPB is the same as the requested location, do nothing.

This worked out great for the test programs I wrote, since they only had one place where SWPB's needed to be inserted. When compiling libgcc however, there were two places where we needed to do this. In this case, it was possible to insert multiple instructions, since the last insrted location ping-pongs between these two places.

All this means that the handling of subreg expressions will be much harder and require much more complicated code than I had originally expected. More research required, I think.