Mendell, Mark P via llvm-dev
2018-Dec-17 14:14 UTC
[llvm-dev] LLVM Backend for a platform with no (normal) stack
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. Mark Mendell From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Bruce Hoult via llvm-dev Sent: December 14, 2018 3:27 PM To: jjones at prc-hsv.com Cc: LLVM Developers Mailing List <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] LLVM Backend for a platform with no (normal) stack You said you can allocate memory? On Fri, Dec 14, 2018 at 12:09 PM JD Jones <jjones at prc-hsv.com<mailto:jjones at prc-hsv.com>> wrote: Thanks, no malloc or free equivalents either (no heap). So, there are no others (to your knowledge) who have built an LLVM backend for a platform with no “normal” stack? I found a presentation about some FPGA work (using LLVM) but it doesn’t seem to apply to my platform. Perhaps someone else on the mailing list will have come across this rarity? Thank you again for your time and responses. If I have inadvertently been rude, please forgive someone new to LLVM? And if your forgiveness stretches that far, perhaps you could clue me on just how I was rude so that I can avoid it in the future? More thanks, JD Jones From: Bruce Hoult [mailto:brucehoult at sifive.com<mailto:brucehoult at sifive.com>] Sent: Friday, December 14, 2018 1:29 PM To: jjones at prc-hsv.com<mailto:jjones at prc-hsv.com> Cc: LLVM Developers Mailing List <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> Subject: Re: [llvm-dev] LLVM Backend for a platform with no (normal) stack Having your function prologue call malloc() and epilogue call free() (or similar functions) instead of bumping a stack pointer is not a problem. That stuff is generated explicitly by ISA-specific code anyway. On Fri, Dec 14, 2018 at 9:05 AM JD Jones <jjones at prc-hsv.com<mailto:jjones at prc-hsv.com>> wrote: Thanks for your response. Please see below. From: Bruce Hoult [mailto:brucehoult at sifive.com<mailto:brucehoult at sifive.com>] Sent: Thursday, December 13, 2018 5:58 PM To: jjones at prc-hsv.com<mailto:jjones at prc-hsv.com> Cc: LLVM Developers Mailing List <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> Subject: Re: [llvm-dev] LLVM Backend for a platform with no (normal) stack Do you have a register that you can store a memory address>> yesin and an addressing mode that allows you to add (or subtract) a constant to that register>> Sometimesand use the address calculated to load//store from memory? Do you have enough registers that you can keep one of them permanently pointed to a particular memory region?>> NoThe platform intentionally does not allow use of some large chunk of memory for shared use by function calls. I can allocate memory (so long as I know the necessary size before-hand). I can work around this issue, but if someone has already addressed it, I’d like to learn from their experiences before rolling my own. If yes, then you have a stack to exactly the same extent as RISC-V or MIPS do. On Thu, Dec 13, 2018 at 12:53 PM JD Jones via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Dear Sir or Ma’am; I have found a wealth of help and information on writing an LLVM backend. And, my platform has no stack. Can you point me to any information that would specifically address creating a backend for this kind of platform? In previous wanderings, I thought I ran across a phrase “platforms with no stack such as FPGAs”, but I can’t find that mention, now. More thanks than I can type, JD Jones Software Engineer This message is intended for the addressee only and may contain Paragon Research Corporation (PRC) confidential or privileged information. Use or distribution of such confidential information is strictly prohibited without the prior written permission of PRC. If you have received this message in error, please contact the sender immediately and delete the message and attachments from your computer._______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev This message is intended for the addressee only and may contain Paragon Research Corporation (PRC) confidential or privileged information. Use or distribution of such confidential information is strictly prohibited without the prior written permission of PRC. If you have received this message in error, please contact the sender immediately and delete the message and attachments from your computer. This message is intended for the addressee only and may contain Paragon Research Corporation (PRC) confidential or privileged information. Use or distribution of such confidential information is strictly prohibited without the prior written permission of PRC. If you have received this message in error, please contact the sender immediately and delete the message and attachments from your computer. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181217/4f63cabe/attachment.html>
Bruce Hoult via llvm-dev
2018-Dec-17 14:28 UTC
[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> 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/29589480/attachment.html>
Mendell, Mark P via llvm-dev
2018-Dec-17 14:31 UTC
[llvm-dev] LLVM Backend for a platform with no (normal) stack
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>