Stream: cranelift

Topic: Strings and string array IR


view this post on Zulip Divya Agrawal (Mar 23 2020 at 10:13):

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 ?

view this post on Zulip Dan Gohman (Mar 24 2020 at 22:26):

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.

view this post on Zulip Dan Gohman (Mar 24 2020 at 22:27):

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.

view this post on Zulip Divya Agrawal (Mar 25 2020 at 04:49):

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 ?

view this post on Zulip Divya Agrawal (Mar 25 2020 at 05:53):

What I mean is modelling writing to an array?

view this post on Zulip Dan Gohman (Mar 25 2020 at 11:20):

If the caller knows how big the array is, it can pass a pointer to a buffer the function can write to.

view this post on Zulip Dan Gohman (Mar 25 2020 at 11:21):

If not, the function can dynamically allocate a buffer and the caller can free it.


Last updated: Dec 23 2024 at 13:07 UTC