-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1833 from GaloisInc/T1828
`write_aig`: Normalize symmetry in multiplication
- Loading branch information
Showing
9 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CC = clang | ||
CFLAGS = -g -frecord-command-line -O0 | ||
|
||
all: test.bc test.exe | ||
|
||
test.bc: test.c | ||
$(CC) $(CFLAGS) -c -emit-llvm $< -o $@ | ||
|
||
test.o: test.c | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
test.exe: test.o | ||
$(CC) $(CFLAGS) $< -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f test.bc test.exe |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <stdint.h> | ||
|
||
uint32_t mult(uint32_t x) { | ||
return x * 0x85EBCA77U; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This test case ensures that ABC can prove that a C implementation of the | ||
// `mult` function is equivalent to a direct Cryptol implementation of the | ||
// same function. | ||
|
||
let | ||
{{ | ||
cryptol_mult : [32] -> [32] | ||
cryptol_mult x = x * 0x85EBCA77 | ||
}}; | ||
|
||
m <- llvm_load_module "test.bc"; | ||
llvm_mult <- llvm_extract m "mult"; | ||
prove abc {{ \x -> llvm_mult x == cryptol_mult x }}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set -e | ||
|
||
$SAW test.saw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
left.aig | ||
right.aig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
write_aig "left.aig" {{ \x -> x * 0x12345678 }}; | ||
write_aig "right.aig" {{ \x -> 0x12345678 * x }}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set -e | ||
|
||
# This test case uses `write_aiger` to produce AIG files for two nearly | ||
# identical functions, where the only difference is the order of arguments (one | ||
# symbolic and one concrete) in a bitvector multiplication. If the `aig` library | ||
# does its job correctly, these should produce identical AIG files, so check | ||
# this using `diff`. | ||
$SAW test.saw | ||
diff -ru left.aig right.aig |