Wednesday, December 17, 2014

At last, I can see some progress. I put in some code in August to handle a problem where word-to-byte conversions were getting dropped. I handled this by inserting a swpb instruction to do the conversion first before doing the operation.

The problem here seems to be that this sequence was being performed on an instruction where the source and destination are the same register. This caused the instruction to be repeated. This might help explain things:

Original:
r27 = subreg_low_part(r27)

After reload:
r27 = subreg_low_part(r27)
r27 = subreg_low_part(r27)

The code in reload pulls the subreg expression out and does that first before doing any other operations. The problem is that in this case, r27 is virtual

There was an earlier modification to prevent instructions like this from being reloaded. So maybe that's the cause of this problem.

Thursday, December 11, 2014

There's another problem that was found on AtariAge. In this one, global variables which are not initialized are not being declared as global. Additionally, for initialized data, the label is emitted before the section directive. It's a mess.


eric@compaq:~/dev/tios/src/temp$ cat emw4.c
int no_init[10];
int init_zero[10] = {0};
int init_val[] = {1,2,3,4};
eric@compaq:~/dev/tios/src/temp$ cat emw4.s
    cseg
# No "def no_init", symbol will not be visible to other modules

no_init
    bss 20

    def    init_zero

    def    init_zero
init_zero
    bss 20

    def    init_val
    dseg
    even


# The "def init_val" line should be here
init_val
    data    1
    data    2
    data    3
    data    4

Saturday, December 6, 2014

It took a bit, but I got the compiler to emit some information


From unwind-dw2-fde.c.164r.subreg2:
(insn 41 40 213 7 ../../../libgcc/../gcc/unwind-dw2-fde.c:612 (set (reg:QI 22 [ prephitmp.500 ])
        (subreg:QI (reg/v:HI 27 [ encoding ]) 1)) 73 {movqi} (nil))
From unwind-dw2-fde.c.172r.ira:
Reloads for insn # 41
Reload 0: reload_in (QI) = (subreg:QI (reg/v:HI 27 [ encoding ]) 1)
        ALL_REGS, RELOAD_FOR_INPUT (opnum = 1)
        reload_in_reg: (subreg:QI (reg/v:HI 27 [ encoding ]) 1)
        reload_reg_rtx: (reg:QI 14 r14 [orig:22 prephitmp.500 ] [22])



(insn 229 40 238 7 ../../../libgcc/../gcc/unwind-dw2-fde.c:612 (set:QI (reg:QI 27)
        (subreg:QI (reg:HI 27) 1)) 73 {movqi} (nil))
../../../libgcc/../gcc/unwind-dw2-fde.c: In function ‘classify_object_over_fdes’:
../../../libgcc/../gcc/unwind-dw2-fde.c:645: internal compiler error: in reload_cse_simplify_operands, at postreload.c:396
Please submit a full bug report,


It looks like the problem is that the instruction is trying to validate R27 for use in strict mode. Since R27 is not a real register, the instruction fails. The instruction needs to be transformed to use a memory address. I'm not quite sure how to do this and why it's not being done now. My guess is that the changes I did to handle subregs is causing something else to break.

I checked the usage of R27, and there's no wierd dependancy forcing it to stay in a register. Hmm. More research is required here.

Friday, December 5, 2014

OK, I've done something horribly wrong. The latest patch fails to build libgcc. The initial problem was reported by TheMole on AtariAge. I just got too confident and didn't test with a full build.

I was able to replicate this depressingly easily. The problem is that the offending line declares a function prototype which uses the FILE macro from stdio.h, but does not include that header file. This apparently is not a problem when compiling GCC, but libgcc is not so forgiving. It turns out that the problem prototype is not really needed there, so we can comment that out and get a bit farther.

Until we hit the next problem:

insn does not satisfy its constraints:
(insn 229 40 238 7 ../../../libgcc/../gcc/unwind-dw2-fde.c:612 (set:QI (reg:QI 27)
        (subreg:QI (reg:HI 27) 1)) 73 {movqi} (nil))
../../../libgcc/../gcc/unwind-dw2-fde.c: In function ‘classify_object_over_fdes’:
../../../libgcc/../gcc/unwind-dw2-fde.c:645: internal compiler error: in reload_cse_simplify_operands, at postreload.c:396
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
make[1]: *** [unwind-dw2-fde.o] Error 1
make[1]: Leaving directory `/home/eric/dev/tios/src/gcc_installer/temp/build/gcc-4.4.0/build/tms9900/libgcc'

Somehow the stupid byte conversion stuff got back in there. Grr.

Thursday, December 4, 2014

GCC 4.4.0 patch 1.10

Changes this version:

Prevented use of R0 as an address base
Moved jump tables into text segment to free up space for variables
Fixed bug which put initialized data in bss section
Fixed negation of byte quantities
Minor code cleanup

Download: gcc-4.4.0-tms9900-1.10-patch.tar.gz

Binutils 2.19.1 patch 1.7

Changes this version:

Restored ability to have label and code on same line
Minor code cleanup

Download: binutils-2.19.1-tms9900-1.7-patch.tar.gz
I was trying to find more compiler stuff to work on, but I'm out of ideas. There are no more bugs I know about, and no obvious features that are lacking. I guess it's time for another release.

By the way, I tried out position-independent code (-fpic), and it seems to work OK. I didn't attempt anything serious, but the resulting code looks like it should be good.

The floating point stuff I was working on earlier would probably work out best as a separate library, and it might be good to write it in C rather than in assembly. That means scrapping all that code and starting over, even though I'm about 80% done with an assembly version. The problem is that handling denormals is a pain, and I'm spending too much time doing early optimization in assembly rather than getting proper functionality first.