circt
circt copied to clipboard
[HWToLLVM] Lower constant HW arrays to static global LLVM arrays
Currently an HW array that only consists of constants is lowered in the same way as an array containing dynamic arrays: by creating the array at runtime and allocating it on the stack. For constant arrays this is very wasteful compared to statically allocating the array. This change makes the ArrayCreateOpConversion lower to a static global LLVM array if the HW array is constant. It will return an array loaded from a global address.
The ArrayGetOpConversion checks if the array was loaded from a LoadOp, and if so just gets the element through the pointer directly rather than dynamically allocating the array on the stack.
I'm not sure how to handle the naming for the generated arrays. I'm currently using a global namespace to do this, but I'm not sure that's a great solution. Let me know if there's a better way, thanks!
I'm going to move this over the to HWToLLVM pass to resolve the conflicts.
I think the CI is failing due to an unrelated bug that was in main at the time when it ran. Is it possible to re-run the test?
@zyedidia you can rebase the PR
Great, thanks! I will make these additional changes, and I'm currently rebasing and resolving conflicts.
Thanks for the comments, I think I have made all the requested changes!