Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Consider using fixed scalar types#59

Open
fornwall wants to merge 12 commits into
scalarfrom
scalar-types
Open

Consider using fixed scalar types#59
fornwall wants to merge 12 commits into
scalarfrom
scalar-types

Conversation

@fornwall

@fornwall fornwall commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

Just an experiment to try out a different approach, haven't checked it in detail.

@fornwall fornwall requested a review from eddyb as a code owner January 22, 2024 02:22
Comment thread src/scalar.rs Outdated
Comment on lines 14 to 29
pub enum Type {
Bool,
SInt(IntWidth),
UInt(IntWidth),
Float(FloatWidth),
S8,
S16,
S32,
S64,
S128,
U8,
U16,
U32,
U64,
U128,
F16,
F32,
F64,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting in a way I hadn't considered.
I might be open to this if the actual hardcoded list was a private enum and Type was a struct newtype around it, what do you think?

For the record, the reason Type being 2 bytes is slightly suboptimal for me, is that you can actually pack (TypeKind, IntWidth) into 5 bits, and use the remaining 3 bits to also support vector types or something. It's not that important, just a thought exercise I started ages ago (for LLVM IR types, once you remove pointee types, and arrays/structs, because the only nesting left is vector types around scalar types).

@fornwall fornwall Jan 24, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be open to this if the actual hardcoded list was a private enum and Type was a struct newtype around it, what do you think?

Did that in 1bdf588 - what do you think?

@eddyb eddyb force-pushed the scalar branch 3 times, most recently from 5eefbcf to ad22784 Compare January 31, 2024 15:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants