Hi all, I have recently started playing with cranelift IR and would like to know how we transform a C++ string array to IR? I am aware of the create_data example used in simplejit_demo, is there a simpler API to create this ?
Hello, if you mean a C++ std::string, we don't yet have a C++ frontend for Cranelift, which would be needed to do that in a reasonable way.
If you mean a string literal, then yes, create_data is what we currently have. You'll need to add a NUL to the end.
Hi, Thank you for the reply. Also how do we return a array from a cranelift function, what I could think of is use heap but am not sure how an array access in a toy language would map to that heap ?
What I mean is modelling writing to an array?
If the caller knows how big the array is, it can pass a pointer to a buffer the function can write to.
If not, the function can dynamically allocate a buffer and the caller can free it.
Last updated: Nov 22 2024 at 16:03 UTC