This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Change int_fast16_t to 32-bit
Changes PlannedPublic

Authored by ncw on Jan 11 2018, 2:32 AM.

Details

Reviewers
dschuff
sunfish
Summary

See: https://bugs.llvm.org/show_bug.cgi?id=35582

Since Wasm has to use 32-to-16 bit instructions to narrow values down, 32-bit should be a tad faster for operations needing 16 or more bits.

Diff Detail

Repository
rC Clang

Event Timeline

ncw created this revision.Jan 11 2018, 2:32 AM
dschuff added inline comments.Jan 11 2018, 9:21 AM
lib/Basic/Targets/WebAssembly.h
108

I think we want least16_t to still be short, no? We do still support 16-bit shorts, so my interpretation is that the smallest type with width of at least 16 should still be 16.

ncw added inline comments.Jan 11 2018, 9:34 AM
lib/Basic/Targets/WebAssembly.h
108

...is there a way to do that? I couldn't find any other archs that do it; it seems like the stdint.h that Clang provides requires least16_t to match fast16_t. I copied this from the AVR target, although maybe that doesn't support 16-bit at all.

ncw added inline comments.Jan 11 2018, 9:43 AM
lib/Basic/Targets/WebAssembly.h
108

Sorry, now I see that AVR uses int because it has 16-bit ints...

There isn't any existing Clang target that uses 32-bit for fast16_t, so maybe it's currently not possible within Clang's framework (or at least, not without also fiddling with least16_t). lib/Frontend/InitPreprocessor.cpp hardcodes some logic with sets them to be the same.

I can abandon this review if that's not acceptable collateral damage (probably not, on reflection) - or could tweak InitPreprocessor.cpp and stdint.h to be more flexible (might need more review if you don't "own" those files?)

dschuff added inline comments.Jan 11 2018, 10:08 AM
lib/Basic/Targets/WebAssembly.h
108

I think it's worth trying to fix InitPreprocessor.cpp/stdint.h to remove the assumption that those types are the same. We'll need to get broader review, so it will be slower than if we were just changing our own files, but that's OK. If you're up for doing that I'd be happy to help you find reviewers, or otherwise I can take a shot at it; now is a good time since we're taking a closer look at our ABIs more generally anyway.

ncw added inline comments.Jan 11 2018, 10:20 AM
lib/Basic/Targets/WebAssembly.h
108

uhh... if you could take a look that would be great! I've only got a limited Wasm "budget" from my employer, and have to get back to customer work for most of the rest of the week.

Was there an issue I seem to remember as well, where Wasm32 was using "unsigned int" for SIZE_TYPE instead of "unsigned long".

dschuff added inline comments.Jan 11 2018, 10:36 AM
lib/Basic/Targets/WebAssembly.h
108

Yes, @sunfish is switching the wasm and asm.js ABIs to both use unsigned long.

ncw planned changes to this revision.Jan 25 2018, 10:53 AM

As @nw points out, clang's lib/Headers/stdint.h doesn't support this yet. Unless anyone feels strongly, I now propose we close this and just leave int_fast16_t/uint_fast16_t as-is.

sunfish resigned from this revision.Jan 14 2019, 8:17 AM