I published the URL to this blog on atari age. The posts are in reverse chronological order but the best place to start is the beginning.
Thursday, 29 February 2024
Wednesday, 28 February 2024
Dev, Release, Install, Test, Debug
Previous: Missing Extends Up: Intro
There are a few scripts in the repo for installing gcc and binutils as well as scripts to create new patches and debian packages.
I work exclusively on Linux (debian bookworm currently) and have a script to create a .deb package which can be used for debian, ubuntu and others. The .deb package installs bins, libs, etc, in /opt/tms9900-gcc by default. Many users though are on Windows or MacOS and I am relying on others to build packaged releases for those OSs since I can't.
Development
The src files are contained in the "dev" directory. Only modifications to gcc and binutils are stored in the repo. This means only storing about 50 files as opposed to over 60,000. The dev directory contains two copies of any files that have been modified. The original files for gcc are in gcc-4.4.0-orig and the modified files are in gcc-4.4.0. Similarly for binutils. New files (including "gcc/config/tms9900/tms9900.md") have a corresponding empty file in the orig directory. This allows diff to create a patch that includes all changes and all additions to the stock gcc-4.4.0 distribution.
Files to be edited are mostly in "dev/gcc-4.4.0/gcc/config/tms9900". This dir contains the md file as well as a few C and H files. It also contains some library asm functions which get included in libgcc.a
To rebuild the compiler in the dev hierarchy, from the "dev/gcc-4.4.0/build" directory, you can use the following commands to build and install gcc and libgcc:
make all-gcc |
This assumes of course this directory has previously been configured for builds, from the build directory, using:
../configure --prefix <target-dir> --target=tms9900 --enable-languages=c,c++ |
Release
The script mkpatches.sh will generate new patch files. It takes a version number as a parameter. It will update the gcc DATESTAMP and REVISION files with the current date and the supplied version number. The patch revision can be queried in code by accessing the __TMS9900_PATCH_MAJOR__ and __TMS9900_PATCH_MINOR__ macros which return integer values.
Install
The primary install tool is a script called install.sh. It downloads gcc-4.4.0 and binutils-2.19.1, applies the patches to them, builds the compiler and toolchain, and installs to the specified directory. This script will create a directory called build in the pwd and do all its work in there. It marks progress by creating progress files such as ".gcc_patched" and ".gcc_built". To do a clean build from updated patches, the easiest thing to do is "rm -rf build" or at the very least remove the progress files.
Test
Debug
#!/bin/bash INCLUDE=-I../libti99i CFLAGS="$2 $3 $4 $5 $6 -Wall -da -std=c99 -fomit-frame-pointer $INCLUDE" ../dev/gcc-4.4.0/build/gcc/cc1 $CFLAGS < $1
|
; addhi3-20 : (insn 20 4 21 <stdin>:6 (set (reg/f:HI 10 r10) ; (plus:HI (reg/f:HI 10 r10) ; (const_int -2 [0xfffffffffffffffe]))) 63 {addhi3} (nil)) dect r10 ; movhi-21 : (insn 21 20 22 <stdin>:6 (set (mem:HI (reg/f:HI 10 r10) [0 S2 A16]) ; (reg:HI 11 r11)) 12 {tms9900_movhi} (expr_list:REG_DEAD (reg:HI 11 r11) ; (nil))) mov r11, *r10
|
Dummy md
Thursday, 1 February 2024
Missing extend and truncate insns
Various fixes have been tried including adding a separate subreg pass to the compiler to detect when subregs have been inserted. I've disabled this pass as I don't think modifying the compiler is the way to go and in any case it didn't seem to be working as intended anyway.
There didn't seem to me to be a pattern to the dropped extends until I noticed it often happened when doing binary "and" operation. So while this C code:
char c; int i; int z; void f() { z = (c + i) & 0x1f; }
|
def f f movb @c, r1 movb r1, r2 sra r2, 8 mov @i, r1 a r2, r1 andi r1, >1F mov r1, @z b *r11 |
def f f movb @c, r1 a @i, r1 andi r1, >1F mov r1, @z b *r11 |
(insn 6 3 7 2 <stdin>:7 (set (reg:HI 22 [ c+-1 ]) (sign_extend:HI (mem/c/i:QI (symbol_ref:HI ("c") <var_decl 0x7f7e81e82000 c>) [0 c+0 S1 A8]))) 17 {extendqihi2} (nil)) (insn 7 6 8 2 <stdin>:7 (set (reg:HI 23) (plus:HI (reg:HI 22 [ c+-1 ]) (mem/c/i:HI (symbol_ref:HI ("i") <var_decl 0x7f7e81e820a0 i>) [2 i+0 S2 A16]))) 63 {addhi3} (expr_list:REG_DEAD (reg:HI 22 [ c+-1 ]) (nil)))
|
(insn 7 6 8 2 <stdin>:7 (set (reg:HI 23) (plus:HI (mem/c/i:HI (symbol_ref:HI ("i") <var_decl 0x7f7e81e820a0 i>) [2 i+0 S2 A16]) (subreg:HI (mem/c/i:QI (symbol_ref:HI ("c") <var_decl 0x7f7e81e82000 c>) [0 c+0 S1 A8]) 0))) 63 {addhi3} (nil))
|
Failed to match this instruction: (set (reg:HI 23) (plus:HI (sign_extend:HI (mem/c/i:QI (symbol_ref:HI ("c") <var_decl 0x7f7e81e82000 c>) [0 c+0 S1 A8])) (mem/c/i:HI (symbol_ref:HI ("i") <var_decl 0x7f7e81e820a0 i>) [2 i+0 S2 A16])))
|
(insn 7 17 8 2 <stdin>:7 (set (reg:HI 1 r1 [23]) (plus:HI (reg:HI 1 r1 [+-1 ]) (mem/c/i:HI (symbol_ref:HI ("i") <var_decl 0x7f7e81e820a0 i>) [2 i+0 S2 A16]))) 63 {addhi3} (nil))
|
int f (char c, unsigned int len) { return c+len; }
|
def f f ; extendqihi2-8 : (insn 8 5 9 <stdin>:2 (set (reg:HI 1 r1 [orig:26 c+-1 ] [26]) ; (sign_extend:HI (reg:QI 1 r1 [ c ]))) 17 {extendqihi2} (nil)) sra r1, 8 ; addhi3-14 : (insn 14 9 20 <stdin>:4 (set (reg/i:HI 1 r1) ; (plus:HI (reg:HI 1 r1 [orig:26 c+-1 ] [26]) ; (reg:HI 2 r2 [ len ]))) 63 {addhi3} (expr_list:REG_DEAD (reg:HI 2 r2 [ len ]) ; (nil)))
|
(ORIGINAL_REGNO (operand) == REGNO (operand)) |
I published the URL to this blog on atari age. The posts are in reverse chronological order but the best place to start is the beginning .
-
Previous: Intro Next: TMS9900 Tools and libraries The tools in binutils seem very mature. I have not found any issues with ...
-
Next : Scope My first computer was a TI99/4A in 1982. I had a mini-memory module with a whopping 4KiB of RAM that came with a line-by-line ...
-
Previous: Scope Next: Coding in C Up: Intro Background The TMS9900 has some unique features among proces...