digitalmars.D.learn - Template and alloca?
- Ola Fosheim Grostad (3/3) May 25 2021 Is it possible to use a template to write a "function" that
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (5/8) May 26 2021 Nevermind, I've realized that I only need a way to force a
- Imperatorn (4/12) May 26 2021 Do you accomplish that with just pragma inline? (for future
- Ola Fosheim Grostad (9/22) May 26 2021 I suspect that LDC allows LLVM to use an external function, but I
- Jack (6/29) May 26 2021 for anyone that would ever use this approach with DMD remember to
Is it possible to use a template to write a "function" that provides initialized stack allocated memory (alloca)? Maybe I would have to use mixin?
May 25 2021
On Tuesday, 25 May 2021 at 17:55:17 UTC, Ola Fosheim Grostad wrote:Is it possible to use a template to write a "function" that provides initialized stack allocated memory (alloca)? Maybe I would have to use mixin?Nevermind, I've realized that I only need a way to force a function to be inlined with 100% certainty. Then I can return a structure holding alloca-allocated memory.
May 26 2021
On Wednesday, 26 May 2021 at 07:34:06 UTC, Ola Fosheim Grøstad wrote:On Tuesday, 25 May 2021 at 17:55:17 UTC, Ola Fosheim Grostad wrote:Do you accomplish that with just pragma inline? (for future reference)Is it possible to use a template to write a "function" that provides initialized stack allocated memory (alloca)? Maybe I would have to use mixin?Nevermind, I've realized that I only need a way to force a function to be inlined with 100% certainty. Then I can return a structure holding alloca-allocated memory.
May 26 2021
On Wednesday, 26 May 2021 at 08:38:29 UTC, Imperatorn wrote:On Wednesday, 26 May 2021 at 07:34:06 UTC, Ola Fosheim Grøstad wrote:I suspect that LDC allows LLVM to use an external function, but I dont know for sure. I would have to look over the code it sends to LLVM... But the beauty of Open Source is that it is easy to modify LDC! Anyway, dont do this with C compilers, as they might refuse to inline functions with alloca to prevent the stack from exploding... Very much a low level approach, but fun!On Tuesday, 25 May 2021 at 17:55:17 UTC, Ola Fosheim Grostad wrote:Do you accomplish that with just pragma inline? (for future reference)Is it possible to use a template to write a "function" that provides initialized stack allocated memory (alloca)? Maybe I would have to use mixin?Nevermind, I've realized that I only need a way to force a function to be inlined with 100% certainty. Then I can return a structure holding alloca-allocated memory.
May 26 2021
On Wednesday, 26 May 2021 at 11:31:31 UTC, Ola Fosheim Grostad wrote:On Wednesday, 26 May 2021 at 08:38:29 UTC, Imperatorn wrote:for anyone that would ever use this approach with DMD remember to *always* use -inline flag otherwise the inline request by ```pragma(inline, true)``` can be ignored and this will result in a nasty bugOn Wednesday, 26 May 2021 at 07:34:06 UTC, Ola Fosheim Grøstad wrote:I suspect that LDC allows LLVM to use an external function, but I dont know for sure. I would have to look over the code it sends to LLVM... But the beauty of Open Source is that it is easy to modify LDC! Anyway, dont do this with C compilers, as they might refuse to inline functions with alloca to prevent the stack from exploding... Very much a low level approach, but fun!On Tuesday, 25 May 2021 at 17:55:17 UTC, Ola Fosheim Grostad wrote:Do you accomplish that with just pragma inline? (for future reference)Is it possible to use a template to write a "function" that provides initialized stack allocated memory (alloca)? Maybe I would have to use mixin?Nevermind, I've realized that I only need a way to force a function to be inlined with 100% certainty. Then I can return a structure holding alloca-allocated memory.
May 26 2021