In LLVM there are routines to get the bit size of a type while taking padding and what not into account. I'm using this to figure out if a returned structure needs to use a regular return or a struct return.
Looking at the Cranelift documentation it seems it doesn't offer anything for this (in part because structures aren't really a thing in the IR). Am I correct in this?
Implementing this myself isn't too hard, but it would be nice if I don't have to repeat something already done by others :smile:
That’s correct, Cranelift has no aggregate types; it’s up to you to compute struct layout and derive pointers appropriately
Gotcha :smile:
You could try using https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.extend for it, but as you say it's not that hard so whether it'd be worth it isn't necessarily obvious.
Last updated: Nov 22 2024 at 16:03 UTC