reilabs / hieratika

Efforts to compile LLVM bytecode to run on top of the CairoVM and hence execute provably on Starknet
http://starknet.io
Apache License 2.0
1 stars 0 forks source link

compiler-rt: alu: add `shl` (shift left) and `lshr` (logical shift right) polyfills #93

Closed wzmuda closed 2 days ago

wzmuda commented 3 days ago

Summary

Both polyfills have very similar logic so I push them in a single PR. They already follow the pattern I introduce in #92 - there's one generic implementation and the concrete implementations are just aliases existing to comply with our design.

This PR is based on #92 to make the diff show only the 2 commits that this PR actually adds. It's important to change the base back to main before merge and merge this PR after #92.

Details

Please check the logic of lsh and lshr functions in lsh.cairo and lshr.cairo files. Test cases are automatically generated (just like I did with and/or/xor) so they're most likely correct

Checklist

wzmuda commented 2 days ago

I want to see the shift algorithms documented liberally for those reading.

Both documented and right shift heavily simplified.