[llvm-dev] LLVM Backend for a platform with no (normal) stack

Mendell, Mark P via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 17 06:31:21 PST 2018


Not only do FPGAs not support recursion, we don’t even support calls!  All user code must be inlined into one kernel/component, which is then used to create HDL for the FPGA.

Mark

From: Bruce Hoult <brucehoult at sifive.com>
Sent: December 17, 2018 9:28 AM
To: Mendell, Mark P <mark.p.mendell at intel.com>
Cc: jjones at prc-hsv.com; LLVM Developers Mailing List <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] LLVM Backend for a platform with no (normal) stack

On Mon, Dec 17, 2018 at 6:14 AM Mendell, Mark P <mark.p.mendell at intel.com<mailto:mark.p.mendell at intel.com>> wrote:
For a machine like an FPGA with no stack, you have to ensure that you have an optimization that rewrites the alloca into either registers (such as PromoteMem2Reg) or that you rewrite the alloca by declaring a static local, and rewriting the code to use that instead of the alloca result.

You'll then have to make sure programs never have recursion.

When it comes down to it, nothing we run programs on actually has a true unbounded stack. We just have a region of memory that we calculate or hope will be big enough. But over a million people (mostly amateurs) happily and regularly run C++ programs (with virtual functions and all) compiled by gcc on machines with only 2 KB of RAM: the ATmega328 in most Arduinos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181217/993bbbc9/attachment.html>


More information about the llvm-dev mailing list