<div dir="ltr">2018-02-20 14:45 GMT+01:00 Mikael Pettersson <span dir="ltr"><<a href="mailto:mikpelinux@gmail.com" target="_blank">mikpelinux@gmail.com</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Feb 20, 2018 at 11:49 AM, Matthias Lang <<a href="mailto:matthias@corelatus.se">matthias@corelatus.se</a>> wrote:<br>
> On 19. February 2018, Mikael Karlsson wrote:<br>
><br>
>> has anyone looked at having the Erlang compiler support RISC-V,<br>
><br>
> I haven't.<br>
><br>
> What do you mean by "the Erlang compiler"?<br>
><br>
> The regular Erlang compiler, i.e. the one that generates .beam files,<br>
> generates .beam files which don't care what CPU you want to run on.<br>
><br>
> HiPE is a different story, but you didn't mention HiPE.<br>
<br>
</span>RISC-V support in HiPE should be straight-forward, but no-one is<br>
working on that AFAIK.<br>
It's not clear there is any need, since the BEAM should work as-is.<br>
<br>
There is also that HiPE/LLVM thing which might be able to support RISC-V<br>
with less effort.<br>
<span class=""><br>
> Getting the VM to run is another task, though once people have linux<br>
> and a toolchain running (I see that there's an active debian effort,<br>
> for instance), I would expect that to be the same level of difficulty<br>
> as compiling on, say, MIPS linux for the first time---i.e. maybe it'll<br>
> just work, maybe you have to do a bit of autotools fiddling.<br>
<br>
</span>RISC-V has full GNU/Linux support with latest GCC, binutils, GLIBC,<br>
and Linux kernel, and I know both Debian and Fedora have started ports.<br>
But you don't need to wait for a full distro port, all you need is a<br>
cross-compiler<br>
and busybox or sth and you're done.<br>
<span class=""><br>
> The mention of RISC-V just made me think, "I haven't heard anything<br>
> about Tilera for a while". I think it's been a few years since anyone<br>
> here said anything about it on the mailing list. Anyone know if it's<br>
> still alive?<br>
<br>
</span>Tilera is dropping their Tile processors and migrating to some other core<br>
(I don't know which one, but probably ARM or MIPS.) See e.g. their recent<br>
announcements to drop the older TilePro from Linux and glibc, keeping only<br>
Tile-Gx due to some customers still using it.<br>
</blockquote></div></div><div class="gmail_extra"><div><br></div><div>Hi again Mikael,</div><div><br></div><div>>It's not clear there is any need, since the BEAM should work as-is.</div><div><br></div><div>Yes, the Fedora port you pointed out has already an Erlang port.</div><div><br></div><div>However
the RISC-V is a register machine (as the Erlang VM) with 32 integer
registers so I wonder it there are any optimizations that may be done.</div><div>I can see in the beam_emu.c a can see for other architectures sections like:</div><div>/*<br> * On certain platforms, make sure that the main variables really are placed<br> * in registers.<br> */</div><div>..<br></div><div>#elif defined(__GNUC__) && defined(__amd64__) && !defined(DEBUG)<br># define REG_xregs asm("%r12")<br># define REG_htop<br># define REG_stop asm("%r13")<br># define REG_I asm("%rbx")<br># define REG_fcalls asm("%r14")<br>#else</div><div>..</div><div>The RISC-V assembly programmer's handbook lists registers as (chapter 20 in the spec):</div><div>Register ABI Name Description Saver<br>x0 zero Hard-wired zero |<br>x1 ra Return address Caller<br>x2 sp Stack pointer Callee<br>x3 gp Global pointer |<br>x4 tp Thread pointer |<br>x5 t0 Temporary/alternate link register Caller<br>x6-7 t1-2 Temporaries Caller<br>x8 s0/fp Saved register/frame pointer Callee<br>x9 s1 Saved register Callee<br>x10-11 a0-1 Function arguments/return values Caller<br>x12-17 a2-7 Function arguments Caller<br>x18-27 s2-11 Saved registers Callee<br>x28-31 t3-6 Temporaries Caller<br></div><div><br></div><div>So I guess some similar "reservations" can be made for RISC-V as for amd64, but I am not sure how to map them here.<br></div><div><br></div><div>Best Regards</div><div>Mikael K<br></div><div class="gmail_extra"><br></div><br></div></div>