[PATCH] D120327: compiler-rt: Add udivmodei5 to builtins and add bitint library
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 22 09:30:04 PDT 2022
erichkeane added a comment.
In D120327#3399849 <https://reviews.llvm.org/D120327#3399849>, @programmerjake wrote:
> In D120327#3398754 <https://reviews.llvm.org/D120327#3398754>, @FreddyYe wrote:
>
>> So everyone is OK with use malloc(), right? That was my biggest concern.
>
> imho if at all possible, the temporary buffers should be passed in from the caller rather than malloc-ed, that way they can be allocated on the stack (or heap, or somewhere else) by the caller who knows exactly how big they should be and can have them be a local variable -- no dynamic alloca or malloc needed. This would allow using >128-bit ints on embedded systems without malloc, and also allows the caller to use the same temporary for multiple division operations, rather than having to call the memory allocator every time.
This sounds like a really good idea to me. The LLVM code generation "Knows" how big this value needs to be and can do it on the stack of the caller. So it would generate IR the equivalent of:
void func_that_bitints(__BitInt(999) a, __BitInt(999) b) {
unsigned int buffer[1024/8]; // Or whatever
something_else = __divmodei5(buffer, <stuff>);
}
Right?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120327/new/
https://reviews.llvm.org/D120327
More information about the llvm-commits
mailing list