Stream: compiler development

Topic: Dev backend - Num functions


view this post on Zulip Luke Boswell (Nov 29 2024 at 21:43):

@shua asked a good question in GH https://github.com/roc-lang/roc/issues/3513#issuecomment-2508674491

I wanted to share here as it's easy to lose this kind of thing in the flood of GH messages.

question for add/sub/mul: should we be using x86/aarch64 carry flags when implementing these? It would mean we could implement the variants like add/addSaturated/addChecked/addWrap all in asm for integers instead of calling out to bitcode. It also leads to a pretty concise u128/i128 impl for add and sub.

view this post on Zulip Richard Feldman (Nov 29 2024 at 21:54):

that sounds like a great idea to me! :heart_eyes:

view this post on Zulip shua (Nov 29 2024 at 23:06):

it looks like roc used the overflow flag in the x86 backend, but it got turned into a bitcode call while adding the aarch64 backend https://github.com/roc-lang/roc/pull/5824/files#diff-23699c56834955756a70ebbe1514d93b91f31073cbc15bc78a352ab70292b2c5L1376-R1385

was that intended to be temporary as aarch64 was added, or was there a reason to prefer calling the bitcode over the asm implementation? Maybe @Folkert de Vries remembers?

view this post on Zulip Brendan Hansknecht (Nov 29 2024 at 23:25):

It was always just done for simplicity.

view this post on Zulip Brendan Hansknecht (Nov 29 2024 at 23:25):

Better solutions are very welcome

view this post on Zulip Brendan Hansknecht (Nov 29 2024 at 23:25):

For checked, it may have also been done to skip making a result (though that is pretty easy to do as well)


Last updated: Jul 06 2025 at 12:14 UTC