aboutsummaryrefslogtreecommitdiffstats
path: root/mppa_k1c/bitmasks.py
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-27 19:23:04 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-27 19:23:04 +0200
commit146bf43966f0d0c7a1587fc4d8dab58958d621fa (patch)
treeb95de34ff87fcbd679056a744e915c3a31e4e25c /mppa_k1c/bitmasks.py
parent28e66eb4b60c485bebb1e217bc8f50bdc2cc6ddb (diff)
downloadcompcert-kvx-146bf43966f0d0c7a1587fc4d8dab58958d621fa.tar.gz
compcert-kvx-146bf43966f0d0c7a1587fc4d8dab58958d621fa.zip
factor expressions into single file
Diffstat (limited to 'mppa_k1c/bitmasks.py')
-rwxr-xr-xmppa_k1c/bitmasks.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mppa_k1c/bitmasks.py b/mppa_k1c/bitmasks.py
new file mode 100755
index 00000000..9f6987d6
--- /dev/null
+++ b/mppa_k1c/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))