I’m currently working on HLS(high level synthesis) project that involves using the llvm (version 10) In my analysis, I need to determine the length of arrays in C function parameters to generate BRAM.
However, I noticed that when Clang generates IR, array parameters are represented as pointers (e.g., i32* for int array). As a result, the array length information is lost during the Clang AST phase.
My question is whether there is any possibility to obtain the array length (only in situations like int a) in C function parameters or to somehow preserve this information in the LLVM IR.
I have considered custom attribute or metadata to store the array length information, but I’m unsure if this is feasible or if there are any existing mechanisms in Clang to achieve this.
To clarify, I’m looking for a way to access the array length (only in situations like int a) in the Clang AST phase before the generation of LLVM IR. If there’s a way to accomplish this or if you have any suggestions or insights, I’d greatly appreciate your help.
Indeed, in this situation, C also cannot obtain the array’s length since it has already been converted into a pointer. However, users write this kind of code with the intention of using an array of length 4, which is why I asked if it is possible to obtain the array’s length.