-
Notifications
You must be signed in to change notification settings - Fork 259
Description
A while back, I implemented a struct layout engine that can handle Rust-like, C, and packed struct layouts with proper alignment and padding, as well as reordering of fields for the Rust-like engine. I think something like this would be wonderful to have in inkwell.
In addition to a struct layout engine, it would also be really nice if we had a derive macro that could be placed on structs/enums that could be used to create these types in LLVM.
So for example, if you had a struct like this:
#[repr(rust)]
struct Foo {
bar: i8,
baz: u32,
}The layout engine could rearrange it into a struct like this:
#[repr(C)]
struct Foo {
baz: u32,
bar: i8,
}This could all be done with a derive macro that would read the repr attribute if it exists, and align the struct accordingly. If there's no repr attribute, it would use a Rust-like layout engine by default.
Additionally, we could create high-level constructs for building IR beyond the Builder struct.
For example, we could design a higher level human-readable language that can be interpreted by Rust macros that would be able to build code more easily and in a more readable format.
Alternatively, we could have high-level abstractions that simply make it easier to express code, such as types that have operators that allow you to build expressions as if you were writing plain Rust that would translate to a type that could be submitted to a builder.
If you like the struct layout engine idea, I could take a crack at it. Same with some other high-level abstractions. I don't have a whole lot of ideas right off the top of my head, but I'm sure with enough time, I could develop a coherent system.