Get lots of Num lowlevel ops working

This commit is contained in:
Brian Carroll 2021-11-10 14:21:32 +00:00
parent 6421ff07a5
commit 7c95189e4a
7 changed files with 532 additions and 61 deletions

View file

@ -127,7 +127,15 @@ pub fn copy_memory(code_builder: &mut CodeBuilder, config: CopyMemoryConfig) {
/// Round up to alignment_bytes (which must be a power of 2)
pub fn round_up_to_alignment(unaligned: i32, alignment_bytes: i32) -> i32 {
debug_assert!(alignment_bytes.count_ones() == 1);
if alignment_bytes <= 1 {
return unaligned;
}
if alignment_bytes.count_ones() != 1 {
panic!(
"Cannot align to {} bytes. Not a power of 2.",
alignment_bytes
);
}
let mut aligned = unaligned;
aligned += alignment_bytes - 1; // if lower bits are non-zero, push it over the next boundary
aligned &= -alignment_bytes; // mask with a flag that has upper bits 1, lower bits 0