diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-05-26 22:04:20 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-05-26 22:04:20 +0200 |
commit | b4a08d0815342b6238d307864f0823d0f07bb691 (patch) | |
tree | 85f48254ca79a6e2bc9d7359017a5731f98f897f /kvx/bitmasks.py | |
parent | 490a6caea1a95cfdbddf7aca244fa6a1c83aa9a2 (diff) | |
download | compcert-kvx-b4a08d0815342b6238d307864f0823d0f07bb691.tar.gz compcert-kvx-b4a08d0815342b6238d307864f0823d0f07bb691.zip |
k1c -> kvx changes
Diffstat (limited to 'kvx/bitmasks.py')
-rwxr-xr-x | kvx/bitmasks.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kvx/bitmasks.py b/kvx/bitmasks.py new file mode 100755 index 00000000..9f6987d6 --- /dev/null +++ b/kvx/bitmasks.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +def bitmask(to, fr): + bit_to = 1<<to + return (bit_to | (bit_to - 1)) & ~((1<<fr)-1) + +def bitmask2(to, fr): + bit_to = 1<<to + return bit_to + (bit_to - (1 << fr)) + +for stop in range(32): + for start in range(stop+1): + assert(bitmask(stop, start) == bitmask2(stop, start)) |