Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More numeric types #81

Closed
6 tasks
steinerkelvin opened this issue Feb 12, 2022 · 8 comments
Closed
6 tasks

More numeric types #81

steinerkelvin opened this issue Feb 12, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@steinerkelvin
Copy link

steinerkelvin commented Feb 12, 2022

Right now, HVM only supports U32. The numeric types above should be supported too. I32 and F32 should be easy to add, since they are unboxed, like U32. I64, U64 and F64 require implementing boxed numbers, since they don't fit inside a 64-bit Lnk (due to the 4-bit pointer), but shouldn't be hard. Discussion on whether we should have unboxed 60-bit variants is valid.

I'd be interested in adding support for at least the unboxed numeric types as this seems like a low hanging fruit. I just wanted to check what the concensus was between implicit/explicit casting and how operators should function in regards to mixed input types. My instinct would just be to cast up to the 'bigger' type but maybe operators should only operate on the same type - combined with explicit casts.
@VictorTaelin what do you think?

Originally posted by @samtoth in #38 (comment)


  • unboxed
    • integer: I32
    • float: F32
  • boxed
    • integer: U64, I64
    • float: F64
@VictorTaelin
Copy link
Member

F60 and U60 are now merged on Master. I don't think we should have other integer types.

@Janiczek
Copy link

@VictorTaelin Can you comment on / give links to some papers on how to lower signed integers (in higher-level languages) to unsigned integers (in HVM as a backend)? It's not immediately obvious to me.

@VictorTaelin
Copy link
Member

VictorTaelin commented Nov 23, 2022

Hmm perhaps adding I60 isn't a bad idea to be fair. Should be very simple to do now (see F60.hvm and U60.hvm).

@zicklag
Copy link

zicklag commented Nov 23, 2022

Do we have f32 and i32 already?

@VictorTaelin
Copy link
Member

No, I think f32/i32/u32 should just be implemented as a lib, but not too sure about that. Any reason you think these should be native? I believe a minimalist design is important, must have caution not to become a bloated spec

@zicklag
Copy link

zicklag commented Nov 23, 2022

If f32/i32/u32 can be implemented as a lib without performance issues I'm totally fine with it. I was just thinking about use-cases for games where f32's are used heavily. I'd assume we'd want to be able to take advantage of hardware float operations, which I wasn't sure if we could do in a lib or not.

@VictorTaelin
Copy link
Member

In that case you should just use a F60. Since the pointer size is 64, a F32 would just have 28 empty bits. What we could (should?) do in a future perhaps is have a 32-bit version of HVM?

@zicklag
Copy link

zicklag commented Nov 23, 2022

That's an interesting question. I'm not sure if using 64 bit floats everywhere would have negative impact on performance or not.

Maybe a 32-bit HVM does make sense. I don't know. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants