Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: David Brown Newsgroups: comp.compilers Subject: Re: Modern compilers for ye olde architectures Date: Tue, 5 Oct 2021 19:59:50 +0200 Organization: A noiseless patient Spider Lines: 31 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <21-10-008@comp.compilers> References: <21-10-007@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="40144"; mail-complaints-to="abuse@iecc.com" Keywords: architecture, tools Posted-Date: 05 Oct 2021 14:07:14 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <21-10-007@comp.compilers> Content-Language: en-GB Xref: csiph.com comp.compilers:2716 On 05/10/2021 14:22, Luke A. Guest wrote: > I have a Z80 project in mind and would like to build a compiler for a > Z80.  I was wondering if modern backend techniques can be applied > successfully for these old CPU's, i.e. SSA. > > I know GCC has backends for some older architectures, but these do weird > gymnastics such as implementing a virtual cpu in rtl and then lowering > further. > Certainly modern techniques /can/ be applied to a Z80 compiler. And the Z80 is a lot more powerful than many 8-bit CISC microcontrollers. As far as I know, the only 8-bit target for gcc (in the mainline at least) is the AVR. This is a RISC processor, with 32 8-bit registers, and a much more orthogonal architecture. gcc does do some "weird gymnastics", however - it allocates registers in pairs so that it can pretend to be 16-bit, and then code gets simplified in peephole passes. gcc also supports some 16-bit CISC devices. For the Z80, however, there are a number of compiler options. There are some commercial toolchains, such as HiSoft (IIRC), and there is the "Rabbit" microcontroller which is a derivative of the Z80. It is supported by a compiler for a somewhat extended version of C. Such compilers are probably quite old, however, and might not be easily available. Your best bet is probably SDCC. This is a multi-target open source compiler that is in regular development, and aimed specifically for small CISC microcontroller cores. The Z80 is one of its targets.