LLVM backend for z80?

By PingPong

Enlighted (4155)

PingPong's picture

05-08-2018, 21:09

I've seen some projects about this.
this will enable c++ programming on msx!
i would be curious about the huge machine code size generated for a simple thing like this.

typedef long long INT64;

INT64 add(INT64 a, INT64 b)
return b+a;

Login or register to post comments

By Grauw

Ascended (10819)

Grauw's picture

05-08-2018, 21:57

That would be nice... Got any links to those projects?

By PingPong

Enlighted (4155)

PingPong's picture

05-08-2018, 22:18

However i do not know the state of the project

By PingPong

Enlighted (4155)

PingPong's picture

05-08-2018, 22:26

By Giangiacomo Zaffini 2

Champion (300)

Giangiacomo Zaffini 2's picture

06-08-2018, 12:46

If You want to stay on the edge please try and keep in touch with this community (and jacobly aka jacobly0, his port repository is this one)

TI-Planet compilateur C via LLVM

It is a long way, I guess. B-)

By Giangiacomo Zaffini 2

Champion (300)

Giangiacomo Zaffini 2's picture

17-01-2021, 11:35

Closing 2020, there was an update on (e)Z80 C/C++ compiler for TI calculators :
CE C Toolchain (LLVM-based)

I think having more toolchain options is a good thing.
Happy 2021 MSXing!

By Louthrax

Prophet (2492)

Louthrax's picture

17-01-2021, 12:45

That is very interesting. Nice thing on the TI-Planet link you gave is that you can download pre-built binaries with some working examples.

By salutte

Master (165)

salutte's picture

17-01-2021, 13:07

I've been trying to follow some of these initiatives to build z80 backends for llvm, but I didn't find much success.
On the other hand, I managed to compile a very simple C++ and run it in MSX, by using the resurrected C backend, the process is as follows:

C++ to intermediate LLVM format (.ll):
$ clang -S -emit-llvm -g main.c

from LLVM intermediate format to C (.cbe.c):
$ llvm-cbe main.ll

from C to msx format then using SDCC.

info on the C backend in:

However, the full process was very brittle. And one of the problems is that the C++ to C uses native libraries, so, when compiled on my PC, ints were 32 bits in size, and size_t was 64 bits, hence the STL code was mostly unusable on MSX.
I also tried unsuccessfully to compile a D program, but the C backend failed to process the intermediate .ll file.